akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') insert(key);
    else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L') deleteLast();
      } else deleteKey(key);
    }
  }
  printList();
  return 0;
}


Measured memory_bytes: 32944
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int Y = int.Parse(s[1]);

            // 指定枚数で超える、足りない場合終了
            if ( N * 1000 > Y || N * 10000 < Y)
            {
                Console.WriteLine("-1 -1 -1");
                return;
            }

            // 指定枚数全部1000円の際の金額
            int step1 = N * 1000;

            for (int i = 0; i <= N; i++)
            {
                for(int j = 0; j <= N - i; j++)
                {
                    if ( step1 + j * 4000 + i * 9000 == Y)
                    {
                        Console.WriteLine("{0} {1} {2}", i, j, N - i - j);
                        return;
                    }

                }
            }

            Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 13268
S = input()

sdict = {}
for s in S:
    sdict.setdefault(s,0)
    sdict[s] += 1

if len(sdict) != 2:
    print("No")
    exit()
for k,v in sdict.items():
    if v != 2:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	static int mod=1000000007;
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stu
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] cmd=br.readLine().split(" ");
		int n=Integer.valueOf(cmd[0]);
		int m=Integer.valueOf(cmd[1]);
		int k=Integer.valueOf(cmd[2]);
		long[] a=new long[n];
		long[] b=new long[m];
		cmd=br.readLine().split(" ");
		for(int i=0;i<n;i++)
		{
			a[i]=Long.valueOf(cmd[i]);
		}
		cmd=br.readLine().split(" ");
		for(int i=0;i<m;i++)
		{
			b[i]=Long.valueOf(cmd[i]);
		}
		long[] sum1=new long[n+1];
		long[] sum2=new long[m+1];
		for(int i=1;i<=n;i++)
		{
			sum1[i]=sum1[i-1]+a[i-1];
		}
		for(int i=1;i<=m;i++)
		{
			sum2[i]=sum2[i-1]+b[i-1];
		}
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			if(sum1[i]<=k)
				ans=i;
			else
				break;
		}
		for(int i=1;i<=m;i++)
		{
			if(sum2[i]<=k)
				ans=Math.max(ans,i);
			else
				break;
		}
		for(int i=1;i<=n;i++)
		{
			if(sum1[i]>k)
				break;
			int ind=Arrays.binarySearch(sum2,k-sum1[i]);
//			System.out.println(i+" "+sum1[i]+" "+ind);
			int x=ind;
			if(ind<0)
				x=Math.abs(x+1)-1;
			ans=Math.max(ans,x+i);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 80076
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;
 
typedef pair < int , int > ii;
 
int n, x, y,  zz;
long long ans;
ii a[N];
priority_queue < int > q;
multiset < ii > s, t;
 
int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d %d",&x ,&y ,&zz);
	n = x + y + zz;
	for(int i = 1; i <= n; i++){
		int aa, bb, cc;
		scanf("%d %d %d",&aa ,&bb, &cc);
		a[i] = mp(aa - cc, bb - cc);
		ans += cc;
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	for(int i = 1; i <= x; i++){
		ans += a[i].st;
		q.push(a[i].nd - a[i].st);
	}
	// cout << ans << endl;
	for(int i = x + 1; i <= n; i++){
		s.insert(a[i]);
		t.insert(mp(a[i].nd, a[i].st));
	}
	while(y--){
		int frk = q.top();
		ii son = *s.rbegin();
		ii alma = *t.rbegin();
		if(frk + son.st > alma.st){
			ans += frk + son.st;
			q.pop();
			s.erase(s.find(son));
			t.erase(t.find(mp(son.nd, son.st)));
			q.push(son.nd - son.st);
		} else{
			ans += alma.st;
			t.erase(t.find(alma));
			s.erase(s.find(mp(alma.nd, alma.st)));
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d %d", &a, &b);
    int m = 0;
    for(int i = 0; i < 2; i++) {
        if(a>b){
            m+=a;
            a--;
        } else {
            m+=b;
            b--;
        }
    }
    printf("%d\n", m);
    return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            char[] cs = s.toCharArray();
            for (int i = 0; i < cs.length - 1; i++) {
                if (cs[i] == cs[i + 1]) {
                    out.println((i + 1) + " " + (i + 2));
                    return;
                }
                if (i < cs.length - 2 && cs[i] == cs[i + 2]) {
                    out.println((i + 1) + " " + (i + 3));
                    return;
                }
            }
            out.println("-1 -1");
        }

    }
}



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

#define ran 101101

int n;
pair<int, int> a[ran];

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i].first);
		a[i].second = i+1;
	}
	sort(a, a+n);
	
	for(int i=0;i<n;i++)
		printf("%d%c", a[i].second, i<n-1 ? ' ' : '\n');
	
	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, x;
  int a[SIZE];
  ll suma = 0;
  
  scanf("%d%d", &n, &x);

  for(int i=0;i<n;i++){
    scanf("%d", a+i);
    suma += a[i];
  }

  int ans = 0;
  
  sort(a,a+n);

  if(suma == x){
    ans = n;
  }else if(suma < x){
    ans = n-1;
  }else{
    ll t = 0;
    for(int i=0;i<n && t+a[i] <= x;i++){
      ans = i+1;
      t += a[i];
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 100005
int A[N], n;
bool cmp(int a, int b){return a > b;}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &A[i]);
	sort(A + 1, A + n + 1, cmp);
	for (int i = 1; i <= n; i++)
	{
		if (i <= A[i] && A[i + 1] < i + 1)
		{
			int j = 0;
			while (A[i + j + 1] == i)
				j++;
			if ((A[i] - i) % 2 == 0 && j % 2 == 0)
				puts("Second");
			else
				puts("First");
			return 0;
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;

int field[350][350];
int dx[] = { 0, 1, 0,-1};
int dy[] = {-1, 0, 1, 0};

void dfs(int y, int x, int label) {
    if (x < 0 || x >= 350 || y < 0 || y >= 350) return;
    if (field[y][x] != -1) return;
    field[y][x] = label;
    for (int i=0; i<4; ++i) {
        dfs(y + dy[i], x + dx[i], label);
    }
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> vx, vy;
        vector<int> ls, ts, rs, bs;

        for (int i=0; i<350; ++i) for (int j=0; j<350; ++j) field[i][j] = -1;

        for (int i=0; i<n; ++i) {
            int l,t,r,b;
            cin >> l >> t >> r >> b;
            ls.push_back(l);
            ts.push_back(t);
            rs.push_back(r);
            bs.push_back(b);

            for (int i=-1; i<=1; ++i) {
                vx.push_back(l + i);
                vx.push_back(r + i);
                vy.push_back(t + i);
                vy.push_back(b + i);
            }
        }

        sort(vx.begin(), vx.end());
        sort(vy.begin(), vy.end());
        map<int,int> convert_x, convert_y;
        for (int i=0; i<vx.size(); ++i) convert_x[vx[i]] = i;
        for (int i=0; i<vy.size(); ++i) convert_y[vy[i]] = i;

        // ??§?¨???§???
        for (int i=0; i<n; ++i) {
            ls[i] = convert_x[ ls[i] ];
            ts[i] = convert_y[ ts[i] ];
            rs[i] = convert_x[ rs[i] ];
            bs[i] = convert_y[ bs[i] ];
        }

        /*
        // debug
        for (int i=0; i<n; ++i) {
            printf("%3d %3d %3d %3d\n", ls[i], ts[i], rs[i], bs[i]);
        }
        cout << endl;
        */

        // ????????????????????????, -1?????????0?????????1??\?????§????????????
        for (int k=0; k<n; ++k) {
            // ?¨???¨????????????
            for (int i=ls[k]; i<=rs[k]; ++i) {
                field[ts[k]][i] = 0;
                field[bs[k]][i] = 0;
            }
            for (int i=bs[k]; i<=ts[k]; ++i) {
                field[i][ls[k]] = 0;
                field[i][rs[k]] = 0;
            }
        }
        /*
        // debug
        for (int i=0; i<50; ++i) {
            for (int j=0; j<50; ++j) {
                printf(" %2d", field[i][j]);
            }
            cout << endl;
        }
        cout << endl;
        */
        int label = 1;
        for (int i=0; i<350; ++i) {
            for (int j=0; j<350; ++j) if (field[i][j] == -1) {
                dfs(i,j,label);
                label++;
            }
        }

        /*
        // debug
        for (int i=0; i<50; ++i) {
            for (int j=0; j<50; ++j) {
                printf(" %2d", field[i][j]);
            }
            cout << endl;
        }
        cout << endl;
        */

        cout << label - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 9272
h,w,a,b = map(int, input().split())
#横を作る
#まずは左が1バージョン
up = []
if a>0:
  for i in range(a):
    up.append(1)
for i in range(w-a):
  up.append(0)
#その反転バージョン
down = [1-up[i] for i in range(w)]

str_up = [str(i) for i in up]
str_down = [str(i) for i in down]

ans_up = ''.join(str_up)
ans_down = ''.join(str_down)

if b>0:
  for i in range(b):
    print(ans_up)
for i in range(h-b):
  print(ans_down)

Measured memory_bytes: 4084
#include <iostream>
#include <vector>

using namespace std;


int main()
{
  int k, n, ans;
  int max = 0;
  ans = 0;
  cin >> k >> n;

  vector<int>v(n);
  vector<int>v2(n);

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

  for (int j = 0; j < n - 1; j++) {
    
    v2[j] = v[j + 1] - v[j];
  }
  v2[n - 1] = (k - v[n - 1]) + v[0];



  for (int m = 0; m < n; m++) {
    ans += v2[m];
    if (max <= v2[m]) {
      max = v2[m];
    }
  }
  ans = ans - max;

  cout << ans;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    map<int,int> mp;
    vec<ll> a2;
    vec<ll> a4;
    rep(i, N){
        int a;cin >> a;
        ++mp[a];
        if(mp[a] == 2) a2.push_back(a);
        if(mp[a] == 4) a4.push_back(a);
    }
    sort(a2.rbegin(),a2.rend());
    sort(a4.rbegin(),a4.rend());
    ll ans = 0;
    if(a2.size()>=2) ans = a2[0]*a2[1];
    if(a4.size()>=1) ans = max(ans,a4[0]*a4[0]);
    cout << ans << endl;
}


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

using namespace std;

string dp[11][10][1 << 10];
bool made[11][10][1 << 10] = {0};

bool isGood(string& s1, string& s2) {
	return s1 == "" || s1.size() < s2.size() || (s1.size() == s2.size() && s1 < s2);
}
void proc(string s, int i, int j, int k) {
	if ( !made[i][j][k] || isGood(s, dp[i][j][k]) ) {
		dp[i][j][k] = s;
	}
	made[i][j][k] = true;
}
string cat(string s1, string s2) {
	if (s1.size() >= s2.size()) {
		for (int i = 0; i <= s1.size()-s2.size(); ++i) {
			bool f = true;
			for (int j = 0; j < s2.size(); ++j) {
				if (s1[i+j] != s2[j]) {
					f = false;
					break;
				}
			}
			if (f) {
				return s1;
			}
		}
	}

	int len = 0;
	for (int k = min(s1.size(), s2.size()); k >= 0; --k) {
		bool f = true;
		for (int i = 0; i < k; ++i) {
			if (s1[s1.size()-k+i] != s2[i]) {
				f = false;
				break;
			}
		}
		if (f) {
			len = k;
			break;
		}
	}
	return s1 + s2.substr(len);
}

int main() {
	int N;
	while ( cin >> N, N ) {
		fill(&made[0][0][0], &made[0][0][0]+11*10*(1 << 10), false);

		string S[10];
		for (int i = 0; i < N; ++i) {
			cin >> S[i];
		}

		vector<bool> f(N, false);
		for (int i = 0; i < N; ++i) {
			for (int j = i+1; j < N; ++j) {
				if ( cat(S[j], S[i]) == S[i] ) {
					f[j] = true;
				}
			}
		}
		vector<string> s;
		for (int i = 0; i < N; ++i) {
			if (!f[i]) s.push_back(S[i]);
		}
		N = s.size();

		made[0][0][0] = true; dp[0][0][0] = "";
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				for (int k = 0; k < (1 << N); ++k) {
					if (made[i][j][k]) {
						for (int l = 0; l < N; ++l) {
							if ((k & (1 << l)) == 0) {
								int nk = k | (1 << l);
								proc(cat(dp[i][j][k], s[l]), i+1, l, nk);
							}
						}
					}
				}
			}
		}

		string ans = "";
		for (int i = 0; i < N; ++i) {
			if ( ans == "" || isGood(dp[N][i][(1 << N)-1], ans) ) {
				ans = dp[N][i][(1 << N)-1];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2752
# coding:utf-8
import itertools

N = int(input())
P = tuple(map(int, input().split(' ')))
Q = tuple(map(int, input().split(' ')))
pnum = 0
qnum = 0

l = [i for i in range(1, N+1)]

for idx, el in enumerate(itertools.permutations(l, N)):
    if el == P:
        pnum = idx + 1
    if el == Q:
        qnum = idx + 1
    if pnum != 0 and qnum != 0:
        break

print(abs(pnum-qnum))

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

using namespace std;

string S;

int main() {
  cin >> S;
  char tmp = S[0];

  for(int i = 1; i < S.length(); i++) {
    if(S[i] == tmp) {
      if(i == 1) {cout << "1 2" <<endl; return 0; }
      else {
	cout << i <<" "<< i+1  <<endl;
	return 0;
      }
    }
    tmp = S[i];
  }
  tmp = S[0];

  for(int i = 2; i < S.length(); i += 2) {
    if(S[i] == tmp) {
      cout << i - 1 <<" "<<i + 1 <<endl;
      return 0;
    }
    tmp = S[i];
  }
  tmp = S[1];

  for(int i = 3; i < S.length(); i+=2) {
    if(S[i] == tmp) {
      cout << i - 1 <<" "<<i + 1<<endl;
      return 0;
    }
    tmp = S[i];
  }

  cout <<"-1 -1"<<endl;
}
      
      
  


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

int main(){
    int N,W;
    cin >> N >> W;
    long long int wt[N+1]={}; 
    long long int val[N+1]={};
    long long int V[N+1][W+1];
    
    for(int i=0;i<N+1;i++){
    	for(int j=0;j<W+1;j++){
            V[i][j]=0;
        }
    }
    
    for(int i=1;i<=N;i++){
    	cin >> wt[i] >> val[i];
    } 

    for(int item = 1;item<=N;item++){
    	for(int weight = 1;weight<=W;weight++){
    		if(wt[item]<=weight){
    			V[item][weight] = max(V[item-1][weight],val[item]+V[item-1][weight-wt[item]]);
    		}
    		else{
    			V[item][weight] = V[item-1][weight];
    		}
    	}
    }
    cout << V[N][W];
	return 0;
}

Measured memory_bytes: 82332
#include <bits/stdc++.h>
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++)
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> t(n);
	
	rep(i,n){
		cin >> s[i];
		cin >> t[i];
	}
	
	string x;
	cin >> x;
	
	int temp = 0;
	rep(i,n){
		if(x == s[i]){
			temp = i;
		}
	}
	
	if (temp == n-1){
		cout << 0 << endl;
		return  0;
	}
	
	
	int ans = 0;
	for (int j = temp+1; j < n; ++j) {
		ans += t[j];
	}
	
	cout << ans << endl;
	
	
	
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;
int main() {
	int a1,a2,a3,a4,b1,b2,b3,b4,k,l,m,hit,blow;
	vector<int> s,t,u;
	while (cin>>a1>>a2>>a3>>a4>>b1>>b2>>b3>>b4) {
		hit = 0;
		blow = 0;
		s.clear();
		t.clear();
		s.push_back(a1);
		s.push_back(a2);
		s.push_back(a3);
		s.push_back(a4);
		t.push_back(b1);
		t.push_back(b2);
		t.push_back(b3);
		t.push_back(b4);
		for (k = 0; k < 4; k++) {
			if (s[k] == t[k]&&s[k]>=0) {
				hit += 1;
				s[k] = -1;
				t[k] = -1;
			}
		}
		for (l = 0; l < 4; l++) {
			for (m = 0; m < 4; m++) {
				if (s[l] == t[m] && s[l] > 0) {
					blow += 1;
					s[l] = -1;
					t[m] = -1;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	string a;
	cin>>a;
	bool cek=false;
	for(int q=0;q<a.size();q++){
		if(q%2==0 && a[q]=='L')cek=true;
		else if(q%2==1 && a[q]=='R')cek=true;
	}
	if(cek)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

char k[55][55];
int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= a; ++i) {
		for (int j = 1; j <= b; ++j) {
			cin >> k[i][j];
		}
	}
	for (int i = 1; i <= a; ++i) {
		for (int j = 1; j <= b; ++j) {
			if (k[i][j] == '.') { continue; }
			if (k[i + 1][j] == '.'&&k[i - 1][j] == '.'&&k[i][j + 1] == '.'&&k[i][j - 1] == '.') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


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

void main(void) {
	int a, b, c;
	int num = 0;
	int i;

	scanf("%d %d %d",&a, &b, &c);


	for(i=a;i<=b;i++){
	   if(c%i==0){
		   num++;
	   }
	}

	printf("%d\n",num);
    fflush(stdin);
}

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

int main() {
  string S,T;
  cin >> S >> T;
  int ans=T.size();
  rep(i,S.size()-T.size()+1){
    int temp=0;
    rep(j,T.size()){
      if(S[i+j]!=T[j]) temp++;
    }
    if(temp<ans) ans=temp;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  string s;
  cin >> s;
  int size=s.size();
  for(int i=0;i<size;i++){
    cout << 'x';
  }
  cout << endl;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  int h[n];
  rep(i, n) cin >> h[i];
  int dp[n] = {};
  dp[0] = 0;
  for(int i = 1; i < n; i++){
    int m = INF;
    for(int j = 1; j <= k; j++){
      if(i-j >= 0) m = min(m, dp[i-j]+abs(h[i]-h[i-j]));
    }
    dp[i] = m;
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>

int main(){
	int h,w,r4,r2,r1,alp[26],matrix[101][101];
	char c;
	for(int i=0;i<26;i++) alp[i]=0;
	scanf("%d %d",&h,&w);
	r4=(h/2)*(w/2);
	r1=(h%2)*(w%2);
	r2=(h*(w%2)+w*(h%2)-2*r1)/2;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			scanf("%c",&c);
			while(c==10){
			scanf("%c",&c);
			}
			alp[c-'a']+=1;
		}
	}
	for(int i=0;i<26;i++){
		//printf("%d",alp[i]);
		r4-=alp[i]/4;
		r2-=(alp[i]/2)%2;
		r1-=alp[i]%2;
		//printf("\n%d %d %d\n",r1,r2,r4);
	}
	//printf("\n%d %d %d\n",r1,r2,r4);
	if((r4==0)&&(r2==0)&&(r1==0))
		printf("Yes");
	else if(((w-1)*(h-1))==0&&r1==0)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
n=int(input())
a=[]
ans=0
for i in range(n):
  s=list(input())
  s.sort()
  a.append(str(s))
a.sort()
y=''
w=0
c=[]
for x in a:
  if y==x:
    w+=1
  else:
    c.append(w)
    w=1
  y=x
c.append(w)
c=c[1:]
for x in c:
  ans+=x*(x-1)//2
print(ans)

Measured memory_bytes: 16736
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int main(void){
	int a[3]={0};
	cin>>a[0]>>a[1]>>a[2];
	sort(a, a+3);
	int cost = abs(a[1] - a[0]) + abs(a[2] - a[1]);

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

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

/* B_i, C_iの条件記述時に同じsuffixを使うのはわかりにくいと思う */

int main(){
    uint32_t N = 0;
    uint32_t A_buf[20];// = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    uint32_t B_buf[20];// = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    uint32_t C_buf[20];// = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    uint32_t sum = 0;

    std::cin >> N;

    for(uint32_t i = 0; i < N; i++){
        std::cin >> A_buf[i];
    }

    for(uint32_t i = 0; i < N; i++){
        std::cin >> B_buf[i];
        sum += B_buf[i];
    }

    for(uint32_t i = 0; i < (N - 1); i++){
        std::cin >> C_buf[i];
    }

    for(uint32_t i = 0; i < (N - 1); i++){
        if((A_buf[i+1] - A_buf[i]) == 1){
            sum = sum + C_buf[(A_buf[i]-1)];
        }
    }

    std::cout << sum << std::endl;

    return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{


    ll n, ans = 0;
    cin >> n;
    vector<ll> v;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    for(ll i = 1; i < v.size()-1; i++)
    {

        ll x = min(v[i], min(v[i-1], v[i+1]));
        ll y = max(v[i], max(v[i-1], v[i+1]));
        if(x != v[i] && y != v[i]) ans++;
    }
    cout << ans;
}


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

int main() {
  int N, M;
  int a[100010];
  priority_queue<int> q;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    q.push(a[i]);
  }

  int x;
  for (int i = 0; i < M; i++) {
    x = q.top() / 2;
    q.pop();
    q.push(x);
  }

  long long res = 0;
  for (int i = 0; i < N; i++) {
    res += q.top();
    q.pop();
  }

  cout << res << endl;
}


Measured memory_bytes: 1148
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[1000000];
        a[0] = sc.nextInt();

        boolean equalFlag = false;
        int ans = 0;
        for(int i = 0;i<1000000;i++){
            if(a[i] % 2 == 0){
                a[i+1] = a[i]/2;
            }else{
                a[i+1] = a[i]*3+1;
            }
            for(int j = 0;j<i+1;j++){
                if(a[i+1] == a[j]){
                    equalFlag = true;
                    ans = i+2;
                    break;
                }
            }
            if(equalFlag == true){
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 29140
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <string>

using namespace std;

int main(){
  int n;
  string s,r="";
  cin >> n >> s;
  
  for(int i=0;i<s.length();i++)
      s[i] = (s[i] - 'A' + n)%26 + 'A';

  cout << s << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
a.append(0)
cost = 0
for i in range(n+1):
    cost += abs(a[i]-a[i+1])
for i in range(1,n+1):
    print(cost-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1]))

Measured memory_bytes: 14168
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,a[1005];
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int s=0;
	for(int i=0;i<m;i++)
	{
		s+=a[i];
	}
	cout<<s<<'\n';
	return 0;
}


Measured memory_bytes: 3600
S = input()

ans1 = 0
ans2 = 0

for i in range(len(S)) :
    if i % 2 == 1 :
        if S[i:i+1] == '0' :
            ans1 += 1
        else :
            ans2 += 1
    else :
        if S[i:i+1] == '1' :
            ans1 += 1
        else :
            ans2 += 1

print(min(ans1, ans2))


Measured memory_bytes: 3188
#include<stdio.h>
int main(void) {
	int H,W,i,j,x;
	char A[100];
	scanf("%d%d",&H,&W);
	for(i=0;i<H;i++) {
		scanf("%s", A);
		
		x=-1;
		for (j = 0; j<W; j++) {
			if (A[j] == 'c') {
				x= 0;
			}
			else if (x>-1) {
				x++;
			}
			printf("%d", x);
			if (j == (W- 1)) {
				printf("\n");
			}
			else {
				printf(" ");
			}
		}
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
const int N=30;

int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if(a<=b) cout<<a<<endl;
        else cout<<a-1<<endl;
        //cout<<min(a,b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
@author: @sancodemonster
*/
 
#include <bits/stdc++.h>
 
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define ll long long int
#define ld long double
#define pb push_back 
#define mp make_pair
#define MOD 1000000007
#define f(i,a,b)  for(long long i=a;i<b;i++)
#define all(c) (c).begin(),(c).end() 
using namespace std;

ll n,m;
ll dp[100005];
vector<ll>v[100005];

ll rec(ll node)
{
   
   if(dp[node]!=-1)
   	return dp[node];

    ll a = 0;
   f(i,0,v[node].size())
   {
       a = max( a, 1 + rec(v[node][i]) );
   }

   dp[node] = a;
   return dp[node];
}


int main()
{
  
     flash;
     /////////////////////////////////////////////////////////////////////////////////////////////////////
       
       ll i;

       cin>>n>>m;
       f(i,0,m)
       {
       	 ll x,y;
       	 cin>>x>>y;
       	 v[x-1].push_back(y-1);
       }

       f(i,0,n)
       {
       	  dp[i] = -1;
       }
      
       ll ans  = 0;
       f(i,0,n)
       {
       	  ans  = max(ans,rec(i));
       }

       cout<<ans;

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

     return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int t,n,k,d,A;
int main()
{
	cin>>t;
	while(t--&&cin>>n>>k)
	{
		while(n%k!=0)
			d=n/k+1,n-=(n%k-1)/d*d+d;
		A^=n/k;
	}
	if(A)
		cout<<"Takahashi";
	else
		cout<<"Aoki";
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
for x, y in edges:
    graph[x - 1].append(y - 1)
    graph[y - 1].append(x - 1)

def dfs(v, c):
    # c: color = 1 or -1
    node[v] = c
    for i in graph[v]:
        if node[i] == c:
            return False
        
        if node[i] == 0 and not dfs(i, -c):
            return False
        
    return True

node = [0] * N
if dfs(0, 1):
    x = sum(v + 1 for v in node) // 2
    print(x * (N - x) - M)
else:
    print(N * (N - 1) // 2 - M)


Measured memory_bytes: 108376
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] closestEnemy = new int[N+1];
        for(int n=0;n<=N;n++) closestEnemy[n] = N+1;
        for(int m=0;m<M;m++){
        	int a = sc.nextInt()-1;
        	int b = sc.nextInt()-1;
        	if(closestEnemy[a] > b)  closestEnemy[a] = b;
        }
        int ans = 0;
        for(int n=0;n<N;n++){
        	if(closestEnemy[n]==n+1) ans++;
        	else closestEnemy[n+1] = Math.min(closestEnemy[n+1],closestEnemy[n]);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 64956
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

typedef pair<int, int> P;

int main()
{
    int N;
    cin >> N;
    int odd[N], even[N];
    REP(i, 1, N+1) {
        if(i%2) cin >> odd[i/2];
        else    cin >> even[i/2-1];
    }

    sort(odd,odd + N/2);
    sort(even, even + N/2);

    vector<P> oddp, evenp;
    REP(i, 0, N/2) {
        if(i == 0) {
            oddp.push_back(P(1,odd[i]));
            evenp.push_back(P(1,even[i]));
            continue;
        }

        int o = oddp.size(), e = evenp.size();
        if(oddp[o-1].second == odd[i]) ++oddp[o-1].first;
        else oddp.push_back(P(1,odd[i]));

        if(evenp[e-1].second == even[i]) ++evenp[e-1].first;
        else evenp.push_back(P(1,even[i]));
    }

    sort(oddp.begin(), oddp.end(), greater<P>());
    sort(evenp.begin(), evenp.end(), greater<P>());
    
    //2つ以上ない場合、0要素を入れても一般性を失わない?
    if(oddp.size() >= 1) oddp.push_back(P(0, 0));
    if(evenp.size() >= 1) evenp.push_back(P(0, 0));
    int O1 = oddp[0].first, O2 = oddp[1].first,
        E1 = evenp[0].first, E2 = evenp[1].first;
    
    if(oddp[0].second != evenp[0].second) {
        cout << N - (O1 + E1) << endl;
    }
    else {
        cout << N - max(O1 + E2, O2 + E1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main(){
  long a, b, c, k, tmpa, tmpb, tmpc; 
  cin >> a >> b >> c >> k;
  long res = a-b;
  if (k % 2 == 1) {
    res *= -1;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  int n; cin >> n;
  
  ll sum = 0;
  loop(i,1,n+1) sum += i;
  
  for (int i=2; i<=n; i++) {
    sum += i; 
    for (int j=i*2; j<=n; j += i) {
      sum += j;
    }
  }
  
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	ll x;
	cin>>x;
	ll i,j;
	for(i=-150;i<=150;i++)
	{
		for(j=-150;j<=150;j++)
		{
			if(pow(i,5)-pow(j,5)==x)
			{
				cout<<i<<" "<<j<<"\n";
				return 0;
			}
		}
	}
	return 0;
}
	

Measured memory_bytes: 4052
s = input()
a, b = int(s[:2]), int(s[2:])
ym, my = False, False
if a > 0 and a <13:
    my = True
if b > 0 and b <13:
    ym = True
if ym and my:
    print('AMBIGUOUS')
elif ym and not my:
    print('YYMM')
elif not ym and my:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
#define MK make_pair 



int main(){
  while(1){


    
  int n;
  cin>>n;
  if(n==0){break;}
  int t[1000000]={};
  for(int i=0;i<n;i++){
    int h,m,s;
    char c;
    cin>>h>>c>>m>>c>>s;
    int a=h*60*60+m*60+s;
    t[a]++;
    cin>>h>>c>>m>>c>>s;
    a=h*60*60+m*60+s;
    t[a]--;
  }
  int mx=0;
  int count=0;
  for(int i=0;i<1e6;i++){
    count+=t[i];
    mx=max(mx,count);
  }
  cout<<mx<<endl;
  



  }
  return 0;
}



Measured memory_bytes: 6960
n, m, x  = map(int, input().split())
List = [int(i) for i in input().split()]

s_count = 0
b_count = 0

for i in range(m):
    if List[i] < x:
        s_count += 1
    elif List[i] > x:
        b_count += 1

print(s_count if s_count < b_count else b_count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int n, a;
int x[55];

int y[55];
int X;
ll dp[55][2555*2] = {0};

int main () {
  cin >> n >> a;
  rep(i,n) cin >> x[i];

  
  //X = max(*max_element(x,x+n),a);
  X = *max_element(x,x+n);

  rep(i,n) y[i] = x[i] - a;

  dp[0][n*X] = 1;
  rep(j,55) {
    rep(s,2555*2) {
      if (j >= 1 && !(0<=s-y[j-1] && s-y[j-1]<=2*n*X)) {
        dp[j][s] = dp[j-1][s];
      }
      if (j >= 1 && (0<=s-y[j-1] && s-y[j-1]<=2*n*X)) {
        dp[j][s] = dp[j-1][s] + dp[j-1][s-y[j-1]];
      }
    }
  }

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

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int h, n;
    cin >> h >> n;
    int sum = 0;
    rep(i, n) {
        int a;
        cin >> a;
        sum += a;
    }

    if (h <= sum)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;
  using ull = unsigned long long;

  int N;
  string S;
  vector<vector<int> > DP;

  void init() {
    cin >> N >> S;
    DP.assign(N+1, vector<int>(N+1, 0));
  }

  void solve() {
    int ans = 0;
    REPCM(i, N-1, 0) REPCM(j, N-1, i) {
      if(S[i] == S[j]) chmax(DP[i][j], DP[i+1][j+1]+1);
      chmax(ans, min(DP[i][j], j-i));
    }
    cout << ans << "\n";
  }
}

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

Measured memory_bytes: 98176
using System;

namespace ConsoleApplication1
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] str;
			str = new string [4];
			int[] n;
			n = new int[4];
			for(int i = 0;i < 4;i++)
			{
				str[i] = Console.ReadLine();
				n[i] = Convert.ToInt32(str[i]);
			}
			int s = n[0] + n[1] + n[2] + n[3];
			int min = s / 60;
			int sec = s % 60;
			Console.WriteLine(min);
			Console.WriteLine(sec);
		}
	}
}

Measured memory_bytes: 5656
#include <stdio.h>

int main(void) {
  int i, n, c, ans = 0, a;
  scanf("%d%d", &n, &c);
  for(i = 0; i < c; ++i) {
    scanf("%d", &a);
    ans += a;
  }
  printf("%d\n", (ans + n) / (n + 1));
  return 0;
}


Measured memory_bytes: 2768
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    let s = readl!(String);
    let (x, y) = readl!(i32, i32);
    let dx = [-1, 0, 1, 0];
    let dy = [0, -1, 0, 1];
    let mut cxy = [0, 0];
    let mut ii = 0;
    let m = s.len()*2+3;
    let mut dp = [vec![[false, false]; m*2], vec![[false, false]; m*2]];
    // let c =  s.chars().take_while(|&x| x == 'F').count();
    // dp[0].insert(c as i32);
    // dp[1].insert(0);
    dp[0][m+0] = [true, false];
    dp[1][m+0] = [true, true];
    for c in s.chars() {
        // debug!(dp[00]);
        // debug!(dp[01]);
        if c == 'T' {
            ii = 1-ii;
            for e in &mut dp[ii] {
                if e[0] || e[1] {
                    e[0] = true;
                    e[1] = true;
                }
            }
        } else {
            let mut nex = vec![[false, false]; m*2];
            for i in 1..dp[ii].len()-1 {
                if dp[ii][i][0] {
                    nex[i+1][0] = true;
                }
            }
            for i in 1..dp[ii].len()-1 {
                if dp[ii][i][1] {
                    nex[i-1][1] = true;
                }
            }
            dp[ii] = nex;
        }
    }
    if (dp[0][(m as i32+x) as usize][0] || dp[0][(m as i32+x) as usize][1]) 
        && (dp[1][(m as i32+y) as usize][0] || dp[1][(m as i32+y) as usize][1]) {
        println!("Yes");
    } else {
        println!("No");
    }
}



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

using namespace std;

#define MAX_NODE 8

int dfs(bool graph[MAX_NODE][MAX_NODE], int curr, int n, bool hist[])
{
  int i=0;
  for(i=0; i<n; i++){
    if(!hist[i])
      break;
  }
  if(i==n){
    //printf("all\n");
    return 1;
  }
  int ret=0;
  for(i=0; i<n; i++){
    if(graph[curr][i] && !hist[i]){
      //printf("next %d\n", i+1);
      hist[i] = true;
      ret += dfs(graph, i, n, hist);
      //printf("--\n");
      hist[i] = false;
    }
  }
  return ret;
}

int main()
{
  int n, m;
  cin >> n >> m;
  
  bool graph[MAX_NODE][MAX_NODE];
  bool hist[MAX_NODE];
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
		graph[i][j] = 0;
    }
    hist[i] = 0;
  }
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    graph[a-1][b-1] = graph[b-1][a-1] = 1;
  }
  
  hist[0] = true;
  int ret = dfs(graph, 0, n, hist);
  
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  long a,b,x;
  scanf("%ld%ld%ld",&a,&b,&x);
  if(a%x != 0){printf("%ld",b/x - a/x);}
  else{printf("%ld",b/x - a/x + 1);}
  return 0;
}

Measured memory_bytes: 128
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    const U_INF: usize = 1 << 60;
    const I_INF: isize = 1 << 60;

    let n: usize = read!();
    let mut a = Vec::with_capacity(n);
    for _ in 0..n {
        let ai: isize = read!();
        a.push(ai);
    }

    let mut dp = vec![vec![None; n + 10]; n + 10];
    for i in 0..=n {
        dp[i][i] = Some(0);
    }

    // for len in 1..=n {
    //     for i in 0..n {
    //         let j = len + i;
    //         if j <= n {
    //             if (n - len) % 2 == 0 {
    //                 let jj = if j == n { -I_INF } else { dp[i][j - 1] + a[j] };
    //                 dp[i][j] = (dp[i + 1][j] + a[i]).max(jj);
    //             } else {
    //                 let jj = if j == n { I_INF } else { dp[i][j - 1] - a[j] };
    //                 dp[i][j] = (dp[i + 1][j] - a[i]).min(jj);
    //             }
    //         }
    //     }
    // }

    println!("{}", memo(n, 0, n, &mut dp, &a));
}

fn memo(n: usize, i: usize, j: usize, dp: &mut Vec<Vec<Option<isize>>>, a: &Vec<isize>) -> isize {
    match dp[i][j] {
        Some(ans) => ans,
        None => {
            if (n - (j - i)) % 2 == 0 {
                let ans =
                    (memo(n, i + 1, j, dp, a) + a[i]).max(memo(n, i, j - 1, dp, a) + a[j - 1]);
                dp[i][j] = Some(ans);
                ans
            } else {
                let ans =
                    (memo(n, i + 1, j, dp, a) - a[i]).min(memo(n, i, j - 1, dp, a) - a[j - 1]);
                dp[i][j] = Some(ans);
                ans
            }
        }
    }
}


Measured memory_bytes: 144132
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = a - b * 2;
		System.out.println((ans < 0) ? 0 : ans);
	}	
}

Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	//再利用の時はここからけす
		while(true) {
			int row = sc.nextInt();
			int column = sc.nextInt();

			if(row == 0 && column ==0) break;

			for(int rowDraw = 0; row > rowDraw; rowDraw++) {

					if(rowDraw == 0 || rowDraw == (row - 1)) {
						//すべてがシャープ
						drawSharp(column);
					}else {
						//シャープとドッドの兼用
						drawSharpAndDots(column);
					}
				}
			System.out.println("");
		}
		//End of Main Method
		}

		private static void drawSharp(int column) {
			String drawSharp = "#";
			for(int i = 1; column  > i; i++) {
				drawSharp = drawSharp + "#";
			}
			System.out.println(drawSharp);
		}

		private static void drawSharpAndDots(int column) {
			String drawSharpAndDots = "#";
			for(int j = 1; column > j; j++) {
				if(j == (column - 1)) {
					drawSharpAndDots = drawSharpAndDots + "#";
				}else {
					drawSharpAndDots = drawSharpAndDots + ".";
				}
			}
			System.out.println(drawSharpAndDots);
		}



	//End of this Class
}



Measured memory_bytes: 50016
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;

const int N=200005;

int n,sz,k;
ll ans;
int a[N],f[N];
ll b[N],s[N],g[N];

void add(int x){
	for (;x<=sz;x+=x&-x) f[x]++;
}

int query(int x){
	int s=0;
	for (;x;x-=x&-x) s+=f[x];
	return s;
}

int main(){
	int i;
	scanf("%d%d",&n,&k);
	g[0]=0; b[++sz]=g[0];
	for (i=1;i<=n;i++){
		scanf("%d",&a[i]);
		s[i]=s[i-1]+1ll*a[i];
		g[i]=b[++sz]=s[i]-1ll*i*k;
	}
	sort(b+1,b+1+sz);
	sz=unique(b+1,b+1+sz)-b-1;
	for (i=0;i<=n;i++) a[i]=lower_bound(b+1,b+1+sz,g[i])-b;
	add(a[0]);
	for (i=1;i<=n;i++){
		ans+=1ll*query(a[i]);
		add(a[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6528
/*
    Shell Sort
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/all/ALDS1_2_D
*/
#include <bits/stdc++.h>
using namespace std;
int cnt = 0;

void insertionSort(vector<int> &a, const int n, const int g) {
    for (auto i = g; i < n; ++i) {
        auto v = a.at(i);
        auto j = i - g;
        while (j >= 0 and a.at(j) > v) {
            a.at(j + g) = a.at(j);
            j -= g;
            ++cnt;
        }
        a.at(j + g) = v;
    }
}

void shellSort(vector<int> &vect, const int n) {
    cnt = 0;
    vector<int> g;
    for (auto m = vect.size() / 3; m > 1; m = (m - 1) / 3)
        g.push_back(m);
    g.push_back(1);
    for (auto v : g)
        insertionSort(vect, n, v);
    cout << g.size() << '\n' << g.front();
    for (auto i = g.begin() + 1; i != g.end(); ++i)
        cout << " " << *i;
    cout << '\n' << cnt << '\n';
    for (auto i : vect)
        cout << i << '\n';
}

int main() {
    int n;
    cin >> n;
    vector<int> vect;
    for (auto i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        vect.push_back(temp);
    }
    shellSort(vect, n);
}



Measured memory_bytes: 7044
L,R=map(int,input().split())
if R-L>=2019:
    minimum=0
else:
    left,right=L%2019,R%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)

Measured memory_bytes: 40812