akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define ll long long
using namespace std;
inline int read()
{
    int x=0,f=1;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s<='9'&&s>='0'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
int main()
{
    char ch[50];
    scanf("%s",ch);
    bool flag=true;
    for(int i=1;i<strlen(ch);i++)
        if(ch[i]!='9')flag=false;
    if(flag)printf("%d\n",(strlen(ch)-1)*9+ch[0]-'0');else
        printf("%d\n",(strlen(ch)-1)*9+ch[0]-'0'-1);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main() {
    char str[1001];
    int i, sum;
    while (gets(str)) {
        if (str[0] == '0') {
            break;
        }
        sum = 0;
        for (i = 0; str[i]; i++) {
            sum += str[i] - 48;
        }
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int n, me;
	cin >> n;
	float sum = 0;
	vector<int> d;
	while (n--) {
		int x;
		cin >> x;
		d.push_back(x);
	}
	sort(d.begin(), d.end());
	me = d.size() / 2;

	if (d[me - 1] == d[me]) {
		cout << 0 << endl;
	}
	else 
	{
		cout << d[me] - d[me - 1]<< endl;
	}
	return 0;
}


Measured memory_bytes: 892
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

n = I()
a = LI()
l = lcm(a)
ans = 0
l %= mod
for i in a:
    ans += l*pow(i,mod-2,mod)
    ans %= mod
print(ans)


Measured memory_bytes: 67248
N = int(input())
s = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(num2alpha(N).lower())

Measured memory_bytes: 9216
#include<stdio.h>
#include<string.h>
//1.
// int main()
// {
//   char s[10];
//   gets(s);
//   if(s[0]=='S'){
//     printf("Cloudy");
//   }else if(s[0]=='C'){
//     printf("Rainy");
//   }else{
//     printf("Sunny");
//   }
// }

//2.
int main() {
  int flag = 1;
  char s[101];
  scanf("%s",s);
  int n = strlen(s);
  int i = 0;
  while (i<n)
  {
    if(i%2==0){
      if(s[i]=='R'||s[i]=='U'||s[i]=='D'){
        flag = flag;
      }else{
        flag = 0;
      }
    }else{
      if(s[i]=='L'||s[i]=='U'||s[i]=='D'){
        flag = flag;
      }else{
        flag  = 0;
      }
    }
    i++;
  }
  if(flag){
    printf("Yes");
  }else{
    printf("No");
  }
}

Measured memory_bytes: 128
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf


a,b = imap()
k,mod = divmod(a+b, 2)
ans = k if not mod else "IMPOSSIBLE"
print(ans)


Measured memory_bytes: 19848
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

string s;

int main(int argc, char const *argv[]) {
	cin >> s;
	// int i = 0;
	// while (true) {
	// 	bool flag = false;
	// 	while(i < s.size()-1) {
	// 		string sub_s = s.substr(i, 2);
	// 		if (sub_s == "ST") {
	// 			int count = 0;
	// 			while (i-count>=0 && i+1+count < s.size()) {
	// 				if (s[i-count] == 'S' && s[i+1+count] == 'T') count++;
	// 				else break;
	// 			}
	// 			s = s.substr(0, i-count) + s.substr(i+1+count);
	// 			flag = true;
	// 			i += count+1;
	// 			break;
	// 		}
	// 	}
	// 	if (!flag || s == "" || i==s.size()-2) break;
	// 	i++;
	// }
	// cout << s.size() << endl;

	int res = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] ==  'T') res++;
		else break;
	}
	s = s.substr(res);

	int s_num = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'S') s_num++;
		else if (s[i] == 'T' && s_num > 0) s_num--;
		else if (s[i] == 'T') res++;
	}
	res += s_num;

	cout << res << endl;


	// for (int i = 0; i < s.size(); i++) {
	// 	if (s[i] == "S" && t_num > 0) {
	// 		s = s.substr(0, i-2*t_num) + s.substr(i);
	// 		t_num = 0;
	// 		s_num = 
	// 	}
	// 	if (s[i] == "S") s_num++;
	// 	if (s[i] == "T" && t_num+1 == s_num) {
	// 		s = s.substr(i+1);
	// 		t_num = 0;
	// 		s_num = 0;
	// 		break;
	// 	}
	// 	else if (s[i] == "T") t_num++;
	// }


	// int n = 0;
	// int num_s = 0;
	// int num_t = 0;
	// while (true) {
	// 	if (s[n] == "S") {
	// 		if (num_s > 0 && num_t > 0) {
	// 			s = s.substr(0, n-2*num_t) + s.substr(n);
	// 			n -= 2*num_t;
	// 			num_s = num_s - num_t + 1;
	// 			num_t = num_t
	// 		}
	// 		num_s += 1;

	// 	}
	// 	if (s[n] == "T") {
	// 		num_t += 1;
	// 		if (num_s == 0) continue;
	// 		if (num_t == num_s) {
	// 			s = s.substr(0, n-2*num_t+1) + s.substr(n+1);
	// 			n = n - 2*num_t + 1;
	// 			num_s = 0;
	// 			num_t = 0;
	// 		}
	// 	}
	// }
	return 0;
}

Measured memory_bytes: 772
from collections import defaultdict
N = int(input())
al = list(map(int,input().split()))
cnt = 0
dic = defaultdict(int)
for i in al:
    if 1<= i <= 399:
        dic['gray'] += 1
    elif 400 <= i <= 799:
        dic['brown'] += 1
    elif 800 <= i <= 1199:
        dic['green'] += 1
    elif 1200 <= i <= 1599:
        dic['cyan'] += 1
    elif 1600 <= i <= 1999:
        dic['blue'] += 1
    elif 2000 <= i <= 2399:
        dic['yellow'] += 1
    elif 2400 <= i <= 2799:
        dic['orange'] += 1
    elif 2800 <= i <= 3199:
        dic['red'] += 1
    else:
        cnt += 1


ansmax = len(dic.keys()) + cnt
if ansmax > N:
    ansmax = N


ansmin = len(dic.keys())
if ansmin == 0 and cnt >= 1:
    ansmin = 1

print(ansmin,ansmax)

Measured memory_bytes: 9464
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
	int n;
    cin>>n;
    vector<int>d(n);
    rep(i,n)cin>>d[i];
    sort(begin(d),end(d));
    int m;
    cin>>m;
    vector<int>t(m);
    rep(i,m)cin>>t[i];
    sort(begin(t),end(t));
    int cur=0;
    rep(i,n){
        if(d[i]==t[cur])++cur;
        if(cur==m){
            cout<<"YES\n";
            return;
        }
    }
    cout<<"NO\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 1792
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> solve(ll A, ll B, ll N){
    vector<ll> res;
    if(N == 2){
        res.push_back(A);
        res.push_back(B);
        return res;
    }
    rep(i,0,N){
        if(((A>>i) & 1) != ((B>>i) & 1)){
            ll v = (1LL<<i);
            ll c = A;
            rep(j,0,N){
                if(i != j){
                    c ^= (1LL<<j);
                    break;
                }
            }
            ll a = A % v + (A - A % (v*2)) / 2;
            ll b = B % v + (B - B % (v*2)) / 2;
            c = c % v + (c - c % (v*2)) / 2;

            // print(i,a,b,c, N);
            vector<ll> r1 = solve(a,c,N/2);
            vector<ll> r2 = solve(c,b,N/2);
            // print(a,b);
            // vector<ll> rr = solve(a, b, N/2);
            ll bit1 = ((A>>i) & 1), bit2 = ((B>>i) & 1);
            for(auto &e: r1){
                ll val = e % v + (1LL<<i) * bit1 + (e - e % v) * 2;
                res.push_back(val);
            }
            for(auto &e: r2){
                ll val = e % v + (1LL<<i) * bit2 + (e - e % v) * 2;
                res.push_back(val);
            }

            break;
        }
    }
    return res;


}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B;
    cin >> N >> A >> B;
    ll na = __builtin_popcount(A);
    ll nb = __builtin_popcount(B);
    if(na % 2 == nb % 2){
        print("NO");
        return 0;
    }
    print("YES");
    vector<ll> ans = solve(A, B, (1LL<<N));
    printa(ans, (1LL<<N));

    

}

Measured memory_bytes: 2392
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(a, value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
 
typedef long long LL;
typedef pair<int, int> PII;

const int mod = 998244353;
const int MAX = 3007;

int add(int a, int b)
{
	return a + b < mod ? a + b : a + b - mod;
}

int sub(int a, int b)
{
	return a - b >= 0 ? a - b : a - b + mod;
}

int mult(int a, int b)
{
	return (LL)a * b % mod;
}

int dp[MAX][MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	FOR(i, a, c + 1)
		FOR(j, b, d + 1)
		{
			if(i == a && j == b)
				dp[a][b] = 1;
			else
				dp[i][j] = sub(add(mult(i, dp[i][j - 1]), mult(j, dp[i - 1][j])), mult(mult(i - 1, j - 1), dp[i - 1][j - 1]));
		}
	cout << dp[c][d] << "\n";
	return 0;
}


Measured memory_bytes: 38848
import java.io.*;

public class Main{
    public static void main(String[] args){
        double r,S,C;
        String line;
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            line=reader.readLine();
            r=Double.parseDouble(line);

            S=r*r*Math.PI;
            C=2.0*r*Math.PI;
            
            System.out.printf("%.10f %.10f\n",S ,C);

        }catch(NumberFormatException e){
            System.out.println(e);
        }catch(IOException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24668
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int64_t> A(N);
    bool zero =false;
    for (int i=0;i<N;i++) {
        cin >> A[i];
        if(A[i]==0){
            zero = true;
        }
    }
    
    
    int64_t ans=1;
    for (int i=0;i<N;i++) {
        if (zero==true) {
            ans = 0;
            break;
        }
        else if(A[i]>1000000000000000000/ans) {
            ans=-1;
            break;
        }
        else {
            ans *= A[i];
        }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;

int main(){
    int k,x;
    cin >> k >> x;
  	if(k == 1){
    	cout << x << endl;
      	return 0;
    }
    for(int i = k-1;i > 0;i--) cout << x - i << " " ;
    cout << x << " ";
    for(int i = 1;i < k;i++) cout << x + i << " ";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  string S, T;
  cin >> S >> T;
  sort(S.begin(), S.end());
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());
  if(S < T) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,K;
cin>>N>>K;
int count=0;
vector<int>wtf(N);
for(int i=0; i<N; i++){
cin>>wtf.at(i);
if(wtf.at(i)>=K){
count++;
}
}
cout<<count<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>

long long gcd(long long a, long long b)
{
	if (a > b) {
		a += b;
		b = a - b;
		a -= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	int i, N;
	long long A[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	
	int j, flag[100001] = {0, 1};
	long long g = A[1], tmp, max = 0;
	for (i = 2; i <= N; i++) {
		tmp = gcd(g, A[i]);
		if (tmp < g) flag[i] = 1;
		g = tmp;
	}
	for (i = 1; i <= N; i++) {
		if (flag[i] == 0) continue;
		g = (i == 1)? A[2]: A[1];
		for (j = 2; j <= N; j++) {
			if (j == i) continue;
			g = gcd(g, A[j]);
		}
		if (g > max) max = g;
	}
	
	printf("%lld\n", max);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1280
A,B,C,D=map(x->Int(x)-48,collect(chomp(readline())))
for i=0:1,j=0:1,k=0:1
  now=A
  now+=[B,-B][i+1]
  now+=[C,-C][j+1]
  now+=[D,-D][k+1]
  if now==7
    println("$A$(i==0?'+':'-')$B$(j==0?'+':'-')$C$(k==0?'+':'-')$D=7")
    exit()
  end
end

Measured memory_bytes: 112400
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int NUM_P = 11;
const int pnums[NUM_P] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};

const unsigned long long LINF = ~1ULL;

/* typedef */

typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef vector<pii> vpii;

/* global variables */

int n;
ull m;

/* subroutines */

inline int ch2int(char ch) {
  if (ch >= '0' && ch <= '9') return ch - '0';
  return ch - 'A' + 10;
}

void prime_decomp(int k, vpii& pds) {
  pds.clear();

  for (int pi = 0; k > 1; pi++) {
    int pn = pnums[pi];
    if (k % pn == 0) {
      int fi = 0;
      while (k % pn == 0)
	k /= pn, fi++;
      pds.push_back(pii(pn, fi));
    }
  }
}

void print_pds(vpii& pds) {
  for (int i = 0; i < pds.size(); i++) {
    if (i > 0) cout << '*';
    cout << pds[i].first << '^' << pds[i].second;
  }
  cout << endl;
}

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

    string mstr;
    cin >> mstr;

    m = 0;
    for (int i = 0; i < mstr.length(); i++)
      m = m * n + ch2int(mstr[i]);
    //cout << m << endl;

    vpii pds;
    prime_decomp(n, pds);
    //print_pds(pds);

    ull min_numz = LINF;
    
    for (int i = 0; i < pds.size(); i++) {
      int pn = pds[i].first;
      ull pns = 0;
      for (ull pexp = pn; pexp <= m; pexp *= pn)
	pns += m / pexp;
      //printf("%lld: %d = %lld\n", m, pn, pns);

      ull numz = pns / pds[i].second;
      if (min_numz > numz) min_numz = numz;
    }

    cout << min_numz << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
using namespace std;

class Dice{
public:
    long r[6];
    Dice(){};
    void roll(long a, long b, long c, long d){
        swap(r[a], r[b]);
        swap(r[b], r[c]);
        swap(r[c], r[d]);
    }
    void spinW(){roll(0, 2, 5, 3);}
    void spinN(){roll(0, 1, 5, 4);}
};

int main() {
    int ans = 0;
    int n;
    cin >> n;
    vector<Dice> D(n);
    for (int i = 0; i < n ; i++) {
        for (int j = 0; j < 6; j++) cin >> D[i].r[j];
    }
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1 ; j < n ; j++) {
            char SWS[8]={"NNNWNNN"};
            for (int k = 0; k < 8; k++){
                if (D[i].r[1] == D[j].r[1]) break;
                if (SWS[k] == 'W') D[j].spinW();
                else D[j].spinN();
            }
            for (int k = 0; k < 4; k++){
                if (D[i].r[0] == D[j].r[0]){
                    if (D[i].r[1] == D[j].r[1] && D[i].r[2] == D[j].r[2] && D[i].r[3]==D[j].r[3] && D[i].r[4] == D[j].r[4] && D[i].r[5] == D[j].r[5])
                        ans++;
                }
                D[j].spinW();
            }
        }
    }

    if (ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1196
from itertools import permutations as perm

n, m = map(int, input().split())

path = [[False] * n for _ in range(n)]
for i in range(n):
    path[i][i] = True

for _ in range(m):
    ai, bi = map(int, input().split())
    a, b = ai - 1, bi - 1
    path[a][b] = True
    path[b][a] = True

ans = 0
for ps in perm(range(1, n)):
    fst = ps[0]
    if not path[0][fst]:
        continue
    check = [path[i][j] for (i, j) in zip(ps, ps[1:])]
    if all(check):
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
using ll = long long;


int main() {
	ll x, y;
	cin >> x >> y;

	int cnt = 0;
	while (x<=y) {
		x *= 2;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  bool flag = false;
  REP(i, N){
    if(S[i] == '7') flag = true;
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
using namespace std;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int price = a * n;

	if (price <= b)
	{
		cout << price << endl;
	}
	else
	{
		cout << b << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int n;

	while (cin >> n, n){
		vector<bool> num(n + 1, true);
		
		for (int i = 2; i <= n; i++){
			if (num[i]){
				for (int j = i; j * i <= n; j++){
					num[j * i] = false;
				}
			}
		}
		bool check = false;
		for (int i = n; i >= 2; i--){
			if (num[i]){
				for (int j = i - 1; j >= 2; j--){
					if (num[j]){
						if (i - j == 2){
							cout << j << " " << i << endl;
							check = true;
							break;
						}
					}
				}
			}
			if (check){
				break;
			}
		}
		num.clear();
	}
	
	return (0);
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,y;
    cin>>x>>y;
    cout<<max(0,x-2*y);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		String line = br.readLine();
		String[] numbers = line.split(" ");
		int[] a = new int[n];
		
		for (int i = 0; i < numbers.length; i++) {
			a[i] = Integer.parseInt(numbers[i]);
		}
		
		for (int k = 0; k < a.length - 1; k++) {
			System.out.print(a[k] + " ");
		}
		System.out.println(a[a.length - 1]);
		
		for (int i = 1; i <= a.length - 1; i++) {
			int v = a[i];
			int j = i - 1;
			
			while(j >= 0 && a[j] > v){
				a[j + 1] = a[j];
				j--;
			}
			
			a[j + 1] = v;
			
			for (int k = 0; k < a.length - 1; k++) {
				System.out.print(a[k] + " ");
			}
			System.out.println(a[a.length - 1]);
			
		}
		
	}
}

Measured memory_bytes: 23824
n1,k1=map(int,input().split())
n2,k2=map(int,input().split())
n3,k3=map(int,input().split())
a=[0,0,0,0,0]
a[n1]+=1
a[n2]+=1
a[n3]+=1
a[k1]+=1
a[k2]+=1
a[k3]+=1
if a[4]==3 or a[1]==3 or a[2]==3 or a[3]==3 :
    print("NO")
else:
    print("YES")



Measured memory_bytes: 3064
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def lcm(x, y):
    return x // gcd(x, y) * y


def cnt(u, x, y):
    return u - (u // x + u // y - u // lcm(x, y))


A, B, C, D = map(int, input().split())

ans = 0

# B以下
ans += cnt(B, C, D)

# A-1以下
ans -= cnt(A - 1, C, D)

print(ans)


Measured memory_bytes: 38384
import sys
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines

# 0-indexed
class UnionFind:
  N=0
  parent=None
  size=None
  def __init__(self,N):
    self.N=N
    self.parent=[i for i in range(self.N)]
    self.size=[1]*self.N
    
  def root(self,x):
    while x!=self.parent[x]:
      self.parent[x]=self.parent[self.parent[x]]
      x=self.parent[x]
    return x
  
  def same(self,x,y):
    return self.root(x)==self.root(y)
  
  def unite(self,x,y):
    x=self.root(x)
    y=self.root(y)
    if x==y:
      return
    if self.size[x]>self.size[y]:
      # 大きい方にくっつける
      self.parent[y]=x
      self.size[x]+=self.size[y]
    else:
      self.parent[x]=y
      self.size[y]+=self.size[x]
      
  def get_group_size(self,x):
    return self.size[self.root(x)]
  
  def get_roots(self):
    r=set()
    for i in range(self.N):
      r.add(self.root(i))
    return r
  
  def show_parent(self):
    print(self.parent)
    
  def show_size(self):
    print(self.size)
    
N,M=map(int,readline().split())
UF=UnionFind(N)
for i in range(M):
  x,y,z=map(int,readline().split())
  UF.unite(x-1,y-1)
  
print(len(UF.get_roots()))


Measured memory_bytes: 16812
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
		
			if(H == 0 && W == 0)
				break;
			
			for(int i = 1;i <= H;i++){
				if(i == 1 || i == H){
					for(int j = 1;j <= W;j++){
						System.out.print("#");
					}
				}else{
					for(int j = 1;j <= W;j++){
						if(j == 1 || j == W)
							System.out.print("#");
						else
							System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 24908
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const ll INF = 1ll << 60;

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    vector<pair<int, string>> v;
    for (auto x : mp)
    {
        v.push_back({x.second, x.first});
    }

    sort(ALL(v), greater<pair<int, string>>());
    int mx = v[0].first;
    vector<string> ans;
    rep(i, n)
    {
        if (v[i].first != mx)
            break;
        ans.push_back(v[i].second);
    }
    sort(ALL(ans));
    rep(i, ans.size())
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 32876
#include <iostream>
#include <set>
using namespace std;
int main(void) {
	int n;
	string s;
	cin >> n;
	set<string> st;
	for (int i = 0; i < n; ++i) {
		cin >> s;
		st.insert(s);
	}
	cout << st.size();
	return 0;
}

Measured memory_bytes: 19184
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int a[MAXN];

void solve(){
	ll n, k;
	cin >> n >> k;
	REP(i, 0, n) {
		cin >> a[i];
	}
	ll cnt = 0;
	REP(i, 0, n) {
		REP(j, i + 1, n) {
			if (a[i] > a[j]) {
				cnt++;
			}
		}
	}
	cnt = (cnt * k) % MOD;
	
	ll v = (k * (k - 1) / 2) % MOD;
	ll v2 = 0ll;
	sort(a, a + n);
	for(int l = 0; l < n; ) {
		int r = l;
		for(; r < n && a[r] == a[l]; r++);
		v2 = (v2 + (r - l) * l * v) % MOD;
		l = r;
	}
	ll ans = (v2 + cnt) % MOD;
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	//n×m  matrix A, m×l matrix B , A x B -> n×l matrix C

	var n, m, l int

	fmt.Scanln(&n, &m, &l)

	A := make([][]int, n)
	for i := range A {
		A[i] = make([]int, m)
	}

	B := make([][]int, m)
	for i := range B {
		B[i] = make([]int, l)
	}

	C := make([][]int, n)
	for i := range C {
		C[i] = make([]int, l)
	}

	for i, An := range A {
		for j, _ := range An {
			fmt.Scanf("%d", &A[i][j])
		}
	}

	for i, Bm := range B {
		for j, _ := range Bm {
			fmt.Scanf("%d", &B[i][j])
		}
	}

	for i := 0; i < n; i++ {
		for k := 0; k < l; k++ {
			for j := 0; j < m; j++ {
				C[i][k] += A[i][j] * B[j][k]
			}
		}
	}

	//fmt.Println(A, B, C)
	for _, Cn := range C {
		for j, Cnl := range Cn {
			if j != l-1 {
				fmt.Printf("%d ", Cnl)
			} else {
				fmt.Printf("%d\n", Cnl)
			}
		}
	}

}



Measured memory_bytes: 2596
#include<bits/stdc++.h>
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define CLR(a) a.clear()
#define VCLR(a, n) for(int i=0; i<=n+3; i++) a[i].clear()
#define SIZE(a) a.size()
#define ERASE(a, b) memset(a, b, sizeof a)
#define PB(a, b) a.push_back(b)
#define PB2(a,i,b) a[i].push_back(b)
#define LL long long
#define ULL unsigned long long
#define DBG cout<<"I Am Here"<<endl
#define DBGA(a) cout<<a<<endl
#define DBGI(b,a) cout<<b<<' '<<a<<endl
#define DBGL(i,s,e,b) or(int i=s; i<=e; i++) cout<<b<<endl
#define INF 1e9
#define INV 1e-6
#define sll(a) scanf("%I64d", &a)
#define pll(a) printf("%I64d\n", a)
#define si(a) scanf("%d", &a)
#define pii pair<int,int>
#define MAX 100006
#define CASE(i) printf("Case %d:\n", i);
#define PI acos(-1)
#define piis pair<int, string>
#define fast1 ios_base::sync_with_stdio(false);
#define fast2 cin.tie(0)

using namespace std;

int main()
{
    LL a, b;
    scanf("%lld %lld", &a, &b);
    if(a>0 && b>0){
        printf("Positive");
    }
    else if(a==0 && (b==0 || b>0)){
        printf("Zero");
    }
    else if(a<0 && b>=0){
        printf("Zero");
    }
    else if(a<0 && b<0){
        a = abs(a); b = abs(b);
        LL len = b - a + 1;
        if(len%2==0)
            printf("Positive");
        else
            printf("Negative");
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int a[10];
bool judge(int x){
    while(x){
        int temp=x%10;
        if(a[temp])
            return 0;
        x/=10;
    }
    return 1;
}
int main(){
    int n,k;
    cin>>n>>k;
    memset(a,0,sizeof(a));
    for(int i=1; i<=k; i++){
        int x;
        cin>>x;
        a[x]=true;
    }
 
    for(int i=n; ;i++){
        if(judge(i)){
            cout<<i;
            break;
        }
    }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
counts = {}
ans = 0
for i in a:
  if not i in counts:
    counts[i] = 1
  else:
    counts[i] += 1

for key, value in counts.items():
  if key == value:
    continue
  elif value > key:
    ans += value - key
  elif value < key:
    ans += value

print(ans)

Measured memory_bytes: 17780
#include <iostream>
#include <stack>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
    stack<int> S1;
    stack<pair<int, int>> S2;
    string S;
    cin >> S;
    int s = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '\\') S1.push(i);
        else if (S[i] == '/' && S1.size() > 0) {
            int j = S1.top(); S1.pop();
            s += i - j;
            int a = i - j;
            while (S2.size() > 0 && S2.top().first > j) {
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while (!S2.empty()) {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << s << endl;
    cout << ans.size();
    for (auto i: ans) {
        cout << " " << i;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll n,m,a[100010]={},dp[100010],x,mod=1e9+7;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x;
        a[x]++;
    }
    dp[0]=1;
    if(a[1]==0){
        dp[1]=1;
    }
    else{
        dp[1]=0;
    }
    for(int i=2;i<=n;i++){
        if(a[i]==1){
            dp[i]=0;
        }
        else{
            dp[i]=(dp[i-1]+dp[i-2])%mod;
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	cin >> N;
	vector<int>W(N);
	//using T = tuple<int, int, int>;
	vector<vector<int>> V(N);

	for (int i = 0; i < N; i++)
	{
		cin >> W[i];
		vector<int> A(W[i]);
		for (int j = 0; j < W[i]; j++)
		{
			cin >> A[j];
		}
		V[i].push_back(0);
		V[i].push_back(1);
		V[i].push_back(2);
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < W[i]; k++)
			{
				if (A[k] == 0)
				{
					if (V[i][j] == 1)V[i][j] = 0;
					else if (V[i][j] == 0)V[i][j] = 1;
				}
				else
				{
					if (V[i][j] == 1)V[i][j] = 2;
					else if (V[i][j] == 2) V[i][j] = 1;
				}
				//cout << A[k] << " " << V[i][j]  << endl;
			}
		}
		//cout << V[i][0] << " " << V[i][1] << " " << V[i][2] << endl;
	}

	int n2 = N / 2;
	vector<int> tmp(3);
	vector<vector<int>> P(1 << n2);
	bool B[3][3][3];
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 3; k++)
			{
				B[i][j][k] = false;
			}
		}
	}
	for (int i = 1; i < 1 << n2; i++)
	{
		P[i].push_back(0);
		P[i].push_back(1);
		P[i].push_back(2);
		for (int j = 0; j < n2; j++)
		{
			if (i >> j & 1) //jを使う
			{
				tmp[0] = P[i][0];
				tmp[1] = P[i][1];
				tmp[2] = P[i][2];
				P[i][0] = tmp[V[j][0]];
				P[i][1] = tmp[V[j][1]];
				P[i][2] = tmp[V[j][2]];
			}
		}
		if (P[i][0] == 0 && P[i][1] == 1 && P[i][2] == 2)
		{
			cout << "yes" << endl;
			return;
		}
		B[P[i][0]][P[i][1]][P[i][2]] = true;
	}


	for (int i = 1; i < 1 << (N - n2); i++)
	{
		vector<int> Q;
		Q.push_back(0);
		Q.push_back(1);
		Q.push_back(2);

		for (int j = 0; j < N - n2; j++)
		{
			if (i >> j & 1)
			{
				tmp[0] = Q[0];
				tmp[1] = Q[1];
				tmp[2] = Q[2];
				//cout << Q[0] << " " << Q[1] << " " << Q[2] << endl;
				Q[0] = tmp[V[j + n2][0]];
				Q[1] = tmp[V[j + n2][1]];
				Q[2] = tmp[V[j + n2][2]];
				//cout << Q[0] << " " << Q[1] << " " << Q[2] << endl;
			}
		}

		if (Q[0] == 0 && Q[1] == 1 && Q[2] == 2)
		{
			cout << "yes" << endl;
			return;
		}
		//cout << Q[0] << " " << Q[1] << " " << Q[2] << endl;
		int zero, one, two;
		for (int k = 0; k < 3; k++)
		{
			if (Q[k] == 0)
			{
				zero = k;
			}
			if (Q[k] == 1)
			{
				one = k;
			}
			if (Q[k] == 2)
			{
				two = k;
			}
		}
		if (B[zero][one][two])
		{
			cout << "yes" << endl;
			return;
		}
	}

	cout << "no" << endl;



}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 395992
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

struct State {
    int r, g, b;
    State(int r, int g, int b): r(r), g(g), b(b) {}
    bool operator < (const State &s) const {
        if(r != s.r) return r < s.r;
        if(g != s.g) return g < s.g;
        return b < s.b;
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin >> a[i];
    }

    if(a[0] != 0) {
        cout << 0 << endl;
        return 0;
    }

    map<State, ll> mp[2];
    mp[1][State(1, 0, 0)] = 1;  // 1人目の帽子の色は固定
    for(int i=1;i<n;++i) {
        mp[(i+1)%2].clear();
        for(auto itr=mp[i%2].begin();itr!=mp[i%2].end();++itr) {
            State s = itr->first;
            State t = s;
            if(s.r == a[i]) {
                ++t.r;
                mp[(i+1)%2][t] += (itr->second);
                mp[(i+1)%2][t] %= MOD;
                --t.r;
            }
            if(s.g == a[i]) {
                ++t.g;
                mp[(i+1)%2][t] += (itr->second);
                mp[(i+1)%2][t] %= MOD;
                --t.g;
            }
            if(s.b == a[i]) {
                ++t.b;
                mp[(i+1)%2][t] += (itr->second);
                mp[(i+1)%2][t] %= MOD;
                --t.r;
            }
        }
    }

    ll ans = 0;
    for(auto itr=mp[n%2].begin();itr!=mp[n%2].end();++itr) {
        ans += (itr->second);
        ans %= MOD;
    }

    cout << (ans * 3) % MOD << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {	
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		
		int now=Integer.parseInt(sc.next());
		int maxcount=0;
		int count=0;
		for(int i=0;i<a-1;i++) {
			int b = Integer.parseInt(sc.next());
			if(now<b) {
				if(maxcount < count)maxcount= count;
				count =0;
			}else {
				count++;
			}
			now=b;
			
		}
		
		if(maxcount < count)maxcount= count;
		count =0;
		System.out.println(maxcount);
	}
}


Measured memory_bytes: 46872
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <map>
#include <set>
#include <vector>
#include <string.h>
#include <cmath>
#include <climits>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
const int N = 1015;

int n, m, tmp, res, ss, ma, vt;
struct data
{
    int x, pre, nex;
};
data a[N][N];
int an[N][N];
int d[N];

int main()
{
    #define file "ss"
    //freopen(file".inp", "r", stdin);
    //freopen(file".out", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            cin >> a[i][j].x;
            a[i][j].nex = j + 1, a[i][j].pre = j - 1;
            an[i][a[i][j].x] = j;
        }
    for (int i = 1; i <= n; i++) a[i][0].nex = 1;
    ss = 0;
    res = 1515;
    while (ss < m)
    {
        ma = 0, vt = 0;
        for (int i = 1; i <= m; i++) d[i] = 0;
        //cout << "asd "<< ss<<endl;
        for (int i = 1; i <= n; i++)
        {
            int id = a[i][0].nex;
            d[a[i][id].x]++;
            if (d[a[i][id].x] > ma)
                ma = d[a[i][id].x], vt = a[i][id].x;
            //cout << a[i][id].x<<" ";
        }
        //cout <<"\n"<< ma <<" "<< vt << endl;
        res = min(res, ma);
        for (int i = 1; i <= n; i++)
        {
            int id = an[i][vt];
            int nex = a[i][id].nex, pre = a[i][id].pre;
            a[i][pre].nex = nex;
            a[i][nex].pre = pre;
        }
        ss++;
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 7552
#include <iostream>
#include <string>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  int ans = 0;
  char prev = s[0];
  for (int i = 1; i < s.size(); ++i) {
    if (prev != s[i])
      ++ans;
    prev = s[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream> 
#include <cstring>
#include <vector>
#include <queue> 
#define MAXN 200000 + 105
#define INF 0x3f3f3f3f
using namespace std;
int dis[MAXN], n, m;
bool vst[MAXN];
vector <int> g[MAXN];
void bfs() {
	memset(dis, INF, sizeof(dis));
	queue <int> q;
	q.push(1);
	vst[1] = 1, dis[1] = 0;
	while(!q.empty()) {
		int t = q.front();
		int len = g[t].size();
		q.pop();
		for(int i = 0; i < len; i++) {
			if(!vst[g[t][i]]) {
				vst[g[t][i]] = 1;
				q.push(g[t][i]);
				dis[g[t][i]] = dis[t] + 1;
			}
		}
	}
}

int main() {
	int u, v;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++) {
		scanf("%d %d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	bfs();
	if(dis[n] == INF || dis[n] > 2) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
	return 0;
}

Measured memory_bytes: 13424
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int[] a={0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x=sc.nextInt();
    int y=sc.nextInt();
    if(a[x]==a[y]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22740
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static Scanner scan;

    private static void start() {
        scan = new Scanner(java.lang.System.in);

    }

    private static void finish() {

    }


    public static void main(String[] args) {
        start();

        int n = scan.nextInt();
        int d = scan.nextInt();
        int x = scan.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }

        int totalChoc = 0;
        for (int i = 0; i < n; i++) {
            int q = 1;
            int choc = 0;
            while (q <= d) {
                q += a[i];
                choc++;
            }
            totalChoc += choc;
        }
        System.out.println(totalChoc + x);

        finish();
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <array>
using namespace std;

int main(void) {
int n, m, i, j;
array<int, 101> t;
array<int, 101> p;
array<int, 101> x;
array<int, 101> sum{0};

std::cin >> n;//入力
for (i = 0; i < n; i++) {
  std::cin >> t[i];
}
std::cin >> m;
for (i = 0; i < m; i++) {
  std::cin >> p[i] >> x[i];
}

for (i = 0; i < m; i++) {
  for (j = 0; j < n; j++) {
    if (j == p[i] - 1) {
      sum[i] = sum[i] + x[i];
    } else {
      sum[i] = sum[i] + t[j];
    }
  }
}
for (i = 0; i < m; i++) {
  std::cout << sum[i] << '\n';
}
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int i = 0;
char arr[6];
int main() {
	int r, c;
	scanf("%d %d", &r, &c);
	while (1) {
		scanf("%s", arr);
		if (!strcmp(arr, "snuke")) break;
		++i;
	}
	printf("%c%d", i%c + 'A', i / c + 1);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(i=a;i<b;i++)
#define inf         INT_MAX

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

using namespace std;
void solve()
{
    ll n,d,i,ans=0;
    cin>>n>>d;
    rep(i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)
         ans++;
    }
    cout<<ans;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;

int main() {
	char ch;
	cin>>ch;
//   ch-
//   65 90
//   ch-'A'
   int x=ch-'A';
   if(x>=0 && x<=25)
   cout<<"A"<<"\n";
   else
   cout<<"a"<<"\n";
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b, c ;
  cin >> a >> b >> c ;
  
  if(a<=c && c<=b){
    cout <<"Yes"<<endl ;
  }
  else{
    cout <<"No"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, m;
    int[] N;
    int[] M;
    int[] get;
    int max, ans;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    m = sc.nextInt();
	    N = new int[n];
	    M = new int[m];
	    get = new int[n];
	    max = 0;
	    ans = 0;

	    for(int i=0; i<n; i++)
		N[i] = sc.nextInt();
	    for(int i=0; i<m; i++)
		M[i] = sc.nextInt();

	    for(int i=0; i<m; i++){
		int k=0;		
		while(N[k]>M[i])k++;
		get[k]++;
		if(get[k]>max){
		    max = get[k];
		    ans = k+1;
		}
	    }

	    System.out.println(ans);
	}
    }
}

Measured memory_bytes: 25100
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<unordered_map>

using namespace std;
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x)  scanf(" %c",&x);
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
#define INF 0x3f3f3f3f
#define ll long long
#define mod  998244353
const  int N = 1e6+5;
int main(){
    ll n,s,k;
    cin >> n >> k >> s;
    ll c = s;
    if(s > 1) {
        c --;
    }
    else c ++;
    for(int i = 1;i <= k;++i) cout<<s<<' ';
    for(int i = 1;i <= n - k; ++i) cout<<c<<' ';
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

template<typename T>
struct Segment_Tree {
	typedef function<T(T, T)> F;

	ll n;
	F f;//モノイドとしての演算(最小値、和　など)
	T unit;//単位元

	ll size;
	vector<T> seg;

	Segment_Tree(ll n0, F f0, T unit0) {
		n = n0;
		f = f0;
		unit = unit0;

		size = 1;
		while (size < n) {
			size *= 2;
		}
		seg.assign(2 * size, unit);
	}


	void update(ll k, T x) {//k番目の要素をxに更新
		k += size - 1;
		seg[k] = x;
		while (k > 1) {
			k /= 2;
			seg[k] = f(seg[2 * k], seg[2 * k + 1]);
		}
	}



	T query_prep(ll a, ll b, ll k, ll l, ll r) {//[a,b)とkに対応する区間[l,r)の共通部分でクエリ
		if (b <= l || a >= r) { return unit; }
		if (a <= l && r <= b) { return seg[k]; }

		T v1 = query_prep(a, b, 2 * k, l, (l + r) / 2);
		T v2 = query_prep(a, b, 2 * k + 1, (l + r) / 2, r);
		return f(v1, v2);

	}

	T query(ll a, ll b) {
		return query_prep(a, b, 1, 1, size + 1);
	}

};


ll p(char c) {
	if (c == 'a') { return 1; }
	return p(c - 1)*2;
}



int main() {

	ll N,Q;
	string S;

	cin >> N >> S >> Q;

	Segment_Tree<ll> sg(N, [](ll a, ll b) {return a | b; }, 0);

	
	repn(i, N) {
		sg.update(i,p(S[i - 1]));
	}


	repn(i, Q) {
		ll t;
		cin >> t;

		if (t == 1) {
			ll i;
			char c;
			cin >> i >> c;
			sg.update(i, p(c));
		}

		if (t == 2) {
			ll l, r;
			cin >> l >> r;
			ll x = sg.query(l, r + 1);

			//cout << x << endl;

			ll ans = 0;

			rep(j, 26) {
				if (x % 2 == 1) { ans++; }
				x /= 2;
			}
			cout << ans<<endl;
		}
	}



	system("PAUSE");
}






Measured memory_bytes: 9340
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct WeightedUnionFind {
    vector<int> data;
    vector<int> diff_weight;

    WeightedUnionFind(int sz) : data(sz, -1), diff_weight(sz, 0) {}

    bool unite(int x, int y, int w) {
        w += weight(x);
        w -= weight(y);
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) {
                swap(x, y);
                w = -w;
            }
            data[x] += data[y];
            data[y] = x;
            diff_weight[y] = w;
        } else {
            if (diff(x, y) == w) return true;
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { 
            return x;
        } else {
            int par = data[x];
            data[x] = find(data[x]);
            diff_weight[x] += diff_weight[par];
            return data[x];
        }
    }

    int weight(int x) {
        find(x);
        return diff_weight[x];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int diff(int x, int y) {
        return weight(y) - weight(x);
    }

    int size(int x) {
        return -data[find(x)];
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	WeightedUnionFind wuf(n);
	rep(i,m){
		int l, r, d;
		cin >> l >> r >> d;
		--l; --r;
		if(!wuf.unite(l, r, d)){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,T;
    cin>>n>>T;
    int t[n];
    long long ans=0;
    for(int i=0;i<n;i++){
      cin>>t[i];  
    }
    for(int i=0;i<n-1;i++){
        if(t[i]+T<=t[i+1]){
          ans+=T;  
        }
        else{
          ans+=t[i+1]-t[i];  
        }
    }
    cout<<ans+T<<endl;
}

Measured memory_bytes: 1024