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

int main(void){

int n;
scanf("%d",&n);
int ans=0;
int tmp;
int keta;

for(int i=1;i<=n;i++){
  tmp=i;
keta=0;
  do{
    tmp=tmp/10;
    keta++;
  }while(tmp!=0);
  if(keta%2==1)
  ans++;
}

printf("%d",ans);
return 0;

}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y; // 削除する対象
  Node *x; // yの子

  // 削除する節点を決める
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
  
  z = (Node *)malloc(sizeof(Node));
  z->key   = k;
  z->left  = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if( z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}


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

bool check(vector<int> &x1, vector<int> &x2) {
  int n=x1.size();
  int s = 0;
  for(int i=0; i<n; i++) s += (x1[i]-x2[i]) * (x1[i]-x2[i]);
  int sq = (int)sqrt(s);
  return (sq*sq) == s;
}

signed main() {
  int N,D;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for(int n=0; n<N; n++) for(int d=0; d<D; d++) cin >> X[n][d]; 

  int ans = 0;
  for(int i=0; i<N; i++) for(int j=i+1; j<N; j++) {
    ans += (int)check(X[i], X[j]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, T, A; // Tは元の気温　A はターゲット
  cin >> N >> T >> A;
  vector<float> temp(N);
  for (int i = 0; i < N ; i++){
    cin >> temp.at(i);
    temp.at(i) = T - 0.006*temp.at(i); //高さを温度に変換
    temp.at(i) = fabsf(A - temp.at(i));// 温度をAとの差に変換
  }
//  cout << temp.at(0) << "  " << temp.at(1) << endl;
  int ans = 0;
  float tempAns =temp.at(0);
  for (int i=1; i < N; i++){
    if (tempAns > temp.at(i)){
      ans = i;
      tempAns = temp.at(i);
    }
  }
  
  cout << ans+1 << endl;  
}


Measured memory_bytes: 3708
// In the name of Allah
// #Isart

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 500 + 10;
int a[MAXN][MAXN];

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	ll n, m, h, w, sum = 0; cin >> n >> m >> h >> w;
	for(int i = 0; i < n; i ++)
		for(int j = 0; j < m; j ++){
			if((i + 1) % h == 0 and (j + 1) % w == 0) a[i][j] = - 1e9;
			else if(i % h == 0 and j % w == 0 and a[i][j] == 0) a[i][j] = 1e9 - 1;
			sum += a[i][j];
		}
	if(sum <= 0) return cout << "No", 0;
	cout << "Yes" << endl;
	for(int i = 0; i < n; i ++, cout << endl)
		for(int j = 0; j < m; j ++)
			cout << a[i][j] << ' ';
	return 0;	
}

Measured memory_bytes: 3968
n,m = map(int,input().split())
info =[list(map(int,input().split())) for i in range(m)]
for i in range(m):
  info[i][0] -= 1
  info[i][1] -= 1

#UnionFindクラス
class UnionFind(object):

  def __init__(self, n=1):
    self.par = [i for i in range(n)]
    self.rank = [0 for _ in range(n)]

  def find(self, x):
  
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
  
  # xとyの根を結合させる
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x != y:
      if self.rank[x] < self.rank[y]:
        x, y = y, x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
      self.par[y] = x
  
  # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False）
  def is_same(self, x, y):
    return self.find(x) == self.find(y)

count = 0     
for i in range(m):
  uf = UnionFind(n)
  for j in range(m):
    if i!=j:
      uf.union(info[j][0],info[j][1])
  for k in range(n):
    for l in range(n): 
      if not uf.is_same(k,l):
        count =  count +1 
        break
      else:
        continue
      break
    else:
      continue
    break
print(count)
        

Measured memory_bytes: 3064
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t<<" "; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}


ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
	int n;
	cin>>n;
	cout<<(n^1)<<endl;
	






}



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

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 100003
#define mod 1000000007
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;

LL ans;
LL a,b,c,d;

int main() {
	ans = -(1LL<<60);
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	if(a <= 0 && b >= 0)
		ans = 0;
	else if(c <= 0 && d >= 0)
		ans = 0;
	ans = max(ans,a*c);
	ans = max(ans,a*d);
	ans = max(ans,b*c);
	ans = max(ans,b*d);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3812
#include <stdio.h>
int main(){
    char s[150];
    int sleng=0,dif=0;
    scanf("%s",s);
    for (size_t i = 0; s[i] != '\0'; i++)
    {
        sleng++;
    }
    
    for (size_t i = 0; sleng-i-1 >= i; i++)
    {
        if(sleng-i-1 <= 0)break;
        if(s[i] != s[sleng-i-1]) dif++; 
    }
    

    printf("%d",dif);
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

int a , b ;

int main ()  {

	scanf ("%d %d" , &a , &b);
	
	if (a<b) {
		printf ("a < b\n" );
	}	else if (a>b) {
		printf ("a > b\n" );
	}	else {
		printf ("a == b\n" );
	}
	return 0;
	
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
long long q_mul( long long a, long long b) 
{
    long long ans = 0;  
    while(b)              
    {
        if(b & 1)           
        {
            b--;
            ans =(ans+ a);   
        }
        b /= 2;                         
        a = (a + a) ;         
    }
    return ans;
}
 
long long q_pow( long long a, long long b) 
{
    long long ans = 1; 
    while(b)
    {
        if(b & 1)  
        {
            ans = q_mul( ans, a); 
        }
        b /= 2;                                    
        a = q_mul( a, a);        
    }
    return ans;
}
 
int main() { 
    int p,n; 
    while(~scanf("%d%d", &n, &p)) {
    	int  ans1=0,ans2=0;
		//cout<<ans1<<" "<<ans2; 
        for(int i=0;i<n;++i)
		{
			int x; 
			scanf("%d",&x); 
		    if(x&1)
			ans1++;
			else
			ans2++;
		}
		//cout<<ans1<<" "<<ans2; 
		if(p){ 
		   if(ans1) printf("%lld\n",q_pow(2,n-1));
		   else cout<<0<<endl;
		   } 
		else{ 
		   printf("%lld\n",ans1?q_pow(2,n-1):q_pow(2,n)); 
        } 
    }
    return 0; 
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	vector<ll> x(n);
	REP(i,n) cin>>x[i];
	double avg=0;
	REP(i,n)avg+=x[i];
	avg/=n;
	double sum=0;
	REP(i,n)sum+=(x[i]-avg)*(x[i]-avg);
	sum/=n;
	ll p=round(avg);//round(sqrt(avg+sum));
	//cout<<p<<endl;
	ll min=INF;
	for(int i=p-5;i<=p+5;i++){
		sum=0;
		REP(j,n)sum+=(x[j]-i)*(x[j]-i);
		if(min>sum)min=sum;
	}
	cout<<min<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int S = Integer.parseInt(line);
		int h = S / 3600;
		int m = (S - 3600 * h) / 60;
		int s = S - (3600 * h + m*60);
		System.out.println(h + ":" + m + ":" + s);
	}

}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{	rtn
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];
inline int mul(int a, int b) { return (1ll * a * b) % M; };
inline int add(int a, int b)
{
	if ( a + b < 0 ) return a + b + M;
	if ( a + b >= M) return a + b - M;
	return a + b;
}


void solve()
{
	int n, k;
	cin >> n >> k;
	lop(i, 1, n + 1) arr[i] = arr[i - 1] + 1;
	lop(i, 1, n + 1) arr[i] = add(arr[i - 1], arr[i]);
	// prarr(arr, 0, n + 1);

	int ans = 0;
	for (int j = k ; j <= n + 1; j++)
	{
		int s = arr[j - 1], e = arr[n];
		if ( j < n + 1 ) e = add(arr[n] , - arr[n - j]);
		int val =  ( e - s + 1 + M ) % M;
		// bug(s, e);
		ans = add(ans, val);
	}
	cout << ans;

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 5196
#include <iostream>
#include <utility>
 
int n;
 
int a;
 
int gcd(int x,int y){
  if(x>y)
    std::swap(x,y);
  return (x==0)? y : gcd(y%x,x);
}

int main() {
  
  std::cin>>n;
  
  std::cin>>a;
  
  int g=a;
  
  for(int i=0;i<n-1;++i){
    std::cin>>a;
    g=gcd(g,a);
  }
  
  std::cout<<g<<std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

constexpr int mod = 1e9 + 7;

int dp[105][105][256];
int a[105];

int main()
{
    int n, k; cin >> n >> k;

    rep(i, n) cin >> a[i];

    dp[0][0][0] = 1;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k <= 255; ++k) {
                (dp[i + 1][j + 1][k ^ a[i]] += dp[i][j][k]) %= mod;
                (dp[i + 1][j][k] += dp[i][j][k]) %= mod;
            }
        }
    }

    ll fact[101] = {};

    fact[0] = 1;
    for (int i = 1; i <= 100; ++i) fact[i] = (ll)i * fact[i - 1], fact[i] %= mod;

    ll ans = 0;

    for (int i = 1; i <= n; ++i) ans += (ll)dp[n][i][k] * fact[i], ans %= mod;

    cout << ans << endl;
}


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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int a[n], grid[h][w];
    for (int i = 0; cin >> a[i]; i++) {
    }
    for (int i = 0, color = 1, count = 0; i < h; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; j++) {
                grid[i][j] = color;
                count++;
                if (count == a[color - 1]) {
                    count = 0;
                    color++;
                }
            }
        } else {
            for (int j = w - 1; j >= 0; j--) {
                grid[i][j] = color;
                count++;
                if (count == a[color - 1]) {
                    count = 0;
                    color++;
                }
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << grid[i][j] << ' ';
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 384
n = int(input())
A = list(map(int, input().split()))
even = [a for a in A if a % 2 == 0]
ok = True
for e in even:
    if e % 3 != 0 and e % 5 != 0:
        ok = False
        break
print("APPROVED" if ok else "DENIED")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


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


int main() {

	while(1) {
		int n; cin >> n;
		if (n == 0) break;

		// 左側(= 0)，下側 (= 1)，右側 (= 2)，上側 (= 3)
		map<int,pair<int,int>> p;
		p[0] = make_pair(0,0);
		for (int i = 1; i < n; i++) {
			int  num,d; cin >> num >> d;
			p[i] = p[num];
			if (d == 0) {
				p[i].first--;
			}else if(d == 1) {	
				p[i].second--;
			}else if(d == 2) {	
				p[i].first++;
			}else if(d == 3) {	
				p[i].second++;
			}
		}

		/*
		for(auto x: p) {
			cout << x.first << " " << x.second <<  endl;
		}
		*/

		int h_max = 0;
		int h_min = 0;
		int w_max = 0;
		int w_min = 0;
		for (int i = 0; i < n; i++) {
			if(w_max < p[i].first) {
				w_max = p[i].first;
			}
			if(w_min > p[i].first) {
				w_min = p[i].first;
			}
			if(h_max < p[i].second) {
				h_max = p[i].second;
			}
			if(h_min > p[i].second) {
				h_min = p[i].second;
			}
		}
		cout << w_max - w_min + 1 << " " << h_max - h_min + 1 << endl;
	}

	return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
inline int nextInt(void){
	int res=0;
	char ch=getchar();
	while(ch>'9'||ch<'0')
		ch=getchar();
	while(ch<='9'&&ch>='0'){
		res=res*10+ch-'0';
		ch=getchar();
	}
	return res;
}
signed main(void){
	int n=nextInt(),m=nextInt();
	int ans[n+1],line[m+1][2];
	for(int i=1;i<=m;i++){
		line[i][0]=nextInt();
		line[i][1]=nextInt();
	}
	for(int i=1,t;i<=n;i++){
		t=i;
		for(int d=1;d<=m;d++){
			if(line[d][0]==t)
				t=line[d][1];
			else if(line[d][1]==t)
				t=line[d][0];
		}
		ans[t]=i;
	}
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
}

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

ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
        
    else:
        ans += A[i]
        B[i] = B[i]-A[i]

        if A[i+1] >= B[i]:
            ans += B[i]
            A[i+1] = A[i+1]-B[i]
        
        else:
            ans += A[i+1]
            A[i+1] = 0

print(ans)

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

int main(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    int v[3] = {r, s, p};
    int win[n], d[n][3];
    for(int i=0;i<n;i++){
        if(t[i]=='r'){
            win[i] = 2;
            continue;
        }
        if(t[i]=='s'){
            win[i] = 0;
            continue;
        }
        if(t[i]=='p'){
            win[i] = 1;
        }
    }

    for(int i=0;i<k;i++){
        for(int j=0;j<3;j++){
            if(win[i]==j){
                d[i][j] = v[j];
            }else{
                d[i][j] = 0;
            }
        }
    }

    for(int i=k;i<n;i++){
        for(int j=0;j<3;j++){
            if(win[i]==j){
                d[i][j] = max(d[i-k][(j+1)%3], d[i-k][(j+2)%3]) + v[j];
            }else{
                d[i][j] = max(d[i-k][(j+1)%3], d[i-k][(j+2)%3]);
            }
        }
    }

    int ans = 0;
    for(int i=n-1;i>=n-k;i--){
        ans += max(d[i][0], max(d[i][1], d[i][2]));
    }

    cout << ans << "\n";
}

Measured memory_bytes: 2048
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int R = scanner.nextInt();
        if (R < 1200) {
            System.out.println("ABC");
        } else if (R < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

string s, t;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> s >> t;
    map<int, VI> a;
    int n=s.length(), m=t.length();
    for(int i=0; i<n; i++) a[s[i]-'a'].PB(i);

    LL ans=0, j=0;
    for(int i=0; i<m; i++) {
        int c = t[i]-'a';
        if(a.count(c) == 0) {
            cout << -1 << endl;
            return 0;
        }
        auto &v=a[c];
        int k = lower_bound(ALL(v), j) - v.begin();
        if(k<(int)v.size()) j=v[k];
        else ans+=n, j=v[0];
        j++;
    }
    cout << ans+j << endl;
    return 0;
}

Measured memory_bytes: 1228
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		int n=gInt();
		if(n<1000)
			System.out.printf("ABC\n");
		else
			System.out.printf("ABD\n");
	}

	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n] = {};

    rep(i,0,n) cin >> a[i];

    ll ok = (ll)1e9+1,ng = 0;
    while(abs(ok-ng) > 1){
        ll mid = (ok+ng)/2;

        ll cnt = 0;
        rep(i,0,n){
            cnt += (a[i]-1)/mid;
        }
        if(cnt <= k){
            ok = mid;
        }
        else{
            ng = mid;
        }
        
    }
    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 5136
N = input()
p = [int(x)-1 for x in raw_input().split()]

ans = 0
for i in range(N-1):
  if p[i]==i:
    p[i],p[i+1] = p[i+1],p[i]
    ans += 1
if p[-1]==N-1:
  ans += 1
print ans


Measured memory_bytes: 11584
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = max(a, c), r = min(b, d);
    cout << max(r - l, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N,K,sum,s;
  cin>>N;
  K=1;
  sum=0;
  for (int i=0;i<8;i++){
    for(int j=0;j<i;j++){
      K*=10;
    }
    s=(N-N%K)%(K*10)/K;
    sum+=s;
    K=1;
  }
  int m;
  m=N%sum;
  if (m==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &e : A) cin >> e;
  sort(A.begin(), A.end());
  vector<bool> B(A[N-1]+1,true);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (!B[A[i]]) continue;
    if (A[i] == A[i+1]) B[A[i]] = false;
    if (B[A[i]]) ans++;
    for (int j = 2; A[i]*j <= A[N-1]; j++) B[j*A[i]] = false;
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,k;
ll dp[2][101][100000];
ll ans;

int main(){
  cin >> n >> k;
  dp[0][0][1] = 1;
  for(ll i = 1;i <= k;i++){
    for(ll j = 1;j*j <= n;j++){
      dp[0][i][j] += dp[1][i-1][j];
      dp[1][i][j] += dp[0][i-1][j];
    }
    ll j = 1;
    for(j = 1;j*j <= n;j++){
      dp[1][i][j] += dp[1][i][j-1];
    }
    dp[0][i][j] = dp[1][i][j-1];
    for(;j >= 0;j--){
      dp[0][i][j] += dp[0][i][j+1];
    }
    for(j = 1;j*j <= n;j++){
      if((j+1)*(j+1) > n) dp[1][i][j] *= n/j-j;
      else dp[1][i][j] *= n/j-n/(j+1);
      dp[1][i][j] %= mod;
      dp[0][i][j] %= mod;
    }
  }
  // for(ll i = 1;i <= k;i++){
  //   for(ll j = 1;(j-1)*(j-1) <= n;j++){
  //     cerr << dp[0][i][j] << " ";
  //   }
  //   cerr << endl;
  // }
  // for(ll i = 1;i <= k;i++){
  //   for(ll j = 1;(j-1)*(j-1) <= n;j++){
  //     cerr << dp[1][i][j] << " ";
  //   }
  //   cerr << endl;
  // }
  for(ll j = 1;j*j <= n;j++){
    ans += dp[0][k][j]+dp[1][k][j];
    ans %= mod;
  }
  cout << ans << endl;

}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k)
        cout << k << ln;
    else if (a + b >= k)
        cout << a << ln;
    else
        cout << a - (k - a - b) << ln;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
 
using namespace std;
#define sz(x) (int)(x).size()
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
const int N=3e5+5,MOD=1e9+7;
 
 
bool vis[5005];
int n,k;
int main()
{	
 	
 	scanf("%d",&n);

 	std::vector<vector<int>> dp(n,vector<int>(3));
 	for(int i=0;i<n;i++){
 		scanf("%d %d %d",&dp[i][0],&dp[i][1],&dp[i][2]);
 		if(i){
 			dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
 			dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
 			dp[i][2]+=max(dp[i-1][0],dp[i-1][1]);
 		}
 	}

 	printf("%d\n",max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
 	
}
 

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		   
			String s = scanner.next();
			long k = scanner.nextLong();
			int counter = 0;
			
			
			String[] array = new String[s.length()];
			for(int i = 0; i < s.length(); i++) 
			{
				array[i] = s.substring(i, i + 1);
			}
			
			for( int i = 0; i < s.length(); i++ ) 
			{
				if( array[i].equals("1") ) 
				{
					counter++;
				}
				else 
				{
					break;
				}
			}
			if( counter >= k) 
			{
				System.out.println(1);
			}
			else 
			{
				System.out.println(array[counter]);
			}
			
		    scanner.close(); }
		  }

Measured memory_bytes: 23124
#include <iostream>
#define LL long long
using namespace std;

LL aI,aO,aT,aJ,aL,aS,aZ;

int main(){
    cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ;

    LL res=2*((aI/2)+(aJ/2)+(aL/2));
    if (aI>0 && aJ>0 && aL>0)
        res=max(res,2*(((aI-1)/2)+((aJ-1)/2)+((aL-1)/2))+3);



    cout << aO+res << "\n";
    return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:x[2],reverse=True)
sx,sy,sh=l[0]
for xx in range(0,101):
  for yy in range(0,101):
    hh=sh+abs(sx-xx)+abs(sy-yy)
    for ll in l[1:]:
      if ll[2]!=max(0,hh-abs(ll[0]-xx)-abs(ll[1]-yy)):
        break
    else:
      print(xx,yy,hh)

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

int D, G;
//vector<int> p(D), c(D);
vector<int> p(20), c(20);

int ans = 1e9;

void rec(int sum, int counter, int i, vector<bool> D_bool) {
  if (i == D) {
    if (sum >= G) {
      ans = min(ans, counter);
    }
    else {
      rrep(j,D-1) {
        if (D_bool.at(j)) 
          continue;
        else {
          for (int l = 0; l < p.at(j)-1 && sum < G; l++) {
            sum += 100*(j+1);
            counter++;
          }
          if (sum >= G) {
            ans = min(ans,counter);
            break;
          }
        }
      }
    }
  }
  else {
    D_bool.at(i) = false;
    rec(sum, counter, i+1, D_bool);
    
    D_bool.at(i) = true;
    rep(j,p[i]) {
      sum += 100*(i+1);
      counter++;
    }
    sum += c.at(i);
    rec(sum, counter, i+1, D_bool);
  }
}

int main() {
  cin >> D >> G;
  rep(i,D) cin >> p.at(i) >> c.at(i);
  
  vector<bool> vec_bool(D, false);
  
  rec(0,0,0,vec_bool);
  
  cout << ans << endl;
  
  return 0;
}



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

 long long n,s,dp[102][11][1001];
int main(void){
     
  dp[0][0][0] = 1;
  
  for(int i=0;i<101;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<1001;k++){
        dp[i+1][j][k]+=dp[i][j][k];
  
        if(8<j||1000<k+i) continue;
        dp[i+1][j+1][k+i]+=dp[i][j][k];
      }
    }
  }
  
  while(cin >> n >> s, n|s)
    cout << dp[101][n][s] << endl;
  return 0;
}

Measured memory_bytes: 9732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef deque<int> di;
typedef pair<int,int> pi;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define s second
#define f first
#define pf push_front
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define FOR(i,a,b) for(int i=a;i<b;i++)


int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    char c;
    cin>>c;
    if(c<91)
        cout<<"A"<<endl;
    else
        cout<<"a"<<endl;

    return 0;
}


Measured memory_bytes: 3496
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>

using ll = long long;
using namespace std;

int main() {
    ll L, R;
    cin >> L >> R;
    ll ans = 2019;
    R = min(R, L + 2019);
    for (ll i = L; i < R; ++i) {
        for (ll j = L + 1; j <= R; ++j) {
            ans = min(ans, i * j % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a,b;
  cin>>n>>m;
  set<int> z;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    if(a==1){
      if(z.count(b)){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
      else z.insert(b);
    }
    else if(b==n){
      if(z.count(a)){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
      else z.insert(a);
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 13008
#include <stdio.h>

int main(){
  int H, W;
  char C[110][110] = {};
  char D[210][110] = {};
  scanf("%d %d", &H, &W);
  for(int i = 0; i < H; i++){
    scanf("%s", C[i]);
  }
  for(int i = 0; i < 2*H; i++){
    for(int j = 0; j < W; j++){
      D[i][j] = C[i/2][j];
    }
    printf("%s\n", D[i]);
  }
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)

int main()
{
	ull n; cin >>n;
	vector<pair<string, ll>> sp(n, pair<string,ll>());
	REP(i,n)
	{
		cin>>sp[i].first>>sp[i].second;
		sp[i].second = ( 1000 - sp[i].second ) * 1000 + i;
	}
	sort( ALL(sp) );
	REP(i,n) cout << sp[i].second % 1000 + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N;
    io.read(N);
    auto a = io.read_vec<int>(N);
    int sum = a[0];
    for(int i = 1; i < N; i++){
        sum = sum ^ a[i];
    }
    for(int i = 0; i < N; i++){
        int x = sum ^ a[i];
        cout << x << ' ';
    }

    return 0;
}

Measured memory_bytes: 4048
import java.util.*;


public class Main{ 
	   public static void main(String args[]) {
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		double arr[]=new double[n+1];
		for(int i=1;i<=n;i++) {
			arr[i]=s.nextDouble();
		}
		
		double dp[][]=new double[n+1][n+1];
		
		for(int i=0;i<n+1;i++) {
			 	for(int j=0;j<=n;j++) {
			     dp[i][j]=-1;
			    }
	    }
//		double ans=0.0;
//		for(int i=n;i>n/2;i--) {
//			ans+=(f(dp,arr,n,i));
//		}
		int x=(n/2)+1;
		double ans=(f(dp,arr,n,x));
		System.out.print(ans);
	   }
	   
   public static double f(double dp[][],double arr[],int i,int x) {
	   if(x==0 ) {
		   return 1;
	   }
	   if(i==0 ) {
		   return 0;
	   }
	   if(dp[i][x]>-0.1) {
		   return dp[i][x];
	   }
	   return dp[i][x]=arr[i]*f(dp,arr,i-1,x-1)+(1-arr[i])*f(dp,arr,i-1,x);
   }
}

Measured memory_bytes: 119340
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int m, d;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> m >> d;
	int cnt = 0;
	for (int i = 22; i <= d; i++) {
		if (i % 10 >= 2 && i / 10 >= 2) {
			for (int j = 4; j <= m; j++)
				if ((i % 10)*(i / 10) == j) cnt++;
		}
	}
	cout << cnt << E;
	//system("pause");
	return 0;
}

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

bool is_triangle(int a, int b, int c) {
    int sum_ = a+b+c;
    if (a >= (sum_+1)/2) {
        return false;
    } else if (b >= (sum_+1)/2) {
        return false;
    } else if (c >= (sum_+1)/2) {
        return false;
    }
    return true;
}

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N; cin >> N;
    int ans = 0;
    vector<int> L(N+1);
    rep(i, N) cin >> L[i];
    L[N] = -1;
    // 降順ソート
    sort(L.rbegin(), L.rend());

    for (int i=0; i<N-2; ++i) {
        int e1 = L[i];
        for (int j=i+1; j<N-1; ++j) {
            int e2 = L[j];
            // cout << "edge: " << e1 << " " << e2 << endl;
            if (e2 == N-2) {
                // cout << "N-2" << endl;
                // 二分探索に十分な幅が無い場合
                if (is_triangle(e1, e2, L[N-1])) {
                    ans += 1;
                }
            } else {
                // 大きすぎるkを見つける
                int sum_e = e1+e2;
                // L[N]にtrueの値を入れる
                L[N] = sum_e-1;
                // if (sum_e > L[j+1])
                int bl = j;
                int br = N;
                while(bl+1<br) {
                    int c = (bl+br)/2;
                    // 大きければlを寄せる
                    if (sum_e <= L[c]) {
                        bl = c;
                    } else {
                        br = c;
                    }
                }
                // cout << "bl br: " << bl << " " << br << endl;
                if (br==N) {
                    // brが動いていない場合、探索範囲は全て大きい
                    cout << ans << endl;
                    return 0;
                }
                // 小さすぎるkを見つける
                int sl = bl;
                int sr = N;
                int diff_e = e1-e2;
                while(sl+1<sr) {
                    int c = (sl+sr)/2;
                    // 小さすぎればsrを寄せる
                    if (L[c] <= diff_e) {
                        sr = c;   
                    } else {
                        sl = c;
                    }
                }
                // cout << "sl sr: " << sl << " " << sr << endl;
                ans += (sl-bl);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
MOD=2019
l,r=map(int,input().split()) #l<=i<i+1<=j<=r
res=[]

if r - l > 2019:
  print(0)
  
else:
  l=l%MOD
  r=r%MOD
  l,r=min(l,r),max(l,r)

  for i in range(l,r):
    for j in range(i+1,r+1):
      res += [(i*j)%MOD]

  print(min(res))

Measured memory_bytes: 75416
package main

import (
	"fmt"
)

func main() {
	var a, b, n int
	fmt.Scanf("%d %d %d", &a, &b, &n)

	x := n
	if n > b-1 {
		x = b - 1
	}

	fmt.Printf("%d\n", (a*x)/b-a*(x/b))
}

Measured memory_bytes: 1820
#include <iostream>

using namespace std;

string test(int k, int a, int b) {
  for (int d = a; d <= b; d++){
    if (d % k == 0) {
      return "OK";
    }
  }
    return "NG";
}

int main() {
  int k;
  int a, b;

  cin >> k;

  cin >> a >> b;

  cout << endl;
  cout <<  test(k, a, b) << endl;

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a[3],k;
  for(int i=0;i<3;i++)
  {
    cin>>a[i];
  }
  cin>>k;
  int j=0;
  //int cards
  
  long long int cards=0;
  
  while(k)
  {
    if(k-a[j]>0)
    {
      if(j==0)
        cards+=a[j] ;
      if(j==2)
         cards-=a[j];
        
      k-=a[j];  
      
      j++;
    }
      
      else
      {
        if(j==0)
          cards+=k;
        if(j==2)
          cards-=k;
          
        k=0;
      }
        
  }
  
  cout<<cards;
  
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    ll r = 0, g = 0, b = 0;
    for(auto c: s){
        r += (c == 'R');
        g += (c == 'G');
        b += (c == 'B');
    }

    ll ans = r * g * b;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int k = j + (j-i);
            if(k<n && s[i] != s[j] && s[j] != s[k] && s[i] != s[k]) ans--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main() {
	ll N, M;
	cin >> N >> M;
	ll low = 0, high = 1e12;
	while (high - low > 1) {
		const ll med = (low+high)/2;
		ll c = 2*med;
		ll restC = M-c;
		if (restC >= 0 && N+restC/2 >= med) low = med;
		else high = med;
	}
	cout << low << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	m, _ := strconv.Atoi(scanner.Text())
	if n == m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AAdditionAndSubtractionEasy {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    ll a, b;
	    char op;
	    in >> a >> op >> b;
	    if(op == '+') out << a+b << endl;
	    else out << a-b << endl;
	}
};


int main() {
	AAdditionAndSubtractionEasy solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)
struct edge{
    ll l;
    ll from, to;
    edge(ll l, ll from, ll to):l(l), from(from), to(to){}
};
int main() {
    ll N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N));
    vector<vector<ll>> C(N, vector<ll>(N, -1));
    REP(i, N)REP(j, N) cin >> A[i][j];
    REP(i, N) C[i][i] = 0;
    vector<edge> v;
    REP(i, N) for(ll j = 0; j < i; j++) v.push_back(edge(A[i][j], j, i));
    sort(v.begin(), v.end(), [](edge& a, edge& b){return a.l < b.l;});
    ll ans = 0;
    REP(i, v.size()){
        ll from = v[i].from;
        ll to = v[i].to;
        bool done = false;
        REP(j, N){
            if (C[from][j] > 0 && C[j][to] > 0){
                if (C[from][j] + C[j][to] < v[i].l){
                    cout << -1 << endl;
                    return 0;
                }
                if (C[from][j] + C[j][to] == v[i].l){
                    C[from][to] = v[i].l;
                    C[to][from] = v[i].l;
                    done = true;
                    break;
                }
            }
        }
        if (done) continue;
        C[from][to] = v[i].l;
        C[to][from] = v[i].l;
        ans += v[i].l;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
#define mst(a) memset(a,0,sizeof a)
vector<int>e[N];
int n,m,ans[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		e[u].push_back(v),e[v].push_back(u);
	}
	ans[1]=1;
	queue<int>q;
	q.push(1);
	while(q.size()){
		int u=q.front();q.pop();
		for(auto v:e[u])
			if(!ans[v]) ans[v]=u,q.push(v); 
	}
	puts("Yes");
	for(int i=2;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
} 

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

typedef long long int ll;

int main() {
    ll n, m, k;
    ll a[200000], b[200000];
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];

    ll sumA[200001], sumB[200001];
    for (int i = 0; i <= n; i++) sumA[i] = 0;
    for (int i = 0; i <= m; i++) sumB[i] = 0;
    for (int i = 1; i <= n; i++) sumA[i] = sumA[i - 1] + a[i - 1];
    for (int i = 1; i <= m; i++) sumB[i] = sumB[i - 1] + b[i - 1];

    ll best = 0;
    ll j = m;
    for (int i = 0; i <= n; i++) {
        if (sumA[i] > k) break;
        while (sumB[j] > k - sumA[i]) j--;
        best = max(best, i + j);
    }

    cout << best << endl;
}

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

int main() 
{
  int n,k;
  int ans=1;
  cin>>n>>k;
  for(int i=0;i<n;i++)
  {
    if (ans+k>=ans*2) ans*=2;
    else ans+=k;
  }
  cout<<ans<<endl;
}
	

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
using namespace std;
int main(){
    int A,B,C,D;cin>>A>>B>>C>>D;
    if((abs(A-B)<=D&&abs(C-B)<=D)||abs(A-C)<=D){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256