akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		char[] input = sc.next().toCharArray();
		for(int i=1;i<input.length;i++) {
			if(input[i]==input[i-1]) {System.out.println("Bad"); return;}
		}
		System.out.println("Good");
		
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
#define loop() for(int i=0; i<(); i++)
const int MOD=1e9+7;
int modpow(int x, int n, int m)
{
    if(n==0) return 1;
    ll ans=1;
    while(n>0)
    {
        if(n%2==1) ans=(ans*x)%m;
        x=(x*x)%m;
        n/=2;
    }
    return ans;
}

void solve()
{
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    vector<vector<ll>>dp(n,vector<ll>(n,0)),s(n,vector<ll>(n,0));
    for(int i=0; i<n; i++) s[i][i]=a[i];
    for(int i=0; i<n-1; i++)
    {
        dp[i][i+1]=a[i]+a[i+1];
        s[i][i+1]=a[i]+a[i+1];
    }
    
    for(int k=2; k<n; k++)
    {
        int i=0,j=k;
        while(j<n)
        {
            dp[i][j]=LLONG_MAX;
            s[i][j]=LLONG_MAX;
            for(int r=i; r<j; r++)
            {
                if(dp[i][r]+dp[r+1][j]+s[i][r]+s[r+1][j]<dp[i][j])
                {
                    dp[i][j]=dp[i][r]+dp[r+1][j]+s[i][r]+s[r+1][j];
                    s[i][j]=s[i][r]+s[r+1][j];
                }
            }
            i++;
            j++;
        }
    }
 cout<<dp[0][n-1]<<endl;
    
}   

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

}


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

int main() {
  //宣言
  int N;
  string ans = "Yes";
  int F = 0;
  
  //入力
  cin >> N;
  
  //処理
  int iN = N;
  while(N>0){
    F += N % 10;
    N /= 10;
  }
  if(iN % F != 0)ans = "No";
  
  //出力
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

struct P {
    int x, y, d;

    P(int x_, int y_, int d_) : x(x_), y(y_), d(d_) { }
};

int W, H;
char M[100][100];
bool N[100][100];

int G_x, G_y;

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

void solve() {
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            N[i][j] = false;
        }
    }

    G_x = 2 * (W - 1);
    G_y = 2 * (H - 1);

    queue<P> que;
    que.push(P(0, 0, 1));

    while (!que.empty()) {
        P p = que.front();
        que.pop();

        if (p.x == G_x && p.y == G_y) {
            printf("%d\n", p.d);
            return;
        }

        for (int i = 0; i < 4; i++) {
            int nx = p.x + dx[i];
            int ny = p.y + dy[i];
            int nnx = p.x + dx[i] * 2;
            int nny = p.y + dy[i] * 2;

            if (!(0 <= nx && nx <= G_x && 0 <= ny && ny <= G_y)) {
                continue;
            }

            if (M[ny][nx] == '1' || N[nny][nnx]) {
                continue;
            }

            N[nny][nnx] = true;
            que.push(P(nnx, nny, p.d + 1));
        }
    }
    printf("0\n");
}

int main() {
    char buf[100];
    while (true) {
        fgets(buf, 99, stdin);
        sscanf(buf, "%d%d ", &W, &H);
        if (W == 0) { break; }
        for (int i = 0; i < H * 2 - 1; i++) {
            fgets(M[i], 100, stdin);
        }
        solve();
    }
    return 0;
}

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

int main(){
  int n_takoyaki;
  scanf("%d", &n_takoyaki);
  
  int answer;
  int oishisa, sum_oishisa = 0, sum_pow_oishisa_self = 0;
  int i;
  for(i=0; i<n_takoyaki; i++){
    scanf("%d", &oishisa);
    sum_oishisa += oishisa;
    sum_pow_oishisa_self += oishisa*oishisa;
  }
  
  answer = ((sum_oishisa * sum_oishisa) - sum_pow_oishisa_self)/2;
  
  printf("%d", answer);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n, a[100010];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int main()
{
	n = read();
	int Mx = 0, Mn = 1e8;
	for(int i = 1; i <= n; i ++)
		a[i] = read(), Mx = max(a[i], Mx), Mn = min(a[i], Mn);
	if(Mx - Mn > 1) {cout << "No" << endl; return 0;}
	if(Mx == Mn)
	{
		if(a[1] == n - 1) {cout << "Yes" << endl; return 0;}
		if(a[1] * 2 > n) cout << "No" << endl;
		else cout << "Yes" << endl;
		return 0;
	}
	int x = 0, y = 0;
	for(int i = 1; i <= n; i ++)
		if(a[i] == Mn) x ++;
		else y ++;
    if(n - x == 1) cout << "No" << endl;
	else if(x + y / 2 < Mx || x > Mn) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


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

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

using namespace std;

template <class T>
void printv(vector<T> v)
{
  cout << '[';
  for (auto vec: v)
  {
    cout << vec << ' ';
  }
  cout << ']' << endl;
}

int main()
{
  int n, result = 0;
  cin >> n;
  vector<int> v;

  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

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

  for (int i = 0; i < n; i++)
  {
    if (i != n-1)
      result += v[i];
    else
      result += v[i] / 2;
  }

  cout << result << endl;
}


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

static const int N = 100;
#define EXTREME 10000000;
int S[N+1][N+1];
int p[N+1];

void multiply(int n){
    int i;
    for(i = 1; i <= n; i++){
        S[i][i] = 0;
    }

    for(int l = 2; l <= n; l++){
        for(int i = 1; i <= n - l + 1; i++){
            int j = i + l - 1;
            S[i][j] = EXTREME;
            for(int k = i; k <= j - 1; k++){
                S[i][j] = min(S[i][j], S[i][k] + S[k+1][j] + p[i-1]*p[k]*p[j]);
            }
        }
    }
}

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


    for(i = 1; i <= n; i++){
        cin >> p[i-1] >> p[i];

    }

    multiply(n);
    cout << S[1][n] << endl;

    return 0;
}


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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 1e5 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// 72
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];

ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

int n, m, k;

ll a[e];

int main()
{
   cin >> n;
   for(int i=1; i<=n; i++)
   {
       cin >> a[i];
   }
   ll ans = 0;
   for(int i=1; i<=n; i++)
   {
       if(a[i] == i)
       {
           swap(a[i], a[i+1]);
           i ++;
           ans ++;
       }
   }
   cout << ans;
}
/*

*/


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] a = new String[n];
        for (int i = 0;i<n;i++) {
            a[i] = sc.next();
        }
        int max = 0;
        Map<String, Integer> map = new HashMap<>();
        for (String s : a) {
            int count = map.getOrDefault(s, 0);
            ++count;
            map.put(s,count);
            max = Math.max(max, count);
        }
        List<String> l = new ArrayList<>();
        for (Map.Entry<String, Integer> e : map.entrySet()) {
            if (max == e.getValue()) l.add(e.getKey());
        }
        Collections.sort(l);
        for (String s : l) System.out.println(s);
    }
}


Measured memory_bytes: 78420
//AcFreak

#include<bits/stdc++.h>
#define lint long long int 
#define mp make_pair
#define pb push_back
#define f first
#define INF (lint )(1e9)
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s second
#define endl '\n'
#define pii pair<int,int >
using namespace std;
struct pair_hash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);
        
        return h1 ^ h2;  
    }
};

int countDivisors(int n)
{
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            // If divisors are equal,
            // count only one
            if (n / i == i)
                cnt++;
 
            else // Otherwise count both
                cnt = cnt + 2;
        }
    }
    return cnt;
}
int main()
{__
      int n;
      cin>>n;
      
      int i;
      int ans=0;
      for(i=1;i<=n;i++)
      {
            if(i% 2==0)
            continue;
            if(countDivisors(i) == 8)
            ans++;
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
    vector<vector<int>> x(n,vector<int>(3));
    for(int i=0; i<n; ++i){
        cin >> x[i][1] >> x[i][2];
        x[i][0] = x[i][2];
    }
    sort(x.begin(),x.end());
    int s=0;
    for(int i=0; i<n; ++i){
        s += x[i][1];
        if(s>x[i][2]){
            cout << "No" << endl;
            return 0;
        }
    }
	cout << "Yes" << endl;
}

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

int main(){
	double v, t, y;
	int n, h[100000];
	
	for(int i=0 ; i<100000 ; i++){
		h[i] = i*5-5;
	}

	while(cin >> v){
		t = v / 9.8;
		y = t*t*4.9;
		n = (int)( (y+5.0)/5.0 );
		for(int i=0 ; i<100000 ; i++){
			if(h[i]>=y){
				n = i;
				break;
			}
		}
		cout << n << endl;
	}
}

Measured memory_bytes: 1612
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
ll longinf=(1ll<<60);

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

vector<ll> ans;
int n;


bool is753(ll k){
    int ret=0;
    while(k>0){
        int aa=k%10;
        if(aa==3) ret|=1;
        if(aa==5) ret|=2;
        if(aa==7) ret|=4;
        k/=10;
    }
    return ret==7;
}

void dfs(ll k){
    if(k>n) return;
    else{
        if(is753(k)){
            ans.push_back(k);
        }
        dfs(10*k+3);
        dfs(10*k+5);
        dfs(10*k+7);
    }
}

int main(){
    cin>>n;
    dfs(0);
    cout<<ans.size()<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  string A,B;
  cin >> A >> B;
  if(A.size()>B.size()){
    cout << "GREATER" << endl;
    return 0;
  }
  else if(A.size()<B.size()){
    cout << "LESS" << endl;
    return 0;
  }
  else if(A.size()==B.size()){
    for(int i=0;i<A.size();++i){
      if(A.at(i)==B.at(i)) continue;
      if(A.at(i)>B.at(i)){
	cout << "GREATER" << endl;
	return 0;
      }
      else{
	cout << "LESS" << endl;
	return 0;
      }
    }
  }

  cout << "EQUAL" << endl;

  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 200000
#define f(a, b) for (int i = a; i < b; i++)
#define f0(a) for (int i=0;i<a;i++)
#define input(d) cin >> d;
#define inputs(n,d) for(int i=0;i<n;i++){cin >> d[i];}
#define output(d) cout << d << endl;
#define outputs(n,d) for(int i=0;i<n;i++){cout << d[i] << endl;}

int main(void) {
	int n;
	input(n);
	if (n >= 30) {
		output("Yes")
	}
	else {
		output("No")
	}
	return 0;
}

Measured memory_bytes: 3640
from collections import deque
S=deque(list(input()))
Q=int(input())
count=0
for i in range(Q):
  A=list(input().split())
  if A[0]=="1":
    count=(count+1)%2
  else:
    if A[1]=="1":
      if count==0:
        S.appendleft(A[2])
      else:
        S.append(A[2])
    else:
      if count==0:
        S.append(A[2])
      else:
        S.appendleft(A[2])
if count==1:
  S.reverse()
ans="".join(S)
print(ans)

Measured memory_bytes: 8676
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
#define ALL(v) (v).begin(), (v).end()
const int mod = INF+7;
using namespace std;

bool dfs(int *alpha, int a, int b){
  if(alpha[a]==b){
    return true;
  }
}

int main(){
  string S,T;
  cin >> S;
  cin >> T;
  int N=S.length();

  int *alphaS=(int *)malloc(sizeof(int)*26);
  int *alphaT=(int *)malloc(sizeof(int)*26);
  rep(i,26){
    alphaS[i]=-1;
    alphaT[i]=-1;
  }
  bool flag=true;
  rep(i,N){
    if(alphaS[S[i]-'a']==-1){
      alphaS[S[i]-'a']=T[i]-'a';
    }
    else if(alphaS[S[i]-'a']!=-1 && alphaS[S[i]-'a']!=T[i]-'a'){
      flag=false;
      break;
    }
    if(alphaT[T[i]-'a']==-1){
      alphaT[T[i]-'a']=S[i]-'a';
    }
    else if(alphaT[T[i]-'a']!=-1 && alphaT[T[i]-'a']!=S[i]-'a'){
      flag=false;
      break;
    }
  }


  if(flag==false){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  // else{
  //   int *count=(int *)calloc(26,sizeof(int));
  //   rep(i,26){
  //     if(alpha[i]!=-1){
  //       count[alpha[i]]++;
  //     }
  //   }
  //   flag=true;
  //   rep(i,26){
  //     if(count[i]>=2){
  //       flag=false;
  //       break;
  //     }
  //   }
  //   if(flag==false){
  //     printf("No\n");
  //   }
  //   else{
  //     printf("Yes\n");
  //   }
  // }
}


Measured memory_bytes: 776
#include <iostream>

using namespace std;

int main()
{
  int count = 0;
  string s;
  getline(cin, s);
  for (int i = 0; i < s.size() / 2; i++)
  {
    if (s[i] != s[s.size() - 1 - i])
      count++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  double d, e;
  
  cin >> a >> b;
  c = (a + b) / 2.0;
  d = (a + b) / 2.0;
  e = d - c;
  if (e > 0) {
    c += 1;
  } 
  cout << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

int main(){
   int ans;
   int D,N;
   cin >>D>>N;
   int a=pow(100,D);

   if(N==100){      
      ans=101*a;
   }
   else{
      ans=N*a;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 998244353
//#define mod2 20071027
//#define MOD 998244353
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=110, M=1000005;
ll n, a[N];
vector<pair<ll, ll>>edge;
bool ok(ll s)
{
    memz(a);
    edge.clear();
//    cout<<"s "<<s<<endl;
    for(ll i=n;i>=1;i--)
    {
        ll baki=s-a[i],doom=0;
//        cout<<"baki1 "<<baki<<endl;
        if(baki<0) return 0;
        vector<ll>v;
        for(ll j=1;baki>0 && j<i;j++)
        {
            if(baki>=j)
            {
                baki-=j;
                v.pb(j);
            }
            else
            {
                ll d = j-baki;
                doom = d;
                baki=0;
                v.pb(j);
                break;
            }
        }
//        cout<<"baki2 "<<baki<<endl;
        if(baki!=0) return 0;
        for(auto u:v)
        {
            if(u!=doom)
            {
                a[u]+=i;
                a[i]+=u;
                edge.pb({i,u});
            }
        }
    }
    return 1;
}
int main()
{

    in1(n);
    ll l = n, r = (n*(n-1))/2,f=0;
    for(ll s=r; s>=l;s--)
    {
        if(ok(s))
        {
            printf("%lld\n", (ll)edge.size());
            for(auto u:edge)
            {
                printf("%lld %lld\n", u.first, u.second);
            }
            return 0;
        }
    }
    return 0;
}
/*

*/


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

#define rep(i,n)  for(int i=0;i<n;++i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)

int isp(int x) {
    if (x==2) {
        return 1;
    } else if (x%2==0) {
        return 0;
    }
    int i=3;
    while (i*i<=x) {
        if (x%i==0) return 0;
        i+=2;
    }
    return 1;
}

int main(){
    int mod=1000000007;
    int n,ans=0;
    sc1(n);
    rep(i,n) {
        int x;
        sc1(x);
        ans+=isp(x);
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 3216
s=input()
#print(s)
length=len(s)

flag1=0
flag2=0
for i in range(length):
  if s[i]=='A' and flag1==0:
    start=i
    flag1=1
#print(start)

for j in range(-1,start-length,-1):
  if s[j]=='Z' and flag2==0:
    end=j
    flag2=1
    
print(length-start+end+1)

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
vector<int> contact[300000];
int cnt1[100010];
int cnt2[100010];
bool u[100010]={false};
void dfs(int i,int father,bool is_Fennec)
{
	u[i]=true;
	for(int k=0;k<contact[i].size();k++)
	{
		if(is_Fennec==true)
		{
			cnt1[i]=father+1;
		}
		else
		{
			cnt2[i]=father+1;
		} 
		if(!u[contact[i][k]])
		{
			dfs(contact[i][k],father+1,is_Fennec);
		}
	}
	return;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		contact[a].push_back(b);
		contact[b].push_back(a);
	}
	/*cout<<endl;
	for(int j=1;j<=n;j++)
	{
		cout<<j<<':';
		for(int k=0;k<contact[j].size();k++)
		{
			cout<<contact[j][k]<<",";
		}
		cout<<endl;
	}
	cout<<endl;*/
	dfs(1,-1,true);
	memset(u,false,sizeof(u));
	dfs(n,-1,false);
	int f=0,s=0; 
	for(int j=1;j<=n;j++)
	{
		if(cnt1[j]<=cnt2[j])
		{
			f++;
		}
		else 
		{
			s++;
		}
	}
	if(f>s)
	{
		cout<<"Fennec";
	}
	else
	{
		cout<<"Snuke";
	}
	return 0;
}

Measured memory_bytes: 19200
#include <iostream>
#include <algorithm>
using namespace std;
int main (void) {
    int N;
    int L;

    cin >> N >> L;
    string S[N];
    for (int i = 0; i < N; i++) cin >> S[i];

    sort(S, S + N);
    
    for (int i = 0; i < N; i++) cout << S[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n, k = map(int, input().split())
    lst = list(map(int, input().split()))

    while True:
        flag = True
        for char in str(n):
            if int(char) in lst:
                flag = False
                break
        if flag:
            break
        n += 1
    print(n)


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  string s;
  string str = "CODEFESTIVAL2016";

  cin >> s;

  int sum = 0;
  while (s.size() != 0) {
    if (s.back() != str.back()) sum += 1;
    s.pop_back();
    str.pop_back();
  }

  printf("%d\n",sum);
}


Measured memory_bytes: 256
c = [input().split() for i in range(3)]
for i in range(3):
    for j in range(3):
        c[i][j] = int(c[i][j])
for i in range(100):
    for j in range(100):
        if i + j == c[0][0]:
            a0, b0 = i, j
            a1, b1 = c[1][0]-b0, c[0][1]-a0
            a2, b2 = c[2][0]-b0, c[0][2]-a0
            if (a1+b1 == c[1][1])and(a1+b2==c[1][2])and(a2+b1==c[2][1])and(a2+b2==c[2][2]):
                print("Yes")
                exit()
print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll MOD=998244353;
const int MAX=200010;

signed main(){
    ll r,c;cin>>r>>c;
    ll n;cin>>n;
    vector<pll>D(0),R(0),U(0),L(0);
    rep(i,n){
        ll x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
        if((x1==0||x1==r||y1==0||y1==c)&&(x2==0||x2==r||y2==0||y2==c)){
            if(x1==0){
                if(y1<c){
                    L.pb(mp(y1,i));
                }
            }
            if(x1==r){
                if(y1>0){
                    R.pb(mp(y1,i));
                }
            }
            if(y1==0){
                if(x1>0){
                    D.pb(mp(x1,i));
                }
            }
            if(y1==c){
                if(x1<r){
                    U.pb(mp(x1,i));
                }
            }
            x1=x2,y1=y2;
            if(x1==0){
                if(y1<c){
                    L.pb(mp(y1,i));
                }
            }
            if(x1==r){
                if(y1>0){
                    R.pb(mp(y1,i));
                }
            }
            if(y1==0){
                if(x1>0){
                    D.pb(mp(x1,i));
                }
            }
            if(y1==c){
                if(x1<r){
                    U.pb(mp(x1,i));
                }
            }
        }
    }
    sort(all(L)),sort(all(U)),sort(rall(R)),sort(rall(D));
    vector<ll>s(0);
    rep(i,L.size()){
        s.pb(L[i].se);
    }
    rep(i,U.size()){
        s.pb(U[i].se);
    }
    rep(i,R.size()){
        s.pb(R[i].se);
    }
    rep(i,D.size()){
        s.pb(D[i].se);
    }
    stack<ll>st;
    bool f=1;
    rep(i,s.size()){
        if(st.empty()){
            st.push(s[i]);
        }else{
            ll k=st.top();
            st.pop();
            if(k!=s[i]){
                st.push(k);
                st.push(s[i]);
            }else{
                continue;
            }
        }
    }
    if(!st.empty())f=0;
    if(f){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 10196
#include <stdio.h>

int main(){
	long long H,W;
	long long H1,H2;
	long long W1,W2;
	long long ans;
	
	scanf("%lld %lld",&H,&W);
	
	if(H==1){
		printf("1");
		return 0;
	}
	if(W==1){
		printf("1");
		return 0;
	}
		
	if(H%2==0){
		if(W%2==0){
			printf("%lld",H*W/2);
		}
		if(W%2!=0){
			W1=W/2;
			W2=W-W1;
			ans = W1*H/2+W2*H/2;
			printf("%lld",ans);
		}
	}
	if(H%2!=0){
		if(W%2==0){
			H1=H/2;
			H2=H-H1;
			ans = H1*W/2+H2*W/2;
			printf("%lld",ans);
		}
		if(W%2!=0){
			H1=H/2;//白
			H2=H-H1;
			W1=W/2;//白
			W2=W-W1;
			ans = H2*W2+H1*W1;
			printf("%lld",ans);
		}
	}
	
	
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        String S = sc.next();

        System.out.println(solve(A, B, S) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(int A, int B, String S) {
        return IntStream.range(0, S.length())
                .allMatch(i -> (i == A) ? (S.charAt(i) == '-') : Character.isDigit(S.charAt(i)));
    }
}

Measured memory_bytes: 28884
//g++でビルド

#include "bits/stdc++.h"

using namespace std;


int main(){
    string S;
    cin >> S;
    long result = 0;
    int size = S.size() - 1;
    for(int bit = 0; bit < (1<<size); ++bit){
        int start = 0;
        int count = 1;
        for(int i = 0; i < size; ++i){
            if(bit & (1<<i)){
                string s = S.substr(start, count);
                result += stol(s);
                start = start + count;
                count = 1;
            }else{
                count++;
            }
        }
        string s = S.substr(start, S.size() - start);
        result += stol(s);
    }
        

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[9] = { 0, 0,0,1,1,1,-1,-1,-1 };
int dyy[9] = { 0, 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

long long power_mod(long long x, long long n, long long m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return power_mod(x * x % m, n / 2, m);
	else
		return x * power_mod(x, n - 1, m) % m;
}

long long power(long long a, long long n) {//aのn乗を計算します。
	long long x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}



long long nCr(long long n, long long r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	long long i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}



const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += power(10, n - i - 1)*(ll)(s[i] - '0');
	}
	return ans;
}



int main() {
	ll K, A, B;
	cin >> K >> A >> B;
	ll ans;
	if (A + 2 <= B) {
		ll c = (K + 1 - A) / 2;
		if ((K + 1 - A) % 2 == 0) {
			ans = A+(B-A)*c;
		}
		else ans = A+(B-A)*c+1;
	}
	else ans = K + 1;
	print(ans);
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	string s, t;
	cin >> s >> t;
	t.resize(s.size());
	if (s == t)cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007
#define MAXS(x,y) (x = max(x,y))
#define MINS(x,y) (x = min(x,y))

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

vector<int> pre, in, post;

int N;
int pos = 0;

void rec(int l, int r){
  if(l>=r)return;

  int root = pre[pos];
  pos++;
  int m = distance(in.begin(), find(in.begin(),in.end(), root));

  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}

int main(){
  cin >> N;

  pre.resize(N);
  in.resize(N);
  post.resize(0);

  REP(i,N)cin >> pre[i];
  REP(i,N)cin >> in[i];

  rec(0,N);

  REP(i,N){
    if(i!=0){
      cout << " ";
    }
    cout << post[i];
  }
  cout << endl;
}


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

using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(n, vector<int>(2));
    for (int i = 0; i < n; i++)cin >> v[i][1] >> v[i][0];
    vector<int> c(m);
    for (int i = 0; i < m; i++)cin >> c[i];

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());

    int ret = 0;
    for (int i = 0; i < n; i++) {
        if (v[i][1] <= c[ret])ret++;
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 8692
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val H, W = in.next().toInt
  val S = new Array[String](H+1)
  for (i <- 1 to H)
    S(i) = "N" + in.next()


  //
  type Coord = (Int, Int)

  val dp = Array.ofDim[Boolean](H+1, W+1)

  def inField(p: Coord): Boolean = {
    val (x, y) = p
    1 <= x && x <= W && 1 <= y && y <= H
  }

  def mk4dir(p: Coord): List[Coord] = {
    val (x, y) = p
    List((x-1, y), (x+1, y), (x, y-1), (x, y+1)).filter(inField)
  }

  def calc(p: Coord): (Int, Int) = {
    var B = 0
    var W = 0

    val stack = new scala.collection.mutable.Stack[(Coord, Char)]
    stack.push((p, 'N'))

    while(!stack.isEmpty) {
      val (p, pre) = stack.pop()

      val (x, y) = p

      if (dp(y)(x))
        ()
      else {
        if (S(y)(x) != pre) {
          dp(y)(x) = true
          if (S(y)(x) == '#')
            B += 1
          else
            W += 1

          mk4dir(p).foreach(p => stack.push((p, S(y)(x))))
        }
      }
    }

    (B, W)
  }

  var ans = 0L
  for (y <- 1 to H)
    for(x <- 1 to W) {
      if (!dp(y)(x) && S(y)(x) == '#') {
        val (b, w) = calc((x, y))

        ans += b.toLong * w
      }
    }

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 113208
<?php
list($n) = ints();
$a = ints();
$ans = PHP_INT_MAX;
for ($i = -100; $i <= 100; ++$i) {
    $c = 0;
    for ($j = 0; $j < $n; ++$j) {
        $c += pow($i - $a[$j], 2);
    }
    $ans = min($ans, $c);
}
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        long N, A, B;

        void solve(InputReader in, PrintWriter out) {
            N = in.nextLong();
            A = in.nextLong();
            B = in.nextLong();
            if (A > B) {
                out.println(0);
            } else if (A < B && N < 2) {
                out.println(0);
            } else {
                out.println((A + B*(N - 1)) - (A*(N - 1) + B) + 1);
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        long nextLong() { return Long.parseLong(next()); }

        int[] nextIntArray(int n) {
        	int[] arr = new int[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextInt();
        	}
        	return arr;
        }

        long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; ++i) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 20948
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



const int NUM = 300000;
bool IsPrime[NUM];

void Era(int n) {
	for (int i = 2; i < NUM; ++i) {
        IsPrime[i] = true;
    }
	for (int i = 2; i <= n; ++i) {
		if (IsPrime[i]) {
			for (int j = i*2; j <= n; j += i) IsPrime[j] = false;
		}
	}
}

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
	int n;
	Era(250000);

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

		int res = 0;
		for (int i = n+1; i <= 2*n; ++i) {
			if (IsPrime[i]) ++res;
		}
    
		cout << res << endl;
	}
    
    return 0;
}


Measured memory_bytes: 1452
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())

    res = set()
    for _ in range(K):
        _ = int(input())
        A = list(map(int, input().split()))
        for a in A:
            res.add(a)

    ans = 0
    for i in range(1, N + 1):
        if i not in res:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68872
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int A,B,C,K;

    cin >> A >> B >> C >> K;

    int m = max({A,B,C});
    int t = m;

    for(int i = 0; i < K; i++){
        m = 2*m;
    }

    cout << A + B + C + m - t << endl;

    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s[2] == s[3] and s[4] == s[5]) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    int index = -1;
    REP(i, n) {
        if (s.substr(i, n - i) == t.substr(0, n - i)) {
            index = i;
            break ;
        }
    }

    if (index == -1) cout << s.size() + t.size() << '\n';
    else cout << n + index << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
 
		long a = 2;
		long b = 1;
		long ans = 1;
 
		if(n == 1){
			System.out.println(1);
			return;
		}
 
		for(int i = 1; i < n; i++){
			ans = a+b;
			a = b;
			b = ans;
		}
		System.out.println(ans);
	}
}

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

int main(){
    cout << fixed << setprecision(5);
    double n,s;
    cin >> n;
    while(n != 0){
    double sum = 0,psum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        sum += s;
        psum += s*s;
    }
    cout << sqrt(psum/n - sum*sum/n/n) << endl;
    cin >> n;
    }
    return 0;
}


Measured memory_bytes: 3284
N = int(input())
S = input()
 
cnt = S[1:].count("E")
ans = cnt
for i in range(1, N):
    if S[i-1] == "W":
        cnt += 1
    if S[i] == "E":
        cnt -= 1
    ans = min(ans, cnt)
 
print(ans)

Measured memory_bytes: 3672
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a > k:
    print(":(")
elif d - a > k or e - b > k:
    print(":(")
elif c - a > k or d - b > k or e - c > k:
    print(":(")
elif b - a > k or c - b > k or d - c > k or e - d > k:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 38452
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <algorithm>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...)  printf("D(L%d) %s: ", __LINE__, __func__); printf(__VA_ARGS__)
#else
#define DPRINTF(...)
#endif // DEBUG

void mySort(int *array, int start, int end);

int main()
{
  const int MAX_S = 10000;
  const int MAX_T = 500;
  int numOfS, numOfT;
  int s[MAX_S], t[MAX_T];

  cin >> numOfS; cin.ignore();
  for (int i = 0; i < numOfS; i++) {
    cin >> s[i];
  }

  cin >> numOfT; cin.ignore();
  for (int i = 0; i < numOfT; i++) {
    cin >> t[i];
  }

#if DEBUG
  DPRINTF("ARRAY S :");
  for (int i = 0; i < numOfS; i++)
    cout << " " << s[i];
  cout << endl;

  DPRINTF("ARRAY T :");
  for (int i = 0; i < numOfT; i++)
    cout << " " << t[i];
  cout << endl;
#endif

  if (0) {
    sort(s, s + numOfS);
    sort(t, t + numOfT);
  } else {
    mySort(s, 0, numOfS - 1);
    mySort(t, 0, numOfT - 1);
  }

#if DEBUG
  DPRINTF("ARRAY S :");
  for (int i = 0; i < numOfS; i++)
    cout << " " << s[i];
  cout << endl;

  DPRINTF("ARRAY T :");
  for (int i = 0; i < numOfT; i++)
    cout << " " << t[i];
  cout << endl;
#endif

  int cnt = 0;
  int i = 0, j = 0;
  while (i < numOfS && j < numOfT)
  {
    if (s[i] == t[j])
    {
      DPRINTF("MATCH : %d\n", s[i]);
      cnt++;
      i++;
      j++;
    }
    else if (s[i] > t[j])
    {
      j++;
    }
    else // s[i] < t[j]
    {
      i++;
    }
  }

  cout << cnt << endl;

  return 0;
}

void mySort(int *array, int start, int end)
{ // quick sort
  if (start >= end)
    return;

  DPRINTF("START %d  END %d\n", start, end);
  int mid = (start + end) / 2;
  int pivot = array[mid];
  int left = start, right = end;

  while (left <= right)
  {
    while (array[left] < pivot) left++;
    while (array[right] > pivot) right--;

    if (left <= right)
    {
      int temp = array[left];
      array[left] = array[right];
      array[right] = temp;
      left++, right--;
    }
  }

#if DEBUG
  DPRINTF("ARRAY ");
  for (int i = start; i < end; i++)
    cout << " " << array[i];
  cout << endl;
#endif

  mySort(array, start, left - 1);
  mySort(array, left, end);

  return ;
}


Measured memory_bytes: 3128
#include <iostream>
using namespace std;
int main(void){
    int n,m,i,j,c;
    int a[100][100],b[100];
    
    cin >> n >> m;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(i=0;i<m;i++) cin >> b[i];
    
    for(i=0;i<n;i++){
        c=0;
        for(j=0;j<m;j++){
            c+=a[i][j]*b[j];
        }
        cout << c << endl;
    }
    
}



Measured memory_bytes: 3144
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define PI 3.1415926535897
#define MEMS(a,b) memset(a,b,sizeof(a))
#define LL long long
#define U unsigned

int a[100100];
int dif[100100];

int main()
{
#ifdef Fcdkbear
	freopen("in.txt", "r", stdin);
	double beg = clock();
	//freopen("out.txt", "w", stdout);
#endif

	int n;
	scanf("%d",&n);
	LL sum = 0;
	FOR(i,0,n) {
		scanf("%d",&a[i]);
		sum += a[i];
	}
	if ((sum + sum) % (n * 1ll * (n + 1)) > 0) {
		printf("NO\n");
		return 0;
	}
	if (n == 1) {
		printf("YES\n");
		return 0;
	}
	LL k = (sum + sum) / (n * 1ll * (n + 1));
	LL tot = 0;
	FOR(i,0,n-1) {
		dif[i] = a[i + 1] - a[i];
		dif[i] -= k;
		if (dif[i] < 0) {
			dif[i] = - dif[i];
			if (dif[i] % n) {
				printf("NO\n");
				return 0;
			}
			dif[i] = 0;
			tot += dif[i] / n;
		} else if (dif[i] > 0) {
			printf("NO\n");
			return 0;
		}
	}
	if (tot <= k) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

#ifdef Fcdkbear
	double end = clock();
	fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  REP(i, R) {
    cin >> r[i];
    r[i]--;
  }
  sort(all(r));
  vector<vector<int>> d(N, vector<int>(N, 1e9));
  REP(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  int ans = 1e18;
  REP(k, N) REP(i, N) REP(j, N) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
  do {
    int tmp = 0;
    REP(i, R - 1) { tmp += d[r[i]][r[i + 1]]; }
    ans = min(ans, tmp);
  } while(next_permutation(all(r)));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
n,k=map(int,input().split())
a=list(map(int,input().split()))

for i in range(n):
    a[i]-=1

#print(a)

ever=[False]*n

ever[0]=True

now=0
saisho=[0]
for i in range(n):
    now=a[now]
    if(not ever[now]):
        saisho.append(now)
        ever[now]=True
    else:
        break

#print(saisho)

roop=[]

roop.append(a[saisho[-1]])
now=roop[0]
for i in range(n):
    now=a[now]
    if(now!=roop[0]):
        roop.append(now)
    else:
        break

#print(roop)

s=len(saisho)
r=len(roop)

if(k<s):
    print(saisho[k]+1)
else:
    nokori=k-s
    nokori%=r
    print(roop[nokori]+1)


Measured memory_bytes: 32400
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	string S;
	cin >> S;

	cout << 700 + count(S.begin(), S.end(), 'o') * 100 << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

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

  ll result=0;
  rep(i, 10)rep(j,10)rep(k, 10){
    int d = 0;
    rep(l, s.size()){
      if(d==2 && (int)(s[l]-'0')==k)d++;
      if(d==1 && (int)(s[l]-'0')==j)d++;
      if(d==0 && (int)(s[l]-'0')==i)d++;
    }
    if(d==3)result++;
  }

  cout<<result;

  return 0;
}

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

int search(int a[], int n, int k) {
    int count = 0;
    int l = 0, r = n - 1;
    while (l <= r) {
        count++;
        int m = (l + r) / 2;
        if (a[m] < k) l = m + 1;
        else if (a[m] > k) r = m - 1;
        else return count;
    }
    return count;
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (!n) return 0;
        int a[n];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int k;
        cin >> k;
        cout << search(a, n, k) << endl;
    }
}

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


int main() {
    cout << fixed << setprecision(12);
    int N,K;
    int a;
    cin>>N>>K;
    double sum =0;
    double ans;
    for(int i=1;i<=N;i++){
        int count =0;
        if(i==K){
            a =i;
            break;
        }
        int b =i;
        while(b<K){
            b*=2;
            count++;
        }
        sum +=pow(0.5,count);
    }
    if(N<K) ans = sum/N;
    else  ans = (sum +N-a+1)/N;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque

K = int(input())

lunlun = []

q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

while len(lunlun) <= K:
    # print(q)
    old = q.popleft()
    lunlun.append(old)
    last = old % 10
    if last - 1 >= 0:
        q.append(old * 10 + last - 1)
    q.append(old * 10 + last)
    if last + 1 <= 9:
        q.append(old * 10 + last + 1)

# print(lunlun)
print(lunlun[K - 1])

Measured memory_bytes: 16036