akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3)
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3)
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int i,n,k;
    sf(n);
    vector<int>vec;
    rep0(i,n)
    {
        sf(k);
        vec.pb(k);
    }
    bool chk=true;
    for(i=n-1;i>=1;i--)
    {
        if(vec[i-1]>vec[i])
            vec[i-1]--;
    }
    rep0(i,n-1)
    {
        if(vec[i]>vec[i+1])
        {
            chk=false;
            break;
        }
    }
    puts(chk?"Yes":"No");
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  vector<i64> A(1000001);
  for (i64 i = 0; i < N; i++)
  {
    i64 a;
    cin >> a;
    A[a]++;
  }
  i64 ans = 0;
  for (i64 i = 0; i < 1000001; i++)
  {
    if (A[i] == 0)
      continue;
    if (A[i] == 1)
      ans++;
    for (i64 j = i * 2; j < 1000001; j += i)
      A[j] = 0;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    unordered_map<int, int> mp;
    for(int i = 0; i < N; i++){
        mp[A[i]]++;
    }
    ll max = 0, submax = 0;
    for(auto e: mp){
        if(e.second >= 4){
            if(max < e.first){
                max = submax = e.first;
            }else if(submax < e.first){
                submax = e.first;
            }
        }else if(e.second >= 2){
            if(max < e.first){
                submax = max;
                max = e.first;
            }else if(submax < e.first){
                submax = e.first;
            }
        }
    }
    cout << max * submax << endl;
}

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

int main(){
    ios::sync_with_stdio(false);
    while(1){
        string s; getline(cin,s);
        if(s[0] == '.') break;

        stack<char>data;
        bool flag = true;
        for(int i=0; i<s.size(); i++){
            if(s[i] == '(' || s[i] == '[') data.push(s[i]);
            if(s[i] == ')' || s[i] == ']'){
                if(data.empty()){
                    flag = false;
                    break;
                }
                if((data.top() == '(' && s[i] == ']')
                ||  (data.top() == '[' && s[i] == ')')){
                    flag = false;
                    break;
                }
                data.pop();
            }
        }
        if(flag && data.empty()) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int main()
{
    int n;

    vi vx;
    vi vy;
    vi vh;

    scanf("%d", &n);

    rep(i, n)
    {
        int x, y, h;
        scanf("%d %d %d", &x, &y, &h);
        vx.pb(x);
        vy.pb(y);
        vh.pb(h);
    }
    rep(cx, 101)
    {
        rep(cy, 101)
        {
            int H;
            bool is_correct = true;
            rep(i, n)
            {
                if (vh[i] != 0) {
                    H = vh[i] + abs(vx[i] - cx) + abs(vy[i] - cy);
                    break;
                }
            }
            rep(i, n)
            {
                if (max(H - abs(vx[i] - cx) - abs(vy[i] - cy), 0) != vh[i]) {
                    is_correct = false;
                    break;
                }
            }
            if (is_correct) {
                printf("%d %d %d", cx, cy, H);
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <cmath>
#include <numeric>
#include <sstream>
#include <iomanip>
using ll = long long;
using namespace std;
#define INF 999999999

int main()
{
    int N, K;
    cin >> N >> K;
    N = N % 2 == 1 ? N : N - 1;
    if (N / 2 + 1 - K >= 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a=list(map(int, input().split()))
Q = int(input())
num_a =[0]*100001
num_b = []
sum_a = sum(a)
b=[]
c=[]
for i in a:
  num_a[i]+= 1
for i in range(Q):
  b1,c1=map(int, input().split())
  b.append(b1)
  c.append(c1)
for i in range(Q):
  if num_a[b[i]]==0:
    num_b.append(0)
    sum_a = sum_a - b[i]*num_b[i] +c[i]*num_b[i]
  else:
    num_b.append(num_a[b[i]])
    num_a[c[i]] += num_a[b[i]]
    num_a[b[i]] = 0
    sum_a = sum_a - b[i]*num_b[i] +c[i]*num_b[i]
  print(sum_a)

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);

	ll a,b,c;
	cin >> a >> b >> c;
	
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		cout << 0 << endl;
	else {
		ll s1,s2,s3;
		s1 = a * b;
		s2 = a * c;
		s3 = b * c;
		s1 = min(s1,s2);
		cout << min(s1,s3) << endl;
	}
	
	
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <iostream>
#include <algorithm> 
using namespace std;
int main(){
	int a[200005],n,i,j;
	long long l=0,k;
	scanf("%d",&n);
 for(i=0;i<n;i++){
 scanf("%d",&a[i]);
 a[i]-=i+1;
}
sort(a,a+n);
	i=(n+1)/2-1;
	i=a[i];
	for(j=0;j<n;j++){
	k=a[j]-i;
	if(k<0)k=-k;
	l+=k;
	}
	printf("%lld",l);
	return 0;
}

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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String text = br.readLine();
        int n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++) {
            String[] lines = br.readLine().split(" ");
            int begin = Integer.parseInt(lines[1]);
            int end = Integer.parseInt(lines[2]) + 1;
            if (lines[0].equals("print")) {
                System.out.println(text.substring(begin, end));
            } else if (lines[0].equals("replace")) {
                char[] oldWord = text.toCharArray();
                char[] newWord = lines[3].toCharArray();
                for (int j = begin, k = 0; j < end; j++) {
                    oldWord[j] = newWord[k++];
                }
                text = String.valueOf(oldWord);
            } else {
                char[] reverseWord = text.toCharArray();
                char[] tempText = text.toCharArray();
                for (int j = begin, k = end - 1; j < end; j++, k--) {
                    tempText[j] = reverseWord[k];
                }
                text = String.valueOf(tempText);
            }
        }
    }
}

Measured memory_bytes: 24792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main()
{
	ll k;
	cin >> k;
	ll skipNumber = 1;
	ll runRunNumberSum = 0;
	ll checkNumber = 0;
	while (runRunNumberSum < k)
	{
		checkNumber += skipNumber;
		skipNumber = 1;
		string checkNumberString = to_string(checkNumber);
		if (checkNumberString.length() == 1)
		{
			runRunNumberSum++;
		}
		else
		{
			for (int i = 0; i < checkNumberString.length() - 1; i++)
			{
				if (abs(checkNumberString[i] - checkNumberString[i + 1]) > 1)
				{
					for (int j = i + 1; j < checkNumberString.length() - 1; j++)
					{
						skipNumber *= 10;
					}
					break;
				}
				if (i >= checkNumberString.length() - 2)
				{
					runRunNumberSum++;
				}
			}
		}
	}
	cout << checkNumber << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>
#include <stdlib.h>
#include <stack>
#include <queue>
#include <bitset>
#include <memory.h>

using namespace std;



int main() {
    char cup[3]={'A','B','C'};
    int ball[3]={0};
    ball[0]=1;
    char c_cup1, c_cup2;
    while(scanf("%c,%c ",&c_cup1, &c_cup2)!=EOF){

        int i_cup1 = c_cup1-65;
        int i_cup2 = c_cup2-65;
        
        swap(ball[i_cup1],ball[i_cup2]);
    }
    for(int i=0; i<3; i++){
        if(ball[i]==1)cout<<cup[i]<<endl;
    }
}

Measured memory_bytes: 1156
UTF8pattern = [   ['0xxxxxxx'], \
    ['110yyyyx','10xxxxxx'], \
    ['1110yyyy','10yxxxxx','10xxxxxx'], \
    ['11110yyy','10yyxxxx', '10xxxxxx', '10xxxxxx'] \
    ]

def func(linelist, pattern):
    mother=UTF8pattern[pattern-1]
    ret=1
    rety=1
    y_hasone=0
    y_allzero=1
    for i in range(pattern):
        for j in range(8):
            #print j, mother[i][j], linelist[i][j]
            if (mother[i][j]=='0' or mother[i][j]=='1') and linelist[i][j]!='x' and mother[i][j]!=linelist[i][j]:
                return 0
            if mother[i][j]=='x' and linelist[i][j]=='x':
                ret*=2
            if mother[i][j]=='y':
                if linelist[i][j]=='1':
                    y_hasone=1
                    y_allzero=0
                elif linelist[i][j]=='x':
                    y_allzero=0
                    rety *= 2
    if pattern >=2:
        if y_allzero:
            return 0
        elif not y_hasone:
            rety-=1
        ret *= rety
    return ret

while(1):
    N=int(raw_input())
    if N==0:
        break
    L=[]
    for n in range(N):
        L.append(raw_input())
    A=[[0 for x in range(4)] for y in range(N)]
    for n in range(N):
        for p in range(4):
            if n+p<N:
                A[n][p]=func(L[n:n+p+1], p+1)
    B=[0 for y in range(N+1)]
    B[0]=1
    for n in range(N+1):
        for p in range(4):
            if n-p>0:
                B[n] += B[n-p-1]*A[n-p-1][p]
    #print A
    #print B
    print B[-1]%1000000



Measured memory_bytes: 5768
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int A = sc.nextInt();
    System.out.println((H+A-1)/A);
  }
}


Measured memory_bytes: 35552
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<string> S(N);
  for(int i=0;i<N;++i) {
    cin>>S[i];
  }
  vector<int> ans(N);
  queue<pair<int, int> > que;
  pair<int, int> state;
  bool can = true;
  int node, dist;
  int ans1 = 0;
  for(int i=0;i<N;++i) {
    for(int j=0;j<N;++j) ans[j] = 0;
    ans[i] = 1;
    que.push(mp(i, 1));
    while(!que.empty()) {
      state = que.front();que.pop();
      node = state.fi;
      dist = state.se;
      for(int i=0;i<N;++i) {
        if(S[node][i]=='1') {
          if(ans[i]==0) {
            que.push(mp(i, dist+1));
            ans[i] = dist + 1;
          }
          else if(ans[i]!=dist-1 && ans[i]!=dist+1) can = false;
        }
      }
    }
    if(can) {
      for(int i=0;i<N;++i) ans1 = max(ans1, ans[i]);
    }
  }
  if(!can) cout<<-1<<endl;
  else cout<<ans1<<endl;
}


Measured memory_bytes: 3668
#include <stdio.h>

int A[200005];

int main(){
    int N;
    scanf("%d", &N);
    A[0] = -1;
    for(int i=1; i<=N; i++){
        scanf("%d", &A[i]);
        if(A[i] > A[i-1]+1){
            printf("-1");
            return 0;
        }
    }
    long long res = 0;
    for(int i=2; i<=N; i++){
        if(A[i] == A[i-1]+1) res++;
        else res += A[i];
    }
    printf("%lld", res);
    return 0;
}


Measured memory_bytes: 896
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = 0
r = k
t = sum(p[l:r])
ans = (t+k)/2
for _ in range(n-k):
    t -= p[l]
    t += p[r]
    l += 1
    r += 1
    ans = max(ans, (t+k)/2)
print(ans)

Measured memory_bytes: 25604
/* ファイル名：ITP1_9_B.c	*/
/* 内容：１つのアルファベットが描かれた n 枚のカードの山をシャッフルし、	*/
/*		 最終的に最後の並び（文字列）を出力する。							*/
/* include	*/
#include <stdio.h>
#include <string.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:１つのアルファベットが描かれた n 枚のカードの山をシャッフルし、	*/
/*			最終的に最後の並び（文字列）を出力する。						*/
int main( void )
{
	/* 内部変数定義	*/
	/* 入力	*/
	char deck[201];	/* カードの山	*/
	int m;			/* シャッフルする回数	*/
	int h;			/* シャッフルする枚数	*/
	/* 処理	*/
	int i;			/* ループ用変数	*/
	char s_deck[201];	/* シャッフル中のカードの山	*/
	
	/* 無限ループ	*/
	while(1){
		scanf("%s",deck);	/* カードの山を取得	*/
		
		/* "-"が入力された場合*/
		if(deck[0] == '-'){
			break;	/* 処理を終了する	*/
		}
		else{
			/* 処理なし	*/
		}
		
		scanf("%d",&m);	/* シャッフルの回数を取得	*/
		
		/* シャッフル回数だけループ	*/
		for(i = 0; i < m; i++){
			scanf("%d",&h);	/* シャッフルする枚数を取得	*/
			
			strncpy(s_deck,&deck[h],strlen(deck) - h);	/* シャッフル中のカードの先頭に、元のカードの山のh枚目から最後までコピー	*/
			s_deck[strlen(deck) - h] = '\0';
			
			strncat(s_deck,deck,h);/* シャッフル中のカードの末尾に、元のカードの山の残りを連結	*/
			
			strcpy(deck,s_deck);	/* カードの山をシャッフル中の状態に書き換える	*/
		}
		/* シャッフルの結果を表示	*/
		printf("%s\n",deck);
	}
	
	return 0;
}



Measured memory_bytes: 2032
import sys
input = sys.stdin.readline

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[1])

sum = 0
for cost, limit in ab:
    sum += cost
    if sum > limit:
        print('No')
        break
else:
    print('Yes')


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

int main(void) {
  string s;
  cin >> s;

int cnt = 0;
  rep(i,s.size()) {
    if (i == s.size()-1) ;
    else if(s[i] != s[i+1]) cnt++;
    else ;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3696
#include <stdio.h>

int main(void) {
  int i, j;
  int n;
  int count = 0;
  int temp;

  scanf("%d", &n);

  int a[n + 1];

  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);

  for (i = 0; i < n; i++) {
    for (j = n - 1; j > i; j--) {
      if (a[j] < a[j - 1]) {
        temp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = temp;
        count++;
      }
    }
  }

  for (i = 0; i < n; i++)
    if (i < n - 1) {
      printf("%d ", a[i]);
    } else {
      printf("%d\n%d\n", a[i], count);
    }

  return 0;
}



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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;




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

	int n; cin>>n;

	map<string,ll> mp;

	for(int i=0; i<n; i++){
		string s;cin>>s;

		sort(s.begin(),s.end());

		mp[s]++;
	}

	ll ans =0;
	for(auto e : mp){
		ans += (e.second*(e.second-1))/2;
	}

	writeln(ans);


}




Measured memory_bytes: 11264
N = int(input())
A= [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

defect_cnt = 0
cooperation = 0
B.append(0)

for i in range(len(A)):
    if A[i] < cooperation:
        defect_cnt += A[i]
        A[i] = 0
    else:
        defect_cnt += cooperation
        A[i] -= cooperation

    cooperation = 0

    if A[i] < B[i]:
        defect_cnt += A[i]
        cooperation = B[i] - A[i]
    else:
        defect_cnt += B[i]

print(str(defect_cnt))

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

int main(int argc, char** argv) {
    
    int n;
    int q;
    int S[100000];
    int left;
    int right;
    int mid;
    int count = 0;
    int key;
    int i;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);

    for(i=0; i<q; i++){
        scanf("%d", &key);
        left = 0;
        right = n;
        while(right>=left){
            mid = (left+right)/2;
            if(S[mid]==key){
                count++;
                break;
            }
            if(key>S[mid]){
                left = mid + 1;
            }
            else{
                right = mid-1;
            }   
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2128
k = int(input())
a, b = map(int, input().split())
i = 1
flag = False


while i < b:
    if k == 1:
        flag = True
        break
    dis = i * k
    if dis >= a and dis <= b:
        flag = True
        break

    i += 1


if flag:
    print("OK")
else:
    print("NG")


Measured memory_bytes: 9176
import sys

num, hp = (int(i) for i in input().split(" "))

katanas_a = []
katanas_b = []

for i in range(num):
    a, b = (int(j) for j in input().split(" "))
    katanas_a.append(a)
    katanas_b.append(b)

katanas_a.sort()
swing_max = katanas_a[len(katanas_a) - 1]

katanas_b.sort()

attack_count = 0
for katana in reversed(katanas_b):
    if katana > swing_max:
        hp -= katana
        attack_count += 1

    if hp <= 0:
        print(attack_count)
        sys.exit()

if hp % swing_max != 0:
    attack_count += int(hp / swing_max) + 1
else:
    attack_count += int(hp / swing_max)

print(attack_count)


Measured memory_bytes: 11296
import itertools
A=map(int,input().split())
lt = list(itertools.permutations(A))
ans=[]

for ary in lt:
    tmp=0
    for i in range(1,len(ary)):
        tmp += abs(ary[i] - ary[i-1])
    ans.append(tmp)

print(min(ans))

Measured memory_bytes: 3060
import copy
D = int( input() )
c = list( map( int, input().split() ) )
s = []
for _ in range( D ):
    s_i = list( map( int, input().split() ) )
    s.append( s_i )
t = []
for _ in range( D ):
    t_i = int( input() )
    t.append( t_i - 1 )

last = []
last_i = [ -1 for _ in range( 26 ) ]
for i in range( D ):
    last_i[ t[ i ] ] = i
    last.append( copy.deepcopy( last_i ) )

# def satisfy( D, c, s, t, last, d ):
satisfy = [ 0 for _ in range( D ) ]
for d in range( D ):
    satisfy[ d ] += s[ d ][ t[ d ] ]
    for i in range( 26 ):
        satisfy[ d ] -= c[ i ] * ( d - last[ d ][ i ] )

v = 0
for v_i in satisfy:
    v += v_i
    print( v )


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

int main(){
    string sen;
    int co[26]={};
    
    while(cin >> sen){
        for (int i=0;i<(int)sen.size();i++){
            if (isupper(sen[i])) sen[i] = tolower(sen[i]);
            if (sen[i] >= 'a' && sen[i] <= 'z'){
                co[sen[i] - 'a'] +=1;
            }
            
        }
    }
    for (int j=0;j<26;j++){
        cout << (char)('a' + j) << " : " << co[j] << endl;
    }
    return 0;
}


Measured memory_bytes: 3204
L, R = map(int, input().split())

maxitr = min([R,L+2019])

minval = 2020

for i in range(L,maxitr+1):
  for j in range(i + 1,maxitr+1):
    if minval > i*j%2019:
      minval = i*j%2019

print(minval)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

int main(){
    vi x(5);
    rep(i, 5) cin >> x[i];
    int ans = 0;
    rep(i, 5) if (x[i] == 0) ans = i + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<list>
using namespace std;

#define PB push_back

int main(int argc,char* argv[]){
  int n,q;
  list<int> lis,lit;
  int i,x,ans=0;
  
  cin>>n;
  for(i=0;i<n;i++){
    cin>>x;
    lis.PB(x);
  }
  cin>>q;
  for(i=0;i<q;i++){
    cin>>x;
    lit.PB(x);
  }
  //重複要素を削除
  lis.sort();
  lis.unique();
  lit.sort();
  lit.unique();

  list<int>::iterator itlit;
  for(itlit=lit.begin();itlit!=lit.end();itlit++){
    if(find(lis.begin(),lis.end(),*itlit)!=lis.end())
      ans++;
  }

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1508
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;



int main(void) {
  int n;
  cin >> n;
  vpii a(n);
  rep(i,n){
    int p,q;
    cin >> p >> q;
    a[i] = make_pair(q,p);
  }
  sort(a.begin(),a.end());
  ll time = 0;
  rep(i,n){
    if(a[i].second+time>a[i].first) {
      cout << "No" << endl;
      return 0;
    }
    time += a[i].second;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
main(){
    #define task "TASK"
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }
    int x=in,y=in;
    forinc(i,0,x)
        if(i*4+(x-i)*2==y)
            return cout<<"Yes",0;
    cout<<"No";
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>

int po(int a,int b){
  int c = 1,i;
  if(b == 0) return 1;
  if(b == 1) return a;
  for(i=0;i<b;i++){
   c = c * a; 
  }
 return c; 
}

int main(void){
  
  int n,i,j,h,w,q;
  int k,l,count = 0;
  char s[6][6];
  char ss[6][6];
  char a[6][16];
  int aa,bb;
  //int AC=0,WA=0,TLE=0,RE=0;
  //char s[100001][16];
 // printf("%d",po(3,3));
  scanf("%d %d %d",&h,&w,&k);
for(i=0;i<h;i++){
scanf("%s",a[i]);
  //printf("\n",s[i]);
}
  //printf("\n");
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      s[i][j] = a[i][j];
      ss[i][j] = s[i][j];
    }
  }
  int co = 0;
  
  /*
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
		printf("%c",s[i][j]);   
    }
    printf("\n");
  }
  */
  
  int hh = po(2,h);
  int ww = po(2,w);
  int ll = 0;
  for(i=0;i<hh;i++){
    for(j=0;j<ww;j++){
      ll++;
      
      for(l=0;l<h;l++){
//        printf("[%d.%d]-",(i&(1<<l)),(1<<l));
        if((i&(1<<l)) == (1<<l)) {
          for(q=0;q<w;q++){
          	ss[l][q] = 'a';
          }
        }      
      }
//      printf("\n");
      for(l=0;l<w;l++){
   //     printf("[%d.%d]-",(j&(1<<l)),(1<<l));
        if((j&(1<<l)) == (1<<l)){
          for(q=0;q<h;q++){
          	ss[q][l] = 'a';
          }     
        }
      }
     //  printf("\n"); 
      for(aa=0;aa<h;aa++){
        for(bb=0;bb<w;bb++){
         // printf("%c",ss[aa][bb]);
          if(ss[aa][bb] == '#') count++;
        }
      //  printf("\n");
      }      
     //          printf("-[%d]%d,%d:%d\n",ll,i,j,count);
      if(count == k){
        co++;
	//    printf("[%d %d ,%d]\n",i,j,count);
      }
      count = 0;
      for(aa=0;aa<h;aa++){
        for(bb=0;bb<w;bb++){
          ss[aa][bb] = s[aa][bb];
        }
      }
      
    }
  }
  
 printf("%d",co);
  
  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 100

struct GROUP{
	vector<int> nodes;
};

GROUP group[NUM];
vector<int> G[NUM];
vector<int> reverse_G[NUM];
stack<int> S;

bool check[NUM];
int table[NUM],in_num[NUM];
double sleep[NUM];

int group_index;

void dfs(int node_id){
	check[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		if(!check[G[node_id][i]])dfs(G[node_id][i]);
	}
	S.push(node_id);
}

void reverse_dfs(int node_id){
	check[node_id] = true;

	group[group_index].nodes.push_back(node_id);
	table[node_id] = group_index;

	for(int i = 0; i < reverse_G[node_id].size(); i++){
		if(!check[reverse_G[node_id][i]])reverse_dfs(reverse_G[node_id][i]);
	}
}


int main(){

	int N,num,to,next_group;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		for(int i = 0; i < N; i++){
			G[i].clear();
			reverse_G[i].clear();
		}

		for(int i = 0; i < N; i++){
			scanf("%lf %d",&sleep[i],&num);

			for(int k = 0; k < num; k++){
				scanf("%d",&to);
				to--;
				G[i].push_back(to);
				reverse_G[to].push_back(i);
			}
		}

		for(int i = 0; i < N; i++)check[i] = false;

		for(int i = 0; i < N;i++){
			if(!check[i])dfs(i);
		}

		for(int i = 0; i < N;i++)check[i] = false;
		for(int i = 0; i < NUM; i++)group[i].nodes.clear();

		group_index = -1;

		while(!S.empty()){
			if(!check[S.top()]){
				group_index++;

				reverse_dfs(S.top());
			}
			S.pop();
		}

		for(int i = 0; i <= group_index; i++)in_num[i] = 0;

		for(int i = 0; i <= group_index; i++){
			for(int k = 0; k < group[i].nodes.size(); k++){
				for(int p = 0; p < G[group[i].nodes[k]].size(); p++){
					next_group = table[G[group[i].nodes[k]][p]];
					if(next_group != i){
						in_num[next_group]++;
					}
				}
			}
		}

		double ans = 1.0;
		for(int i = 0; i <= group_index; i++){
			if(in_num[i] == 0){
				double all_sleep = 1.0;

				for(int k = 0; k < group[i].nodes.size(); k++){
					all_sleep *= sleep[group[i].nodes[k]];
				}
				ans *= (1.0-all_sleep);
			}
		}
		printf("%.10lf\n",ans);
	}

	return 0;
}

Measured memory_bytes: 3288
#include <stdio.h>


int main(int argc, const char * argv[]) {
    int a[10]={};
    int i,j;
    int b=0;

    for(i=0;i<10;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            if(a[j]<=a[i]){
                b=a[j];
                a[j]=a[i];
                a[i]=b;
            }
        }
    }
    printf("%d\n",a[0]);
    printf("%d\n",a[1]);
    printf("%d\n",a[2]);
    return 0;
}


Measured memory_bytes: 2072
#include <stdio.h>
 
int main(){
 int i,j,h,w;
 while(1){
  scanf("%d %d",&h,&w);
  if(h==0 && w==0){break;}
  for(i=0;i<h;i++){
   for(j=0;j<w;j++){
    if(i==0 || j==0 || i==h-1 || j==w-1){
     printf("#");
    }else{
     printf(".");
    }
   }
   printf("\n");
  }
 printf("\n");
 }
 return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
int main(void){
int N;
cin >> N;
int a[N],sorted[N];
for(int i=0;i<N;i++){
int temp;
cin >> temp;
a[i]=temp;
sorted[i]=temp;
}
int Q;
cin >> Q;
int x[Q],y[Q];
for(int i=0;i<Q;i++){
int tempx,tempy;
cin >> tempx >> tempy;
x[i]=tempx-1;
y[i]=tempy-1;
}
sort(sorted,sorted+N);

int invalid=0;
for(int i=0;i<N;i++){
if(a[i]!=sorted[i])invalid++;
}

int answer=-1;
if(invalid==0)answer=0;
else{
for(int j=0;j<Q;j++){
int cx=x[j],cy=y[j];
if(a[cx]!=sorted[cx] && a[cy]==sorted[cx] )invalid--;
if(a[cx]==sorted[cx] && a[cy]!=sorted[cx] )invalid++;
if(a[cy]!=sorted[cy] && a[cx]==sorted[cy] )invalid--;
if(a[cy]==sorted[cy] && a[cx]!=sorted[cy] )invalid++;
int temp=a[cx];
a[cx]=a[cy];
a[cy]=temp;
if(invalid==0 && answer<0){
answer=j+1;
}
}
}
cout << answer << endl;
}


Measured memory_bytes: 7788
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cassert>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

template <typename T>
struct edge
{
};

/*int main()
{
    ll N;
    scanf("%lld", &N);

    vector<ll> A(3 * N);
    for (ll i; i < 3 * N; i++)
        scanf("%lld", &A[i]);

    ll ans = 0;
    printf("%lld\n", ans);
}*/

struct movable_grid
{
    ll cost;
    pair<ll, ll> relative;
};

vector<vector<ll>> bfs_grid_shotest_path(vector<vector<bool>> gridmap, pair<ll, ll> start, list<movable_grid> searchgrid)
{
    const ll first_edge = gridmap.size();
    const ll second_edge = gridmap[0].size();

    priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<pair<ll, pair<ll, ll>>>> nexts;
    nexts.push({0, {start.first, start.second}});
    vector<vector<ll>> mincostmap(first_edge, vector<ll>(second_edge, __LONG_LONG_MAX__));
    while (!nexts.empty())
    {
        auto current = nexts.top();
        nexts.pop();
        for (auto &&grid : searchgrid)
        {
            pair<ll, ll> currentpos = current.second;
            currentpos.first += grid.relative.first;
            currentpos.second += grid.relative.second;
            ll cost = current.first;
            if (currentpos.first < 0 || currentpos.second < 0 || currentpos.first >= first_edge || currentpos.second >= second_edge)
                continue;

            if (!gridmap[currentpos.first][currentpos.second])
                continue;

            cost += grid.cost;
            if (mincostmap[currentpos.first][currentpos.second] > cost)
            {
                mincostmap[currentpos.first][currentpos.second] = cost;
                nexts.push({cost, {currentpos.first, currentpos.second}});
            }
        }
    }

    return mincostmap;
}

int main()
{
    ll H, W;
    ll CH, CW;
    ll DH, DW;
    scanf("%lld", &H);
    scanf("%lld", &W);
    scanf("%lld", &CH);
    scanf("%lld", &CW);
    scanf("%lld", &DH);
    scanf("%lld", &DW);
    CH--;
    CW--;
    DH--;
    DW--;

    vector<vector<bool>> mazemap(H, vector<bool>(W));
    char c;
    scanf("%c", &c);
    for (ll i = 0; i < H; i++)
    {
        char c;
        for (ll j = 0; j < W; j++)
        {
            scanf("%c", &c);
            mazemap[i][j] = (c == '.');
        }
        scanf("%c", &c);
    }

    ll ans = 127;
    if (!mazemap[CH][CW])
    {
        ans = -1;
        printf("%lld\n", ans);
        return 0;
    }

    list<movable_grid> ml;
    for (ll i = -2; i < 3; i++)
    {
        for (ll j = -2; j < 3; j++)
        {
            ll cost = 1;
            if (abs(i) <= 1 && abs(j) <= 1 && abs(i) != abs(j))
                cost = 0;
            ml.push_back({cost, {i, j}});
        }
    }

    ans = bfs_grid_shotest_path(mazemap, {CH, CW}, ml)[DH][DW];
    if (ans == __LONG_LONG_MAX__)
        ans = -1;
    printf("%lld\n", ans);
}


Measured memory_bytes: 12052
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
 string S; cin >> S;
  bool a = false, b = false, c = false;
  
  for(int i = 0; i < 3; i++){ 
    if(S[i] == 'a'){ a = true;}
    if(S[i] == 'b'){ b = true;}
    if(S[i] == 'c'){ c = true;}
  }
  
  if(a&&b&&c){ cout << "Yes" << endl;}
  else{ cout << "No" << endl;}
  
  return 0;
}

Measured memory_bytes: 256
q,h,s,d=map(int,input().split())
n=int(input())

a,b,c=q*8,h*4,s*2

x=n//2

ans=0

ans+=x*min(a,b,c,d)

if n%2==1:
  ans+=min(a//2,b//2,c//2)
  
print(ans)

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

using namespace std;

#define ll       long long
#define PII      pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);

int vis[N];
set<int> done[N];
vector<int> g[N];
vector<PII> edge;
map<PII, int> ans;

int bfs() {
    queue<int> q;
    q.push(1);
    vis[1] = 1;
    int mx = 0;
    while (!q.empty()) {
        int c = 1, u = q.front();
        q.pop();
        for (auto v : g[u]) if (!vis[v]) {
            while (done[u].find(c) != done[u].end()) c++;
            ans[{u, v}] = ans[{v, u}] = c;
            done[u].insert(c);
            done[v].insert(c);
            mx = max(c, mx);
            vis[v] = 1;
            q.push(v);
            c++;
        }
    }
    return mx;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
        edge.push_back({u, v});
    }
    printf("%d\n", bfs());
    for (auto i : edge) {
        if (ans[{i.first, i.second}] != 0) {
            printf("%d\n", ans[{i.first, i.second}]);
        } else {
            printf("%d\n", ans[{i.second, i.first}]);
        }
    }
    return 0;
}


Measured memory_bytes: 33780
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

struct UF
{
    vi p;
    int m;
    UF(int n) : p(n, 0), m(n)
    {
        iota(p.begin(), p.end(), 0);
    }

    int f(int x)
    {
        return (p[x] == x ? x : p[x] = f(p[x]));
    }

    void u(int i, int j)
    {
        int x = f(i), y = f(j);
        if (x == y)
            return;

        p[y] = x;
        m--;
    }

    bool s(int i, int j)
    {
        return f(i) == f(j);
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    UF uf(n);
    for (int i = 1; i <= m; ++i)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        uf.u(x, y);
    }
    cout << uf.m;
}


Measured memory_bytes: 640
#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;
  cin >> n;
  vector<P> p(n);
  int x,l;
  rep(i,n){
    cin >> x>>l;
    p[i].first=x+l;
    p[i].second=x-l;
  }
  sort(p.begin(),p.end());
  int ans=0,t=-100000000;
  rep(i,n){
    if(t<=p[i].second){
      t=p[i].first;
      ans++;
    }
  }
  cout << ans <<endl;
}


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

int main() {

  int n;
  cin >> n;
  
  vector<int> a(n);
  
  for ( int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  sort(a.begin(),a.end());
  
  a.erase(unique(a.begin(),a.end()),a.end());
  
  if ( a.size() == n ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }  
  
}

Measured memory_bytes: 3964
#include<stdio.h>
 
int main(void)
{
  int W,H,N,x[100],y[100],a[100],i,j,pox[102],poy[102],ansx = 0,ansy = 0;
  scanf("%d %d %d",&W,&H,&N);
  for(i = 0;i < N;i++){
    scanf("%d %d %d",&x[i],&y[i],&a[i]);
  }
  for(i = 0;i < 101;i++) {
    pox[i] = 1;
    poy[i] = 1;
  }
  for(i = 0;i < N;i++){
    if(a[i] == 1) {
      for(j = 0;j < x[i];j++) pox[j] = 0;
    } else if(a[i] == 2) {
      for(j = W - 1;j >= x[i];j--) pox[j] = 0;
    } else if(a[i] == 3) {
      for(j = 0;j < y[i];j++) poy[j] = 0;
    } else {
      for(j = H - 1;j >= y[i];j--) poy[j] = 0;
    }
  }
  for(i = 0;i < W;i++) {
    if(pox[i] == 1) ansx++;
  }
  for(i = 0;i < H;i++) {
    if(poy[i] == 1) ansy++;
  }
  printf("%d\n",ansx * ansy);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define int long long
    #define lb long double
    #define f(i,a,b) for(int i=a;i<=b;i++)
    #define fd(i,a,b) for(int i=a;i>=b;i--)
    #define vi vector<int>
    #define mii map<int,int>
    #define pii pair<int,int>
    #define si set<int>
    #define pb push_back
    #define mk make_pair
    #define fi first
    #define se second
    #define fv(i,v) for(auto i=v.begin();i!=v.end();++i)
    #define fdv(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
    #define print(a,n) f(i,1,n) cout<<a[i]<<" "; cout<<endl;
    #define printv(v) for(auto iv: v) cout<<iv<<" "; cout<<endl;
    #define all(v) v.begin(),v.end()
    #define r(a,n) ll a[n+1]; f(i,1,n) cin>>a[i];
    #define pi 3.141592653589793238
    const int mod=998244353;
    const int inf=1e18;
    //bool vis[1000+1]={};
    const int MAXN=1e6+1;
    int spf[MAXN];
    ll power(ll x, unsigned ll y)
    {
        ll res = 1;
        while (y > 0)
        {
            if (y & 1)
                res = res*x;
            y = y>>1;
            x = x*x;
        }
        return res;
    }

    bool isPrime(int n)
    {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }
        void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;
        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)
                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }

    int lcm(int a, int b)
    {
        return (a*b)/__gcd(a,b);
    }
    signed main()
    {
        int t=1;
        //cin>>t;
        while(t--)
        {
            int n;
            cin>>n;
            r(a,n);
            sort(a+1,a+n+1);
            bool dp[a[n]+1];
            f(i,0,a[n])
            dp[i]=true;
            mii m;
            f(i,1,n)
            m[a[i]]++;
            bool used[a[n]+1]={0};
            f(i,1,n)
            {
                if(dp[a[i]]==true&&used[a[i]]==0)
                {for(int j=a[i]*2;j<=a[n];j+=a[i])
                {dp[j]=false;}
                used[a[i]]=1;
                }
            }
            int c=0;
            f(i,1,n)
            {
                if(dp[a[i]]==true&&m[a[i]]==1)c++;
            }
            cout<<c<<endl;
        }
    }


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 1000000 + 10;

bool ham[MAXN];

int main()
{
    ham[1] = 1;
    REP(MAXN)if(ham[i])
    {
        for(int j=i*2; j<MAXN;j*=2)ham[j] = 1;
        for(int j=i*3; j<MAXN;j*=3)ham[j] = 1;
        for(int j=i*5; j<MAXN;j*=5)ham[j] = 1;
    }
    int m, n;
    while(cin >> m && m)
    {
        cin >> n;
        int ans = 0;
        for(int i = m;i<=n;i++)if(ham[i])ans++;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int K;
  cin >> K;
  int x=1;
  
  for(int i=0;i<N;i++) {
    
    if(x*2>=x+K) {
      x+=K;}
    
    else {
      x*=2;}
    }
  cout << x << endl;
  }
  


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
int main(){
    int a,b,x;
    while(~scanf("%d%d%d",&x,&a,&b)){
        int alen=abs(a-x);
        int blen=abs(b-x);
        if(alen>blen)cout<<'B'<<endl;
        else cout<<'A'<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;

  string A;
  for(int i=1; i<=s.size(); i++){
    if( i%2 == 1) A.push_back( s.at(i-1) );
  }
  cout << A << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<deque>

using namespace std;

int main() {
    string S;
    cin >> S;
    deque<char> q(S.begin(), S.end());
    int Q;
    cin >> Q;
    int re = 0;
    for (int i = 0; i < Q; ++i) {
        int T;
        cin >> T;
        if (T == 1) {
            re += 1;
            re %= 2;
        }
        else {
            int F;
            char C;
            cin >> F >> C;
            if (F == 1){
                if (re) q.push_back(C);
                else q.push_front(C);
            }
            else {
                if (re) q.push_front(C);
                else q.push_back(C);
            }
        }
    }
    if (re) reverse(q.begin(), q.end());
    for (auto itr = q.begin(); itr!= q.end(); itr++){
        cout << *itr;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (X, N) = Scanner.Scan<int, int>();
            if (N == 0)
            {
                Console.ReadLine();
                Console.WriteLine(X);
                return;
            }
            var P = Scanner.ScanEnumerable<int>().ToArray();
            var list = Enumerable.Range(-1, 103).Except(P).ToArray();
            var answer = (int)1e9;
            var delta = (int)1e9;
            foreach (var x in list)
            {
                if (delta <= Math.Abs(X - x)) continue;
                answer = x;
                delta = Math.Abs(X - x);
            }
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

using namespace std;

const int ALPHA = 26;

string s;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();

    cin >> s;

    int ans = s.length();
    for (char letter = 'a'; letter < 'a' + ALPHA; letter++) {
        int res = 0, last = -1;
        for (int i = 0; i < s.length(); i++) {
            if (s[i] == letter) {
                res = max(res, i - last - 1);

                last = i;
            }
        }

        res = max(res, (int)(s.length()) - last - 1);

        ans = min(ans, res);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import Prelude
import Data.List
import Control.Monad

evenstring :: String -> Bool
evenstring s
    |even (length s) == False = False
    |otherwise = s == shalf ++ shalf
    where shalf = take ((length s) `div` 2) s

solverpre :: String ->[Int]-> [Int]
solverpre [] log = log
solverpre s log
    |evenstring s = solverpre (drop 1 s) ((length s):log)
    |otherwise = solverpre (drop 1 s) log

solver s = maximum $ solverpre (drop 1 (reverse s)) []

main :: IO ()
main = do
    s <- getLine
    print $ solver s



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

int main(void)
{
  string S;
  cin >> S;
  
  if(S == "ABC")
  {
    cout << "ARC" << endl;
  }
  else if(S == "ARC")
  {
    cout << "ABC" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3576
#include<stdio.h>
#define N 100000

int binary_search(int a[],int key,int n){
	int left=0;
	int right=n-1;
	
	while(left <= right){
		int mid=(left+right)/2;
		
		if(a[mid]==key)return 1;
		
		else if(a[mid] < key){
			left=mid+1;
		}
		
		else {
			right=mid-1;
		}
	}
	
	return 0;
}

int main(){
	int n,i,q,x;
	int a[N];
	int cnt=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	
	scanf("%d",&q);
	
	for(i=0;i<q;i++){
		scanf("%d",&x);
		cnt+=binary_search(a,x,n);
	}
	
	printf("%d\n",cnt);
	
	return 0;
	
}


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

int main(){
  vector<int> A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << A.at(K-1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    ll n, k;
    cin >> n >> k;
    n %= k;
    while(n > abs(n - k)) {
        n = abs(n - k);
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3632