akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
            using namespace std;
     
            int main() {
                int N;
                cin>>N;
                vector<int> L(N); 
     
              
              for(int i=0; i<N; i++){
                   cin>> L.at(i);  
              }
     
              sort(L.begin(),L.end()); 
              
              int count =0; 
              
              for(int i=0; i<N-1;i++){
                    for(int j=i+1; j<N; j++){  
                        for(int k=j+1; k<N; k++){
                          if( L.at(i)+L.at(j) > L.at(k)) count++; 
                        }
                    }
              }  
              
              cout<< count << endl; 
     
            }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#
using namespace std;

map<string,int>mp;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    string st;
    cin>>st;
    int cnt = 0;
    for(int i=0; i<st.size(); i++)
    {   //printf("%d",i);
        if(i<n)
        {
            if(st[i]<'0'||st[i]>'9')
            {
                printf("No\n");
                return 0;
            }
        }
        else if(i==n)
        {
            if(st[i]!='-')
            {
                printf("No\n");
                return 0;
            }
        }
        else
        {
            cnt++;
            if(st[i]<'0'||st[i]>'9')
            {
                printf("No\n");
                return 0;
            }
        }

    }
    //printf("%d",cnt);
    if(cnt != m)
    {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}


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

template <typename T>
struct RSQ{
	const T INF = numeric_limits<T>::max();
	int n;
	vector<T> dat;
	RSQ(int n_) : n(), dat(n_ * 4, 0){
		int x = 1;
		while(n_ > x){
			x *= 2;
		}
		n = x;
	}

	void update(int k, T a){
		k += n - 1;
		dat[k] += a;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
		}
	}

	T query_sub(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return 0;
		else if(a <= l && r <= b) return dat[k];
		else{
			T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
			T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
			return vl + vr;
		}
	}

	T query(int a, int b){
		return query_sub(a, b, 0, 0, n);
	}
};

signed main(){
	int n, Q;
	vector<int> ans;
	scanf("%d %d", &n, &Q);
	RSQ<int> rsq(n);
	for(int i = 0; i < Q; i++){
		int type;
		scanf("%d", &type);
		if(type == 0){
			int s, x;
			scanf("%d %d", &s, &x);
			rsq.update(s - 1, x);
		}
		else{
			int s, t;
			scanf("%d %d", &s, &t);
			ans.push_back(rsq.query(s - 1, t));
		}
	}
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}
}




Measured memory_bytes: 4800
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
#include<math.h>
 
using namespace std;

int N,M,C;


int main(){
  
  cin>>N>>M>>C;
  
  vector<int> B(M);
  vector<vector<int>> A(N,vector<int>(M));
  
  for(int i = 0; i < M; ++i) cin>>B[i];
  
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < M; ++j){
      cin>>A[i][j];
    }
  }
  
  int sum;
  int counts = 0;
  
  for(int i = 0; i < N; ++i){
  	sum = 0;
    for(int j = 0; j < M; ++j){
    	sum += (A[i][j] * B[j]);
    }
    sum += C;
    if(sum > 0) ++counts;
  }
  
  cout << counts << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

typedef pair<int,int>  pi;
typedef vector<pair<int,int> >  vpi;

struct Edge { int to, cost; };
vector<Edge> G[101];

int d[101];

int min_cost(int a, int b) {
    fill(d, d+101, INT_MAX);
    d[a] = 0;
    priority_queue<pi, vpi, greater<pi> > q;
    q.push(make_pair(0, a));
    while ( ! q.empty()) {
        int cost = q.top().first;
        int now = q.top().second;
        q.pop();
        for (int i=0; i<(int)G[now].size(); ++i) {
            Edge &e = G[now][i];
            if (cost + e.cost < d[e.to]) {
                d[e.to] = cost + e.cost;
                q.push(make_pair(d[e.to], e.to));
            }
        }
    }
    return d[b] == INT_MAX ? -1 : d[b];
}

int main() {
    int n, k;
    while (cin >> n >> k, n) {
        fill(G, G+101, vector<Edge>());
        int type, a, b, c, d, e;
        for (int i=0; i<k; ++i) {
            cin >> type;
            if (type == 0) {
                cin >> a >> b;
                cout << min_cost(a, b) << endl;
            } else {
                cin >> c >> d >> e;
                G[c].push_back((Edge){ d, e });
                G[d].push_back((Edge){ c, e });
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

/*
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/


int main(void) {
  int W,H,N;
  vector<vector<int>> tb;
  scanf("%d %d %d",&W,&H,&N);

  tb.resize(H);
  for (int i = 0; i < H; i++) {
    tb[i].resize(W);
  }

  int xd,yd,a;
  for (int j = 0; j < N; j++) {
    scanf("%d %d %d",&xd,&yd,&a);
    xd--, yd--;
    switch(a){
      case 1:
        for (int x = 0; x <= xd; x++) {
          for (int y = 0; y < H; y++) {
            tb[y][x] = 1;
          }
        }
        break;
      case 2:
        for (int x = xd+1; x < W; x++) {
          for (int y = 0; y < H; y++) {
            tb[y][x] = 1;
          }
        }
        break;
      case 3:
        for (int x = 0; x < W; x++) {
          for (int y = 0; y <= yd; y++) {
            tb[y][x] = 1;
          }
        }
        break;
      case 4:
        for (int x = 0; x < W; x++) {
          for (int y = yd+1; y < H; y++) {
            tb[y][x] = 1;
          }
        }
        break;
    }
  }

  int ans=0;

  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (tb[y][x]==0) {
        ans++;
      }
    }
  }

  printf("%d\n",ans);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A+B > C+D) puts("Left");
    else if(A+B == C+D) puts("Balanced");
    else puts("Right");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl

const ll INF=1e9+7;
const ll N = 102;
ll alf[26];
string s;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	FOR(i,0,s.size()){
		alf[s[i]-'a']++;
	}
	bool ok=true;
	FOR(i,0,26){
		if(alf[i]%2==1)ok=false;
	}
	if(ok)pri("Yes");
	else pri("No");
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define MAX_N 10000000;

using namespace std;

long long int dp[20][20];
int w,h;

int main(){
    while(1){
        
        for(int i=0;i<20;i++){
            for(int j=0;j<20;++j){
                dp[i][j]=0;
            }
        }
        
        dp[1][1]=1;
        cin>>w>>h;
        int n,x,y;
        if(w==0&&h==0)break;
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>x>>y;
            dp[x][y]=-1;
        }
        for(int i=1;i<=w;++i){
            for(int j=1;j<=h;++j){
                if(dp[i][j]!=-1){
                if(dp[i+1][j]!=-1)
                    dp[i+1][j]+=dp[i][j];
                if(dp[i][j+1]!=-1)
                    dp[i][j+1]+=dp[i][j];
                }
            }
        }
        cout<<dp[w][h]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker,"/stack:200000000")
#include <bits/stdc++.h>
using namespace std;

#define PI 2*acos(0.0)
#define print(x) return cout<<x<<endl,0
#define watch(x) cerr<<#x<<"-> "<<x<<endl
#define CLEAR(x,val) memset(x,val,sizeof(x))
#define int long long

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int INF = 1000000000;
const int MOD = 1000000007; //998244353

signed main()
{	
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	cin.tie(0), cout.tie(0);
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	int a[n];
	int sum = 0;
	for(int i = 0; i < n; i++)
		cin >> a[i], sum += a[i];
	int cur = 0;
	int res = 1e18;
	for(int i = n-1; i >= 0; i--)
	{
		sum -= a[i];
		cur += a[i];
		res = min(res,abs(cur-sum));
	}	
	return cout<<res<<endl,0;
}

Measured memory_bytes: 1792
(defn find-sum-of-digits [n]
  (->> (str n)
       (map #(- (int %) 48))
       (reduce +)))

(defn some-sums [[n a b]]
  (reduce +
          (for [i (range 1 (inc n))
                :let [sum (find-sum-of-digits i)]
                :when (<= a sum b)] i)))

(defn create-data [s]
  (map #(Long/parseLong %) (.split s " ")))

(println (some-sums (create-data (read-line))))


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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);

    vector<int> sukunai;
    vector<int> ooi;

    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin>>b[i];
    }
    for (int i = 0; i < n; ++i) {
        if(a[i]>=b[i])ooi.emplace_back(a[i]-b[i]);
        else sukunai.emplace_back(b[i]-a[i]);
    }
    sort(sukunai.begin(),sukunai.end());
    sort(ooi.begin(),ooi.end(),greater<int>());

    int oit=0-1;
    int ans=sukunai.size();
    for (int i = 0; i < sukunai.size(); ++i) {
        while(sukunai[i]>0){
            if(oit<0){
                oit=0;
                ++ans;
            }
            if(oit>=ooi.size()){
                cout<<-1<<endl;
                return 0;
            }
            if(sukunai[i]<ooi[oit]){
                ooi[oit]-=sukunai[i];
                sukunai[i]=0;
            }
            else{
                sukunai[i]-=ooi[oit];
                ooi[oit]=0;
                ++oit;
                ++ans;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1660
N=int(input())
a=list(map(int,input().split()))
a=sorted(a)

if a[0]==0:
    print(0)
    exit()
else:
    ans=a[0]
    for i in range(1,N):
        ans *= a[i]
        if ans >10**18:
            print(-1)
            exit()

    print(ans)
    

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

#define INF 2147483647

signed main()
{
    int n, k, h[100000], dp[100000];

    cin >> n >> k;

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

    dp[0] = 0;
    for(int i=1 ;i<n ;i++ ){
        dp[i] = INF;
        for(int j=1 ;i-j>=0 && j<=k ;j++ ){
            dp[i] = min(dp[i], abs(h[i] - h[i-j]) + dp[i-j]);
        }
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4380
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int pow(int x, int n) {
  int ans = 1;
  for(int i = 0; i < n; i++) {
    ans *= x;
  }
  return ans;
}

int charToInt(char c) {
  return (int)c - (int)'0';
}

int _16to10(char c) {
  int ans = charToInt(c);
  if(ans >= 0 && ans <= 9) return ans;
  else return (int)tolower(c) - (int)'a' + 10;
}

int _16to10(string str) {
  int ans = 0;
  for(int i = 0; i < str.length(); i++) {
    ans += _16to10(str[i])*pow(16, str.length()-i-1);
  }
  return ans;
}

int d2(string a, string b) {
  int ans = 0;
  for(int i = 0; i < 3; i++) {
    int p = i*2;
    ans += pow(_16to10(a.substr(p,2))-_16to10(b.substr(p,2)), 2);
  }
  return ans;
}

int main() {
  string colors[8][2] = {{"black", "000000"},
			 {"blue", "0000ff"},
			 {"lime", "00ff00"},
			 {"aqua", "00ffff"},
			 {"red", "ff0000"},
			 {"fuchsia", "ff00ff"},
			 {"yellow", "ffff00"},
			 {"white", "ffffff"}};
  while(1) {
    string str;
    cin >> str;
    if(str == "0") break;

    int min = 999999;
    int k;
    for(int i = 0; i < 8; i++) {
      int temp = d2(str.substr(1, 6), colors[i][1]);
      if(temp < min) {
	min = temp;
	k = i;
      }
    }
    cout << colors[k][0] << endl;
  }
  return 0;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    string S;
    cin >> S;
    bool flg = false;
    FOR (i, 1, S.length()) {
        if (S[i - 1] == S[i]) {
            flg = true;
            break;
        }
    }
    cout << (flg ? "Bad" : "Good") << endl;
    return 0;
}

Measured memory_bytes: 3500
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265358979323846;

#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

class TaskA {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n; in>>n;
		int res = 0;
		while(n) res += (n%10), n/=10;
        if(res==1) res = 10;
        out<<res;
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	TaskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
def solve(ds) -> int:
  ret = 0
  for i in range(len(ds)):
    for j in range(i + 1, len(ds)):
      ds_i = ds[i]
      ds_j = ds[j]
      ret += ds_i * ds_j
  return ret


n = int(input().strip())
ds = [int(d) for d in input().split()]

print(solve(ds))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define dbl double
#define forn(i,n,k) for(int i=0;i<n;i=i+k)
#define forpn(p,n,k) for(int i=p;i<n;i+=k)
#define for0(n) for(int i=0;i<n;i++)
#define for1(n) for(int i=1;i<=n;i++)
using namespace std;
int no_of_bits(long long n)
{
    int count=0;
    while(n>0)
    {
        n=n>>1;
        count++;
    }
    return count;
}
long long gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main()
{   ios::sync_with_stdio(0);
   int k;
 cin>>k;
 string s;
 cin>>s;
    cin.tie(0);
    cout.tie(0);
    if(s.size()<=k) cout<<s;
 else{
   for(int i=0;i<k;i++)
     cout<<s[i];
   cout<<"...";}
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <string>

using namespace std;

const int CMax = 100002;

int n, m, k;

int counter(int a, int b, int x, int y)
{
    return a*x + b*y - a*b*2;
}

int main ()
{
    scanf("%d %d %d", &n, &m, &k);
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (k == counter(i, j, m, n)){
                printf("Yes\n");
                return 0;
            }
        }
    }

    printf("No\n");
}


Measured memory_bytes: 256
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();

		double[] E = new double[N];
		double sum = 0;

		for (int i = 0; i < N; i++) {
			double dice = sc.nextDouble();
			E[i] = (1 + dice) / 2;
			if (i < K) {
				sum += E[i];
			}
		}

		double max = sum;

		for (int i = K; i < N; i++) {
			sum = sum - E[i - K] + E[i];
			if (sum > max) {
				max =sum;
			}
		}

		System.out.println(max);
	}
}

Measured memory_bytes: 65908
N=int(input())
A=list(map(int,input().split()))

ans=[]
box=[0]*N

for i in reversed(range(1,N+1)):
  asum=sum(box[i-1::i])
  if asum%2+A[i-1]==1:
    box[i-1]=1
    ans.append(i)

print(len(ans))
print(*ans)

Measured memory_bytes: 14048
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int A, B, C, D, E, F, sw, ans1 = 0, ans2 = 0;
  	float dens, max = 0;
  	vector<int> water, sugar;
  	cin >> A >> B >> C >> D >> E >> F;
  	for (int i = 0; i * 100 <= F; i++){
    	for (int j = 0; j * 100 <= F; j++){
        	int w; w = 100 * (A * i + B * j);
          	if (w <= F && find(water.begin(), water.end(), w) == water.end()){
            	water.push_back(w);
            }
        }
    }
  	for (int i = 0; i <= F; i++){
    	for (int j = 0; j <= F; j++){
        	int s; s = C * i + D * j;
          	if (s <= F && find(sugar.begin(), sugar.end(), s) == sugar.end()){
            	sugar.push_back(s);
            }
        }
    }
  	for (int i = 0; i < water.size(); i++){
    	for (int j = 0; j < sugar.size(); j++){
        	sw = water[i] + sugar[j];
          	if (water[i] > 0 && sw <= F && (float)sugar[j] * 100 / water[i] <= E){
            	dens = (float)sugar[j] / sw;
              	if (max <= dens){
                	max = dens;
                  	ans1 = sw;
                  	ans2 = sugar[j];
                }
            }
        }
    } 
  	cout << ans1 << " " << ans2 << endl;
}

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

int main() {
    int k, a, b; cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            puts("OK");
            return 0;
        }
    }
    puts("NG");
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"

using namespace std;

const int INF = 1000000000;

void Main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N, vector<int>(N, INF));
    vector<pair<pair<int, int>, int>> edges;
    for (int i = 0; i < M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        graph[a][b] = c;
        graph[b][a] = c;
        edges.push_back(make_pair(make_pair(a, b), c));
    }
    for (int i = 0; i < N; ++i) {
        graph[i][i] = 0;
    }

    vector<vector<int>> minPath = graph;
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                minPath[i][j] = min(minPath[i][j], minPath[i][k] + minPath[k][j]);
            }
        }
    }

    //// As editorial
    //int ans = 0;
    //for (auto e : edges) {
    //    int a = e.first.first;
    //    int b = e.first.second;
    //    int c = e.second;
    //    bool found = false;
    //    for (int i = 0; i < N; ++i) {
    //        for (int j = 0; j < N; ++j) {
    //            if (minPath[i][j] == minPath[i][a] + c + minPath[b][j]) {
    //                found = true;
    //            }
    //        }
    //    }
    //    if (!found) {
    //        ++ans;
    //    }
    //}
    //cout << ans << endl;

    int ans = 0;
    for (auto e : edges) {
        int a = e.first.first;
        int b = e.first.second;
        int c = e.second;
        if (minPath[a][b] < c) {
            ++ans;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main(){
  string a,b;
  cin >> a >> b;
  int aSize = a.size();
  int bSize = b.size();
  int equalFlag = true;
  if(aSize > bSize){
    cout << "GREATER" << endl;
    equalFlag = false;
  }else if(aSize < bSize){
    cout << "LESS" << endl;
    equalFlag = false;
  }else{
    rep(i,aSize){ //同じ桁数だからb.Sizeでも当然おｋ
      if(a[i]==b[i]) continue;
      if(a[i]>b[i]){
        cout << "GREATER" << endl;
        equalFlag = false;
        break;
      }
      if(a[i] < b[i]){
        cout << "LESS" << endl;
        equalFlag = false;
        break;
      }
    }
  }
  if(equalFlag) cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
n , m , x = map(int,input().split())
a = list(map(int,input().split()))
lef = 0
rig = 0
for i in range(1,x):
    if a.count(i) == 1:
        lef += 1
for i in range(x+1,n):
    if a.count(i) == 1:
        rig += 1
print(min(lef,rig))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;cin>>n;
	int m;cin>>m;
	int ans=m;
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		m+=a-b;
		if(m<0)ans=-1;
		else if(ans!=-1)ans=max(ans,m);
	}
	if(ans==-1)cout<<0<<endl;
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n;
  ll d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; i++) {
      ll x, y;
      cin >> x >> y;
      if (x*x + y*y <= d*d) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

long long n, l, ans = 0;
bool ch = 0;

int main() {
  cin >> n >> l;
  for(int i = 0; i < n; ++i) {
    ans += l + i;
    if(l + i == 0) ch = 1;
  }
  if(!ch) {
    if(l > 0)
      ans -= l;
    else
      ans -= l + n - 1;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
#ifdef LOCAL_DEFINE
  // freopen("data.in", "rt", stdin);
  // freopen("data.out", "w", stdout);
  auto _start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n, W;
	cin >> n >> W;
	vector<int> w(n), v(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	vector<long long> dp(W + 1);
	for(int i = 0; i < n; i++) {
		for(int j = W; j >= w[i]; j--) {
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		}
	}
	cout << dp[W] << '\n';

#ifdef LOCAL_DEFINE
  auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define all(v) v.begin(), v.end()
int garr[100001];
vector<pair<int, int>> gvec;
long long mat[105][100000];
int gv, gk;

long long whatdo(int n, long long cap) {
  if (n == -1 || cap == 0)
    return 0;

  if (mat[n][cap] > 0)
    return mat[n][cap];

  if (gvec[n].first > cap)
    mat[n][cap] = whatdo(n - 1, cap);
  else
    mat[n][cap] =
        max(whatdo(n - 1, cap),
            gvec[n].second +
                whatdo(n - 1, cap - gvec[n].first)); // asdasddsasasasas
  return mat[n][cap];
}

void solve() {
  //----------------------VARs---------------------------------------------
  char car, car2;
  string s, st;
  long long n = 0, a = 0, b = 0, c = 0, e, d = 0, m = 0, t = 0, q = 0, r = 0,
            l = 0, middle = 0, count = 0, add = 0, k, ans = 300, temp = 0,
            rootsa, save = 0, bigg = 0, save2 = 0, counter = 0, counter2 = 0,
            sum = 0, x, y;
  bool flag = false, flag2;

  //-------- --------------VARs--------------------------------------------
  memset(mat, -1, sizeof(mat));
  int arr[1000] = {};
  vector<int> vec;
  cin >> gv >> gk;
  for (int i = 1; i <= gv; i++) {
    cin >> a >> b;
    gvec.push_back(make_pair(a, b));
  }
  sort(all(gvec));
  cout << whatdo(gv - 1, gk);
}
int main() {
#ifndef ONLINE_JUDGE
  system("clear");
  freopen("Test0.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cin.tie(0);

  cout << fixed << setprecision(10);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 85640
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int m, f, r;
  while (cin >> m >> f >> r) {
    if (m == -1 && f == -1 && r == -1)
      break;
    int x = m + f;
    if (m == -1 || f == -1)
      cout << "F" << endl;
    else if (x >= 80)
      cout << "A" << endl;
    else if (x >= 65)
      cout << "B" << endl;
    else if (x >= 50)
      cout << "C" << endl;
    else if (x >= 30) {
      if (r >= 50)
        cout << "C" << endl;
      else
        cout << "D" << endl;
    } else
      cout << "F" << endl;
  }
}



Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int N = in.nextInt(), W = in.nextInt();
			int[] v = new int[N+1], w = new int[N+1];
			for (int i = 1; i <= N; i++) {
				v[i] = in.nextInt(); w[i] = in.nextInt();
			}

			int[][] dp = new int[N+1][W+1];
			for (int i = 1; i <= N; i++) {
				for (int j = 1; j <= W; j++) {
					if (j >= w[i]) {
						dp[i][j] = Math.max(dp[i-1][j], dp[i][j-w[i]]+v[i]);
					} else {
						dp[i][j] = dp[i-1][j];
					}
				}
			}
			out.println(dp[N][W]);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



Measured memory_bytes: 29244
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc093/tasks/abc093_b

int main() {
    int A, B, K;

    cin >> A >> B >> K;

    set<int> st;
    for (int i = A; i < A+K; i++) {
        if (i <= B) st.insert(i);
    }
    for (int i = B; i > B-K; i--) {
        if (i >= A) st.insert(i);
    }

    for (int t : st) {
        cout << t << "\n";
    }



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<ll> H(N);
    for (auto& h : H) {
        cin >> h;
    }
    vector<vector<int>> graph(N);
    int a, b;
    rep(i, 0, M) {
        cin >> a >> b;
        --a, --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int ans = 0;
    rep(i, 0, N) {
        bool is_ok = true;
        for (auto& next_node : graph[i]) {
            if (H[i] <= H[next_node]) {
                is_ok = false;
                break;
            }
        }
        if (is_ok) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9272
#include<bits/stdc++.h>
using namespace std;
const int N(333);
int cst[N][N], dp[N][N];
char a[N][N];
int main() {
	int n, m;
	cin >> n >> m;
	for(int i(1); i <= n; i++) {
		scanf("%s", a[i] + 1);
	}
	int ans(0);
	for(int i(1); i < m; i++) {
		for(int j(0); j <= n; j++) {
			for(int k(0); k <= n; k++) {
				cst[j][k] = 0;
			}
		}
		for(int j(1); j <= n; j++) {
			for(int k(1); k <= n; k++) {
				if(a[j][i] == a[k][i + 1]) {
					//h1 = n - j + 1, h2 = n - k + 1
					cst[n - j][n - k]++;
				//	printf("%d %d %d\n", i, j, k);
				}
			}
		}
		for(int j(n); j >= 0; j--) {
			for(int k(n); k >= 0; k--) {
				cst[j][k] = cst[j][k] + cst[j + 1][k + 1];
			}
		}
		for(int j(0); j <= n; j++) {
			for(int k(0); k <= n; k++) {
				dp[j][k] = j == 0 && k == 0 ? 0 : 1e9;
				if(j) {
					dp[j][k] = min(dp[j][k], dp[j - 1][k]);
				}
				if(k) {
					dp[j][k] = min(dp[j][k], dp[j][k - 1]);
				}
			//	printf("!%d %d %d\n", j, k, cst[j][k]);
				dp[j][k] += cst[j][k];
			}
		}
		ans += dp[n][n];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1280
use std::io::*;
use std::str::*;
use std::f64::consts::*;
use std::f64;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i64,
        m: i64,
    }
    if (m < 1) { println!("0"); return; }
    if (n == 1 || m == 1) { println!("1"); return; }
    let all = n * m;
    println!("{}", (all as f64 / 2.0).ceil());
}

Measured memory_bytes: 2584
main = do
  dum <- getLine
  s <- getLine
  kIn <- getLine
  let 
    k = head $ map read $ words kIn :: Int
    at n ls
      | ls == [] = '-'
      | n == 1 = head ls
      | otherwise = at (n-1) (tail ls)
    key = at k s
    repl key str ret
      | str == [] = reverse ret
      | head str == key = repl key (tail str) (key:ret)
      | otherwise = repl key (tail str) ('*':ret)
    in
    putStrLn $ repl key s ""


Measured memory_bytes: 508
n=int(input())
List=[]
List+=[0]*100
for i in range(1,n+1):
  List[int(str(i)[0])*10+int(str(i)[-1])]+=1
sum=0
for i in range(1,10):
  sum+=List[11*i]**2
for i in range(1,10):
  for j in range(1,10):
    if i!=j:
      sum+=List[10*i+j]*List[10*j+i]
print(sum)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll K;
    cin >> K;

    vector<ll> ans(50);
    // 操作の巻き戻し
    // 2 2 2
    // 5 1 1
    // 4 4 0
    // 3 3 3
    // 操作を一周すると全体が +1
    // 操作を K / 50 + K % 50 回するとする
    // K / 50
    for (int i = 0; i < 50; i++) ans[i] = 49 + K / 50;
    // K % 50
    for (int i = 0; i < K % 50; i++) {
        ans[i] += 50 + 1;
        for (int j = 0; j < 50; j++) ans[j] -= 1;
    }
    cout << 50 << '\n';
    for (int i = 0; i < 50; i++) { cout << ans[i] << (i == 49 ? '\n':' ' ); }
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	say(min(A, B) + min(C, D));
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int H, W, K;
  cin >> H >> W >> K;
  int X1, Y1, X2, Y2;
  cin >> X1 >> Y1 >> X2 >> Y2;
  X1--, Y1--, X2--, Y2--;
  vector<string> C(H);
  cin >> C;

  vvi dist(H, vi(W, INF));
  queue<pii> q;
  dist[X1][Y1] = 0;
  q.push({X1, Y1});
  while (sz(q)) {
    int x, y;
    tie(x, y) = q.front();
    if (x == X2 && y == Y2) {
      cout << dist[x][y] << endl;
      return 0;
    }
    q.pop();
    rep(dir, 0, 4) {
      rep(k, 1, K + 1) {
        int xx = x + DX[dir] * k;
        int yy = y + DY[dir] * k;
        if (!inseg(0, xx, H) || !inseg(0, yy, W)) break;
        if (C[xx][yy] == '@') break;
        if (dist[xx][yy] <= dist[x][y]) break;
        if (chmin(dist[xx][yy], dist[x][y] + 1)) {
          q.push({xx, yy});
        }
      }
    }
  }
  cout << -1 << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 19836
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int N = 100;

int main() {
  int M[N][N];
  int n, u, k, v;

  cin >> n;

  for (int i = 0; i< n; i++) {
    for (int j = 0; j < n; j++) M[i][j] = 0;
  }

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j) cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b; cin >> a >> b;
    vector<string> ans(100,string(100,'.'));
    rep(i,50){
        ans[i+50] = string(100,'#');
    }
    a--;
    b--;
    int y = 0;
    int x = 0;
    while(b){
        ans[y][x] = '#';
        b--;
        x += 2;
        if(x>=50){
            y += 2;
            x = 0;
        }
    }
    y = 99;
    x = 0;
    while(a){
        ans[y][x] = '.';
        a--;
        x += 2;
        if(x>=50){
            y -= 2;
            x = 0;
        }
    }
    cout << "100 100\n";
    rep(i,100){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <complex>
#include <iomanip>
#include <bitset>
#include <random>
#include <vector>
#include<string>
#include <limits.h>

using namespace std;


int main() {
	long long n, i, r, x[111111], ans = 1, mod = 1000000007;
	cin >> n;
	for (i = 1; i <= n; i++)
		cin >> x[i];
	r = 1;
	for (i = 0; i < n; i++) {
		while (1) {
			if (r + 1 <= n && x[r + 1] >= 2 * (r - i)){
				r++;
              	if(x[r]==2*(r-i-1))
                  break;
            }
			else
				break;
		}
		ans = ans * (r - i) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#import heapq
#import itertools
#import math
#import numpy as np
#import sys

N = int(input())
S = list(input())
#A,B = list(map(int, input().split()))
#S = [input() for _ in range(H)]
#T = [list(map(int,input().split())) for _ in range(N)]
#sys.exit()
ALPHA = [chr(ord('A') + i) for i in range(26)]

for i in range(len(S)):
    ind = ALPHA.index(S[i])
    if int(ind) + N > 25 :
        S[i] = ALPHA[int(ind) + N - 26]
    else :
        S[i] = ALPHA[int(ind) + N]
print(''.join(S))

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

using namespace std;

int main() {
  int a, b, c;
  int k;
  cin >> k;
  long long sum = 0;

  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        sum += __gcd(a, __gcd(b, c));
      }
    }
  }
  cout << sum;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main( void )
{
	int n;
	int map[51];
	int save[50][2];
	while(cin >> n, n) {
		for(int i=0; i < n; ++i) {
			cin >> map[i];
		}
		//--n;
		int count = 0;
		int start = 0;
		map[n] = -1;
		for(int i=0; i < n; ++i) {
			int sub = map[i+1] - map[i];
			if(sub != 1) {
				save[count][0] = start;
				save[count][1] = i;
				start = i+1;
				++count;
			}
		}
		for(int i=0; i < count; ++i) {
			if(save[i][0] == save[i][1]) {
				cout << map[save[i][0]];
			}
			else {
				cout << map[save[i][0]] << '-' << map[save[i][1]];
			}
			if(i != count - 1) cout << ' ';
		}
		cout << endl;
	}
	return 0;
}

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

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

using Graph = vector<vector<int>>;

int main(){
    int N, M;
    cin >> N >> M;
    Graph G(N);
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(N, -1);
    vector<int> pre(N, -1);
    queue<int> q;

    dist[0] = 0;
    q.push(0);

    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int nv : G[v]){
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            pre[nv] = v;
            q.push(nv);
        }
    }

    cout << "Yes" << endl;
    rep(i, N){
        if(i == 0) continue;
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10640
n=int(input())
lst=[]
for i in range(n):
	a,b=map(int,input().split())
	lst.append((b,a))

#dictは同じキーが登場すると上書きしてしまうので工夫が必要
#タプルのリストのままやるぞ

lst.sort()

#print(lst)
#=>[(4, 2), (8, 1), (9, 1), (9, 4), (12, 3)]
#(deadline,time)の順で配置されている

result='Yes'
time=0 #i番目にやる仕事まで終わらせるのにかかる時間

for i in range(n):
	time+=lst[i][1]
	if time>lst[i][0]:
		result='No'
		break;

print(result)

Measured memory_bytes: 29444
#include <stdio.h>

#define MOD 1000000007
typedef long long ll;

int main(){
	int n, m;
	scanf("%d%d", &n, &m);

	ll a[112345];
	for(int i = 1; i < m; ++i) a[i] = 0;
	a[0] = a[m] = 1;

	ll ans = 0;
	for(int i = m; i <= n; ++i){
		ans = (ans * 2 + a[i]) % MOD;
		a[i + 1] = (a[i] * 2 - a[i - m] + MOD) % MOD;
	}

	printf("%lld\n", ans);
}



Measured memory_bytes: 2592
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <chrono>
#include <random>

using namespace std;

typedef long long ll;

void solve() {
	string s;
	cin >> s;
	if (s.back() != 's')
		cout << s << 's';
	else
		cout << s << "es";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		//cout << endl;
	}
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    char[] c = {'A', 'T', 'G', 'C'};
    String ans = "", tmp = "";
    for (int i = 0; i < str.length(); i++) {
      switch (str.charAt(i)) {
        case 'A' :
        case 'T' :
        case 'C' :
        case 'G' :
          tmp += String.valueOf(str.charAt(i));
          break;
        default :
          if (ans.length() < tmp.length()) {
            ans = tmp;
          }
          tmp = "";
          break;
      }
    }
    if (ans.length() < tmp.length()) {
      System.out.println(tmp.length());
    } else {
      System.out.println(ans.length());
    }
  }
}

Measured memory_bytes: 21204
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
const int limit = 100000;
int N, M;
int P[limit], Y[limit];
vector<int> yd[limit + 1];
int main() {
    scanf("%d%d", &N, &M);
    rep(i, M) {
        scanf("%d%d", &P[i], &Y[i]);
        yd[P[i]].push_back(Y[i]);
    }
    rep(i, N) {
        sort(yd[i + 1].begin(), yd[i + 1].end()); //県ごとにyear並び替え
    }
    rep(i, M) {
        printf("%012lld\n", ll(P[i]) * limit * 10 + int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1);
    }
    return 0;
}


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

int main(){
    int a, b;
    int res = 0;

    cin >> a >> b;
    if ((a + b) % 2 == 0){
        cout << (a + b) / 2 << endl;
    }
    else {
        cout << (a + b + 1) / 2 << endl;
    }
}

Measured memory_bytes: 256