akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
 
int main(){
    int k;
    int i, j;
    int list[5];
    
    for (i=0; i<5; i++) {
        cin >> list[i];
    }
    
    cin >> k;
    
    for (i=0; i<4; i++) {
        for (j=i+1; j<5; j++) {
            if (list[j] - list[i] > k) {
                cout << ":(";
                return 0;
            }
        }
    }
    
    cout << "Yay!";
    
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll ma = 1e6;

bool prime[ll(1e6)+2];
vector <ll> vec;
void prep()
{
	prime[1] = false;
	
	for(ll i=2;i<=ma;i++)
	{
		if(prime[i]==true)
		{
			vec.push_back(i);
			for(ll j=2*i;j<=ma;j+=i)
			{
				prime[j] = false;
			}
		}
	}
}


int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	
	memset(prime, true, sizeof(prime));
	
	prep();
	ll n;
	cin>>n;
	
	ll ans = 0;
	
	map <ll,ll> mp;
	for(ll a:vec)
	{
		ll v = a;
		while(n%v == 0)
		{
			mp[v]++;
			//cout<<v<<" "<<n<<endl;
			ans++;
			n = n/v;
			v = v*a;
		}
		while(n%a == 0)
		{
			n = n/a;
		}
	}
	
	

	if(n>1)
	{
		if(mp.find(n)==mp.end())
		ans++;
	}
	
	cout<<ans<<endl;
	
}



























Measured memory_bytes: 5192
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=998244353;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

ll dp[3003][3003][3];

void add(ll &a,ll b){
    a=(a+b)%MOD;
}

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

  int N,S;
  cin>>N>>S;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  dp[0][0][0]=1;
  for(int i=0;i<N;i++){
      for(int j=0;j<=S;j++){
          add(dp[i+1][j][0],dp[i][j][0]);
          add(dp[i+1][j][1],dp[i][j][0]+dp[i][j][1]);
          add(dp[i+1][j][2],dp[i][j][0]+dp[i][j][1]+dp[i][j][2]);
          if(j+A[i]<=S){
              add(dp[i+1][j+A[i]][1],dp[i][j][0]+dp[i][j][1]);
              add(dp[i+1][j+A[i]][2],dp[i][j][0]+dp[i][j][1]);
          }
      }
  }

  cout<<dp[N][S][2]<<endl;

  return 0;
}


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


int N,K;
int P[1005];



int cmpnum(const void * n1,const void * n2){
     if(*(int *)n1 < *(int *)n2)
	 return -1;
     else if(*(int *)n1 > *(int *)n2)
	 return 1;
     else
	 return 0;
 }

int main(){
    int total=0;
    scanf("%d %d",&N,&K);
    for(int i=0;i<N;i++)
	scanf("%d",&P[i]);

    qsort(P,N,sizeof(int),cmpnum);

    for(int i=0;i<K;i++)
	total+=P[i];

    printf("%d\n",total);
    
    return 0;
}




Measured memory_bytes: 1704
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int H,W;
char c[17][65];
int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};

pi nx[17][65][4];
vector<pi> from[17][65][4];
bool used[17][65][4][17][65][4];
int gy,gx,gd,ans;
int gy2,gx2;

void f(int y0,int x0,int d0,int y1,int x1,int d1){
	if(ans == 2 || used[y0][x0][d0][y1][x1][d1])return;
	used[y0][x0][d0][y1][x1][d1] = 1;
	if(y0 == gy && x0 == gx && y1 == gy2 && x1 == gx2 && d1 == gd){
		ans = 2;
		return;
	}
	if(y0 == gy && x0 == gx) ans = 1;
	rep(i,sz(from[y1][x1][d1])+1)for(int dd=1;dd<=3;dd+=2){
		int nd0 = (d0 + dd) % 4;
		int nd1 = (d1 + dd) % 4;
		pi &p = nx[y0][x0][nd0];
		if(i == sz(from[y1][x1][d1])){
			f(p.fir,p.sec,nd0,H+1,0,0);
			continue;
		}
		pi &q = from[y1][x1][d1][i];
		if(c[q.fir + dy[nd1]][q.sec + dx[nd1]] == '#'){
			f(p.fir,p.sec,nd0,q.fir,q.sec,nd1);
		}
	}
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>W>>H && W){
		rep(i,H+1)rep(j,W)rep(d,4)from[i][j][d].clear();
		int sy=-1,sx=-1,sd=-1;
		gy = gx = gd = -1;
		rep(i,H)rep(j,W){
			cin>>c[i][j];
		}
		rep(i,H)rep(j,W){
			if(c[i][j] == 'K'){
				sy = i, sx = j;
				rep(d,4){
					if(c[i+dy[d]][j+dx[d]] == '.'){
						sd = d;
					}
				}
				c[i][j] = '.';
			}
			if(c[i][j] == 'M'){
				gy = i, gx = j;
				rep(d,4){
					if(c[i+dy[d]][j+dx[d]] == '.'){
						gd = d;
					}
				}
				c[i][j] = '.';
			}
		}
		rep(i,H)rep(j,W)if(c[i][j] == '.')rep(d,4){
			int y = i, x = j;
			while(c[y+dy[d]][x+dx[d]] == '.'){
				y += dy[d], x += dx[d];
			}
			nx[i][j][d] = mp(y,x);
			from[y][x][d].pb(mp(i,j));
		}
		memset(used,0,sizeof(used));
		ans = 0;
		pi s2 = nx[sy][sx][sd];
		if(s2.fir == gy && s2.sec == gx){
			cout<<"He can accomplish his mission."<<endl;
			continue;
		}
		pi g2 = nx[gy][gx][gd];
		gy2 = g2.fir, gx2 = g2.sec;
		rep(d,4)f(s2.fir,s2.sec,sd,sy,sx,d);
		if(ans==2)cout<<"He can accomplish his mission."<<endl;
		else if(ans==1)cout<<"He cannot return to the kitchen."<<endl;
		else cout<<"He cannot bring tea to his master."<<endl;
	}
}

Measured memory_bytes: 21308
// https://beta.atcoder.jp/contests/abc067
// status:
// tag: [bfs]

#define SUBMIT
//#define DEBUG

#include <bits/stdc++.h>
using namespace std;
using ui64 = uint64_t;

const int INF = INT_MAX / 4;
const int MAX_N = 100000;
int N;
set<int> adj[MAX_N + 1];
bool done_black[MAX_N + 1];
bool done_white[MAX_N + 1];

int d_black[MAX_N + 1];
int d_white[MAX_N + 1];

void bfs(int s, int d[MAX_N + 1], bool done[MAX_N + 1]) {
    queue<int> q;
    d[s] = 0;
    done[s] = true;
    q.push(s);

    while (!q.empty()) {
        auto u = q.front(); q.pop();
        for (auto v : adj[u]) {
            if (done[v]) continue;
            d[v] = d[u] + 1;
            done[v] = true;
            q.push(v);
        }
    }
}

void solve() {
    fill(d_black, d_black + MAX_N + 1, INF);
    fill(d_white, d_white + MAX_N + 1, INF);
    bfs(1, d_black, done_black);
    bfs(N, d_white, done_white);

    int n_black = 0, n_white = 0;
    for (int i = 1; i <= N; ++i) {
        if (d_black[i] <= d_white[i]) n_black++;
        else n_white++;
    }
    if (n_black <= n_white) cout << "Snuke" << endl;
    else cout << "Fennec" << endl;
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(7
3 6
1 2
3 1
7 4
5 7
1 4
)");
#endif
    stream >> N;
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        stream >> a >> b;
        adj[a].insert(b);
        adj[b].insert(a);
    }

    solve();
    return 0;
}

Measured memory_bytes: 15232
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;int a,b,c;
  a=count(s.cbegin(),s.cend(),'0');
  b=count(s.cbegin(),s.cend(),'1');
  c=s.size();
  cout<<c-abs(a-b)<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int left[3000000],right[3000000],tree[3000000],lazy[3000000]={0};
int a[1000000],f[1000000]={0},record[1000000];
int min(int a,int b){
	if (a<b) return a;else return b;
}
int max(int a,int b){
	if (a>b) return a;else return b;
}
void build(int l,int r,int k){
   tree[k]=0;
   left[k]=l;
   right[k]=r;
   lazy[k]=0;
   int mid=(l+r)/2;
   if (l==r) {record[l]=k;return;}
   build(l,mid,k*2);
   build(mid+1,r,k*2+1);	
}
void laze(int k){
   if (k>=4*300000) return;
   lazy[k*2]=max(lazy[k*2],lazy[k]); lazy[k*2+1]=max(lazy[k],lazy[k*2+1]);
   tree[k]=max(tree[k],lazy[k]);
   lazy[k]=0; 
}
int find(int l,int r,int k){
	if (k>=4*300000) return 0;
    laze(k);
	if (r<left[k]||l>right[k]) return 0;
	if (left[k]>=l&&right[k]<=r) return tree[k];
	int ans1=find(l,r,k*2);
	int ans2=find(l,r,k*2+1);
	tree[k]=max(tree[k*2],tree[k*2+1]);
	return max(ans1,ans2);
}
void update(int l,int r,int num,int k){
	if (k>=4*300000) return;
	laze(k);
	if (r<left[k]||l>right[k]) return;
	if (left[k]>=l&&right[k]<=r) {
		lazy[k]=max(lazy[k],num);
		laze(k);
		return;
	}
		update(l,r,num,k*2);
		update(l,r,num,k*2+1);
		tree[k]=max(tree[k*2],tree[k*2+1]);
}
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	for (int i=1;i<=n;i++)
	   scanf("%d",&a[i]);
	build(0,300000,1);
	for (int i=1;i<=n;i++){
		f[i]=find(a[i],a[i],1)+1;
		update(max(0,a[i]-k),min(a[i]+k,300000),f[i],1);
	}
	int ans=0;
	for (int i=1;i<=n;i++){
		if (f[i]>ans)
		 ans=f[i];
	}
	printf("%d",ans);
}

Measured memory_bytes: 25692
#include <bits/stdc++.h>
 
#define ll long long
#define loop(a) for(long long i=0; i<a; i++)
 
using namespace std;

int main(){
	ll a,b,x,ans;
	cin >> a >> b;
	x=__gcd(a,b);
	ans=1;
	bool t;
	for(int i=2; i<=sqrt(x); i++){
		t=false;
		while(x%i==0){
			x=x/i;
			t=true;
		}
		if(t) ans++;
	}
	if(x>1) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int n, m; cin >> n >> m;

    vi v(n);
    int sum = 0;
    rep (i, 0, n-1) {
    	cin >> v[i];
    	sum += v[i];
    }

    int votes = 0;
    rep (i, 0, n-1) {
    	if (v[i] * 4 * m < sum)
    		continue;
    	votes++;
    }
  //  db2(votesm )
    if (votes >= m) cout << "Yes";
    else cout << "No";
}
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    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 unsigned long ul;
typedef pair<ul, ul> P;

int main(){
    int N, M, X, Y;
    int xi, yi;
    
    cin >> N >> M >> X >> Y;
    
    int maxX = -1000;
    rep(i,N){
        cin >> xi;

        maxX = max(maxX, xi);
    }

    int minY = 1000;
    rep(i,M){
        cin >> yi;

        minY = min(minY, yi);
    }

    cout << ((min(minY, Y) <= max(maxX, X)) ? "War" : "No War") << endl;
} 

Measured memory_bytes: 764
main(){
int S,h,m,s;
scanf("%d",&S);
if (S>=3600){
h=S/3600;
m=S%3600/60;
s=(S%3600)%60;
}
else if (S>=60 || S>=3600){
h=0;
m=S/60;
s=S%60;
}
else if (S<60){
h=0;
m=0;
s=S%60;
}
printf("%d:%d:%d\n",h,m,s);
return 0;
}

Measured memory_bytes: 592
N = int(input())
S = input()

a = ''

for i in range(len(S)):
  s = ''
  if ord(S[i]) + N <= 90:
    s = chr(ord(S[i]) + N)
  else:
    s = chr(ord(S[i]) + N - 26)
  a = a + s
  
print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << 24 + (24 - n) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define ll long long

using namespace std;

const int N = int(1e5 + 5);

int main() {
    
    FIO
    int n; cin >> n;
    pair<pair<string, int>, int> guide[N];
    for (int i = 1; i <= n; i++) {
        string city; int score;
        cin >> city >> score;
        guide[i] = {{city, -score}, i};
    }
    sort(guide, guide + (n+1));
    for (int i = 1; i <= n; i++)
        cout << guide[i].second << endl;
    return 0;
}

Measured memory_bytes: 8316
#ABC114

s = input()
m = int(s[0]+s[1]+s[2])
for i in range(len(s)-2):
    n = int(s[i] + s[i+1] + s[i+2])
    
    if abs(n-753) < abs(m-753):
        m = n
        
print(abs(m-753))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,ans=1;
	cin>>n;
	vector<string>ga(n);
	rep(i,n)cin>>ga[i];
	sort(ga.begin(),ga.end());
	for(int i=1;i<n;i++){
	    if(ga[i]!=ga[i-1])ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
const int N=200010,Mod=998244353;
const double pi=acos(-1.0);
typedef long long int ll;
typedef pair<int,int> pii;
int n,a[N],ans[N],cnt;
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++) cin>>a[i];
  for(int i=n;i>=1;i--)
  {
    int temp=0;
    for(int j=2*i;j<=n;j+=i) temp^=ans[j];
    ans[i]=temp^a[i];
    if(ans[i]) cnt++;
  }
  cout<<cnt<<endl;
  for(int i=1;i<=n;i++) if(ans[i]) cout<<i<<" ";
  cout<<endl;
  return 0;
}


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

int N, C;
int V[101], W[101];
int dp[101][10001];

int maxValue() {
  for (int i = 0; i <= N; i++) dp[i][0] = 0;
  for (int j = 0; j <= C; j++) dp[0][j] = 0;
  
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= C; j++) {
      if (j < W[i]) dp[i][j] = dp[i - 1][j];
      else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - W[i]] + V[i]);
    }
  }
  
  return dp[N][C];
}

int main(void){
  cin >> N >> C;
  for (int i = 1; i <= N; i++) cin >> V[i] >> W[i];
  V[0] = W[0] = 0;

  cout << maxValue() << endl;

  return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

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

//main code

int main(int argc, char const* argv[])
{
    int n,a,b;
    cin >> n >> a >> b;
    cout << ((b-a)%2 == 0 ? "Alice" : "Borys") << endl;
    return 0;
}


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans;
  if ((b - a) % 2 == 0) {
    ans = (b - a) / 2;
  } else {
    // ans = min(a - 1, n - b) + 1 + (b - a - 1) / 2;
    ans = min((b + a - 1) / 2, (2 * n - b + 1 - a) / 2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int binerySearch(int a[], int n, int key) {
    int left = 0;
    int right = n;
    int mid;
    while(left < right) {
        mid = (left + right) / 2;
        if(a[mid] == key) 
            return mid;
        else if(a[mid] > key) 
            right = mid;
        else 
            left = mid + 1;
    }
    return 0;
}
int main() {
    int i, n, a[100001], q, key, sum = 0;
    scanf("%d\n", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", a+i);
    }
    scanf("%d\n", &q);
    for(i = 0; i < q; i++) {
        scanf("%d", &key);
        if(binerySearch(a, n, key)) {
            sum++;
        }
    }
    printf("%d\n", sum);

}


Measured memory_bytes: 2076
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  long N;
  cin >> N;
  map<string, int> m;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    char* c = new char[10];
    s.copy(c, 10);
    sort(c, c+10);
    s = string(c);
    //cout << s << endl;
    auto itr = m.find(s);
    if (itr != m.end()) {
      m[s] += 1;
    } else {
      m[s] = 1;
    }
  }
  long cnt = 0;
  for (auto i = m.begin(); i != m.end(); ++i) {
    long x = i->second;
    if (x > 1) {
      cnt += x * (x - 1) / 2;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 11136
#include<iostream>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(a,n) find(a.begin(),a.end(),n)
/*bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
l bfs(vector<l> like[],vector<l> dislike[],l s,bool vis[])
{
	vector<l> ans;
	queue<l> q;
	vis[s]=1;
	q.push(s);
	while(q.empty()==false)
	{
		l temp=q.front();
		ans.pb(temp);
		q.pop();
		for(l i=0;i<like[temp].size();i++)
		{
			if(vis[like[temp][i]]==0)
			{
				q.push(like[temp][i]);
				vis[like[temp][i]]=1;
			}
		}
	}
	for(l i=0;i<ans.size();i++)
	{
		for(l j=0;j<dislike[ans[i]].size();j++)
		{
			if(find(ans,dislike[ans[i]][j])!=ans.end())
			{
				l pos=find(ans,dislike[ans[i]][j])-ans.begin();
				vis[dislike[ans[i]][j]]=0;
				ans.erase(ans.begin()+pos);
			}
		}
	}
	return ans.size();
}*/
void frooty()
{
	l n;
	cin>>n;
	l count=0;
	l sum=100;
	while(sum<n)
	{
		sum+=(sum/100);
		count++;
	}
	cout<<count<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    l t=1;
  //  cin>>t;
    while(t--)
    {
    	frooty();	
	}
}

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

using namespace std;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

int main()
{
    int x;
    int n;
    int rcounter;
    int lcounter;
    rcounter = 0;
    lcounter = 0;

    cin >> x >> n;
    vector<int> v(n);

    rep(it, 0, n)
        cin >> v[it];

    if (n==0) {
        cout << x << "\n";
        return 0;
    }

    while (true) {
        if (find(v.begin(), v.end(), x+rcounter) != v.end()) {
            // in right
            rcounter++;
            if (find(v.begin(), v.end(), x-lcounter) != v.end()) {
                // in left
                lcounter++;
                continue;
            }
        } else {
            // not in right
            if (find(v.begin(), v.end(), x-lcounter) != v.end()) {
                // in left
                cout << x+rcounter << "\n";
                return 0;
            } else {
                cout << x-lcounter << "\n";
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3616
n,k=map(int,input().split())
mod=10**9+7
ans=0
dp=[0]*(k+1)
for i in range(k,0,-1):
  dp[i]=pow(k//i,n,mod)
  for j in range(i+i,k+1,i):dp[i]-=dp[j]
  ans=(ans+dp[i]*i)%mod
print(ans)

Measured memory_bytes: 11080
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;

//#define int ll


const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,m,ans=INF1,s[11],c[11];
void rec(int x, int num) {
  if (x==n+1) {
    string k=to_string(num);
    if (k.size()!=n) return;
    bool flag=0;
    fo(i,1,m,1) if (k[s[i]-1]-'0'!=c[i]) flag=1;
    if (!flag) chmin(ans,num);
    return;
  }
  fo(i, 0, 9, 1) {
    rec(x+1, num*10+i);
  }
}
main() {
  file("threesum");
  ios;
  cin>>n>>m;
  fo(i,1,m,1) cin>>s[i]>>c[i];
  rec(1,0);
  if (ans==INF1)ans=-1;
  cout<<ans;
  cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
  return 0;
}
/**

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
	cin>>n>>s;
	for(int i=0;i<s.length();i++) 
		if(int(s[i])+n<=int('Z')) cout<<char(int(s[i])+n);
		else cout<<char(int(s[i])+n-26);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll a[111], b[111];



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


  cin >> n;
  bool f = true;
  FOR(i, 1, n + 1) cin >> a[i];
  FOR(i, 1, n + 1) b[i] = inf;
  ll cur, dist, cnt, idx;
  FOR(i, 1, n + 1) {
    dist = i - a[i];
    if (dist < 0) {
      f = false; break;
    }
    f = false;
    RFOR(j, 1, i + 1) {
      cur = a[i];
      cnt = 0;
      FOR(k, j, i + 1) {
        if (cur >= b[k]) {
          cur++;
          cnt++;
        }
      }
      if (cnt == dist) {
        idx = j;
        f = true;
        break;
      }
    }
    if (!f) break;
    RFOR(j, idx + 1, i + 1) {
      b[j] = b[j - 1];
    }
    b[idx] = a[i];
  }



  if (f) {
    FOR(i, 1, n + 1) cout << b[i] << endl;
  }
  else cout << "-1" << endl;


  return 0;
}

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

using namespace std;
int n, m, p[100001];
vector < int > g[100001];
bool u[100001], cnt[100001];
vector < int > v;
void dfs(int x){
    u[x] = 1;
    v.push_back(x);
    for(int i = 0; i < g[x].size(); i++){
        int to = g[x][i];
        if(!u[to]){
            dfs(to);
        }
    }
}
int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> p[i];
    }
    for(int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!u[i]){
            dfs(i);
            for(int j = 0; j < v.size(); j++){
                cnt[v[j]] = 1;
            }
            for(int j = 0; j < v.size(); j++){
                if(cnt[p[v[j]]]){
                    ans++;
                }
            }
            for(int j = 0; j < v.size(); j++){
                cnt[v[j]] = 0;
            }
            v.clear();
        }
    }
    cout << ans;
}


Measured memory_bytes: 8828
#include <iostream>

using namespace std;

long long N,K;

int main(){
    cin >> N >> K;
    if(K%2 == 1){
        long long l = N / K;
        l = l * l * l;
        cout << l << endl;
    }else{
        long long l = N / K;
        l = l * l * l;
        if(N % K < K/2){
            cout << 2*l << endl;
        }else{
            long long r = N/K + 1;
            cout << l + r*r*r << endl;
        }
    }   
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iii pair<ii, int>
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define PI acos(-1.0)
using namespace std;
ll a[200010];
int main(){
    int n;
    cin>>n;
    ll amid = 1e18, mx = 0, b = 0;
    map<ll,ll>cnt;
    vector<ll>v;
    for(int i=1;i<=n;i++){
        cin>>a[i];//a[i] = rand()%20 + 1;  //cin>>a[i];
        a[i]-=i;
        v.pb(a[i]);
        a[i]+=i;
    }
    sort(v.begin(), v.end());
    int sz = v.size();
    b = v[sz/2];
    vector<ll>vv;
    vv.pb(b);
    for(auto b:vv){
        ll cur = 0;
        for(int i=1;i<=n;i++){
            cur+=abs(a[i]-(b+i));
        }
        amid = min(amid, cur);
    }

    cout<<amid<<endl;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    string s,t;
    cin >> N;
    cin >> s >> t;
    for (int i = 0; i < N; i++) {
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var weights = new List<KeyValuePair<int, int>>[n];
        for (int i = 0; i < weights.Length; ++i)
            weights[i] = new List<KeyValuePair<int, int>>();
        for (var count = n - 1; count > 0; --count)
        {
            var list = Console.ReadLine().Split(' ');
            var u = int.Parse(list[0]) - 1;
            var v = int.Parse(list[1]) - 1;
            var w = int.Parse(list[2]);
            weights[u].Add(new KeyValuePair<int, int>(v, w));
            weights[v].Add(new KeyValuePair<int, int>(u, w));
        }

        var colors = new int[n];
        var candidates = new List<int>();

        candidates.Add(0);
        colors[0] = 2;

        while (candidates.Count > 0)
        {
            var index = candidates.Count - 1;
            var t = candidates[index];
            candidates.RemoveAt(index);
            var c = colors[t];
            var ws = weights[t];

            for (int i = 0, count = ws.Count; i < count; ++i)
            {
                var weight = ws[i];
                if (colors[weight.Key] == 0)
                {
                    colors[weight.Key] = (weight.Value % 2 == 0) ? c : (c == 2 ? 1 : 2);
                    candidates.Add(weight.Key);
                }
            }
        }

        for (int i = 0; i < colors.Length; ++i)
            Console.WriteLine(colors[i] % 2);
    }
}


Measured memory_bytes: 26436
import math
ans=0
n=int(input())
for i in range(1,n+1):
  for j in range(i,n+1):
    for k in range(j,n+1):
      a=math.gcd(math.gcd(i,j),k)
      if i==j==k:
        ans=ans+a
      elif i==j or i==k or j==k:
        ans=ans+3*a
      else:
        ans=ans+6*a
print(ans)

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

int main(void){
  char s[2000001];
  scanf("%s", s);

  int len = strlen(s);
  long long num=len,lap=0,a,b=0;
  
    for(int i=len-1;i>=0;i-=1){
   	 if(s[i]=='W'){
      a=(num-i-1)*lap;
      b+=a;
      lap++;
      num=i;
     }
    }
  
  	printf("%lld", b+num*lap);
}
      
		
  	


Measured memory_bytes: 384
n,m = map(int,input().split())
s = str(input())
t = str(input())
def get_gcd(a, b): #最大公約数を求める関数
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return get_gcd(b, a % b)
def get_lcm(a, b, gcd): #みたまんまそういうやつです
    lcm = a * b // gcd
    return lcm
lcm = get_lcm(n,m,get_gcd(n,m)) #lcmはn,m最小公倍数
lcm2 = get_lcm(lcm/n,lcm/m,get_gcd(lcm/n,lcm/m)) #lcm２はlcm/nとlcm/mの最小公倍数
ans = 0
for i in range(int(lcm//lcm2)):
    if s[int(i*lcm2//(lcm/n))] == t[int(i*lcm2//(lcm/m))]:
        pass
    else:
        ans = 1
        break
if ans == 1:
    print(-1)
else:
    print(lcm)

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int a, b;
    cin >> a >> b;

    if (a >= 10 || b >= 10)
        cout << -1 << endl;
    else
        cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.next());
        long w = Long.parseLong(sc.next());
        if (h % 3 == 0 || w % 3 == 0) {
            System.out.println(0);
        } else {
            long diff = Long.MAX_VALUE;
            diff = Math.min(diff, getDiff(h, w));
            diff = Math.min(diff, getDiff(w, h));
            if (h > 2) {
                diff = Math.min(diff, getDiff2(h, w));
            }
            if (w > 2) {
                diff = Math.min(diff, getDiff2(w, h));
            }
            System.out.println(diff);
        }
    }

    private static long getDiff(long h, long w) {
        long L = 0;
        long R = w;
        long temp = 0;
        long diff = Long.MAX_VALUE;
        while (L < R) {
            temp = (L + R) / 2;
            long LL = h * temp;
            long RR = (h / 2) * (w - temp);
            if (h % 2 != 0) {
                if (LL < RR) {
                    RR = ((h / 2) + 1) * (w - temp);
                }
            }
            diff = Math.min(diff, Math.abs(LL - RR));
            if (LL > RR) {
                R = temp;
            } else {
                L = temp;
                if (R - L == 1) {
                    break;
                }
            }
        }
        return diff;
    }

    private static long getDiff2(long h, long w) {
        long L = 0;
        long R = w;
        long temp = 0;
        long diff = Long.MAX_VALUE;
        while (L < R) {
            temp = (L + R) / 2;
            long LL = h * temp;
            long RR = h * ((w - temp) / 2);
            if ((w - temp) % 2 != 0) {
                if (LL <= RR) {
                    RR = h * (((w - temp) / 2) + 1);
                }
            }
            diff = Math.min(diff, Math.abs(LL - RR));
            if (LL > RR) {
                R = temp;
            } else {
                L = temp;
                if (R - L == 1) {
                    break;
                }
            }
        }
        return diff;
    }
}

Measured memory_bytes: 21844
def main():
    n = int(input())
    a = []
    b = []
    s = []
    for i in range(n):
        atmp,btmp = map(int,input().split())
        a.append(atmp)
        b.append(btmp)
        s.append([atmp+btmp,i])


    s = sorted(s, key=lambda x: x[0], reverse=True)

    rem = [1 for i in range(n)]

    takahashi = 0
    aoki = 0

    for e,i in enumerate(s):
        if not e % 2:
            takahashi += a[i[1]]
        else:
            aoki += b[i[1]]
        

    print(takahashi-aoki)




main()

Measured memory_bytes: 29940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
using namespace std;

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

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

char field[12][6];
bool used[12][6];
char now;
int cnt;

void dfs(int x, int y){
  cnt++;
  used[y][x] = true;
  rep(i, 4){
    int nx = x+dx[i], ny = y+dy[i];
    if(nx < 0 || nx > 5 || ny < 0 || ny > 11 || used[ny][nx]) continue;
    if(field[ny][nx] == now) dfs(nx, ny);
  }
}

void del(int x, int y){
  field[y][x] = '.';
  rep(i, 4){
    int nx = x+dx[i], ny = y+dy[i];
    if(nx < 0 || nx > 5 || ny < 0 || ny > 11) continue;    
    if(field[ny][nx] == 'O') field[ny][nx] = '.';
    if(field[ny][nx] == now) del(nx, ny);    
  }
}

void drop(){
  rep(k, 12){
    for(int i = 1 ; i < 12 ; i++){
      for(int j = 0 ; j < 6 ; j++){
	if(field[i][j] == '.'){
	  field[i][j] = field[i-1][j];
	  field[i-1][j] = '.';
	}
      }
    }
  }
}

void init(){
  cnt = 0;
  memset(used, 0, sizeof(used));
}

void output(){
  rep(i, 12){
    rep(j, 6){
      cout << field[i][j];
    }
    cout << endl;
  }
  cout << endl;
}

int main(){
  int n;
  cin >> n;
  rep(cs, n){
    int ans = 0;
    rep(i, 12) cin >> field[i];
    
    for(; ;){
      bool flag = false;
      rep(i, 12){
	rep(j, 6){
	  if(isalpha(field[i][j]) && field[i][j] != 'O'){
	    init();
	    now = field[i][j];
	    dfs(j, i);
	    if(cnt >= 4){	      
	      //cout << "Start delete" << endl;
	      //output();
	      flag = true;
	      //ans++;
	      del(j, i);
	      //cout << "Finish delete" << endl;
	      //output();
	    }
	  }
	}
      }
      if(flag){
	ans++;
	drop();
	//cout << "Finish drop" << endl;
	//output();
      }	
      else goto END;
    }
  END:;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
# ABC148 B
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
s,t=map(str, input().split())
ans=''
for i in range(n):
    ss=s[i:i+1]
    tt=t[i:i+1]
    ans+=ss
    ans+=tt
print(ans)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
#define N 500007
#define pb push_back;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    ll n;
    cin>>n;
    ll i;
    ll g=__gcd((ll)360,n);
    cout<<360/g;
}

Measured memory_bytes: 3620
N,M=map(int,input().split())
ac=[False for _ in range(N+1)]
wa=[0 for _ in range(N+1)]
for i in range(M):
    p,S=input().split()
    p=int(p)
    if S=='AC':
        ac[p]=True
    elif ac[p]==False:
        wa[p]+=1
for i in range(N+1):
    if ac[i]==False:
        wa[i]=0
print(sum(ac),sum(wa))

Measured memory_bytes: 4656
from collections import defaultdict

N, A = map(int, input().split())
x = list(map(lambda x: int(x) - A, input().split()))

# dp[i][j]: i番目, j合計
dp = [defaultdict(int) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
    for key in dp[i]:
        dp[i + 1][key + x[i]] += dp[i][key]
        dp[i + 1][key] += dp[i][key]

print(dp[N][0] - 1)

Measured memory_bytes: 5364
N = gets.to_i
a = []
N.times do
	a.push(gets.to_i)
end

maxval = a.max
if a.select{|n| n == maxval}.size >= 2
	N.times do
		puts maxval
	end
else
	N.times do |i|
		if a[i] < maxval
			puts maxval
		else
			puts a.select{|n| n < maxval}.max
		end
	end
end

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

using namespace std;



int main() {
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;

	if (n % k != 0) cout << 1;
	else cout << 0;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define VEC(kata, num) (kata*)malloc(num * sizeof(kata))
#define DB puts("ok")
#define SENTINEL 1000000007
typedef long long lli;

int main()
{
    int a, b, t;
    scanf("%d%d%d",&a,&b,&t);
    int ans = t / a;
    ans = ans * b;
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static final int P = 1_000_000_007;

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();

		int[][] dp = new int[n + 1][n + 1];
		dp[1][0] = 1;

		for (int it = 0; it < m; it++) {
			int[][] nxt = new int[n + 1][n + 1];

			for (int s1 = 0; s1 <= n; s1++) {
				for (int s2 = 0; s1 + s2 <= n; s2++) {
					if (dp[s1][s2] == 0) {
						continue;
					}

					long val = dp[s1][s2];

					// if (s2 == 0) {
					//
					// nxt[s1][s2] += (int)(val * s1 % P);
					// if (nxt[s1][s2] >= P) {
					// nxt[s1][s2] -= P;
					// }
					//
					// nxt[s1][1] += (int)(val * (n - s1) % P);
					// if (nxt[s1][1] >= P) {
					// nxt[s1][1] -= P;
					// }
					//
					// } else {

					nxt[s1 + s2][0] += (int) (val * s1 % P);
					if (nxt[s1 + s2][0] >= P) {
						nxt[s1 + s2][0] -= P;
					}

					nxt[s1][s2] += (int) (val * s2 % P);
					if (nxt[s1][s2] >= P) {
						nxt[s1][s2] -= P;
					}

					nxt[s1][s2 + 1] += (int) (val * (n - s1 - s2) % P);
					if (nxt[s1][s2 + 1] >= P) {
						nxt[s1][s2 + 1] -= P;
					}

					// }

				}
			}
			dp = nxt;
		}
		
		out.println(dp[n][0]);

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 42772
i = input()

a=int(i[0])
b=int(i[1])
c=int(i[2])
d=int(i[3])
sa=i[0]
sb=i[1]
sc=i[2]
sd=i[3]

if(a+b+c+d==7):
    print(sa+"+"+sb+"+"+sc+"+"+sd+"=7")
elif (a+b+c-d==7):
    print(sa+"+"+sb+"+"+sc+"-"+sd+"=7")
elif (a+b-c+d==7):
    print(sa+"+"+sb+"-"+sc+"+"+sd+"=7")
elif(a-b+c+d==7):
    print(sa+"-"+sb+"+"+sc+"+"+sd+"=7")
elif(a-b-c+d==7):
    print(sa+"-"+sb+"-"+sc+"+"+sd+"=7")
elif(a-b+c-d==7):
    print(sa+"-"+sb+"+"+sc+"-"+sd+"=7")
elif(a+b-c-d==7):
    print(sa+"+"+sb+"-"+sc+"-"+sd+"=7")
elif(a-b-c-d==7):
    print(sa+"-"+sb+"-"+sc+"-"+sd+"=7")


Measured memory_bytes: 3064
import java.util.*;

public class Main {
  private static final long MOD_CONST = 1000000007;
  
  private static long mul(long a, long b) {
    return (a * b) % MOD_CONST;
  }
  
  private static long add(long a, long b) {
    return (a + b) % MOD_CONST;
  }
  
  
  private static ArrayList<Integer> runLengthCompression(ArrayList<Integer> rawInput) {
    ArrayList<Integer> compressedInput = new ArrayList<Integer>();
    
    int prevInput = 0;
    for (int input : rawInput) {
      if (input != prevInput) {
        compressedInput.add(input);
        prevInput = input;
      }
    }
    return compressedInput;
  }
  
  private static long solve(ArrayList<Integer> rawInput) {
    ArrayList<Integer> compressedInput = runLengthCompression(rawInput);
    /*
    for (int c : compressedInput) {
      System.out.print(c);
      System.out.print(", ");
    }
    System.out.println();
    */
    
    long[] dptable = new long[compressedInput.size() + 1];
    Map<Integer, Integer> lastShownIndexMap = new HashMap<Integer, Integer>();
    
    dptable[0] = 1;
    for (int i = 0; i < compressedInput.size(); i++) {
      int color = compressedInput.get(i);
      if (lastShownIndexMap.get(color) != null) {
        dptable[i+1] = add(dptable[i], dptable[lastShownIndexMap.get(color) + 1]);
      } else {
        dptable[i+1] = dptable[i];
      }
      lastShownIndexMap.put(color, i);
    }
    
    return dptable[compressedInput.size()];
  }
  
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    
    int n = s.nextInt();
    ArrayList<Integer> rawInput = new ArrayList<Integer>();
    for (int i = 0; i < n; i++) {
      rawInput.add(s.nextInt());
    }
    
    System.out.println(solve(rawInput));
  }
}


Measured memory_bytes: 97832
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int S,W;
    printf("\n");
    scanf("%d %d",&S,&W);
    if(S>W){
        printf("safe\n");
    }
    else{
        printf("unsafe\n");
    }
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
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; }

int main(){
  int r,D,x;
  cin >> r >>D>>x;
  for(int i=0;i<10;++i){
    x = x*r-D;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	static char [] [] mygrid;
	static int h;
	static int w;
	static long [][]mydpArr ;
	public static long dp(int x, int y) {
		if (x==h-1 &&y==w-1)
			return 1;
		
		if (mydpArr[x][y] != -1)
			return mydpArr[x][y];
		if ((x+1>=h||mygrid [x+1][y] =='#')&&(y+1>=w||mygrid [x][y+1] =='#'))
				return mydpArr[x][y] =0;
		
		if((x+1<h&&mygrid [x+1][y]  !='#')&&(y+1<w&&mygrid [x][y+1]  !='#'))
			return mydpArr[x][y]= dp(x+1,y)%1000000007 +dp (x,y+1)%1000000007;
		if(x+1<h&&mygrid [x+1][y]  !='#')
			return  mydpArr[x][y]= dp(x+1,y)%1000000007;
		return mydpArr[x][y]= dp (x,y+1)%1000000007;
			

	}
	public static void main(String[] args) throws IOException {
       //Scanner sc = new Scanner(System.in);
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);

      StringTokenizer st =  new StringTokenizer(br.readLine());
        h=Integer.parseInt( st.nextToken());
       w= Integer.parseInt( st.nextToken());
        mygrid = new char [h][w];
       for(int i =0;i<h;i++) {
    	String s=br.readLine();
    	  for(int j =0;j<w;j++) {
    		  mygrid[i][j]= s.charAt(j);
    	  }
    	   
       }
       mydpArr = new long[h][w];
       for(long x[]: mydpArr) {
    	   Arrays.fill(x, -1);
       }
       
        pw.print((long)dp(0,0)%1000000007);
        pw.close();
        }
	  static class Scanner {
	         BufferedReader br;
	         StringTokenizer st;
	 
	         public Scanner(InputStream s) {
	             br = new BufferedReader(new InputStreamReader(s));
	         }
	 
	         public String next() throws IOException {
	             while (st == null || !st.hasMoreTokens())
	                 st = new StringTokenizer(br.readLine());
	             return st.nextToken();
	         }
	 
	         public int nextInt() throws IOException {
	             return Integer.parseInt(next());
	         }
	 
	         public long nextLong() throws IOException {
	             return Long.parseLong(next());
	         }
	 
	         public double nextDouble() throws IOException {
	             return Double.parseDouble(next());
	         }
	 
	         public int[] nextIntArr(int n) throws IOException {
	             int[] arr = new int[n];
	             for (int i = 0; i < n; i++) {
	                 arr[i] = Integer.parseInt(next());
	             }
	             return arr;
	         }
	 
	     }
}

Measured memory_bytes: 42600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int H,W,h,w;
  cin >> H >> W >> h >> w;
  int ans = 0;
  ans = H*W+h*w;
  ans -= (H*w+h*W);
  cout << ans << endl;
  return 0;
}

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

int main(){
    long long int n, m;
    vector<long long int> m_v;
    
    cin >> n >> m;

    if( m <= n){
        cout << 0 << endl;
        return 0;
    } 
    
    for(int i = 0; i < m; i++){
        long long int mi;
        cin >> mi;
        m_v.push_back(mi);
    }

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

    vector<long long int> diffs;
    for(int i = 0; i < m-1; i++){
        diffs.push_back(abs(m_v[i] - m_v[i+1]));
    }

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

    int ans = 0;
    for(int i = 0; i < diffs.size() - n + 1; i++){
        ans += diffs[i];
    }
        cout << ans << endl;
}

Measured memory_bytes: 2548
n = int(input())
a = list(map(int,input().split()))
b = []
minus = 0
for i in range(n):
  if a[i] < 0:
    minus += 1
  b.append(abs(a[i]))
b.sort()
if minus % 2 == 0:
  print(sum(b))
else:
  print(sum(b) - 2 * b[0])

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

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)

long long int n,cnt=0,ans=0,a,b,c,cmp[100000],data[100000],m;



int main(void){
	string s;
	cin >> s;
	string w;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0'){
			w+=s[i];
		}else if(s[i]=='1'){
			w+=s[i];
		}else{
			if(w.size()>0){
				w.erase(w.size()-1);
			}
		}
	}
	cout << w << endl;
	return 0;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;
        

        static void Main(string[] args)
        {
            if (Console.ReadLine() == "0") Console.WriteLine("1");
            else Console.WriteLine("0");

        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        /*static public void DFS(int h, int w, bool[][] _visited)
        {
            
            if (w < 0 || h < 0 || h > _visited.Length - 1 || w > _visited[h].Length-1 || map[h][w]=='x')
                return;
            if (_visited[h][w])
                return;
            //Console.WriteLine(h + " " + w+" "+ _visited[h].Length + " " + _visited.Length);
            _visited[h][w] = true;

            DFS(h + 1, w,_visited);
            DFS(h - 1, w,_visited);
            DFS(h, w + 1,_visited);
            DFS(h, w - 1,_visited);

        }*/
        
        
        
    }
}


Measured memory_bytes: 25780
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def solve(M: list, d: list, visited: list, u: int = 0):
    global N
    visited[u] = True
    for m in M[u]:
        i = m[0]
        w = m[1]
        if not visited[i]:
            d[i] = d[u] + w
            solve(M, d, visited, i)


def main():
    global N
    N = int(input())
    M = [[] for _ in range(N)]
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        M[u-1].append((v-1, w))
        M[v-1].append((u-1, w))
    visited = [False] * N
    d = [0] * N
    solve(M, d, visited)
    for i in d:
        if i%2 == 0:
            print(0)
        else:
            print(1)

if __name__ == '__main__': main()

Measured memory_bytes: 95920
n=int(input())
a=list(map(int,input().split()))
t={}
for i in range(n):
  if a[i] in t:
    t[a[i]]+=1
  else:
    t[a[i]]=1
ans=0
for i in t:
  if i>t[i]:
    ans+=t[i]
  else:
    ans+=t[i]-i
print(ans)

Measured memory_bytes: 99064