akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int a = 5;
  rep(i, 10e+9){
    a = 5;
  }
  //cout << 1 << endl;
  int most_left, most_right, middle;
  int count = 0;
  string moji;
  rep(i, 10){
    //cout <<"i: " << i << endl;
    most_left = S.find(to_string(i));
    if (most_left == string::npos) continue;
    else moji = S.substr(most_left+1);
    //sscanf(most_left.c_str(), "数値：%d", &num)

    rep(j, 10){
      most_right = moji.rfind(to_string(j));
      if (most_right == string::npos) continue;
      rep(k, 10){
        middle = moji.find(to_string(k));
        if (middle != string::npos && middle<most_right) {
          //cout << "middle: " << middle << "most_right" << most_right << endl;
          //cout << "moji: " << moji << endl;
          //cout << i << k << j << endl;
          count++;
        }
      }
    }
    //cout << "i: " << i << endl;
  }
  cout << count << endl;

  

}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
class rectangle {
public:
	int h, w, area;
	rectangle(int h1, int w1) {
		h = h1;
		w = w1;
		area = h1*h1 + w1*w1;
	}
	bool operator<(rectangle &other)const {
		if (this->area != other.area)return this->area < other.area;
		else return this->h < other.h;

	}
};
int main() {
	vector<rectangle>v;
	for (int i = 1; i <= 150; i++) {
		for (int j = i + 1; j <= 150; j++) {
			v.push_back(rectangle(i, j));
		}
	}
	sort(v.begin(), v.end());

	int h, w;
	while (cin >> h >> w, w) {
		auto out = upper_bound(v.begin(), v.end(), rectangle(h, w));
		cout << out->h << " " << out->w << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;
int t[32][32];
int dp[32][1<<17];

int dfs(int n, int bit){
  if((1<<N)-1 == bit) return 0;
  int &res = dp[n][bit];
  if(res >= 0) return res;
  res = INF;
  rep(i,N){
    if((bit>>i)&1) continue;
    int cost = t[i][0];
    rep(j,N) if((bit>>j)&1) cost = min(cost, t[i][j+1]);
    res = min(res, dfs(i, bit | (1<<i))+cost);
  }
  return res;
}

int main(){
  while(scanf("%d", &N) && N){
    rep(i,N) rep(j,N+1) scanf("%d", &t[i][j]);
    int res = INF;
    memset(dp, -1, sizeof(dp));
    rep(i,N) res = min(res, dfs(i, 1<<i)+t[i][0]);
    cout << res << endl;
  }
  return 0;
}

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

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

    vector<int> x(n), l(n);
    vector<pair<pair<int,int>,int>> robot(n);
    for(int i=0; i<n; i++){
        cin >> x[i] >> l[i];
        robot[i] = {{x[i]+l[i], l[i]}, i};
    }
    sort(robot.begin(),robot.end());

    int ans = 0;
    set<int> pos;
    for(int i=0; i<n; i++){
        int r = robot[i].second;
        if(pos.upper_bound(x[r]-l[r]) == pos.lower_bound(x[r]+l[r])){
            ans += 1;
            pos.insert(x[r] - l[r]);
            pos.insert(x[r] + l[r]);
        }
        //for(auto p : pos) cout << p << " ";
        //cout << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14564
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
	int N;
	long long A,B;
	long long h[100000];

	long long ans = 0;

	scanf("%d %lld %lld",&N,&A,&B);
	for(int i=0;i<N;i++){
		scanf("%lld",&h[i]);
	}
	long long C = A - B;

	long long left = 0;
	long long right = 1000000000;
	long long pivot = (left + right) / 2;

	while(left<right){
		long long T = 0;
		for(int i=0;i<N;i++){
			long long tmp = h[i] - pivot*B;
			if(tmp>0) T += (tmp+C-1)/C;
		}
		if(T<=pivot){
			right = pivot;
			pivot = (left+right)/2;
		}else{
			left = pivot+1;
			pivot = (left+right)/2;
		}
	}

	printf("%lld\n",left);

	return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 100005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, m, cnt, ans, head[MAXN], f[MAXN], b[MAXN];
LL num[MAXN];

struct Edge {int next, to; LL dis;} edge[MAXN*2];
struct E {int x, y; LL z;} e[MAXN];

void addedge(int from, int to, LL dis)
{
    edge[++cnt].next=head[from];
    edge[cnt].to=to;
    edge[cnt].dis=dis;
    head[from]=cnt;
}

bool CMP(E x, E y)
{
    return x.z<y.z;
}

int find(int x)
{
    if(f[x]!=x) f[x]=find(f[x]);
    return f[x];
}

int main()
{
    scanf("%d%d", &n, &m);
    for(rint i=1; i<=n; ++i) scanf("%lld", &num[i]);
    for(rint i=1, x, y; i<=m; ++i)
    {
        scanf("%d%d%lld", &e[i].x, &e[i].y, &e[i].z);
        addedge(e[i].x, e[i].y, e[i].z);
        addedge(e[i].y, e[i].x, e[i].z);
    }
    for(rint i=1; i<=n; ++i) f[i]=i;
    sort(e+1, e+m+1, CMP);
    for(rint i=1; i<=m; ++i)
    {
        int fx=find(e[i].x), fy=find(e[i].y);
        if(fx==fy)
        {
            if(num[fx]<e[i].z) ans++, b[fx]++;
        }
        else
        {
            f[fx]=fy, num[fy]+=num[fx];
            b[fy]+=b[fx];
            if(num[fy]>=e[i].z)
            {
                ans-=b[fy];
                b[fy]=0;
            }
            else
            {
                b[fy]++;
                ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ss second
#define ff first
#define N 200005
#define inf 1000000009
#define ll long long
#define pii pair<int,int>
#define sz(a) int(a.size())
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int n,a[N],b[N];

int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; i++)
		scanf("%d%d",&a[i],&b[i]);		
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	if(n % 2 == 1) printf("%d",b[(n+1)/2]-a[(n+1)/2]+1);
	else {
		int ma = a[n/2+1] + a[n/2];
		int mb = b[n/2+1]+b[n/2];
		printf("%d",mb - ma + 1);
	}
}


Measured memory_bytes: 5336
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){

 int b,N;
 int check=0;
 vector<int> A;
 vector<int> ans;

 cin>>N; 
 for(int i=0; i<N;i++){
  cin>>b;
  A.push_back(b);
 }

 for(int i=0; i<N; i++){
  for(int j=A.size()-1;j>=0;j--){
   if(j+1==A[j]){
    ans.push_back(A[j]);
    A.erase(A.begin()+j);
    break;
   }
   if(j==0)check=1;
  }
 }
 
 if(check==1)std::cout<<"-1"<<endl;
 else{
  for(int i=ans.size()-1; i>=0;i--){
   cout<<ans[i]<<endl;
  }
 }
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int Mod=(1e9)+7;
const int maxn=(1e4)+10;
int n,mod;
char s[maxn];
int dp[maxn][110][2];
void update(int &x,int y) {
	x+=y; if (x>=Mod) x-=Mod;
}
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	n=strlen(s+1);
	read(mod);
	dp[0][0][1]=1;
	for (int i=0;i<=n;i++) {
		for (int j=0;j<mod;j++) {
			for (int op=0;op<2;op++) {
				if (!dp[i][j][op]) continue;
			//	printf("%d %d %d %d\n",i,j,op,dp[i][j][op]);
				for (int k=0;k<=9;k++) {
					if (op&&k>s[i+1]-'0') break;
					update(dp[i+1][(j+k)%mod][op&&(k==s[i+1]-'0')],dp[i][j][op]);
				}
			}	
		}
	}
	printf("%d\n",((ll)dp[n][0][0]+dp[n][0][1]+Mod-1)%Mod);
	return 0;
}

Measured memory_bytes: 8832
import math
import bisect
q=int(input())
query=[list(map(int,input().split())) for i in range(q)]
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
prime = set(primes(10**5))
ok_n = []
for i in range(1,10**5+1):
  if i in prime and (i+1)//2 in prime:
    ok_n.append(i)
for i in range(q):
  x1=bisect.bisect_left(ok_n,query[i][0])
  x2=bisect.bisect_right(ok_n,query[i][1])
  print(x2-x1)

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

int N, X;

int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int main() {
	cin >> N >> X;
	
	int res = 0;
	for(int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		res = gcd(res, abs(x - X));
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define HSORT(V,n) sort(V,V+n)
#define RSORT(V) sort((V).rbegin(), (V).rend())
#define INF 1e+9
#define MININF -INF
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(){
    ll n,m,k;
    ll c;
    cin >> n >> m;
    priority_queue<int> q;
    REP(i,n){
        cin >> c;
        q.push(c);
    }
    REP(i,m){
        c = q.top()/2;
        q.pop();
        q.push(c);
    }
    c = 0;
    REP(i,n){
        c += q.top();
        q.pop();
    }
    PRINT(c);
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000000000

int main(){
  int N,C;
  cin>>N>>C;
  vector<vector<int>> D(C,vector<int>(C)),c(N,vector<int>(N));
  for(int i=0;i<C;i++){
    for(int j=0;j<C;j++){
      cin>>D.at(i).at(j);
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin>>c.at(i).at(j);
    }
  }
  vector<vector<int>> count(3,vector<int>(C,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      count.at((i+j)%3).at(c.at(i).at(j)-1)++;
    }
  }
  int ans=1000000000;
  for(int i=0;i<C;i++){
    for(int j=0;j<C;j++){
      if(j==i){
        continue;
      }
      for(int k=0;k<C;k++){
        if(k==i||k==j){
          continue;
        }
        int ans2=0;
        for(int color=0;color<C;color++){
          ans2+=count.at(0).at(color)*D.at(color).at(i);
          ans2+=count.at(1).at(color)*D.at(color).at(j);
          ans2+=count.at(2).at(color)*D.at(color).at(k);
        }
        ans=min(ans,ans2);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1280
n=int(input())
w=list(map(int,input().split()))
m=[]
for t in range(n-1):
  a=sum(w[i] for i in range(t+1))
  b=sum(w[i] for i in range(t+1,n))
  m.append(abs(a-b))
print(min(m))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,t;
  cin >> n >> t >>  a;
  vector<int> h(n);
  int cc=1<<30;
  int res = 0;
  for(int i=0;i<n;i++){
    int d;
    cin >> h[i];
    d=(t*1000-h[i]*6)-a*1000;
    if(d<0)d=-d;
    if(cc>d)cc=d,res=i+1;
  }
  cout << res << endl;
}


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,b,a)     for(int i=b;i>=a;i--)

int temp,n,m,c,b[21],a[21][21],cnt=0;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
   

    cin>>n>>m>>c;
    rep(i,1,m)
        cin>>b[i];
    rep(i,1,n)
    {
        temp=0;
        rep(j,1,m)
        {
            cin>>a[i][j],temp+=a[i][j]*b[j];
        }
        temp+=c;
        if(temp>0)
            cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include <string> 
#include <string.h>
#include <utility>
using namespace std;


int main(){
	string str;
	char word[1010][35];
	int x=0,y=0,i=0,j,length=0,maxl=0,maxq[35],q,p=0;maxq[0]=0;
	getline(cin,str);
	while(1){
		if(str[i]==' '){
			word[y][x]='\0';
			x=0;
			y++;
		}
		else if(str[i]=='\0'){
			word[y][x]='\0';
			word[y+1][0]='\0';
			break;
		}
		else{
			word[y][x]=str[i];
			x++;
		}
		i++;
	}
	for(i=0;i<y;i++){
		for(j=0;j<y-i;j++){
			if(strcmp(word[j],word[j+1])>0){
				for(x=0;x<35;x++){
					swap(word[j][x],word[j+1][x]);
				}
			}
		}
	}
	for(i=0;i<=y;i++){
		for(j=0;word[i][j]!='\0';j++){}
		if(maxl<j){
			maxl=j;
			length=i;
		}
		if(strcmp(word[i],word[i+1])==0){
			maxq[i+1]=maxq[i]+1;
		}
		else{
			maxq[i+1]=0;
		}
	}
	for(i=0;i<=y;i++){
		if(p<maxq[i]){
			p=maxq[i];
			q=i;
		}
	}
	printf("%s %s\n",word[q],word[length]);
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  bool bo=false;
  for(int i=1;i<10;i++)
    for(int j=1;j<10;j++)
      if(i*j==N){
        bo=true;
        break;
      }
  if(bo)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#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++ ){

      if ( i == 0 || i == H - 1 ){

	for ( j = 0 ; j < W ; j++ ){
	  printf("#"); 
	}
      } else {
	
	printf("#");
	for ( j = 0 ; j < W - 2 ; j++ ){
	  printf(".");
	}
	printf("#");
	
      }
      
      printf("\n");
      
    }

    printf("\n");

  }
  
  return 0;
  
}

Measured memory_bytes: 572
fun main(args: Array<String>) {
  val (k, s) = readLine()!!.split(" ").map(String::toInt)
  
  var result = 0
  for (x in 0..k) {
    for (y in 0..k) {
      val z = s - x - y
      if (0 <= z && z <= k) {
        result++
      }
    }
  }
  println(result)
}

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

struct base{
    #define type long long
    #define log 60
    type d[log+1] = {};
    bool insert(type x){
        for(int i=log; ~i; i--) if((x>>i)&1){
            if(!d[i]){
                d[i] = x;
                break;
            }
            x ^= d[i];
        }
        return x;
    }
    type max(){
        type ret = 0;
        for(int i=log; ~i; i--)
            if((ret^d[i]) > ret)
                ret ^= d[i];
        return ret;
    }
};

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

    long long xo = 0;
    vector <long long> v(n) ,prt(60 ,0);
    for(auto&a : v){
        scanf("%lld",&a) ,xo ^= a;
        for(int b=0; b<60; b++)
            prt[b] ^= (a>>b)&1;
    }

    base h;
    for(auto&a : v){
        for(int b=0; b<60; b++)
            a &= ~(prt[b]<<b);
        h.insert(a);
    }

    long long mx = h.max();
    printf("%lld\n",(xo^mx)+mx);
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<algorithm>
int N,M;
struct range{
	int i,l,r,x;
	bool operator<(const range&b)const{return x<b.x||x==b.x&&i>b.i;}
}a[510];
int f[510];
int min(int a,int b){return a<b?a:b;}
int main(){
	scanf("%d%d",&N,&M);
	int cnt=0,ans=0;
	for(int i=N*2;i--;){
		a[i]=a[i+1];
		a[i].i=i;
		while(a[i].l*a[i].l+i*i<N*N)a[i].l++;
		while(a[i].r<N*2&&a[i].r*a[i].r+i*i<=N*N*4)a[i].r++;
		a[i].x=!a[i].l?++cnt,a[i].r:a[i].l;
	}
	std::sort(a,a+N*2);
	for(int k=0;k<=N*2-cnt;k++){
		for(int i=0;i<=k;i++)f[i]=!i;
		for(int i=0,c=0;i<N*2;i++){
			int l=-min(N*2-cnt-i+c-k,0),r=min(i-c,k);
			if(a[i].l){
				for(int j=r;j>=l;j--){
					f[j+1]=(f[j+1]-1ll*f[j]*(a[i].l-c-j))%M;
					f[j]=1ll*f[j]*(a[i].r-cnt-k-(i-c-j))%M;
				}
			}
			else{
				for(int j=r;j>=l;j--)f[j]=1ll*f[j]*(a[i].r-c-j)%M;
				c++;
			}
		}
		ans=(ans+f[k])%M;
	}
	printf("%d\n",(ans+M)%M);
}

Measured memory_bytes: 128
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <climits>
#include <set>

//#define int long long
//typedef long long ll;
using ll = long long;
//using R = double;

//#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

const int INF = int(1e9);

using namespace std;

typedef vector<int> V;
typedef vector<V> VV;

signed main()
{
    char a, b;

    cin >> a >> b;
    cout << (a == 'H' ? (b == 'H' ? 'H' : 'D') : (b == 'H' ? 'D' : 'H')) << endl;

    return 0;
}


Measured memory_bytes: 256
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
using namespace std;
int main(){
  int N, ans = 0, maxlen, sign = -1 ;
  cin >> N ;
  int x[N],y[N], p[N],q[N] ;
  for(int i=0;i<N;i++){
    cin >> x[i] >> y[i] ;
    p[i] = x[i] + y[i] ;
    q[i] = x[i] - y[i] ;
  }
  sort(p,p+N) ;
  sort(q,q+N) ;
  ans = max(p[N-1]-p[0],q[N-1]-q[0]) ;
  
  cout << ans << endl ;
  return 0 ;
}

Measured memory_bytes: 6716
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
    val n, a, b = sc.nextInt
//  val list = List.fill(3)(sc.nextInt)

  val ans = min(a * n, b)

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 27348
#include <stdio.h>
 #include <string>
 #include <algorithm>
 using namespace std;
 char in[110];
 int main(){
 int a,b;scanf("%d%d",&a,&b);
 for(int i=0;i<b;i++)in[i]='0'+a;
 string L=in;
 for(int i=0;i<a;i++)in[i]='0'+b;
 in[a]=0;
 string R=in;
 printf("%s\n",min(L,R).c_str());
 }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  int N, D;
  cin >> N >> D;
  
  int now=N;
  int c=0;
  while(now>0){
    now-=(2*D+1);
    c++;
  }

  cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(b<=a) cout<<"delicious"<<endl;
  else if(a+x<b) cout<<"dangerous"<<endl;
  else cout<<"safe"<<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
list=["" for _ in range(1000)]
ans=0
for i in range(1000):
  t=str(i)
  u="0"*(3-len(t))+t
  j=0
  exi=0
  p=u[0]
  for x in s:
    if x==p:
      j+=1
      if j==3:
        ans+=1
        break
      p=u[j]
    

  









print(ans)


Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int main() {
	int k, r, l;
	double p, e, t;
	cin >> k >> r >> l >> p >> e >> t;
	double ans = 1, p2 = 1;
	double d = t - e;
	double r1 = r, l1 = l;
	for (int i = 0; i <= k; i++) {
		double h = (r1 + l1) / 2;
		if (h <= d) {
			if (i == k)ans -= p2;
			else ans -= p*p2;
			r1 = h;
			p2 *= (1 - p);
		}
		else {
			l1 = h;
			if (h <= t)p2 *= p;
			else p2 *= (1 - p);
		}
	}
	d = t + e;
	r1 = r, l1 = l;
	p2 = 1;
	for (int i = 0; i <= k; i++) {
		double h = (r1 + l1) / 2;
		if (h > d) {
			if (i == k)ans -= p2;
			else ans -= p*p2;
			l1 = h;
			p2 *= (1 - p);
		}
		else {
			r1 = h;
			if (h > t)p2 *= p;
			else p2 *= (1 - p);
		}
	}
	cout <<fixed<<setprecision(10)<< ans << endl;
}

Measured memory_bytes: 3280
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int32_t N, M;
  cin >> N >> M;
  vector<Pair> students(N);
  vector<Pair> checkpoints(M);
  for (int32_t i = 0; i < N; ++i) {
    cin >> students[i].first >> students[i].second;
  }
  for (int32_t i = 0; i < M; ++i) {
    cin >> checkpoints[i].first >> checkpoints[i].second;
  }
  for (int32_t s = 0; s < N; ++s) {
    int32_t min_distance = INT32_MAX;
    int32_t nearest_checkpoint = -1;
    for (int32_t c = 0; c < M; ++c) {
      const int32_t distance =
          abs(students[s].first - checkpoints[c].first) + abs(students[s].second - checkpoints[c].second);
      if (distance < min_distance) {
        min_distance = distance;
        nearest_checkpoint = c + 1;
      }
    }
    cout << nearest_checkpoint << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    string s;
    ll ans = 0;
    cin >> s;
    rep(i, s.length()){
        if(s[i] == '+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
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.
 */

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    
    int[] arr = new int[n];
    int xor = 0;
    for(int i=0;i<n;i++){
      arr[i] = sc.nextInt();
      xor^=arr[i];
    }
    
    for(int i=0;i<n;i++){
      System.out.print((xor^arr[i]) + " ");
    }
  }
}


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

int main() {
  int N; cin >> N;
  vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i];
  ll r {}, ans {};
  for (int i = 0; i < N; i++) {
    ans += (r + A[i]) / 2;
    r = ( (A[i] == 0) ? 0 : (r + A[i]) % 2);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  bool p = ((s[0] - '0') * 10 + (s[1] - '0') <= 12 && (s[0] - '0') * 10 + (s[1] - '0') > 0);
  bool q = ((s[2] - '0') * 10 + (s[3] - '0') <= 12 && (s[2] - '0') * 10 + (s[3] - '0') > 0);
  if(p && q) cout << "AMBIGUOUS" << endl;
  else if(p == true && q == false) cout << "MMYY" << endl;
  else if(p == false && q == true) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}


Measured memory_bytes: 3636
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrA = list(map(int,input().split()))

pre = 0
ans = 0
for i in arrA:
    if pre<i:
        ans += i - pre
    pre = i

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void solve() {
  int n, a;
  unsigned char d;
  in, n, a;
  d = a;
  err("");
  int ans = d;
  rep(i, n - 1) {
    unsigned char c = ~d;
    c &= 0x7f;
    err(std::bitset<8>(c));
    ans += c + 127 - d;
    err((int) c);
    d = c;
  }

  cout << (ans) << endl;
}

void Calc() {
  int t = in;
  rep(i, t)solve();
}


Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o B.exe B.cpp 
Execute: ./B
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int n, k, p[1000], result = 0;
	cin >> n >> k;
	for(int i = 0; i < n; i++) {
		cin >> p[i]; 
	}
	
	sort(p, p+n); 
	
	for(int i = 0; i < k; i++) {
		result += p[i]; 
	}
	
	cout << result << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3676
#include <stdio.h>

int main (void){
    char a[100] = {0};
    char b[100] = {0};

    int i = 0,
        j = 0;

    scanf("%s",a);
    scanf("%s",b);

    while(1){
        if(a[i] != '\0'){
            printf("%c",a[i]);
        }
        if(b[j] != '\0'){
            printf("%c",b[j]);
        }
        i++;
        j++;
        if(a[i] == '\0' && b[j] == '\0')
            break;
    }
    printf("\n");

    return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s) {
	return '"' + s + '"';
}
string debug_string(bool b) {
	return (b ? "true" : "false");
}
string debug_string(const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f(...) {
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p) {
	string s = "(";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += ")";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	cout << n * n * n << '\n';
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll K; cin >> K;
    string S; cin >> S;
    if (S.size() <= K){
        cout << S << endl;
    } else {
        cout << S.substr(0, K) + "..." << endl;
    }
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3656
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int len=s.nextInt();
  String string=s.next();
  char[] arr=string.toCharArray();
  for(int j=0;j<arr.length;j++){
  for(int i=0;i<len;i++){
    if(arr[j]=='Z')
      arr[j]='A';
    else
      ++arr[j];
  }
  }
  System.out.println(Arrays.toString(arr).substring(1,3*arr.length-1).replaceAll(", ",""));
}}

Measured memory_bytes: 25684
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int b[52],w[52],r[52];
int main(){
    int n,m;
    cin>>n>>m;
    string s;
    rep(i,n){
        cin>>s;
        rep(j,m){
            if(s[j]=='B') ++w[i+1],++r[i+1];
            else if(s[j]=='W') ++b[i+1],++r[i+1];
            else ++w[i+1],++b[i+1];
        }
    }
    FOR(i,1,n) b[i+1]+=b[i],w[i+1]+=w[i],r[i+1]+=r[i];
    int mn=5000;
    FOR(i,1,n-1)for(int j=1;j+i<n;++j){
        int sum=w[j]+b[j+i]-b[j]+r[n]-r[j+i];
        mn=min(mn,sum);
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 3208
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, d;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> d;
    
    cout << (n+2*d)/(2*d+1) << "\n";
    
    
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
t, a = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)

min = nil
h.each_with_index{|x, i|
    temp = ((t - x * 0.006) - a).abs
    min = [temp, i + 1] if min.nil? || min[0] > temp
}
puts min[1]

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long N, long long M, long long C, std::vector<long long> B, std::vector<std::vector<long long>> A){
    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        int sum = 0;
        for(int j = 0; j < M; ++j) {
            sum += A[i][j] * B[j];
        }
        if (sum + C > 0) ++cnt;
    }
    cout << cnt << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, M, C, std::move(B), std::move(A));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int l;
string s;
int main()
{
	cin>>s;
	l=s.size();
	for(register int i=0;i<l;i++)
		if(s[i]=='C')
			for(register int j=i+1;j<l;j++)
				if(s[j]=='F')
					printf("Yes\n"),exit(0);
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll v;cin>>v;vec.push_back(v);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
ll inv(ll a)
{
    ll p=mod2;
    ll b=p-2,ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll ncr(ll n,ll m)
{
    ll p=mod2;
    if(m > n)return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<n+1;i++)up*=i,up%=p;
    for(int i=1;i<m+1;i++)down*=i,down%=p;
    return up*inv(down)%p;
}

ll countDigit(ll n)
{   
    return floor(log10(n) + 1); 
}  
ll a_pow_b(ll a,ll b)
{
    ll p=1000000007;
    ll ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll gcd(ll a,ll b) 
{ 
    if (b==0) 
        return a; 
    return gcd(b,a%b);      
} 
ll lcm(ll a, ll b)  
{  
    return (a*b)/gcd(a, b);  
}
bool isPerfectSquare(ll x) 
{   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
}
ll ncr123(ll n, ll k){
    if (k == 1) {
        return n;
    }
    if (k == 2) {
        return n * (n - 1) / 2;
    }
    if (k == 3) {
        return n * (n - 1) * (n - 2) / 6;
    }
}
bool com(const pi &a,const pi &b)   //acc to second element sort for vec of pi
{ 
    if(a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
}


void solve(){

    ll k;
    cin>>k;
    string s;
    cin>>s;

    if(s.length()<=k){
        cout<<s; return;
    }

    ll cnt=1;
    loop(i,0,s.length()){
        cout<<s[i];

        cnt++;
        if(cnt>k){
            cout<<"..."; return;
        }
    }

    return;
}
 
 
int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    //y /= gcd(x,y);
    return (x*y);
}

#define WA printf("WA\n");
int main()
{
    char c,ans;
    cin >> c;
    if(c == 'A')ans = 'T';
    else if(c == 'T')ans = 'A';
    else if(c == 'C')ans = 'G';
    else if(c == 'G')ans = 'C';
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, A[3][3], b[10];
bool appear[3][3];
int main() {
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) cin >> A[i][j];
}
cin >> N;
for(int i = 0; i < N; i++) cin >> b[i];
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++) {
appear[i][j] = false;
for(int k = 0; k < N; k++) {
if(A[i][j] == b[k]) appear[i][j] = true;
}
}
}
string ANS = "No";
for(int i = 0; i < 3; i++) {
if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
}
for(int i = 0; i < 3; i++) {
if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
}
if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
cout << ANS << endl;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n,s = 0;
    scanf("%d",&n);
    int a[n];
    for(int i = 0;i < n;i++){
        scanf("%d",&a[i]);
        a[i]--;
        s += a[i];
    }
    printf("%d\n",s);

}

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

int main() {
	vector<int>a(3);

	rep(i, 3) cin >> a.at(i);
	sort(a.begin(), a.end());
	if (a.at(0) == 5 && a.at(1) == 5 && a.at(2) == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int map[5][6];
int map_ruiseki[5][6];
int chousa_now[5];

int main(void) {
	int dataset_num,c_dataset;
	int i,j,k;
	int now;
	int result;
	int prev_atai;
	scanf("%d",&dataset_num);
	for(c_dataset=0;c_dataset<dataset_num;c_dataset++) {
		for(i=0;i<5;i++) {
			for(j=0;j<5;j++)scanf("%d",&map[i][j]);
		}
		for(i=0;i<5;i++) {
			now=0;
			for(j=0;j<5;j++) {
				if(!map[j][i])now=0; else now++;
				map_ruiseki[j][i]=now;
			}
		}
		result=0;
		for(i=0;i<5;i++) {
			for(j=0;j<5;j++)chousa_now[j]=0;
			prev_atai=0;
			for(j=0;j<5;j++) {
				for(k=0;k<map_ruiseki[i][j];k++) {
					chousa_now[k]++;
					if((k+1)*chousa_now[k]>result) {
						result=(k+1)*chousa_now[k];
					}
				}
				if(map_ruiseki[i][j]<prev_atai) {
					for(k=map_ruiseki[i][j];k<prev_atai;k++) {
						chousa_now[k]=0;
					}
				}
				prev_atai=map_ruiseki[i][j];
			}
		}
		printf("%d\n",result);
	}
	return 0;
}

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

public class Main {
    static boolean isPrime(int q){
        if (q == 2) return true;
        if (q < 2 || ((q & 1) == 0)) return false;
        
        int i = 3;
        while (i * i <= q){
            if (q % i == 0){
                return false;
            }
            i += 2;
        }
        return true;
    }
    
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int n = sc.nextInt();
            int count = 0;
            for (int i = 2; i <= n; i++){
                if (isPrime(i)){
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 19196
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;


void Main(){
   string s;
   cin >> s;
   
  rep(i,s.size()){
  if(s[i] == ','){
     s[i] = ' ';
  }
  }
  cout << s << endl;
 return;
 }
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void trace(int64_t A[], int64_t N) {
	for (int64_t i = 0; i < N; i++) {
		if (i > 0) std::cout << " ";
		std::cout << A[i];
	}
	std::cout << std::endl;
}

int64_t bubbleSort(int64_t A[], int64_t N) {
	int64_t sw = 0;
	bool sorted = true;
	for (int64_t i = 0; sorted; i++) {
		sorted = false;
		for (int64_t j = N - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				std::swap(A[j], A[j - 1]);
				sorted = true;
				sw++;
			}
		}
	}
	return sw;
}

void solve()
{
	int64_t A[100], N, sw;
	std::cin >> N;
	for (int64_t i = 0; i < N; i++) {
		std::cin >> A[i];
	}

	sw = bubbleSort(A, N);

	trace(A, N);
	std::cout << sw << std::endl;

	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}



Measured memory_bytes: 3176
#include <stdio.h>
#include <string.h>
 
#define N 1000000
#define L 14
 
char A[N][L];
 
int getChar(char c);
long long getKey(char str[]);
int h1(int key){ return key%N; }
int h2(int key){ return 1+(key%(N-1)); }
int find(char str[]);
int insert(char str[]);

int main(){
  int i, n;
  char str[L], cmp[9];

  for(i = 0; i < N; i++){
    A[i][0] = '\0';
  }
  scanf("%d", &n); 
  for(i = 0; i < n; i++){
    scanf("%s %s", cmp, str);
    if(cmp[0] == 'i'){
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}

int getChar(char c){
  if( c == 'A') return 1;
  else if( c == 'C') return 2;
  else if( c == 'G') return 3;
  else if( c == 'T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int find(char str[]){
  int i, h;
 
  h = (h1(getKey(str)) + i * h2(getKey(str))) % N;
  for(i = 0; i < 14; i++){
    h = (h1(getKey(str)) + i * h2(getKey(str))) % N;
    if(strcmp(A[h], str) == 0) return 1;
  }
  return 0; 
}

int insert(char str[]){
  int i;
  if(find(str)) return 0;
  for(i = 0; i < 14; i++){
    if(A[ (h1(getKey(str)) + i * h2(getKey(str))) % N ][0] == '\0'){
      strcpy(A[ (h1(getKey(str)) + i * h2(getKey(str))) % N ], str);
      return 1;
    }
  }
  return 0;
}

Measured memory_bytes: 14280
n,k = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))

def perprod(x,y): #xy
    nn = len(x)
    ret = [0 for i in range(nn)]

    for i in range(nn):
        ret[i] = x[y[i]-1]

    return ret

def perinv(x): #inverse
    nn = len(x)
    ret = [0 for i in range(nn)]
    for i in range(nn):
        ret[x[i]-1] =i+1

    return ret 

amari = (k-1) % 6
e = (k-1) //6

a =[[] for i in range(6)]

a[0] = p
a[1] = q
a[2] = perprod(a[1],perinv(a[0]))
a[3] = perprod(a[2],perinv(a[1]))
a[4] = perprod(a[3],perinv(a[2]))
a[5] = perprod(a[4],perinv(a[3]))

pp = perprod(perprod(a[1],perinv(a[0])),perprod(perinv(a[1]),a[0]))


ans1 = [i+1 for i in range(n)]

while e>0:
    if(e & 1): ans1 = perprod(ans1,pp)
    pp = perprod(pp,pp)
    e >>= 1

ans2 = perinv(ans1)

ans = perprod(ans1,a[amari])
ans = perprod(ans,ans2)

print(*ans)

Measured memory_bytes: 128020
H,W=map(int,input().split())
L=[list(input())for i in range(H)]
#print(L)

P=[i for i in range(H*W)]
size=[[0,0]for i in range(H*W)]

for i in range(H):
    for j in range(W):
        if L[i][j]==".":
            size[i*W+j][0]+=1
        else:
            size[i*W+j][1]+=1
#print(size)

def find(z):
    if  z==P[z]:
        return z
    else:
        return find(P[z])
def union(x,y):
    X=find(x)
    Y=find(y)
    if sum(size[X])>=sum(size[Y]):
        P[Y]=P[X]
        size[X][0]+=size[Y][0]
        size[X][0]+=size[Y][1]
    else:
        P[X]=P[Y]
        size[Y][0]+=size[X][0]
        size[Y][0]+=size[X][1]
        
for i in range(H):
    for j in range(W):
        if j+1<=W-1:
            
            if L[i][j]!=L[i][j+1]:
                
                if find(i*W+j)!=find(i*W+j+1):
                    #print(i,j)
                    union(i*W+j,i*W+j+1)
        if i+1<=H-1:
            if L[i][j]!=L[i+1][j]:
                if find((i)*W+j)!=find((i+1)*W+j):
                    union(i*W+j,(i+1)*W+j)
BW=[[0,0]for i in range(H*W)]
for i in range(H):
    for j in range(W):
        if L[i][j]==".":
            BW[find(i*W+j)][0]+=1
        else:
            BW[find(i*W+j)][1]+=1

ans=0
for i in range(H):
    for j in range(W):
        if P[i*W+j]==i*W+j:
            ans+=BW[i*W+j][0]*BW[i*W+j][1]
#print(P)
#print(BW)
print(ans)

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

int main(){
  //int a, b, c;
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  if(A[0]%2==0&&A[1]%2==0&&A[2]%2==0) cout << (2*A[2]-A[1]-A[0])/2 << endl;
  else if(A[0]%2==1&&A[1]%2==1&&A[2]%2==1) cout << (2*A[2]-A[1]-A[0])/2 << endl;
  else if(A[0]%2==0&&A[1]%2==0&&A[2]%2==1) cout << (A[2]-A[1])+(A[1]-A[0])/2 << endl;
  else if(A[0]%2==1&&A[1]%2==1&&A[2]%2==0) cout << (A[2]-A[1])+(A[1]-A[0])/2 << endl;
  else if(A[0]%2==1&&A[1]%2==0&&A[2]%2==0) cout << (A[2]-A[1])/2+(A[2]-A[0])/2+2 << endl;
  else if(A[0]%2==0&&A[1]%2==1&&A[2]%2==1) cout << (A[2]-A[1])/2+(A[2]-A[0])/2+2 << endl;
  else  cout << (A[2]-A[1])/2+(A[2]-A[0])/2+2 << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
result = {}
for a in A:
    result[a-1] = result.get(a-1, 0) + 1
    result[a] = result.get(a, 0) + 1
    result[a+1] = result.get(a+1, 0) + 1
print(max((result.values())))

Measured memory_bytes: 23416