akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int a, b;
   cin >> a >> b;
   int ans = 0;
   rep(i, a, b + 1) {
      string s = to_string(i);
      int n = s.size();
      bool ok = true;
      rep(j, 0, n) {
         int k = n - 1 - j;
         if (j < k && s[j] != s[k]) ok = false;
      }
      if (ok) ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
N = gets.to_i

a_list = gets.strip.split(/ /).collect{|num| num.to_i}

odd_count = 0
a_list.each{|n|
	odd_count += 1 if n % 2 == 1
}
if odd_count % 2 == 0
	puts "YES"
else
	puts "NO"
end


Measured memory_bytes: 9604
#include <iostream>
using namespace std;
//C - Minimization
int main(void){
    int n,k;
    std::cin >> n >> k;
    int a,index;
    for (int i = 1; i <= n; i++) {
        std::cin >> a;
        if(a==1)index=i;
    }
    int ans=(n-1+k-1-1)/(k-1);

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,n,a,b;
	double x,y,z;
	while(scanf("%d",&n)!=EOF) {
		for(i=1;i<=n;i++) {
			scanf("%d:%d",&a,&b);
			x=a*5.00+(b/60.00*5);
			if(x>=60.00) {
				x=x-60.00;
			}
			y=b*1.00;
	//		printf("X=%f Y=%f\n",x,y);
			if(x>=y) {
				z=x-y;
			}
			else {
				z=y-x;
			}
			if(30<z) {
				z=60.0-z;
			}
//			printf ("%lf\n",z);
			if(0.00<=z && z<5.00) {
				printf("alert\n");
			}
			else if(5.00<=z && z<15.00) {
				printf("warning\n");
			}
			else if(15.00<=z && z<=30.00) {
				printf("safe\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int M=1e9+7,N=50;
struct matrix{
  int a[N][N];
  inline matrix operator*(matrix b){
    matrix c;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++){
      c.a[i][j]=0;
      for(int k=0;k<N;k++)
        c.a[i][j]=(c.a[i][j]+1ll*a[i][k]*b.a[k][j])%M;
      }return c;
  }
}a,s;
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
} 
int n,m,ans;
signed main(){
  //fopen();
  scanf("%lld%lld",&n,&m);
  for(int j=0;j<n;j++)s.a[j][j]=1;
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)
    scanf("%lld",&a.a[i][j]);
  for(;m;m>>=1)m&1?s=s*a:(matrix){0},a=a*a;
    //cout<<ans<<endl;
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)
    ans=(ans+s.a[i][j])%M;
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
 
int main(){
    int n,cnt=0;
    string s;
    cin>>n>>s;
 
    for(int i=0; i<n; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

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

int main(void){
	int N;
	cin >> N;
	int A[N];
	unordered_set<int> u_s;
	bool dup = false;
	for(int i = 0;i < N;++i){
		cin >> A[i];
		if(u_s.find(A[i]) == u_s.end()){
			u_s.insert(A[i]);
		}else{
			dup = true;
			break;
		}
	}
	if(dup){
		cout << "NO\n"; 
	}else{
		cout << "YES\n";
	}
}



Measured memory_bytes: 9288
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

s = raw_input()
N = len(s)
g, p = 0, 0
ans = 0
for si in s:
    if si == "g":
        if g > p:
            ans += 1
            p += 1
        else:
            g += 1
    else:
        if g > p:
            p += 1
        else:
            ans -= 1
            g += 1
print ans


Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100001];
    cin>>n;
    int f=0;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
        if((a[i]%2==0) && (a[i]%3==0 || a[i]%5==0))
            f=0;
        else if(a[i]%2==0)
        {
            f=1;
            break;
        }
        else
        {

        }
    }
    if(f)
        cout<<"DENIED\n";
    else
        cout<<"APPROVED\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int r, c;
    cin >> r >> c;
    int ans[r + 1][c + 1] = {};
    rep(i, 0, r) {
        int rsum = 0;
        rep(j, 0, c) {
            cin >> ans[i][j];
            rsum += ans[i][j];
        }
        ans[i][c] = rsum;
    }
    rep(i, 0, c + 1) {
        int csum = 0;
        rep(j, 0, r) {
            csum += ans[j][i];
        }
        ans[r][i] = csum;
    }
    rep(i, 0, r + 1) {
        rep(j, 0, c + 1) {
            if (j == c) cout << ans[i][j] << endl;
            else cout << ans[i][j] << " ";
        }
    }
    return 0;

}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  vl a(N),b(N);
  rep(i,N){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b.begin(),b.end());
  ll fi=b[N-1],se=b[N-2];
  for(int i=0;i<N;i++){
    if(a[i]==fi){
      cout<<se<<endl;
    }
    else{
      cout<<fi<<endl;
    }
  }
}


Measured memory_bytes: 6372
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<cstdlib>
#include<unordered_set>
#include<algorithm>
#include<chrono>
 
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
//~ #define ii pair	<long long ,long 	long >
#define i64ii pair< long long, pair<int,int> >
#define i64i pair<long long , int >
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define ii pair<int, int > 
#define iii pair<int, ii >	
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;

typedef long long ll;	
typedef vector< int> vi;
typedef long double ld;

typedef unsigned long long ull;
		
typedef  pair <ii, ii > iiii;
typedef vector < ii > vii;

const int MAX = 2100;
const int maxn = 1e6 + 100;

 
 

char a[10];

int main() {
 //~ in
 
 scanf("%s", a);
 
 if (a[2] == a[3] && 
  a[5] == a[4] )
   printf("Yes\n");
  else
   printf("No\n");
   
  
  return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
        string s = ReadLine();
        string t = ReadLine();
        int n = s.Length;

        bool ans = false;
        for (int i = 0; i < n; i++)
        {
            bool chk = true;
            for (int j = 0; j < n; j ++)
            {
                if (s[(j+i)%n] != t[j]){ chk = false; break; }
            }
            if (chk){ ans = true; break; }
        }

        WriteLine(ans?"Yes":"No");
    }
}


Measured memory_bytes: 11092
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;
 
 double abs(double x)
 {
   if(x>0) return x;
   else return -x;       
 }
 
 int main()
 {
   double x,a,b;
   while(cin>>x>>a>>b)
   {
     double dis_a=abs(x-a);
     double dis_b=abs(x-b);
     if(dis_a<dis_b) cout<<"A"<<endl;
     else cout<<"B"<<endl;                   
   }
   //while(1);
   return 0;
 }

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N 100

int main(void) {
  int N;
  scanf("%d\n", &N);
  int T[MAX_N];
  int SUM_T = 0;
  for(int i = 0; i < N; i++) {
    scanf("%d", &T[i]);
    SUM_T += T[i];
  }

  int M;
  int P[MAX_N];
  int X[MAX_N];
  scanf("%d", &M);
  for(int i = 0; i < M; i++) {
    scanf("%d %d", &P[i], &X[i]);
  }
  
  for(int i = 0; i < M; i++) {
    printf("%d\n", SUM_T - T[P[i]-1] + X[i]);
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, a, b;
    cin >> n >> a >> b;
    if(a > b) cout << "0" << endl;
    else{
        long ans = (a+b*(n-1)) - (b+a*(n-1)) + 1;
        if(ans < 0) ans = 0;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a=0,b=0,c=0,d=0;
	int e[3];
	while(cin >> e[0] >> e[1] >> e[2]){
		sort(e,e+3);
		if(e[0]+e[1]>e[2]){
			++a;
			for(int i=0; i<3; ++i)	e[i]*=e[i];
			if(e[0]+e[1]==e[2])	++b;
			else if(e[0]+e[1]>e[2])	++c;
			else	++d;
		}else	break;
	}
	cout << a << " " << b << " " << c << " " << d << endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'o') cnt++;
    }
    if (15 - n + cnt < 8) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mod 1000000007
#define har ios_base::sync_with_stdio(),cout.tie(NULL),cin.tie(NULL);
const int N = 1e5 + 5;
int arr[N];
int main()
{
	har;
	int n;
	cin >> n;
	ll dp[N];
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	dp[0] = 0;
	dp[1] = arr[1] - arr[0];
	for (int i = 1; i < n; i++)
	{
		dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
	}
	cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N,K;
  cin >> N >> K;
  ll A[N];
  vector<ll> S[200003];
  ll M[200003];
  for (int i = 0; i < 200003; i++) {
    M[i] = -1LL;
  }
  vector<ll> cycle(0);
  vector<ll> start(0);
  start.push_back(0LL);
  ll where[N];
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
    S[A[i]].push_back(i);
    where[i] = S[A[i]].size() - 1;
  }
  ll cnt = 0;
  while (0 == 0) {
    if (S[A[start[cnt]]].size() != where[start[cnt]] + 1) {
      cycle.push_back(S[A[start[cnt]]][where[start[cnt]] + 1] - S[A[start[cnt]]][where[start[cnt]]] + 1);
      start.push_back((start[cnt] + cycle[cnt]) % N);
    } else {
      cycle.push_back(S[A[start[cnt]]][0] + N - S[A[start[cnt]]][where[start[cnt]]] + 1);
      start.push_back((start[cnt] + cycle[cnt]) % N);
    }
    if (start[cnt+1] == 0) {
      break;
    }
    cnt++;
  }
  ll sum = 0;
  for (int i = 0; i < cycle.size(); i++) {
    sum += cycle[i];
  }
  ll X = ((N % sum) * (K % sum)) % sum;
  ll n;
  for (int i = 0; i < cycle.size(); i++) {
    X -= cycle[i];
    if (X <= 0) {
      n = i;
      break;
    }
  }
  X += cycle[n] - 1;
  vector<ll> ans(0);
  for (int i = 0; i <= X; i++) {
    int a = A[(start[n] + i) % N];
    int m = M[a];
    if (M[a] == -1) {
      ans.push_back(a);
      M[a] = ans.size() - 1;
    } else {
      for (int j = ans.size() - 1; j >= m; j--) {
        ans.pop_back();
        M[ans[j]] = -1;
      }
      M[a] = -1;
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] + 1 << " "; 
  }
  return 0;
}

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

#define INF 100000001

int main(){
    int N,W; cin >> N >> W;
    int v[N],w[N]; 
    int sum_v(0);
    for(int i=0;i<N;i++){
        cin >> v[i] >> w[i];
        sum_v += v[i];
    }

    int DP[N+1][sum_v+1];
    
    DP[0][0] = 0;
    for(int j=1;j<=sum_v;j++){
        DP[0][j] = INF;
    }
    
    for(int i=1;i<=N;i++){
        for(int j=0; j<=sum_v; j++){
            if(j<v[i-1]){
                DP[i][j] = DP[i-1][j];
            }else{
                DP[i][j] = min(DP[i-1][j], DP[i-1][j-v[i-1]]+w[i-1]);
            }
        }
    }

    for(int i=sum_v;i>=0;i--){
        if(DP[N][i]<=W){
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 7028
import heapq
import sys
input=sys.stdin.readline

N,M=map(int,input().split())

ablist=[]
for i in range(N):
  A,B=map(int,input().split())
  ablist.append((A,B))
ablist.sort(reverse=True)
  
hq=[]
answer=0
for i in reversed(range(M)):
  while ablist:
    a,b=ablist[-1]
    if i+a<=M:
      ablist.pop()
      heapq.heappush(hq,((-b,a)))
    else:
      break
  
  if hq:
    mb,a=heapq.heappop(hq)
    answer-=mb
    #print(i,a+i,-mb)
    
print(answer)

Measured memory_bytes: 17232
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//これはひどい提出だ

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 8) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	const int cm = 1 << 21;
	char cn[cm], * ci = cn;
	fread(cn, 1, cm, stdin);

	int N = 0;
	while (*ci >= '0') N = N * 10 + *ci++ - '0';
	ci++;

	int s[100000];
	rep(i, N) {
		sort(ci, ci + 10);
		int k = 0;
		rep(j, 10) {
			k *= 27;
			k += *ci++ - 'a';
		}
		ci++;
		s[i] = k;
	}

	pakuri_sort(N, s);

	ll kotae = 0;
	ll mae = -1;
	ll kazu = 0;
	rep(i, N) {
		if (mae != s[i]) {
			kotae += kazu * (kazu - 1) / 2;
			mae = s[i];
			kazu = 1;
		}
		else kazu++;
	}

	kotae += kazu * (kazu - 1) / 2;

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<int, vector<int>, greater<int> > PQ_ASK;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> logs(n);
    rep(i, n) cin >> logs[i];

    auto check = [&](ll mid) -> bool {
        ll t = 0;

        for (ll l : logs) {
            ll now = (l + mid - 1) / mid;
            now--;
            t += now;
        }

        return t <= k;
    };

    ll floor = 1, ceil = INF;
    if (check(1)) {
        cout << 1 << endl;
        ret();
    }

    while (floor + 1 < ceil) {
        ll mid = (floor + ceil) / 2;
        bool b = check(mid);
        if (b) ceil = mid;
        else floor = mid;
    }

    // floorより大きくできるか
    auto can_maxi = [&](ll floor) -> bool {
        assert(check(ceil));
        assert(!check(floor));
        int u = 0;
        for (ll l : logs) {
            if (l % ceil == 0) u++;
        }

        ll t = 0;
        for (ll l : logs) {
            ll now = (l + ceil - 1) / ceil;
            now--;
            t += now;
        }

        assert(t <= k);

        bool ans = t + u <= k;
        return ans;
    };

    cout << ceil << endl;

//    if (can_maxi(floor)) {
//        cout << ceil << endl;
//    } else {
//        cout << floor << endl;
//
//    }


}


Measured memory_bytes: 4724
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	std::string str;
	std::cin >> str;
	std::string ans;
	std::cin >> ans;

	for (int i = 0; i < str.size(); ++i) {
		char c = str[0];
		str.erase(str.begin(), str.begin()+1);
		str.push_back(c);
		if (str == ans) {
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}
	std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
//const ll p = 1e9 + 7;
//const ll p = 998244353;
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll a, b;
	cin >> a >> b;
	if (a + b == 15) cout << "+" << endl;
	else if (a * b == 15) cout << "*" << endl;
	else cout << "x" << endl; 
}


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


int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size() - 1] == c[0]){
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    
    cout << endl;
}


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

int main (void) {
    long long ans = 0;
    long long x, rem;

    scanf("%lld", &x);

    ans += (x / 500) * 1000;
    rem = x - 500 * (x / 500);
    ans += (rem / 5) * 5;

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

    return EXIT_SUCCESS;
}


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

string f(string s){
  string ans = "";
  for(int i = 0; i < s.length(); i++){
    if(s[i] == '0'){
      ans += '0';
    }else if(s[i] == '1'){
      ans += '1';
    }
    else{
      int temp = ans.length();
      ans = ans.substr(0, temp - 1);
    }
  }
  return ans;
}

int main(void){
  string s;
  cin >> s;
  string ans = f(s);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[100010],ans,c;
int main() {
	//freopen("2.txt","r",stdin);
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++)
		if (a[i]!=0)
			c+=a[i];
		else ans+=c/2,c=0;
	ans+=c/2;
	printf("%lld\n",ans);
	return 0;
}

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

const int N=505;
int n;
char a[N][N];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%s",a[i]+1);
	int cnt=0;
	bool nosol=true;
	for(int i=1;i<=n;++i){
		bool flag=true;
		for(int j=1;j<=n;++j)flag&=a[j][i]=='#',nosol&=a[j][i]=='.';
		if(!flag)++cnt;
	}
	if(nosol)return puts("-1"),0;
	int ans=1<<30;
	for(int i=1;i<=n;++i){
		int cnt=count(a[i]+1,a[i]+1+n,'.');
		bool flag=false;
		for(int j=1;j<=n&&!flag;++j)flag|=a[j][i]=='#';
		ans=min(ans,cnt+(!flag));
	}
	printf("%d\n",ans+cnt);
	return 0;
}


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

using namespace std;

#define NAX 1e15

#define MXVAl (int)1e5+2

int main(){
	
	long n,w;
	scanf("%ld%ld",&n,&w);
	vector<long> ww(n),vv(n);
	for(int i=0;i<n;i++)
		scanf("%ld%ld",&ww[i],&vv[i]);
	
	long dp[n+1][MXVAl];
	for(int i=1;i<MXVAl;i++)
		dp[0][i]=NAX;
	dp[0][0]=0;
	
	for(int i=1;i<=n;i++){
		
		for(int j=0;j<MXVAl;j++){
			
			dp[i][j]=NAX;
			dp[i][j]=min(dp[i][j],dp[i-1][j]);
			if(j-vv[i-1]>=0)
				dp[i][j]=min(dp[i][j],dp[i-1][j-vv[i-1]]+ww[i-1]);
			
			}
		
		}
		long res=0;
		for(int i=0;i<MXVAl;i++){
			
			if(dp[n][i]<=w)
				res=i;
		}
		printf("%ld",res);
	}


Measured memory_bytes: 79104
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int N;
    cin >> N;
    string str;
    cin >> str;
    int c[N];
    int N0 = 0, N1 = 0;

    for (int i = 0; i < N; i++)
    {
        c[i] = (str.at(i) == 'R') ? 0 : 1;
        if (c[i] == 0)
        {
            N0++;
        }
        else
        {
            N1++;
        }
    }
    if (N0 == N || N1 == N)
    {
        cout << 0;
        return 0;
    }

    int i_leftmost_1, i_rightmost_0;

    for (int i = 0; i < N; i++)
    {
        if (c[i] == 1)
        {
            i_leftmost_1 = i;
            break;
        }
    }

    for (int i = N - 1; i >= 0; i--)
    {
        if (c[i] == 0)
        {
            i_rightmost_0 = i;
            break;
        }
    }

    int swapped = 0;

    while (i_leftmost_1 < i_rightmost_0)
    {
        c[i_leftmost_1] = 0;
        c[i_rightmost_0] = 1;
        swapped++;
        for (int i = i_leftmost_1 + 1; i < N; i++)
        {
            if (c[i] == 1)
            {
                i_leftmost_1 = i;
                break;
            }
        }

        for (int i = i_rightmost_0 - 1; i >= 0; i--)
        {
            if (c[i] == 0)
            {
                i_rightmost_0 = i;
                break;
            }
        }
    }
    cout << swapped;
    return 0;
}

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

int main()
{
    int a,b;
    scanf("%d %d\n",&a, &b);
    int c = a + b;
    if (c >= 10)
    {
        printf("error\n");
    }
    else
    {
        printf("%d\n", c);
    }
    return 0;
}


Measured memory_bytes: 128
// ini template jangan diedit
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int M,N,Hasil;
	cin >> N;
	bool jarum=false;
	int i;
	for (i=1;i<10;i++)
	{
		//cout << "Nilai I adalah: "<< i << endl;
		int j;
		for (j=1;j<10;j++)
		{
			int k;
			k = i*j;
			if (k == N)
			{//cout << j << endl;
			jarum = true;
			//cout << "Nilai i*j adalah: "<< k << endl;
			//break;
			}
		}
	}
	if (jarum)
	{
	cout << "Yes";
	}
	else
	{
	cout << "No";
	}
// Type Your Body of Code Here
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    cin >> N;
    res = N % 1000;
    if (res == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        res = 1000 - res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3644
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ans := 0
	for i := 0; i < n; i++ {
		l, r := nextInt(), nextInt()
		ans += r - l + 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
 
void solve(){
	string a, b, c;
  	cin >> a >> b >> c;
  	cout << a[0] << b[0] << c[0];
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;


int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> graph[100100];
  vector<P> A(M);
  REP(i,M){
    cin >> A[i].first >> A[i].second;
    graph[A[i].first-1].push_back(A[i].second-1);
    graph[A[i].second-1].push_back(A[i].first-1);
  }
  
  vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
  vector<int> ans(N,0);
  queue<int> que;

  // 初期条件 (頂点 0 を初期ノードとする)
  dist[0] = 0;
  que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
    int v = que.front(); // キューから先頭頂点を取り出す
    que.pop();

    // v から辿れる頂点をすべて調べる
    for (int nv : graph[v]) {
      if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

      // 新たな白色頂点 nv について距離情報を更新してキューに追加する
      dist[nv] = dist[v] + 1;
      ans[nv]=v;
      que.push(nv);
    }
  }

  cout << "Yes" << endl;
  FOR(i,1,N){
    cout << ans[i]+1 << endl;
  }
}

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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=1e5+5,mod=1e9+7,bit=61;


signed main()
{
    fast;

    int t=1;
    //cin>>t;
    f(tc,1,t)
    {
        string s1,s2;
        cin>>s1>>s2;
        int ans=inf;
        int n=s1.length();
        int m=s2.length();
        for(int i=0;i+m-1<n;i++)
        {
            int curr=0;
            for(int j=0;j<m;j++)
            {
                curr+=(s2[j]!=s1[i+j]);
            }
            ans=min(ans,curr);
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

 int main()
 {
     int ara[4],i,f=0,s=0;

     for(i=0;i<3;i++){
        cin>>ara[i];
     }

     for(i=0;i<3;i++){
        if(ara[i]==5){
            f++;
        }
     }
     if(f==2){
        cout<<"YES\n";
     }
     else{
        cout<<"NO\n";
     }

     return 0;
 }


Measured memory_bytes: 3024
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanInt() int {
	sc.Scan(); a,_ := strconv.Atoi(sc.Text()); return a
}

func scanInt64() int64 {
	sc.Scan(); a,_ := strconv.ParseInt(sc.Text(),10,64); return a
}

func scanFloat64() float64 {
	sc.Scan(); a,_ := strconv.ParseFloat(sc.Text(),64); return a
}

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanString() string {
	sc.Scan(); return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e); if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr); wr.Flush()
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanFloat64()
	m := scanFloat64()
	d := scanFloat64()

	ans := (n-d)*(m-1)/n/n
	if d != 0 {
		ans*=2
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
//I am so vegetable
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 1e5 + 5;
const int MOD = 1e9 + 7;
const double exps = 1e-8;
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	FIO;
	int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int n; cin >> n;
	cout << a[n - 1] << '\n';
	return 0;
}

Measured memory_bytes: 256
/*
author : seryu
title : ABC177A_"Don't be late"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

void solve()
{
    int d, t, s;
    cin >> d >> t >> s;
    if(d <= t*s)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return;	
}

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


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long ct = 0;
		long sum = 0;
		for(var i=str.Length-1;i>=0;i--){
			if(str.Substring(i,1)=="W"){
				ct += 1;
			} else {
				sum += ct;
			}
		}
		Console.WriteLine(sum);
	}
}

Measured memory_bytes: 15836
import java.math.BigInteger;
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {
     static final long MOD = 1000000007;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int sx, sy, gx, gy;
        sx = scanner.nextInt();
        sy = scanner.nextInt();
        gx = scanner.nextInt();
        gy = scanner.nextInt();

        for (int i = 0; i < gx - sx; i++) {
            System.out.print("R");
        }
        for (int i = 0; i < gy - sy; i++) {
            System.out.print("U");
        }
        for (int i = 0; i < gx - sx; i++) {
            System.out.print("L");
        }
        for (int i = 0; i < gy - sy + 1; i++) {
            System.out.print("D");
        }
        for (int i = 0; i < gx - sx + 1; i++) {
            System.out.print("R");
        }
        for (int i = 0; i < gy - sy + 1; i++) {
            System.out.print("U");
        }
        System.out.print("LU");
        for (int i = 0; i < gx - sx + 1; i++) {
            System.out.print("L");
        }
        for (int i = 0; i < gy - sy + 1; i++) {
            System.out.print("D");
        }
        System.out.print("R");


    }





}




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

int main (){
    int a, b, c;
    cin>>a>>b>>c;
    if (b-c>-1){
        cout<<"delicious"<<endl;
    }
    else if(c-b<a+1){
        cout<<"safe"<<endl;
    }
    else{
        cout<<"dangerous"<<endl;
    }
    
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))

min = 1000000
min_index = -1
for i, h in enumerate(H):
    v = abs(A-(T-h*0.006))
    if v < min:
        min = v
        min_index = i
print(min_index+1)

Measured memory_bytes: 3060
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, M, K) = nextIntList()
    val UF = UnionFind(N)
    val G = IntArray(N + 1) { 0 }
    repeat(M) {
        val (a, b) = nextIntList()
        UF.union(a, b)
        G[a]++
        G[b]++
    }
    val answers = IntArray(N + 1)
    for (i in 1..N) {
        answers[i] = UF.sizeOf(i) - G[i] - 1
    }
    repeat(K) {
        val (c, d) = nextIntList()
        if (UF.same(c, d)) {
            answers[c]--
            answers[d]--
        }
    }
    println(answers.drop(1).joinToString(" "))
}

class UnionFind(n: Int) {
    private val roots = Array(n + 1) { Root(it) }

    tailrec fun find(x: Int): Root {
        if (roots[x].root == x) {
            return roots[x]
        }
        roots[x].root = roots[roots[x].root].root
        return find(roots[x].root)
    }

    fun union(x: Int, y: Int) {
        val rx = find(x)
        val ry = find(y)
        if (rx.root == ry.root) return
        if (rx.size < ry.size) {
            rx.root = ry.root
            ry.size += rx.size
        } else {
            ry.root = rx.root
            rx.size += ry.size
        }
    }

    fun same(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }

    fun sizeOf(x: Int): Int {
        return find(x).size
    }

    data class Root(var root: Int, var size: Int = 1)
}

Measured memory_bytes: 66108
import math

raw = input()
N = int(raw)
n = math.sqrt(N)
a,b = math.modf(n)
m = int(b)

count = N - 1

for i in range(m,1,-1):
    if (N % i)==0:
        ans = i + (N // i) -2
        count = ans
        break

print(count) 

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<queue>
using namespace std;
int main(){
    priority_queue<unsigned long long int> x;
    unsigned long long int n,a=-1,w=0,b=0;
    unsigned long long int temp;
    cin >> n;
    for(unsigned long long int i;i<n;i++){
        cin >> temp;
        x.push(temp);
    }
    while(!x.empty()){
        if(x.top() == a){
            w = a;
            x.pop();
            break;
        }
        a = x.top();
        x.pop();
    }
    a = 0;
    while(!x.empty()){
        if(x.top() == a){
            b = a;
            break;
        }
        a = x.top();
        x.pop();
    }
    cout << b*w;
}


Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main(void){
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    
    int cnt = 0;
    for(int i=0; i<n; ++i){
        if((a[i]==b[i]) && (b[i]==c[i])){
            continue;
        }else if((a[i]==b[i]) || (a[i]==c[i]) || (b[i]==c[i])){
            ++cnt;
        }else{
            cnt += 2;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000;

typedef long long ll;
typedef unsigned long long ull;

ll dp[1010][3][1010];

int main(void) {
  int n, k; cin >> n >> k;
  ll r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;

  ll ans = 0;
  int c[100010] = {};
  rep(i, n) {
    if (c[i] == 0) {
      if (t[i] == 'r') ans += p;
      if (t[i] == 'p') ans += s;
      if (t[i] == 's') ans += r;
      if (i + k < n && t[i] == t[i + k]) c[i + k]++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 896
import numpy as np
N = int(input())
AB = []
for i in range(N):
    ab = list(map(int,input().split()))
    AB.append(ab)
AB_matrix = np.array([AB])
A = AB_matrix[0]
AB_sort = A[np.argsort(A[:,1])]
now = 0
for j in AB_sort:
    now += j[0]
    if now <= j[1]:
        ans = 'Yes'
    else:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 67152
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(read())
lim = int(n ** 0.5)
fact = [1]
for i in range(2, lim + 1):
    if (n % i == 0):
        fact.append(i)
    else:
        pass

if (len(fact) == 1):
    ans = n - 1

else:
    tar = fact[-1]
    ans = tar + int(n // tar) - 2

print(ans)


Measured memory_bytes: 9332
#include<stdio.h>
int main(){
	int i,n;

	scanf("%d",&n);
	for(i=3;i<=n;i++){
		if(i%3==0||chk(i)){
			printf(" %d",i);
		}
	}
	printf("\n");
	return 0;
}

int chk(int num)
{
	int i;
	for(i=0;i<5;i++){
		if(num%10==3)return 1;
		num/=10;
	}
	return 0;
}

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

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


    for (int i = 0; i < N; i++){
        int X;
        cin >> X;
        if (X % 2 == 0 && (X % 3== 0 || X % 5 == 0)){
            if (i == N - 1){
                cout << "APPROVED" << endl;
            }
        }
        else if(X % 2 != 0){
            if (i == N - 1){
            cout << "APPROVED" << endl;
            }
        }
        else{  
            cout << "DENIED" <<endl;
            break;
        }
    }
         
}

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

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

void solve() 
{
    int k,sum=0;cin>>k;
    rep(i,1,k+1)rep(j,1,k+1)rep(kk,1,k+1){
        sum+=gcd(gcd(i,j),gcd(j,kk));
    }cout<<sum<<endl;
}

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

Measured memory_bytes: 3648
N = int(input())

A = list(map(int, input().split()))

total = 0
for i in range(N):
    total += A[i]

sum = 0
for i in range(N-1):
    total -= A[i]
    sum += (A[i] * total) % 1000000007
print(sum % 1000000007)


Measured memory_bytes: 105268
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//#define fr(i,j,k) for(int i=j;i<k;i++)
//#define f(n) fr(i,0,n)
//#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const ll mod = 1e9 + 7;
const int maxn = 2e5+5;
#include<atcoder/all>
using namespace atcoder;
void solve() {
    int n, d;
    cin >> n >> d;
    int x[n],y[n];
    for (int i = 0 ; i < n ; i++) {
        cin >> x[i] >> y[i];
    }
    two_sat g(n);
    for (int i = 0 ; i < n ; i++) {
        for (int j = i+1 ; j < n ; j++) {
            if (abs(x[i] - x[j]) < d) {
                g.add_clause(i,false,j,false);
            }
            if (abs(x[i] - y[j]) < d) {
                g.add_clause(i,false,j,true);
            }
            if (abs(y[i] - x[j]) < d) {
                g.add_clause(i,true,j,false);
            }
            if (abs(y[i] - y[j]) < d) {
                g.add_clause(i,true,j,true);
            }
        }
    }
    if (!g.satisfiable()) {
        cout << "No\n";
        return;
    }
    auto res = g.answer();
    cout << "Yes\n";
    for (int i = 0 ; i <n ; i++) {
        cout << (res[i] ? x[i] : y[i]) << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        solve();
    }
    
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	int ans = 0;
	string prev;
	for (int i = 0; i < (int)s.size(); i++) {
		string cur;
		cur.push_back(s[i]);
		while (prev == cur && i + 1 < (int)s.size()) {
			i++;
			cur.push_back(s[i]);
		}
		// cerr << cur << '-' << prev << '-' << (int)(cur == prev) << endl;
		if (prev != cur) {
			prev = cur;
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 720
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b and b==c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end() 
 
using namespace std;

const int INF = 1 << 25;
const int MOD = 1000000007;
 
template<class T>
void chmin (T& a, const T& b) { a = min(a, b); }
 
template<class T>
void chmax (T& a, const T& b) { a = max(a, b); }

int main() {
    int N;
    string S;
    cin >> N >> S;
    
    vector<int> count(26, 0);
    long long sum = 1;
    
    for (int i = 0; i < N; ++i) {
        count[S[i] - 'a'] += 1;
    }
    for (int i = 0; i < 26; ++i) {
        if (count[i] == 0) continue;
        sum = (sum * (count[i] + 1)) % MOD;     
    }
    sum = (sum + 1000000006) % MOD;
    cout << sum << endl;
}


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

using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  sort(h.rbegin(), h.rend());
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    if (k > 0) {
      k--;
    } else {
      ans += h[i];
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define N 200005
#define ll long long
using namespace std;
inline ll read(){
	ll ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
ll n,k;
int main(){
	n=read(),k=read();
	if(k&1){
		ll tmp=n/k;
		cout<<tmp*tmp*tmp;
	}
	else{
		ll tmp1=n/k,tmp2=tmp1;
		if(n%k>=k/2)++tmp2;
		cout<<tmp1*tmp1*tmp1+tmp2*tmp2*tmp2;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3") 

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

typedef long long int           ll;
typedef unsigned long long int  ull;
typedef long double             ld;

typedef pair<int, int>          pii;
typedef pair<ll,ll>             pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<pii>             vpii;
typedef vector<pll>             vpll;

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define maxvec(vec)             *max_element(all(vec))
#define minvec(vec)             *min_element(all(vec))
#define maxarr(arr)             *max_element(arr, arr + n)
#define minarr(arr)             *min_element(arr, arr + n)
#define deb(x)		        cout << #x << "--" << x << "--" << endl;
#define deb2(x,y)	        cout << #x << "-" << x << "-" << " ~~ " <<  #y << "-" << y << "-" << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

int fun(int x, int y, int z) 
{
	return x * x + y * y + z * z + x * y + y * z + z * x;
}

void solve() {
  int n;
  cin >> n;
  int ans[10005] = {0};
  for (int x = 1; x * x <= n; ++x) 
    for (int y = 1; x * x + y * y + x * y <= n; ++y) 
      for (int z = 1; fun(x, y, z) <= n; ++z) 
        ans[fun(x, y, z)]++;
  for (int i = 1; i <= n; ++i) 
    cout << ans[i] << endl;
}

int main()
{
    fast;
    // test(t)
        solve();
    return 0;
}


Measured memory_bytes: 3692