akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll X;
  cin>>X;
  rep(i,sqrt(X)+10){
    if(X%(i+1)==0){
      ll tmp=i+1;
      rep(j,sqrt(X)+10){
        ll A=j;
        ll B=A-tmp;
        if(A*A*A*A*A-B*B*B*B*B==X){
          cout<<A<<" "<<B<<endl;
          return 0;
        }
      }
    }
  }
}



Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int N, M, Q, X[501][501], C[501][501];
int L, R;
int p, q;

int main(){
  cin >> N >> M >> Q;
  rep (i, M){
    cin >> L >> R;
    X[L][R] += 1;
  }
  rep (i, N){
    rep(j, N){
      C[i][j] = C[i][j-1] + X[i][j];
    }
  }
  rep (i, Q){
    cin >> p >> q;
    int ans = 0;
    for (int j = p ; j <= q; j++){
      ans += C[j][q]-C[j][p-1];
    }
    cout << ans << endl;
  }
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<pii> arr (2*N);
	F0R(i, 2*N) {
		char c; cin >> c;
		int a; cin >> a;
		arr[i] = {c == 'B', a};
	}

	vector<vi> wbelow(2*N, vi (N+1));
	F0R(i, 2*N) F0R(j, N+1) {
		wbelow[i][j] = (!arr[i].first) && arr[i].second <= j;
		if (i > 0) wbelow[i][j] += wbelow[i-1][j];
	}
	
	vector<vi> bbelow(2*N, vi (N+1));
	F0R(i, 2*N) F0R(j, N+1) {
		bbelow[i][j] = (arr[i].first) && arr[i].second <= j;
		if (i > 0) bbelow[i][j] += bbelow[i-1][j];
	}

	vi wpos (N+1);
	vi bpos (N+1);
	F0R(i, 2*N) {
		if (arr[i].first) bpos[arr[i].second] = i;
		else wpos[arr[i].second] = i;
	}

	vector<vi> dp (N+1, vi (N+1, 4*N*N));
	dp[0][0] = 0;
	F0R(w, N+1) F0R(b, N+1) {
		if (w == 0 && b == 0) continue;
		if (w > 0) dp[w][b] = min(dp[w][b], dp[w-1][b] + wpos[w] - wbelow[wpos[w]][w-1] - bbelow[wpos[w]][b]);
		if (b > 0) dp[w][b] = min(dp[w][b], dp[w][b-1] + bpos[b] - bbelow[bpos[b]][b-1] - wbelow[bpos[b]][w]);
	}
	print(dp[N][N]);
}

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

long long int umin(long long int a, long long int b){
    if(a>=b){
        return b;
    }
    return a;
}

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);
    int n;  cin >> n;   vector<long long int> vec(n+5); vector<long long int> dp(n+5);
    for(int i=1;n>=i;i++){
        cin >> vec[i];
    }
    dp[2]=abs(vec[2]-vec[1]);   dp[3]=umin(dp[2]+abs(vec[3]-vec[2]), abs(vec[3]-vec[1]));
    for(int i=4;n>=i;i++){
        dp[i]=umin(dp[i-1]+abs(vec[i]-vec[i-1]), dp[i-2]+abs(vec[i]-vec[i-2]));
    }
    cout << dp[n];    
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0 && m == 0)
            return 0;

        vector<int> a(n+m);
        for(int i=0; i<n+m; ++i)
            cin >> a[i];
        inplace_merge(a.begin(), a.begin()+n, a.end());

        int ret = a[0];
        for(int i=1; i<n+m; ++i)
            ret = max(ret, a[i] - a[i-1]);
        cout << ret << endl;
    }
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    vector <int> ls;
    int temp=0;
    for (int i=1;i<100;i++){
        temp+=i;
        ls.push_back(temp);
        //cout<<i<<endl;
    }
    long long int N;
    cin>>N;
    int ans=0;
    int limit=sqrt(N);
    for (int i=2;i<=limit;i++){
        int cnt=0;
        while (N%i==0){
            cnt++;
            N=N/i;
        }
        if(cnt){
            vector<int>::iterator upper;
            upper = upper_bound (ls.begin(), ls.end(), cnt);
            //cout<<upper-ls.begin()<<endl;
            ans+=upper-ls.begin();
        }    
    }
    if(N>2) ans++;
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3676
n,m=map(int,input().split())
List=[list(map(int,input().split())) for i in range(m)]
P=list(map(int,input().split()))

ans=0

for i in range(2**n):
    flug=True
    for l in range(m):
        count=0
        for j in range(List[l][0]):
            if ((i >> (List[l][j+1]-1))&1)==1:
                count += 1
        if count%2 != P[l]:
            flug=False
    if flug==True:
        ans += 1
        
print(ans)

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

int score,p_avail;

int main(void){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if((s[i]=='g') && p_avail == 0){
            p_avail++;
        }
        else if((s[i]=='g') && p_avail > 0){
            p_avail--;
            score++;
        }
        else if((s[i]=='p') && p_avail == 0){
            p_avail++;
            score--;
        }
        else{
            p_avail--;
        }
    }
    cout<<score<<endl;
    return 0;
}


Measured memory_bytes: 512
/*
memo
????????°??????

*/

#include<iostream>
#include<cstring>
#include<vector>
using namespace std;

int m, n;
int ma[300];
int ka[300][300];
vector<int> g[300];
bool go[300], ba[300];
void iki(int x)
{
	//????????§????????¨????????????????????????

	//????????????????????´??????????????????????????°?????¨??????
	//????????´??????????????°???????????????
	//???????????????????????§??????????????¶???????????????????????????????????£???
	//??????????????°????????????????????°????????????????????°?????¨???????????????????????????
	//?????????????????????????????°?????¨??°?????°????????´???????¨???????????????????
	//????????????????????´???????????£???????????´???????????????????????????????????????
	//??´?????????????????????????????´??????????§???????????????????????????????????????´????????????????????¨??????????????°????????????????????????????????????

	int i;

	if (go[x]) return;
	go[x] = true;				//????????°??????
	if (x == n + 1) return;
	for (i = 1; i <= m; i++)
	{
		int y = x + i;
		if (y <= n+1)
		{
			y = y + ma[y];
			if (y>0)
			{
				if (y > n + 1) y = n + 1;
				//if (ka[y][x] == 1)break;
				//ka[y][x] = 1;

				g[y].push_back(x);
				iki(y);
			}
		}

	}
	return;
}

void kae(int x)
{
	//????????§?????°?????¨????????´???????????????????????????????????¨???????????????????????????

	//????????????????????´?????????????§??????¨??????????????????????????°????????????????????§???????????´?????????????????????
	//??????????????§?????£?????´??????????????¨?????????????????°???????????????


	int i;
	if (ba[x]) return;
	ba[x] = true;
	if (x == 0) return;
	for (i = 0; i<g[x].size(); i++)
	{
		kae(g[x][i]);
	}
	return;
}

int main()
{
	int i;
	while (cin >> m, m)
	{
		cin >> n;

		//---------------?????????--------------------//
		for (i = 0; i<300; i++)
		{
			g[i].clear();
			ma[i] = 0;
			for (int j = 0; j<300; j++)
			{
				ka[i][j] = 0;
			}
		}
		memset(go, 0, sizeof(go));
		memset(ba, 0, sizeof(ba));


		for (i = 1; i <= n; i++)
		{
			cin >> ma[i];
		}
		ma[0] = ma[n + 1] = 0;

		iki(0);
		kae(n + 1);


		/*
		for (i = 0; i <= n + 1; i++)
		{
			cout << "  " << go[i] << "  " ;
		}
		cout << endl;
		for (i = 0; i <= n + 1; i++)
		{
			cout << "  " << ba[i] << "  ";
		}
		*/



		for (i = 0; i <= n + 1; i++)
		{
			if (go[i])
			{
				if (ba[i] == 0)
				{
					cout << "NG\n";
					break;
				}
			}
			if (i == n + 1) cout << "OK\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
#define N 200010
int n,va[N],c[N],ans,s,f[N],ss[N],nm[N];
int main(){
	cin>>n;
	for(int i=1;i<N;i++)
		nm[i]=nm[i-(i&-i)]+1;
	for(int i=1;i<N;i++)nm[i]--;
	for(int i=1;i<n;i++){
		int x,y,z;
		cin>>x>>y>>z;
		va[x]^=z;
		va[y]^=z;
	}
	for(int i=0;i<n;i++)
		c[va[i]]++;
	for(int i=1;i<=15;i++){
		ans+=c[i]/2;
		if(c[i]%2==1)s|=(1<<(i-1));
	}
	for(int i=1;i<(1<<15);i++)
		for(int j=0;j<15;j++)
			if(i&(1<<j))ss[i]^=(j+1);
	for(int i=1;i<(1<<15);i++)
		if(!ss[i])
			for(int j=i;j;j=(j-1)&i)
				if(!ss[j]&&!ss[i-j])
					nm[i]=min(nm[i],nm[i-j]+nm[j]);
	cout<<ans+nm[s];
}

Measured memory_bytes: 1664
N, T = map(int, raw_input().split())
a = []
ans=10000
for i in range(N):
    a.append(map(int, raw_input().split()))
# print a
for i in range(N):
    # print i
    if ans>a[i][0] and T>=a[i][1]:
        ans=a[i][0]
if ans<10000:
    print ans
else:
    print "TLE"


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int i=0,count=0;
    while(s[i]!='\0'){
        if(s[i]!=t[i]){
            count++;
        }
        i++;
    }
    cout<<count;
}

Measured memory_bytes: 3872
N,X,Y = map(int,input().split())
X-=1
Y-=1

ans = [0 for i in range(N-1)]
for i in range(N-1):
    for j in range(i+1,N):
        dis1 = j-i
        dis2 = abs(X-i)+1+abs(Y-j)
        dis = min(dis1,dis2)
        # print(i,j,dis)
        ans[dis-1] += 1

for i in range(N-1):
    print(ans[i])

Measured memory_bytes: 3444
n,m = map(int,input().split())

MOD = 10**9 + 7
FAC = [1]
INV = [1]
for i in range(1,max(m,n)+1):
  FAC.append((FAC[i-1]*i) % MOD)
  INV.append(pow(FAC[-1],MOD-2,MOD))

def nPr(n,r):
  return FAC[n]*INV[n-r]

if abs(n-m) > 1:
  print(0)
else:
  ans = nPr(n,n)*nPr(m,m)
  ans %= MOD
  if n == m:
    ans *= 2
    ans %= MOD
  print(ans)

Measured memory_bytes: 79848
#include <stdio.h>

int main(int argc, char** argv)
{
	char str[1200];
	int i;

	memset(str, '\0', sizeof(str));
	scanf("%[^\n]", &str);

	for (i = 0; str[i] != '\0'; i++) {
		if (str[i] >= 'A' && str[i] <= 'Z') {
			str[i] = str[i] + 32;
		}
		else if (str[i] >= 'a' && str[i] <= 'z') {
			str[i] = str[i] - 32;
		}
	}

	printf("%s\n", str);

	return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans=1;
		for(int i=0;i<N;i++) 
			if(ans * 2 < ans + K)		ans *= 2; 
			else							ans += K;
		System.out.println(ans);
	}
	

}


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

int main(){
  int N,count = 0;
  int ans = 1;
  cin >> N;
  
  while(N > 1){
    N /= 2;
    count++;
  }
  while(count != 0){
    ans *= 2;
    count--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define s(a,l,r) sort(a+l,a+r+1)
#define f(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
int a[110000];
int main()
{
	int n,ans=0;
    scanf("%d",&n);
    f(i,1,n) scanf("%d",&a[i]);
    s(a,1,n);
    f(i,1,n) if(a[i]==a[i-1]) ans++;
    ans=(ans+1)/2*2;
    printf("%d\n",n-ans);
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] x = new int[N+1];
    int[] y = new int[N+1];
    int[] h = new int[N+1];
    int[] Hc = new int[N+1];
    int maxh =0;
    for (int i =1; i<N+1; i++) {
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
      h[i] = sc.nextInt();
      maxh = Math.max(h[i],maxh);
    }
    int Cx =0; int Cy =0; int H =0; int count =0; int count2 =0;
    for (int i =0; i<101; i++) {
      for (int j =0; j<101; j++) {
        for (int k =1; k<N+1; k++) {
          if (h[k] ==0) {
            Hc[k] =0;
          } else {
            Hc[k] = h[k] + Math.abs(x[k] - i) + Math.abs(y[k] - j);
            H = Hc[k];
          }
        }
        for (int k =1; k<N; k++) {
          if (Hc[k] == H || Hc[k] ==0) count++;
        }
        if (count == N-1) {
          Cx = i;
          Cy = j;
          for (int k =1; k<N+1; k++) {
            if (h[k] == Math.max(H - Math.abs(x[k] - Cx) - Math.abs(y[k] - Cy),0)) {
              count2++;
            }
          }
          if (count2 == N) {
            System.out.println(Cx + " " + Cy + " " + H);
            return;
          }
          count2 =0;
        }
        count =0;
      }
    }
  }
}

Measured memory_bytes: 40392
n = int(input())
for i in range(n):
    data = [int(i) for i in input().split()]
    flag = False
    a = [0]
    b = [0]
    for ball in data:
        if ball > a[-1]:
            a.append(ball)
        elif ball > b[-1]:
            b.append(ball)
        else:
            flag = True
            break
    print("NO") if flag else print("YES")


Measured memory_bytes: 5600
N = int(input())
E = [[] for _ in range(N)]
dic = {}
for i in range(N-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    E[a].append(b)
    E[b].append(a)
    dic[(a, b)] = i

k = 0
for e in E:
    k = max(k, len(e))

ans = [0]*(N-1)
from collections import deque
q = deque()
q.append((0, 0))
used = [0]*N
used[0] = 1
while q:
    temp = q.pop()
    v = temp[0]
    num = temp[1]
    for t in E[v]:
        if used[t] == 1:
            continue
        used[t] = 1
        a = min(v, t)
        b = max(v, t)
        num += 1
        ans[dic[(a, b)]] = (num%k) + 1
        q.append((t, (num%k)))
print(k)
for a in ans:
    print(a)

Measured memory_bytes: 81696
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

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

  int N;
  cin >> N;
  int ans = 0 , sum = 0;
  for(int i = 1;i <= N; i++) {
    int x;
    cin >> x;
    if(x == 0) {
      ans += sum / 2;
      sum = 0;
      continue;
    }
    sum += x;
  }
  ans += sum / 2;
  cout << ans << '\n';

}


Measured memory_bytes: 3120
#include<iostream>
#include<string>
int main(){
	std::string s;
	int i=0;
	getline(std::cin,s);
	while (s[i] != '\0'){
		if (s[i] >= 65 && s[i] <= 90)s[i] += 32;
		else if(s[i] >= 97 && s[i] <= 122)s[i] -= 32;
		++i;
	}
	std::cout << s << std::endl;
}

Measured memory_bytes: 1176
# coding:UTF-8

cA = 500
cB = 100
cC = 50

a = int(input())
b = int(input())
c = int(input())
x = int(input())  # 要求金額

cnt = 0
for i in range(0, a + 1):
    for j in range(0, b + 1):
        for k in range(0, c + 1):
            sum = cA * i + cB * j + cC * k
            if sum == x:
                cnt+=1

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int add(int x,int y){return x+y<mod?x+y:x+y-mod;}
void ade(int& x,int y){x+=y;if(x>=mod)x-=mod;}
map<string,int>dp;
int solve(string s)
{
    int n=s.size();
    if(n==0)return 1;
    if(n==1)return s[0]-'0'+1;
    if(dp[s])return dp[s];
    string x,y;
    x="",y="";
    x.push_back(s[0]);
    for(int i=1;i<n;++i)y.push_back(s[i]);
    int res=1ll*solve(x)*solve(y)%mod;
    for(int i=1;i<=n;++i)
    {
        x="";
        for(int j=0;j<i;++j)x.push_back(s[j]);
        for(int j=i+i-1;j<n;j+=i)
        {
            for(int k=j-i+1,p=0;k<=j;++k,++p)x[p]=min(x[p],s[k]);
            y="";
            for(int k=j+1;k<n;++k)y.push_back(s[k]);
            ade(res,1ll*solve(x)*solve(y)%mod);
        }
    }
    dp[s]=res;
    return res;
}
int main()
{
    string(s);
    cin>>s;
    printf("%d\n",solve(s));
    return 0;
}


Measured memory_bytes: 7040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073
{
	class Program
	{
		static void Main(string[] args)
		{
			string n;
			n = Console.ReadLine();
			if (n[0] == '9' || n[1] == '9')
				Console.WriteLine("Yes");
			else
				Console.WriteLine("No");
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 13140
// https://atcoder.jp/contests/abc133/tasks/abc133_b

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
#define DBL_EPSILON 2.2204460492503131E-16
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

int in[20][20];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, d, ans = 0;
    cin >> n >> d;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> in[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int sum = 0;
            for (int k = 0; k < d; k++) {
                // int t1 = in[i][k];
                // int t2 = in[j][k];
                sum += (in[i][k] - in[j][k]) * (in[i][k] - in[j][k]);
            }
            double integral_part = 0;
            double fractional_part = modf(sqrt(sum), &integral_part);
            if (fractional_part <= DBL_EPSILON) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 55;
LL dp[maxn][2][maxn][2];
int digit[maxn],N;

LL dfs(const int i, const int ic, const int j, const int jc)
{
    if (i > j)
        return 1;
    const int a = digit[i];
    const int b = digit[j];
    LL& ans = dp[i][ic][j][jc];
    if (ans == -1) {
        ans = 0;
        FOR(x,0,10) {
            const int lft = x+a+ic;
            const int y = (i == j) ? x : lft % 10;
            const int rht[] = { y+b, y+b+1 };
            if (i == 0 && y == 0)
                continue;
            FOR(k,0,SZ(rht)) {
                if (jc && rht[k] > 9 || !jc && rht[k] <= 9) {
                    if (rht[k]%10 == x) {
                        const LL res = dfs(i+1, lft>9, j-1, k);
                        ans += res;
                    }
                }
            }
        }
    }
    return ans;
}

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int D;
    while (cin >> D) {
        memset(digit,0,sizeof(digit));
        N = 0;
        while (D) {
            digit[N++] = D%10; D /= 10;
        }
        LL ans = 0;
        FOR(n,N-1,maxn-1) {
            memset(dp,-1,sizeof(dp));
            const LL res = dfs(0,0,n,0);
            ans += res;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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;
}

bool is_prime(int k, int i) {
    if(k == 2) return true;
    if(k <= i) return true;
    else {
        if(k % i == 0) return false;
        else return is_prime(k, i + 1);
    }
}


int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s;
    REP(i, m) {
        int k;
        cin >> k;
        vector<int> s_i(k);
        REP(j, k) {
            cin >> s_i[j];
        }
        s.push_back(s_i);
    }
    vector<int> p(m);
    REP(i, m) {
        cin >> p[i];
    }
    int counter = 0;
    REP(i, pow(2, n)) {
        ll bi_i  = i;
        vector<int> bi(n);
        REP(j, n) {
            bi[j] = bi_i % 2;
            bi_i /= 2;
        }
        /*REP(j, n) {
            cout << bi[j] << ' ';
        }
        cout << endl;*/
        
        bool flag = true;
        REP(j, m){
            int swi_sum = 0;
            for(int sw : s[j]){
                /*cout << "sw = " << sw - 1 << endl;*/
                if(bi[sw-1] == 1) {
                    swi_sum += 1;
                }
            }
            /*cout << "swi_sum = " << swi_sum << endl;*/
            if(swi_sum %2 != p[j]) {
                flag = false;
            }
        }
        if(flag) counter += 1;
    }
    cout << counter << endl;
    

}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	cin >> N >> M >> K;
	if (N <= M * K)cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
#define max 100

int aa[max][max];
int n;
int d[max];
int f[max];
int color[max];
int tt = 0;
int p[max];

void dfscount(int u) {
	color[u - 1] = 1;
	int x = -1;
	for (int i = n-1; i >= 0; i--) {
		if (aa[u - 1][i] == 1 && color[i] == 0) x = i + 1;
	}
	if (x == -1) {
		f[u - 1] = ++tt;
		color[u - 1] = 2;
		if (p[u - 1] == -1) {
			for (int i = 0; i < n; i++) {
				if (color[i] != 2) {
					d[i] = ++tt;
					dfscount(i + 1);
				}
			}
			return;
		}
		dfscount(p[u - 1]);
	}
	else {
		d[x - 1] = ++tt;
		p[x - 1] = u;
		dfscount(x);
	}
}

void dfs() {
	d[0] = ++tt;

	for (int i = 0; i < n; i++) {
		color[i] = 0;
		p[i] = -1;
	}

	dfscount(1);
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;
	}
}

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			aa[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		int num1;
		cin >> num1;
		for (int j = 0; j < num1; j++) {
			int x;
			cin >> x;
			aa[num - 1][x - 1] = 1;
		}
	}

	dfs();

	return 0;
}


Measured memory_bytes: 3160
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    while True:
        A.sort()
        l = A.pop()
        if l < N:
            break
        x = (l-N)//N + 1
        ans += x
        l -= x*N
        A = [a+x for a in A]
        A.append(l)


    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6476
n = int(input())

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    mod = 10**9+7
    tmp_all = 1
    tmp_not09 = 1
    tmp_not0 = 1
    tmp_not9 = 1
    for i in range(n):
        tmp_all *= 10
        tmp_not09 *= 8
        tmp_not0 *= 9
        tmp_not9 *= 9

        tmp_all %= mod
        tmp_not09 %= mod
        tmp_not0 %= mod
        tmp_not9 %= mod

    print((tmp_all + tmp_not09 - tmp_not0 - tmp_not9)%mod)



Measured memory_bytes: 63580
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	n := scanInt()
	p, m := n/2, n%2
	if m != 0 {
		p++
	}

	fmt.Println(p)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[0] = scanInt()
	}
	return ints
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}


Measured memory_bytes: 640
/*

??????????????贈????????????

?????????Run time error

C?即??????則???????????????????????????????????贈??\??????????????卒???????????????????????則'\0'?????\??????????????属???????????????
??\???????????即???????????卒????????????????????贈???????????????
strcpy()???strcat()???????????則????属????'\0'?????\??????????????????
C++??則???????????則?????贈???????????????


*/

#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main()
{
	char top[300];
	char bottom[300];
	char data[300];
	char none[1] = "";
	int kai,mai;
	int i,k,m,len;
	while(1){
		scanf("%s", data);
		if(data[0]=='-'&&strlen(data)==1){
			break;
		}
		len=strlen(data);
		scanf("%d", &kai);
		for(i=0; i<kai; i++){
			scanf("%d", &mai);
			for(k=0; k<mai; k++){
				top[k]=data[k];
			}
			top[mai] = '\0';
			m=0;
			for(k=mai; k<len; k++){
				bottom[m]=data[k];
				m++;
			}
			bottom[len-mai] = '\0';
			strcpy(data, bottom);
			strcat(data, top);
			top[0] = '\0';
			bottom[0] = '\0';
		}
		printf("%s\n", data);
	}
}

Measured memory_bytes: 600
# -*- coding: utf-8 -*-
"""
A - Haiku
https://atcoder.jp/contests/abc051/tasks/abc051_a

"""
import sys


def solve(s):
    return s.replace(',', ' ')


def main(args):
    s = input()
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
n, k = map(int, input().split())
s = list(map(lambda x: x == "1", list(input())))

change_flg = False
cnt = 0
ilands = []


def cumsum(array):
    value = array[0]
    results = [value] * len(array)
    for index, elm in enumerate(array[1:], 1):
        value += elm
        results[index] = value
    return results


def change():
    global cnt, change_flg
    ilands.append(cnt)
    cnt = 0
    change_flg = not change_flg

for value in s:
    if value: # case 1 cnt
        if change_flg:
            change()
    else: # case 0 cnt : plus
        if not change_flg:
            change()
    cnt += 1

ilands.append(cnt)

if not len(ilands) % 2:
    ilands.append(0)

merged = list(cumsum(ilands))
section = 2 * k + 1

results = [0] * (len(ilands) // 2 - (k - 1))
if len(results) < 1 or len(merged) < section:
    print(n)
    exit()

merged.append(0)
for i in range(len(results)):
    start = i * 2 - 1
    results[i] = merged[start + section] - merged[start]

print(max(results))


Measured memory_bytes: 11288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D= sc.nextInt();
		if (D==7||D==5||D==3) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    plglg T[N];
    REP(i, 0, N) {
        ll a, b;
        cin >> a >> b;
        T[i] = plglg(a, b);
    }
    sort(T , T + N);
    ll ans = 0;
    REP(i, 0, N) {
        if (T[i].second >= M) {
            ans += T[i].first * M;
            break;
        } else {
            ans += T[i].first * T[i].second;
            M -= T[i].second;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
use proconio::input;

fn main() {
    // a^5-b^5 = (a-b)(a^4+a^3b+a^2b^2+ab^3+b^4) = x
    input! {
        x: isize,
    }
    for a in -200..200 {
        for b in -200..a {
            if a * a * a * a * a - b * b * b * b * b == x {
                println!("{} {}", a, b);
                std::process::exit(0);
            }
        }
    }
}


Measured memory_bytes: 2168
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

void enumerate_prime(vector<bool> &a){
    a[0] = false; a[1] = false;
    for(int i = 2; i*i<=a.size(); ++i){
        if(a[i]){ for(int j = 2; i*j<=a.size()-1; ++j){ a[i*j] = false; }}
    }
}

int main(){
	int N_MAX = 55556;
	vector<bool> primes(N_MAX,true);
	enumerate_prime(primes);
	int N; cin>>N;
	vector<int>ans(N);
	rep(i,N_MAX){
		if(N==0)break;
		if(primes[i] && i%5 == 1){
			--N;
			ans[N] = i;
		}
	}
	show(ans);
	return 0;
}

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

int main(){
  int n,k; cin >> n >> k;
  string s; cin >> s;
  s[k-1] = tolower(s[k-1]);
  cout << s;
}

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

int main() {
	int N;
	cin >> N;
	if (N % 2 == 0)
		cout << 0.5000000000 << endl;
	else
		printf("%.10f\n", (((double)N + 1) / (2 * (double)N)));
}


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

struct UnionFind {
  vector<int> r;
  
  UnionFind(int n) {
    r = vector<int>(n, -1);
  }
  
  int root(int x) {
    if (r[x] < 0) return x;
    return r[x] = root(r[x]);
  }
  
  int unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }
  
  int size(int x) {
    return -r[root(x)];
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind UF(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a -= 1; b -= 1;
    UF.unite(a, b);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, UF.size(i));
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int N,r=0,m=0;
	cin >> N;
	vector<int> A(N);
	set<int> s,d;

	rep(i,N) {
		cin >> A.at(i);
		m = max(m, A.at(i));

		if(!d.count(A.at(i)) && !s.count(A.at(i)))
			s.insert(A.at(i));
		else
			d.insert(A.at(i));
	}

	vector<bool> dp(m+1,1);
	for(auto x : s) {
		if(!dp.at(x))
			continue;
		
		int t = x;
		while(t+x <= m) {
			t += x;
			dp.at(t) = 0;
		}
	}

	rep(i,N)
		if(!d.count(A.at(i)))
			r += dp.at(A.at(i));
	cout << r << endl;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        vector<vector<int>> A(N, vector<int>(M)); cin >> A;
        rep(i, N) rep(j, M) A[i][j]--;
        vector<bool> nouse(M);
        vector<int> pos(N, 0);
        int ans = INF;        
        rep(m, M) {
            vector<int> cnt(M);
            rep(n, N) {
                while(pos[n] < M and nouse[A[n][pos[n]]]) pos[n]++;
                if(pos[n] == M) goto END;
                cnt[A[n][pos[n]]]++;                
            }
            auto itr = max_element(all(cnt));
            set_min(ans, *itr);
            nouse[itr - begin(cnt)] = true;
        }
  END:;
        cout << ans << endl;
        return 0;
    }
};

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


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#define MAX 100000007
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,K;
  cin >> N >> K;
  ll x[N];

  for(int i=0;i<N;i++){
    cin >> x[i];
  }
  ll sum=1000000000;
  for(int i=0;i<N-K+1;i++){
    sum=min({sum,abs(x[i])+abs(-x[i]+x[i+K-1]),abs(x[i+K-1])+abs(x[i+K-1]-(x[i]))});
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a(n);
    rep(i,n) cin>>a[i];
    sort(rall(a));
    int alice=0, bob=0;
    rep(i,n){
        if (i%2==0) alice+=a[i];
        else bob+=a[i];
    }
    cout<<alice-bob<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	in := bufio.NewScanner(os.Stdin)
	questionA(in)
}

func questionA(in *bufio.Scanner) {
	in.Scan()
	s := in.Text()
	if strings.Contains(s, "AC") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e3 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	vector<pair<int, int>> vp;
	int n, k;
	cin >> n >> k;
	if (k > (n - 1) * (n - 2) / 2) puts("-1"), exit(0);
	for (int i = 2; i <= n; i++) vp.emplace_back(1, i);
	int cur = (n - 1) * (n - 2) / 2;
	for (int i = 2; i <= n; i++)
	{
		for (int j = i + 1; cur > k && j <= n; j++)
		{
			cur--;
			vp.emplace_back(i, j);
		}
	}
	printf("%d\n", vp.size());
	for (auto& p : vp)
		printf("%d %d\n", p.first, p.second);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e16
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b,ll m){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % m;  a = (a * a) % m;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e2 + 3;
ll i,n,a,ans = MAX;
ll s[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,1,n + 1){
        cin>>a;
        s[i] = s[i - 1] + a;
    }
    rep(i,1,n) ans = min(ans, llabs(s[i] - s[n] + s[i]));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

using ld= long double;
ld eps=1e-9;

/* 幾何の基本 */

#include <complex>

typedef complex<ld> Point;


// 外積
ld cross(const Point& a, const Point& b) {
	return imag(conj(a) * b);
}

// 直線の定義
class Line {
public:
	Point a, b;
	Line() : a(Point(0, 0)), b(Point(0, 0)) {}
	Line(Point a, Point b) : a(a), b(b) {}
	Point operator[](const int _num)const {
		if (_num == 0)return a;
		else if (_num == 1)return b;
		else {
			assert(false);
			return Point();
		}
	}
};

// 直線と直線の交点
Point is_ll(const Line &s, const Line& t) {
	Point sv = s.b - s.a, tv = t.b - t.a;
	assert(cross(sv, tv) != 0);
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}


bool connect(pair<long long int, long long int>l, pair<long long int,long long  int>r) {
	long long int dx=r.first-l.first;
	long long int dy=r.second-l.second;
	if (!dx || !dy || abs(dx) == abs(dy)) {
		return true;
	}
	else {
		return false;
	}
}

vector<pair<long long int, long long int>>kouhos(pair<long long int, long long int>l, pair<long long int, long long int>r) {

	vector<pair<long long int, long long int>>kouho;
	int dx[4] = { 1,1,1,0 };
	int dy[4] = { -1,0,1,1 };
	for (int way1 = 0; way1 < 4; ++way1) {
		for (int way2 = 0; way2 < 4; ++way2) {
			if(way1==way2)continue;
			Point p1(l.first,l.second);
			Line l1(p1,p1+Point(dx[way1],dy[way1]));
			Point p2(r.first,r.second);
			Line l2(p2,p2+Point(dx[way2],dy[way2]));
			Point sect(is_ll(l1,l2));
			long long int n=static_cast<long long int>(sect.real()+eps*100);
			if (abs(static_cast<long long int>(sect.real()+eps*100) - sect.real()) < 0.1) {
				kouho.push_back(make_pair(static_cast<long long int>(sect.real()+eps*100), static_cast<long long int>(sect.imag()+eps*100)));
			}
		}
	}
	return kouho;
}

int solve(vector<pair<long long int, long long int>>&bases, const pair<long long int, long long  int>&goal) {
	if(bases.size()==6)return 4;
	
	int ans=4;
	for (int i = 0; i < bases.size(); ++i) {
		if (bases[i] == goal) {
			ans=min(ans,int(bases.size())-2);
		}
		if (connect(bases[i], goal)) {
			ans=min(ans,int(bases.size())-2+2);
		}
		if(bases.size()==5)continue;
		for (int j = 0; j < bases.size(); ++j) {
			if(i==j)continue;
			pair<long long int, long long int>l(bases[i]);
			pair<long long int, long long int>r(bases[j]);
			if (connect(l, goal) && connect(r, goal)) {
				ans=min(ans,int(bases.size()-2+1));
			}
			if (connect(l, r)) {
				ans=min(ans,int(bases.size())-2+3);
			}
			else {
				if (bases.size() == 2) {
					auto cands(kouhos(l, r));
					for (auto cand : cands) {
						if (connect(cand, goal)) {
							ans=min(ans,3);
						}
					}
				}
				
			}
		}
	}
	return ans;
}
int main() {
	int Q;cin>>Q;
	while (Q--) {
		long long int x1,y1,x2,y2,X,Y;cin>>x1>>y1>>x2>>y2>>X>>Y;
		x1+=1e10;
		y1+=1e10;
		x2+=1e10;
		y2+=1e10;
		X+=1e10;
		Y+=1e10;
		vector<pair<long long int, long long int>>bases{ make_pair(x1,y1),make_pair(x2,y2) };
		pair<long long int, long long int>goal(X,Y);
		int ans=solve(bases,goal);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  int b;
  cin >> b;
  if(a==1 && b==2) {
    cout << 3 << endl;}
  else if(a==1 && b==3) {
    cout << 2 << endl;}
  else if(a==2 && b==1) {
    cout << 3 << endl;}
  else if(a==2 && b==3) {
    cout << 1 << endl;}
  else if(a==3 && b==1) {
    cout << 2 << endl;}
  else if(a==3 && b==2) {
    cout << 1 << endl;}
  }

Measured memory_bytes: 256