akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N;
vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  ll n;
  cin >> n;
  map<string, int> m;
  rep(i, n) {
    string s;
    cin >> s;
    m[s]++;
  }

  int maxv = 0;

  for(auto a: m) maxv=max(maxv, a.second);
  for(auto a: m) {
    if (a.second == maxv) {
      cout << a.first << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if (a * b % 2 == 1){
    cout << "Odd" << endl;
  }else if(a * b % 2 == 0){
    cout << "Even" << endl;
  }
}

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

int main(){    
    //grafo bebe
    int matriz[4][4]; 
    memset(matriz, 0, sizeof(matriz));
    
    for(int i = 0; i < 3; i++){
        int peso;
        cin>>peso;
        
        if(i == 0){
            matriz[1][2] = peso;
            matriz[2][1] = peso;
        }else if(i == 1){
            matriz[1][3] = peso;
            matriz[3][1] = peso;
        }else{
            matriz[2][3] = peso;
            matriz[3][2] = peso;
        }
    }
    
    int aux = 0;
    int minimo = 1e6;
    
     for(int i = 1; i <= 3; i++){
         aux = 0;
        for(int j = 1; j <= 3; j++){
            aux += matriz[i][j];
        
        }
        if(aux < minimo){
            minimo = aux; 
        }
    }
    
    cout <<minimo;
    
    
    return 0;
}


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

if N == 10**5:
    print(90909)
elif N >= 10**4:
    print(9+len(range(10**2, 10**3))+len(range(10**4, N+1)))
elif N >= 10**3:
    print(9+len(range(10**2, 10**3)))
elif N >= 10**2:
    print(9+len(range(10**2, N+1)))
elif N >= 10:
    print(9)
elif N >= 1:
    print(N)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int x[n], y[n];
    for (int i=0; i<n; i++) cin>>x[i];
    for (int i=0; i<n; i++) y[i]=x[i];
    sort(y,y+n);
    int m=y[n/2];
    for (int i=0; i<n; i++)
    {
        if (x[i]<m) cout<<m<<endl;
        if (x[i]>=m) cout<<y[(n-1)/2]<<endl;
    }
  return 0;
}





Measured memory_bytes: 3712
'use strict';
// const p = s => console.log(s);

// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  let tmp = input[0].split(" ");
  let test;

  let A = [];
  for (let i= 0; i < tmp.length; i++) {
    A.push(parseInt(tmp[i],10));
  }
  test = A[0];
  A[0] = A[1];
  A[1] = test;

  test = A[0];
  A[0] = A[2];
  A[2] = test;
  console.log(A[0] + " " + A[1] + " " + A[2]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,ans=0,g=0;
	cin>>n;
	vi v(n),sufx(n),pfx(n);
	for(int i=0;i<n;++i){
		cin>>v[i];
	}
	for(int i=0;i<n;++i){
		g = __gcd(g,v[i]);
		pfx[i] = g;
	}
	g=0;
	for(int i=n-1;i>=0;--i){
		g = __gcd(g,v[i]);
		sufx[i]=g;
	}
	for(int i=0;i<n;++i){
		int now = 0;
		if(i>0) now = __gcd(now,pfx[i-1]);
		if(i+1 < n) now = __gcd(now,sufx[i+1]);
		ans=max(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main()
{
    int s;
    int black_head;
    int white_head;

    black_head = 0;
    white_head = 0;
    while(1) {
        //  - -
        // '0101' white_head
        // '1010' black_head
        s = getchar();
        if(s != '0' && s != '1') {
            break;
        }
        if(s == '0') {
            black_head += 1;
        } else {
            white_head += 1;
        }

        //   - -
        // '0101' white_head
        // '1010' black_head
        s = getchar();
        if(s != '0' && s != '1') {
            break;
        }
        if(s == '0') {
            white_head += 1;
        } else {
            black_head += 1;
        }
    }

    if(black_head <= white_head) {
        printf("%d\n", black_head);
    } else {
        printf("%d\n", white_head);
    }

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
int main(){
    int N;
    int A[100]={};
    int M;
    int B[100]={};
    int i;
    
    scanf("%d",&N);
    for(i=0;i<N;i++){
       scanf("%d", &A[i]);
    }
    scanf("%d",&M);
    for(i=0;i<M;i++){
       scanf("%d", &B[i]);
    }
   for(i=0;i<M;i++){
      if( (A[B[i]-1]!=2019)&&((A[B[i]-1]+1)!=A[B[i]])){
          A[B[i]-1]++;
      }
   }
      for(i=0;i<N;i++){
      printf("%d\n", A[i]);
      }
  
    return 0;
    
}


Measured memory_bytes: 2108
n = input()
if len(n) == 1:
    print(n)
elif len(n) == 2:
    print(9)
elif len(n) == 3:
    print(9 + int(n) - 99)
elif len(n) == 4:
    print(9 + 900)
elif len(n) == 5:
    print(9 + 900 + int(n) - 9999)
elif len(n) == 6:
    print(9 + 900 + 90000)

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

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

using namespace std;

const int K = 1e5 + 5;

int r[K];

void _smooth(int& n, int x) {
    if (n < 0) n = 0;
    if (n > x) n = x;
}

int main() {
    int x, k;
    scanf("%d %d", &x, &k);
    for (int i = 1; i <= k; ++i) {
        scanf("%d", r + i);
    }

    int q;
    scanf("%d", &q);
    int i = 1;
    int mx = x, mn = 0, h = 0;
    int f = -1;
    auto smooth = [=](int& n) { return _smooth(n, x); };
    while (q--) {
        int t, a;
        scanf("%d %d", &t, &a);
        for (; i <= k && r[i] < t; ++i) {
            int v = (r[i] - r[i - 1]) * f;
            mx += v; mn += v; h += v;
            smooth(mx); smooth(mn);
            f = -f;
        }
        a += h;
        if (a < mn) a = mn;
        if (a > mx) a = mx;
        a += f * (t - r[i - 1]);
        smooth(a);
        printf("%d\n", a);
    }

    return 0;
}

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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i, n) { cin >> a.at(i); }
  sort(all(a));
  int high = 0;
  rep(i, n) {
    int x, y;
    x = a.at(i);
    if (i == n - 1) {
      y = a.at(0);
    } else {
      y = a.at(i + 1);
    }
    high = max((y - x + k) % k, high);
  }
  cout << k - high << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010;
typedef long long LL;
LL sta[maxn],a[maxn],t[maxn],s[maxn];
int find(LL k,int r){
	int l=1,ANS=0;
	while(l<=r){
		int mid=(l+r)>>1;
		if(a[mid]<=k)ANS=mid,l=mid+1;
		else r=mid-1;
	}
	return ANS;
}
int n,m;
int top;
int main(){
	scanf("%d%d",&n,&m);
	sta[top=1]=n;
	for(int i=1;i<=m;++i){
		LL x;
		scanf("%lld",&x);
		while(sta[top]>=x)--top;
		sta[++top]=x;
	}
	m=top;
	for(int i=1;i<=m;++i)a[i]=sta[i];
	t[m]=1;
	for(int i=m;i>=1;--i){
		LL k=a[i];int p=find(k,i-1);
		while(p){
			t[p]+=t[i]*(k/a[p]);
			k%=a[p];
			p=find(k,p-1);
		}
		s[1]+=t[i];s[k+1]-=t[i];
	}
	LL ans=0;
	for(int i=1;i<=n;++i){ans+=s[i];printf("%lld\n",ans);}
	return 0;
}

Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int x,y,s;
  
  while(cin>>x>>y>>s,x,y,s){
    int m1=1;
    int m2=s-1;
    int ms1,ms2;
    int max=0;
    int total=0;

    while((s/2+1)!=m1){
      if((m1*100)%(100+x)==0)
	ms1=m1*100/(100+x);
      else
	ms1=m1*100/(100+x)+1;
      
      if((m2*100)%(100+x)==0)
	ms2=m2*100/(100+x);
      else
	ms2=m2*100/(100+x)+1;

      if((ms1*(100+x)/100 + ms2*(100+x)/100)==s){
	
	total=ms1*(100+y)/100 + ms2*(100+y)/100;
	
	if(max<total)
	  max=total;
      }
      m1++;
      m2--;
    }  
      cout<<max<<endl;
  }
}
    

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;


int main(){

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if(k <= a){
        cout << k << endl;
    }
    else if(k <= a + b){
        cout << a  << endl;
    }
    else{
        cout << a - (k - (a + b )) << endl;
    }

    return 0;

    return 0;
}

Measured memory_bytes: 3620
#!/usr/bin/env python
# coding: utf-8

# In[8]:


from bisect import bisect_left,bisect


# In[6]:


N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))


# In[9]:


ans = 0
for b in B:
    i = bisect_left(A,b)
    j = bisect(C,b)
    ans += i*(N-j)
print(ans)


# In[ ]:






Measured memory_bytes: 101820
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long c=sqrt(n);
    for(int i=c;i>=1;--i){
        if(n%i==0){
            cout<<(i+n/i-2)<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<int(n);i++)
using namespace std;
int main(){
    int x1, x2, y1, y2;
    cin >> x1 >>y1>>x2>>y2;
/*
    int l=sqrt(pow(x1-x2, 2)+pow(y1-y2, 2));
    int x4=x1+(y1-y2);
    int y4=y1+(x1-x2);
    int x3=x4+(y4-y1);
    int y3=y4+(x4-x1);
*/
    int dx=x2-x1;
    int dy = y2-y1;
    int x3=x2-dy;
    int y3=y2+dx;
    int x4=x1-dy;
    int y4=y1+dx;
    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
a = ['#']*(W+2)
for i in range(H): a += [x for x in '#'+input()+'#']
a += ['#']*(W+2)
for i in range(0, (W+2)*(H+2), W+2):
    print(''.join(a[i:i+W+2]))


Measured memory_bytes: 9212
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    int cnt = 0;
    vvint dis(h,vint(w,INF));
    REP(i,h){
        string s;
        cin >> s;
        REP(j,w){
            if(s[j]=='#'){
                dis[i][j]=-1;
                cnt++;
            }else{
                dis[i][j]=INF;
            }
        }
    }
    queue<pair<int,int> > q;
    dis[0][0] = 0;
    q.push(make_pair(0,0));
    while(!q.empty()){
        auto now = q.front();
        q.pop();
        REP(i,4){
            int nx = now.fi+dx[i];
            int ny = now.se+dy[i];
            if(nx<0||nx>=h||ny<0||ny>=w) continue;
            if(dis[nx][ny]==-1) continue;
            if(dis[nx][ny]>dis[now.fi][now.se]+1){
                dis[nx][ny]=dis[now.fi][now.se]+1;
                q.push(make_pair(nx,ny));
            }
        }
    }
    if(dis[h-1][w-1]==INF){
        cout << -1 << endl;
    }else{
        int ans = h*w - dis[h-1][w-1] - cnt - 1;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long ll;

const ll INF = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 55;
const int MAXM = 205;

int n,m,S,len;
int head[MAXN],in[MAXN][MAXN * MAXN];
ll dis[MAXN][MAXN * MAXN],c[MAXN],d[MAXN];
queue<pair<int,ll> > q;

struct Edge{
	int to,next;
	ll a,b;
} e[MAXM];

void add(int u,int v,ll a,ll b){
	e[++len].to = v;
	e[len].next = head[u];
	e[len].a = a;
	e[len].b = b;
	head[u] = len;
}

void spfa(){
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= 2500;j++)
			dis[i][j] = INF;
	}
	dis[1][S] = 0;
	q.push(make_pair(1,S));
	while(!q.empty()){
		int u = q.front().first;
		ll w = q.front().second;
		q.pop();
		in[u][w] = 0;
		for(int i = head[u];i != -1;i = e[i].next){
			int v = e[i].to;
			ll a = e[i].a,b = e[i].b;
			if(w >= a && dis[v][w - a] > dis[u][w] + b){
				dis[v][w - a] = dis[u][w] + b;
				if(!in[v][w - a])
					q.push(make_pair(v,w - a));
			}
		}
		int t = min(w + c[u],2500ll);
		if(dis[u][t] > dis[u][w] + d[u]){
			dis[u][t] = dis[u][w] + d[u];
			if(!in[u][t])
				q.push(make_pair(u,t));
		}
	}
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	memset(head,-1,sizeof(head));
	scanf("%d%d%d",&n,&m,&S);
	S = min(S,2500);
	for(int i = 1;i <= m;i++){
		int u,v;
		ll a,b;
		scanf("%d%d%lld%lld",&u,&v,&a,&b);
		add(u,v,a,b);
		add(v,u,a,b);
	}
	for(int i = 1;i <= n;i++)
		scanf("%lld%lld",&c[i],&d[i]);
	spfa();
	for(int i = 2;i <= n;i++){
		ll res = INF;
		for(int j = 0;j <= 2500;j++)
			res = min(res,dis[i][j]);
		printf("%lld\n",res);
	}
	return 0;
}



Measured memory_bytes: 6084
object Main {
  def bfs(ar: Array[String], x: Int, y: Int, w: Int, h: Int): Array[String] = {
    if (x < 0 || x >= w || y < 0 || y >= h)
      return ar
    if (ar(y)(x) != '.')
      return ar
    // ????????\?????????????????????????????????????????£???
    var br = ar
    br(y) = br(y).patch(x, "C", 1)
    br = bfs(br, x - 1, y, w, h)
    br = bfs(br, x + 1, y, w, h)
    br = bfs(br, x, y + 1, w, h)
    br = bfs(br, x, y - 1, w, h)
    return br
  }


  def solve(ar: Array[String], room: Array[Int]): Int = {
    var x = -1
    var y = -1
    for(i <- 0 until ar.length) {
      val tmp = ar(i).indexOf('@')
      if (tmp != -1) {
        x = tmp
        y = i
      }
    }
    var br = ar
    br(y) = br(y).patch(x, ".", 1)
    br = bfs(br, x, y, room(0), room(1))
    var cnt = 0
    for(res <- br)
      cnt += res.count{_ == 'C'}
    cnt
  }

  def main(args: Array[String]) = {
    var room = io.StdIn.readLine().split(' ').map(_.toInt)
    while (room(0) != 0) {
      val ar = new Array[String](room(1))
      for (i <- 0 until room(1))
        ar(i) = io.StdIn.readLine()
      println(solve(ar, room))
      room = io.StdIn.readLine().split(' ').map(_.toInt)
    }
  }
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


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

    int ans = 1;
    for(int i = 2; i <= 1000; i++){
        for(int j = 2; j <= 1000; j++){
            if(pow(i, j) > ans && pow(i, j) <= n) ans = pow(i, j);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    V<string> g(h);
    for (int i = 0; i < h; i++) {
        static char buf[10000];
        scanf("%s", buf);
        g[i] = string(buf);
    }
    VV<int> dp(h, V<int>(w, TEN(9)));
    dp[0][0] = (g[0][0] == '#' ? 1 : 0);
    for (int r = 0; r < h; r++) {
        for (int c = 0; c < w; c++) {
            if (r) {
                bool same = (g[r][c] == g[r - 1][c]);
                dp[r][c] = min(dp[r][c], dp[r - 1][c] + (same ? 0 : 1));
            }
            if (c) {
                bool same = (g[r][c] == g[r][c - 1]);
                dp[r][c] = min(dp[r][c], dp[r][c - 1] + (same ? 0 : 1));
            }
        }
    }
    printf("%d\n", (dp[h - 1][w - 1] + 1) / 2);
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
        var n int
        fmt.Scanf("%d", &n)
        var input string
        fmt.Scanf("%s", &input)
        var count int
        for i := 0; i < len(input)-2; i++ {
                if input[i:i+3] == "ABC" {
                        count++
                }
        }
        fmt.Printf("%d\n", count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define oo 1000000010
using namespace std;

int main()
{
    int n, k;
    map<int, int> mp;
    cin >> n >> k;
    while(k--){
		int d;
		cin >> d;
		int a[d+1];
		for(int i=0; i<d; i++){
			cin >> a[i];
			mp[a[i]]++;
		}
    }

    cout << n - mp.size();

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#define INT_MAX 1000000
#include <cstring>
#include <unordered_map>
#include <vector>
using namespace std;

int helper(vector<vector<int>>&a, int i, int j, int n, vector<vector<int>>& map)
{
  if (i>=n)
    return 0;
  if (map[i][j])
    return map[i][j];
  int ans = max(ans, j!=0?a[i][0]+helper(a, i+1, 0, n, map):0);
  ans = max(ans, j!=1?a[i][1]+helper(a, i+1, 1, n, map):0); 
  ans = max(ans, j!=2?a[i][2]+helper(a, i+1, 2, n, map):0);
  if (j != -1)
  	map[i][j] = ans;
  return ans;
}

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> arr(n, vector<int>(3, 0));
  vector<vector<int>> map(n, vector<int>(3, 0));
  for(int i=0; i<n; i++)
    cin >> arr[i][0]>>arr[i][1]>>arr[i][2];
  cout<<helper(arr, 0, -1, n, map);
  return 0;
}

Measured memory_bytes: 23584
input_line = input()
numbers = input_line.split(" ")

a = ""
b = ""

n = int(numbers[0])
m = int(numbers[1])

num = 0

while (num < m):
    a += numbers[0]
    num+=1

num=0
while (num < n):
    b += numbers[1]
    num+=1

result = a if int(a) > int(b) else b

print(result)

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

int main()
{
    FAST;
    ll n;
    cin>>n;
    ll x,i,sm=0;
    map<ll,ll> mp;
    for(i=0;i<n;i++)
    {
        cin>>x;
        mp[x]++;
        sm+=x;
    }
    ll q,freq=0;
    
    cin>>q;
    while(q--)
    {
        ll b,c;
        cin>>b>>c;
        freq=mp[b];
        sm-=(freq*b);
        sm+=(freq*c);
        mp[b]=0;
        mp[c]+=freq;
        cout<<sm<<endl;
    }
}

Measured memory_bytes: 9596
import re
import math

if __name__ == '__main__':

    n, x = [int(x) for x in input().split()]
    ms = [int(input()) for m in range(n)]

    x -= sum(ms)
    ms = sorted(ms)

    ans = len(ms)
    while True:
        x -= ms[0]
        if x < 0:
            break
        ans += 1

    print(ans)




Measured memory_bytes: 3188
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N, K, Q = MAP()
    B = [0] * N
    for i in range(Q):
        B[INT() - 1] += 1
    for nn in range(N):
        if Q - B[nn] >= K:
            No()
        else:
            Yes()


if __name__ == '__main__':
    main()


Measured memory_bytes: 47964
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
   C : Integer;
   M : Integer;
begin
   Get (A);
   Get (B);
   Get (C);
   M := A;
   if B > M then
      M := B;
   end if;
   if C > M then
      M := C;
   end if;
   Put_Line (Integer'Image (A+B+C-M));
end Solve;

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

int main(void){
    string S;
    cin>>S;
    string year=S.substr(0,4);
    string month=S.substr(5,2);
    string date=S.substr(8,2);
    int nyear=atoi(year.c_str());
    int nmonth=atoi(month.c_str());
    int ndate=atoi(date.c_str());


    if(nyear<2019)
        cout<<"Heisei"<<endl;
    else if(nyear==2019&&nmonth<=4&&ndate<=30)
        cout<<"Heisei"<<endl;
    else
        cout<<"TBD"<<endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n,m = map(int,input().split())
    un = UnionFind(n)
    xyz = [list(map(int,input().split())) for i in range(m)]
    for i in range(m):
        un.union(xyz[i][0]-1,xyz[i][1]-1)
    ans = 0
    for i in range(n):
        if un.findroot(i) == i:
            ans += 1
    print(ans)
if __name__ == "__main__":
    main() 
    
#endline===============================================
    

Measured memory_bytes: 42120
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
vector<int>v[200005];
int vis[200005];
int dfs(int now){
	vis[now]=1;
	int num=1;
	for (int i : v[now])
		if (!vis[i])
			num+=dfs(i);
	re num;
}
signed main()
{
	int n,m;
	cin>>n>>m;
	while (m--){
		int a,b;
		cin>>a>>b;
		a--, b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	int ans=0;
	for (int i=0;i<n;i++){
		if (!vis[i])
			ans=max(ans,dfs(i));
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 25416
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int n, a, c = 0;
	cin >> n;
	rep(i, 0, n) {
		cin >> a;
		if (a % 2 && i % 2 == 0)c++;
	}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, M, L; 
  cin >> N >> M >> L;

  vector<vector<int>> dist(N, vector<int>(N, INF));
  REP(i, N) dist[i][i] = 0;
  
  REP(i, M){
    int u, v, d;
    cin >> u >> v >> d;
    u--; v--;
    dist[u][v] = d;
    dist[v][u] = d;
  }

  REP(k, N) REP(i, N) REP(j, N){
    chmin(dist[i][j], dist[i][k]+dist[k][j]);
  }

  vector<vector<int>> ans(N, vector<int>(N, INF));
  REP(i, N) REP(j, N){
    if(dist[i][j] <= L) ans[i][j] = 1;
  }

  REP(k, N) REP(i, N) REP(j, N){
    chmin(ans[i][j], ans[i][k]+ans[k][j]);
  }
  REP(i, N) REP(j, N){
    if(ans[i][j] == INF) ans[i][j] = -1;
    else ans[i][j]--;
  }

  int Q;
  cin >> Q;

  REP(i, Q){
    int s, t;
    cin >> s >> t;
    cout << ans[s-1][t-1] << "\n";
  }

  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool taka = true;
  while(1){
    if(taka){
      c -= b;
      taka = false;
      if (c <= 0) {
        cout << "Yes" << endl;
        return 0;
      }
    } else {
      a -= d;
      taka = true;
      if (a <= 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;

int main(){
    int64_t N,A,B;
    cin>>N>>A>>B;
    int64_t lo = (N-1)*A+B;
    int64_t up = (N-1)*B+A;
    cout<<max(int64_t(0),up-lo+1)<<endl;
    return 0;
}

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

int main(){
    long long int n;
    cin >> n;
    
    long long int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    /*
    long long int s[n];
    s[0] = a[0];
    for(int i=1;i<n;i++){
        s[i] *= (s[i-1]%1000000007);  
    }
    
    long long int sum=0;
    for(long long int i=0;i<=n-2;i++){
        for(long long int j=i+1;j<=n-1;j++){
            sum += ((a[i]*a[j])%1000000007);
            sum %= 1000000007;
        }
    }
    cout << sum << endl;
    */

   /*----------------------------------------------
    解説：累積和を用いて処理しよう！
    a[i]*a[i+1] + a[i]*a[i+2] + ... + a[i]*a[n]
    = a[i] * (a[i+1] + a[i+2] + ... + a[n])
    この()内で累積和を用いる
   ----------------------------------------------*/
   long long int sum[n]; //累積和 sum[0] = a[0], sum[1] = sum[0] + a[1], sum[2] = sum[1] + a[2], a[i]+...+a[j]=s[j]-s[i-1]
   sum[0] = a[0];
   for(int i=1;i<n;i++){
       sum[i] = sum[i-1] + a[i];
       sum[i] %= 1000000007;
   }

   long long int ans = 0;
    long long int mod_sum;
   for(int i=0;i<n;i++){
       //cout << i << " " << sum[n-1] - sum[i] << endl;
       mod_sum = (sum[n-1]-sum[i]) % 1000000007;
       if(mod_sum<0){
           mod_sum+=1000000007;
       }
       ans += (a[i]*mod_sum % 1000000007);
       ans %= 1000000007;
   }
   ans %= 1000000007;
    cout << ans << endl;
}

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

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

using namespace std;

int main() {
  long long h, w;
  std::cin >> h >> w;

  if (h == 1 || w == 1) {
    std::cout << 1 << std::endl;
  } else {
    std::cout << (h * w + 1) / 2 << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
 
int main(){
  int A,B;
  cin>>A>>B;
  VS S(100);
  rep(i,100) rep(j,100){
    if(i<50) S[i]+='#';
    else S[i]+='.';
  }
  rep(i,100) rep(j,100){
    if(i%2==0 and j%2==0 and A>1){
      S[i][j]='.';
      A--;
    }
  }
  rep(i,100) rep(j,100){
    if(i%2==0 and j%2==0 and B>1){
      S[99-i][99-j]='#';
      B--;
    }
  }
  cout<<100<<" "<<100<<endl;
  rep(i,100) cout<<S[i]<<endl;
}

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

int main() {
  int N, A;
  cin >> N >> A;
  int R = N % 500;

  if (N <= A) {
    cout << "Yes" << endl;
  }
  else if (N > A) {
    if (R <= A){
      cout << "Yes" << endl;
    }
    else if (R > A) {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	string *registeredID = new string[n];
	for(int i=0;i<n;i++){
		cin >> registeredID[i];
	}
	sort(registeredID, registeredID+n);
	int m;
	cin >> m;
	string *cardID = new string[m];
	for(int i=0;i<m;i++){
		cin >> cardID[i];
	}
	bool isOpen = false;
	for(int i=0;i<m;i++){
		bool contains = binary_search(registeredID,registeredID+n, cardID[i]);
		if(contains==true){
			if(isOpen == true){
				cout << "Closed by " << cardID[i] << endl;
				isOpen = false;
			}else{
				cout << "Opened by " << cardID[i] << endl;
				isOpen = true;
			}
		}else{
			cout << "Unknown " << cardID[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
import sys
from collections import defaultdict
from itertools import combinations

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    S = rl().rstrip()
    s1, s2 = S[:N], S[N:][::-1]
    
    l_dict = defaultdict(int)
    r_dict = defaultdict(int)
    for i in range(N + 1):
        for red_idx in combinations(range(N), i):
            red, blue = '', ''
            for j in range(N):
                if j in red_idx:
                    red += s1[j]
                else:
                    blue += s1[j]
            l_dict[red + ' ' + blue] += 1
    for i in range(N + 1):
        for red_idx in combinations(range(N), i):
            red, blue = '', ''
            for j in range(N):
                if j in red_idx:
                    red += s2[j]
                else:
                    blue += s2[j]
            r_dict[red + ' ' + blue] += 1
    
    ans = sum(l_dict[key] * r_dict[key] for key in l_dict)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 199648
#include<stdio.h>
int main(void){
	int a, b, c, l, m, s;
	scanf("%d%d%d", &a, &b, &c);
	if(a<b){
		if(b>c){
			l = b;
			if(a<c){
				m = c;
				s = a;
			}else{
				m = a;
				s = c;
			}
		}else{
			l = c;
			m = b;
			s = a;
		}
	}else{
		if(a<c){
			l = c;
			m = a;
			s = b;
		}else{
			l = a;
			if(b<c){
				m = c;
				s = b;
			}else{
				m = b;
				s = c;
			}
		}
	}
	printf("%d %d %d\n", s, m, l);
	return 0;
}

Measured memory_bytes: 596
class Node
  attr_reader :go, :come

  def initialize(id)
    @id = id
    @go = []
    @come = []
  end
end

class Arrow
  attr_reader :source, :sink, :label
  
  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
    source.go << self
    source.come << self
  end
end

class Result
  attr_reader :target, :spell

  def initialize(target, spell)
    @target = target
    @spell = spell
  end
end

def advance(table, nodes, arrows)
  next_table = {}
  nodes.each do |node|
    best = table[node]
    node.go.each do |arrow|
      result = table[arrow.sink]
      next unless result
      test = arrow.label + result.spell
      if !best || test < best.spell
        best = Result.new(arrow.sink, test)
      end
    end
    next_table[node] = best if best
  end
  next_table
end

def check(table, result)
  used = {}
  loop do
    node = result.target
    return true unless node
    return false if used[node]
    used[node] = true
    result = table[node]
  end
end

def work(nodes, arrows, start, goal)
  table = {goal => Result.new(nil, '')}

  nodes.size.times do
    table = advance(table, nodes, arrows)
  end

  result = table[start]
  return nil unless result

  (nodes.size*5).times do
    table = advance(table, nodes, arrows)
  end

  result = table[start]
  check(table, result) ? result.spell : nil
end

loop do
  n, a, s, g = STDIN.gets.split.map(&:to_i)
  break if n == 0

  nodes = (0...n).map{|i| Node.new(i)}

  arrows = (0...a).map do |i|
    x, y, lab = STDIN.gets.split
    x = x.to_i
    y = y.to_i
    Arrow.new(nodes[x], nodes[y], lab)
  end

  start = nodes[s]
  goal = nodes[g]

  puts work(nodes, arrows, start, goal) || 'NO'
end

Measured memory_bytes: 26760
import math
N, M = map(int, input().split())

n = 0
for i in range(1, int(math.sqrt(M))+1):
    if M < i * N:
        break

    if M % i == 0:
        n = max(i, n)
        if i >= N:
            n = max(M//i, n)

print(n)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    rep(i,n){
        int x; cin>>x;
        ans+=min(2*x,2*abs(k-x));
    }
    cout<<ans<<endl;
    return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

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


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

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Array.Sort(a);
        Console.WriteLine(a[N/2]-a[N/2-1]);
    }
}

Measured memory_bytes: 18784
import sys
sys.setrecursionlimit(10**6)
N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    edge[a].append((b, 1+i))

color = [0] * N

def dfs(v, c, idx):
    color[idx] = c
    now = 0
    for nv, i in edge[v]:
        now += 1
        if now == c:
            now += 1
        dfs(nv, now, i)

dfs(0, 0, 0)
color[0] = max(color)
print(*color, sep="\n")


Measured memory_bytes: 131740
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]

res=False
for i in range(n-m+1):
    for j in range(n-m+1):
        t=[r[j:j+m] for r in a[i:i+m]]
        res|=t==b
print('Yes' if res else 'No')


Measured memory_bytes: 3060
import sys

# 入力
a, b, c = map(int, input().split())

cnt5, cnt7 = 0, 0

# 5文字と7文字がいくつあったか
if a == 5:
    cnt5 += 1
if a == 7:
    cnt7 += 1
if b == 5:
    cnt5 += 1
if b == 7:
    cnt7 += 1
if c == 5:
    cnt5 += 1
if c == 7:
    cnt7 += 1

# 評価
if cnt5 == 2 and cnt7 == 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int a[300000];
int main(){
	long int N;
	bool flag = 0;
	cin >>N;
	for(int i = 1;i <= N;i++){
		cin >> a[i-1];
	}
	if(a[0]  >= 10 && a[N-1] >= 10){
		for(int k = 1;k <= N-2;k++){
		if(a[k] < 10){
			flag = 0;
			int yosi = 0;
			for(int o =1;;o++){
				if(a[k-o] >= (10*o+10)){
					yosi++;
					break;
				}
				if((k-o) == 0){
					cout << "no"<<endl;
					return 0;
				}
			}
			for(int u = 1;;u++){
				if(a[k+u] >= (10*u+10)){
					yosi++;
					break;
				}
				if((k+u) == (N-1)){
					cout << "no"<<endl;
					return 0;
				}
			}
			if(yosi == 2){
				flag = 1;
			}else{
				cout <<"no"<<endl;
				return 0;
			}
		}
		}
		flag = 1;
	}

	if(flag == 0){
		cout << "no" << endl;
	}else{
		cout << "yes" << endl;
	}

		return 0;
}

Measured memory_bytes: 4248
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	int n;
	cin >> n;
	vector<string> s(n);
	map<string, int> mp;
	REP(i, n) {
		cin >> s[i];
		mp[s[i]]++;
	}
	using pr = pair<int, string>;
	vector<pr> p;
	for (auto v : mp) {
		p.push_back(pr(v.second, v.first));
	}
	sort(all(p));
	reverse(all(p));
	int m = p[0].first;
	vector<string> res;
	REP(i, p.size()) {
		if (p[i].first == m) {
			res.push_back(p[i].second);
		}
	}
	sort(all(res));
	REP(i, res.size()) {
		put(res[i]);
	}
	return 0;
}

Measured memory_bytes: 33132
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> p(n);
  vector<ll> q(n);
  rep(i,n) { cin >> p[i]; }
  rep(i,n) { cin >> q[i]; }
  vector<ll> p2 = p; // copy
  vector<ll> q2 = q; // copy
  sort(all(p2));
  sort(all(q2));

  vector<ll> cnts(2);
  vector<vector<ll>> orig = { p, q };
  vector<vector<ll>> vars = { p2, q2 };
  rep(k,2) {
    ll& cnt = cnts[k];
    vector<ll>& p  = orig[k];
    vector<ll>& p2 = vars[k];

    do {
      bool same = true;
      rep(i,n) {
        if (p[i] != p2[i]) { same = false; break; }
      }
      if (same) { break; }
      ++cnt;
    } while (next_permutation(all(p2)));
  }

  cout << abs(cnts[0]-cnts[1]) << endl;
}


Measured memory_bytes: 256
from collections import deque

def main():    
    n = int(input())
    s = input()

    que = deque(s)
    ans = 0
    q2 = ''

    while len(que)>0:
        q1 = que.popleft()
        if q1 == q2:
            continue
        else:
            ans += 1
            q2 = q1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4212
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w; cin >> h >> w;
    int r, c; cin >> r >> c;

    cout << h * w - (r * w + c * h - r * c)  << endl;

    return 0;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N;
    cin >> N;
    cout << (1000 - N % 1000) % 1000 << endl;
    return 0;
}

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

using namespace std;


int main()
{

    int a , b , k , x[101];

    cin >> a >> b >> k;

    int m = max(a , b);
    int j = 0;

    for(int i = 1 ; i <= m ; i++)
    {
        if(a % i == 0 && b % i == 0)
        {
            x[j++] = i;
        }
    }

    sort(x , x + j);

    cout << x[ j - k] << endl;

    //for(int i = 0; i < j; i++)
    //{
     //   cout << x[i] << " ";
   // }



    return 0;
}


Measured memory_bytes: 256