akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
using namespace std;
int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, -1, 0, 1 };
struct axis { int x, y; };
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;  while (cin >> N && N != 0)
	{
		vector<axis> dat(N + 2);
		axis ans_max; ans_max.x = 0, ans_max.y = 0;
		axis ans_min; ans_min.x = 0, ans_min.y = 0;
		for(int i = 1; i < N; i++)
		{
			int pic = 0, dir = 0; cin >> pic >> dir;
			dat[i].x = dat[pic].x + dx[dir];
			dat[i].y = dat[pic].y + dy[dir];
			ans_max.x = max(ans_max.x, dat[i].x);
			ans_max.y = max(ans_max.y, dat[i].y);
			ans_min.x = min(ans_min.x, dat[i].x);
			ans_min.y = min(ans_min.y, dat[i].y);
		}
		printf("%d ", abs(ans_max.x) + abs(ans_min.x) + 1);
		printf("%d\n", abs(ans_max.y) + abs(ans_min.y) + 1);
	}
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;


int main(){
    string S, S_; cin >> S; S_ = S + 'p';
    int N = S.size();
    string X = "";
    for(int i = 0; i < N; i++){
        if(S_[i] == 'A') X += 'A';
        else if(S_[i] == 'B'){
            if(S_[i+1] == 'C') {X += 'D'; i++;}
            else X += 'B';
        }
        else X += 'C';
    }
    vector<ll> V(X.size()+5);
    for(int i = 0; i < X.size(); i++){
        if(i == 0){
            if(X[i] == 'A') V[i] = 1;
            else V[i] = 0;
        }
        else{
            if(X[i] == 'A') V[i] = V[i-1]+1;
            else if(X[i] == 'D') V[i] = V[i-1];
            else if(X[i] == 'B' || X[i] == 'C') V[i] = 0;
        }
    }
    ll cnt = 0;
    for(int i = 0; i < X.size(); i++){
        if(X[i] == 'D'){
            cnt += V[i];
        }
    }
    cout << cnt << endl;
}

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

typedef long long ll;
typedef pair<int, int> ii;

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

    if (n % 2 == 1) {
        printf("No\n");
        return 0;
    }

    char inp[n + 3];
    scanf("%s", inp);
    for (int i = 0; i < n / 2; i++) {
        if (inp[i] == inp[i + n / 2])
            continue;

        printf("No\n");
        return 0;
    }

    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string yohou, result;
  cin >> yohou >> result;
  int count = 0;
  rep(i, 3){
  	if(yohou[i] == result[i]) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = gets.chomp
sum = []
sum[0] = 0

cnt = 0
1.upto(n) do |i|
  if s[i-1] == "#"
    cnt += 1
  end
  sum[i] = cnt
end

cnt = 0
(n-1).downto(0) do |i|
  if s[i] == "."
    cnt += 1
  end
  sum[i] += cnt
end

puts sum.min


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, k;

// {おいしさ, 種類}
PI val[100100];

int main() {
    cin >> n >> k;
    rin{
        cin >> val[i].S >> val[i].F;
    }
    sort(val, val + n);
    reverse(val, val + n);

    li now = 0;
    set<li> st;
    priority_queue<li> pq;
    rep(i, k) {
        now += val[i].F;
        if (st.count(val[i].S) > 0) {
            pq.push(-val[i].F);
        }
        st.insert(val[i].S);
    }
    li res = now + sz(st) * sz(st);
    repp(i, k, n) {
        if (st.count(val[i].S) > 0) {
            continue;
        }
        if (pq.empty()) {
            break;
        }
        now = now - (-pq.top()) + val[i].F;
        pq.pop();
        st.insert(val[i].S);
        res = max(res, now + sz(st) * sz(st));
    }
    cout << res << endl;



    return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  if (S == "SUN"){
    cout << "7" << endl;
  }
  else if (S == "MON"){
    cout << "6" << endl;
  }
  else if (S == "TUE"){
    cout << "5" << endl;
  }
  else if (S == "WED"){
    cout << "4" << endl;
  }
  else if (S == "THU"){
    cout << "3" << endl;
  }
  else if (S == "FRI"){
    cout << "2" << endl;
  }
  else{
    cout << "1" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const lint MOD = (lint)1e9+7;

string S;
int L;
string s;
map<string, int> mp;
string buff;
int cnt;

void func(int index)
{
    // 最後まで走査したら
    if (index >= L)
    {
        return;
    }

    if (s == "")
    {
        s = S[index];
    }
    else
    {
        s += S[index];
    }

    if (mp[s] == 0)
    {
        mp[s]++;
        cnt++;
        if (buff == "")
        {
            buff = s;
        }
        else
        {
            mp[buff] = 0;
            buff = s;
        }
        cerr << s << " ";
        s = "";
    }

    func(index + 1);
}


int main()
{
    buff = "";
    cnt = 0;
    cin >> S;
    L = S.length();

    func(0);

    int ans = cnt;

//    for (auto& it : mp)
//    {
//        cerr << it.first << " ";
//    }
//    cerr << endl;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

string s,t,c[]={"100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};

int main(){
	while(getline(cin,s)){
		t="";
		int cur=0;
		while(cur<s.size()){
			if(s[cur]==' ')t+="101";
			if(s[cur]=='\'')t+="000000";
			if(s[cur]==',')t+="000011";
			if(s[cur]=='-')t+="10010001";
			if(s[cur]=='.')t+="010001";
			if(s[cur]=='?')t+="000001";
			if(s[cur]>='A'&&s[cur]<='Z')t+=c[s[cur]-'A'];
			cur++;
		}
		if(t.size()%5){
			int u=5-t.size()%5;
			rep(i,u)t+="0";
		}
		//cout<<t<<" "<<t.size()<<endl;
		rep(i,t.size())t[i]-='0';
		cur=0;
		s="";
		while(cur<t.size()){
			int a=t[cur]*16+t[cur+1]*8+t[cur+2]*4+t[cur+3]*2+t[cur+4];
			//cout<<(int)t[cur]<<(int)t[cur+1]<<(int)t[cur+2]<<(int)t[cur+3]<<(int)t[cur+4]<<" "<<a<<endl;
			if(a<=25)s+='A'+a;
			if(a==26)s+=' ';
			if(a==27)s+='.';
			if(a==28)s+=',';
			if(a==29)s+='-';
			if(a==30)s+='\'';
			if(a==31)s+='?';
			cur+=5;
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 0
while 1:
    n = int(input())
    if n == 0:
        break
    team = []
    for _ in range(n):
        i, *T = map(int, input().split())
        t = 0
        for m, s in zip(T[::2], T[1::2]):
            t += m*60 + s
        team.append((t, i))
    team.sort()
    print(*[team[0][1], team[1][1], team[-2][1]], sep='\n')

Measured memory_bytes: 8272
N = int(input())
h= list(map(int, input().split()))

dp=[0]*(N)
dp[1]=abs(h[0]-h[1])

for i in range(2,N):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 20380
s = int(input())

alist = []
alist.append(s)
for i in range(1000000):
    if s % 2 == 0:
        a = int(s / 2)
    else:
        a = 3 * s + 1
    s = a
    alist.append(a)
for num in alist:
    if alist.count(num) > 1:
        index = alist.index(num)
        alist.pop(index)
        find = alist.index(num)
        print(find + 2)
        break
    else:
        continue

Measured memory_bytes: 10904
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int a, b;

  cin >> a >> b;

  if(a <= b)
    cout << a << endl;
  else
    cout << a - 1 << endl;


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,ans=0,max = 0;
  int all[100005];
  scanf("%d",&n);
  for(int i = 0;i<n;i++)
    scanf("%d",&all[i]);
  for(int i = 0;i<n-1;i++)
  {
    if(all[i]>=all[i+1])
      	max++;
     else
       max=0;
      if(max>ans)
        ans=max;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
// bool cmp()
// {
//     return 
// }

void combi(vector<vector<int>> &vec,vector<int>l,vector<int>arr,int start,int end,int index,int r)
{
    if(index == r)
    {
		  vec.push_back(l);
	    return; 
    }

    for (int i = start; i <= end && end - i + 1 >= r - index; i++) 
    {
        l[index] = arr[i];
        combi(vec,l,arr,i+1,end,index+1,r);
    }

}
void combi1(vector<vector<int>>& vec,vector<int>arr,int n,int r)
{
      vector<int>l(n);
      combi(vec,l,arr,0,n-1,0,r);
}
int cnt(vector<vector<char>>arr)
{
  int r=arr.size();
  int c=arr[0].size();
  int ans=0;
  for(int i=0;i<r;i++)
  {
    for(int j=0;j<c;j++)
    {
        if(arr[i][j] == '#')
        ans++;
    }
  }

  return ans;
}
int32_t main()
{
  // int t;cin>>t;
  // while(t--)
  // {
    int r,c,tar;
    cin >> r >> c >> tar;
    vector<vector<char>>mat(r,vector<char>(c));

    for(int i=0;i<r;i++)
    {
      for(int j=0;j<c;j++)
      {
        cin >> mat[i][j];
      }
    }

     int ans=0;
    vector<int>row(r),col(c);
    for(int i=0;i<r;i++)
    row[i]=i;
    for(int i=0;i<c;i++)
    col[i]=i;

    for(int i=0;i<=r;i++)
    {
      for(int j=0;j<=c;j++)
      {
          int numr=i,numc=j;
          vector<vector<int>>vecr,vecc;
          combi1(vecr,row,r,numr);
          combi1(vecc,col,c,numc);

          
          for(auto l:vecr)
          {
            for(auto k:vecc)
            {
              vector<int>wr,wc;
              wr=l;wc=k;
              //cout<<i<<" "<<j<<" "<<wr.size()<<" "<<wc.size()<<endl;

              // for(int kp=0;kp<i;kp++)
              // {
              //   cout<<wr[kp]<<" ";
              // }
              // cout<<"--------";
              // for(int kp=0;kp<j;kp++)
              // {
              //   cout<<wc[kp]<<" ";
              // }
              // cout<<endl;


              vector<vector<char>> dup;
              dup=mat;
              for(int kp=0;kp<i;kp++)
              {
                for(int y=0;y<c;y++)
                dup[wr[kp]][y] = 'R';
              }

              for(int kp=0;kp<j;kp++)
              {
                for(int y=0;y<r;y++)
                dup[y][wc[kp]] = 'R';
              }

              // for(int x=0;x<r;x++)
              // {
              //   for(int y=0;y<c;y++)
              //   {
              //     cout<<dup[x][y]<<" ";
              //   }
              //   cout<<endl;
              // }
              
              int fg= cnt(dup);
              if(fg == tar)
              {
                ans+=1;
                //cout<<i<<" "<<j<<endl;
              }
            }
          }
      }
    }


    cout<<ans<<endl;
  // }
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define int long long 
using namespace std;

inline void read(int &x)
{
	x=0;char ch=getchar();int pd=1;
	while(ch<'0'||ch>'9'){if(ch=='-')pd=-pd;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=pd;
}
inline void write(const int &x)
{
	char ggg[10001];int s=0;int tmp=x;
	if(tmp==0){putchar('0');return;}
	if(tmp<0){tmp=-tmp;putchar('-');}
	while(tmp>0){ggg[s++]=tmp%10+'0';tmp/=10;}
	while(s>0){putchar(ggg[--s]);}
}

int n,ans,a[100010];
int cnt;
bool can[100010];
signed main()
{
	read(n);
	for(register int i=1;i<=n;++i)
	{
		read(a[i]);
		ans^=a[i];
	}
    // puts("");
    // cout<<ans<<endl;
	for(register int i=1;i<=n;++i)
	{
    	for(register int j=0;j<=30;++j)
		{
			if(a[i]&(1<<j))
			{
                // cout<<j<<endl;
				can[j]=1;
				break;
			}
		}
	}
    // puts("");
    // cout<<ans<<endl;
	for(register int i=30;i>=0;--i)
	{
        // cout<<ans<<"   "  <<(1<<i)<<"  "<<(ans&(1<<i))<<endl;
		if(ans&(1<<i))
        {
            // cout<<i<<endl;
            if(!can[i])
            {
                
                puts("-1");
                return 0;
            }
            else 
            {
                cnt++;
                ans^=(1<<i)-1;
            }
        }
        
	}
    write(cnt);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b, c;
    cin >> a >> b >> c;

    cout << min(c, b/a) << endl;
}

Measured memory_bytes: 256
n = int(input())
A = input().rstrip()
B = input().rstrip()
C = input().rstrip()
ans = 0
for a, b, c in zip(A, B, C):
    if a != b and b != c and c != a:
        ans += 2
    elif (a != b and b !=c) or (b!= c and c != a) or (c != a and a != b):
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll h, w;    cin >> h >> w;
    vector<vector<char>> g(h, vector<char>(w));
    vector<vector<ll>> hor(h+1, vector<ll>(w+1, 0)), ver(h+1, vector<ll>(w+1, 0));
    REP(i, h) REP(j, w) cin >> g[i][j];
    REP(i, h){
        REP(j, w){
            if(g[i][j]=='.')    hor[i][j+1] += hor[i][j]+1;
        }
        REPD(j, w)
            if(g[i][j]=='.') hor[i][j] = hor[i][j+1];
    }
    REP(j, w){
        REP(i, h)
            if(g[i][j]=='.')    ver[i+1][j] += ver[i][j]+1;
            
        REPD(i, h)
            if(g[i][j]=='.') ver[i][j] = ver[i+1][j];
    }
    ll res=0;
    REP(i, h+1){
        REP(j, w+1){
            ll tmp = ver[i][j]+hor[i][j];
            if(ver[i][j] && hor[i][j]) tmp -= 1;
            res = max(res, tmp);
        }
    }
    cout << res << endl;

}


Measured memory_bytes: 70020
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace A
{
    partial class Program
    {
        public IEnumerable<string> Solve()
        {
            var n = Num;
            var ds = new List<long>();
            for (int i = 0; i < n; i++)
            {
                ds.Add(Num);
            }
            var dds = ds.OrderBy(x => x).Skip((int)(n / 2 - 1)).Take(2).ToList();

            var res = dds[1] - dds[0];
            yield return res.ToString();
        }
    }

    class StartingPoint
    {
        static void Main(string[] args)
        {
            if (args?.Any() == true)
            {
                var assembly = Assembly.GetExecutingAssembly();
                var resourceName = "AtCoder.Resources.In.txt";
                var stream = assembly.GetManifestResourceStream(resourceName);
                var streamReader = new StreamReader(stream, Encoding.UTF8);
                var str = streamReader.ReadToEnd();
                var textReader = new StringReader(str);
                Console.SetIn(textReader);
            }

            try
            {
                foreach (var s in new Program().Solve())
                {
                    Console.WriteLine(s);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                if (args?.Any() != true)
                    throw e;
            }

            if (args?.Any() == true)
                Console.ReadLine();
        }
    }

    partial class Program
    {
        long[] Nums(long count) => Enumerable.Range(0, (int)count).Select(_ => Num).ToArray();
        long Num => long.Parse(Str);
        double NumD => (double)Num;

        StringBuilder sb = new StringBuilder();

        string Str => GetStr();
        string GetStr()
        {
            sb.Clear();

            int r = 0;
            bool? b = null;
            do
            {
                r = Console.Read();
                b = IsBreak(r);
            } while (b == true);

            if (b == null)
                throw new Exception("input error: unexpected end of stream");

            do
            {
                sb.Append((char)r);
                r = Console.Read();
                b = IsBreak(r);
            } while (b == false);

            return sb.ToString();
        }

        bool? IsBreak(int c)
        {
            switch (c)
            {
                case -1:
                    return null;
                case (int)' ':
                case (int)'\n':
                case (int)'\r':
                    return true;
                default:
                    return false;
            }
        }
    }
}

Measured memory_bytes: 19168
n = int(input())
A = list(map(int,input().split()))
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b,a%b)
L = [1]*n
R = [1]*n
L[0] = A[0]
R[n - 1] = A[-1]
for i in range(1,n):
  L[i] = gcd(L[i - 1],A[i])
  R[n - i - 1] = gcd(R[n - i],A[-1 - i])
m = 1
for i in range(0,n-2):
  m = max(m,gcd(L[i],R[i + 2]))
print(max(L[n - 2],m,R[1]))

Measured memory_bytes: 14584
#include <stdio.h>

int main(void)
{
    int n, a, b, total;
    scanf("%d", &n);
    if (n == 1)
        puts("Hello World");
    if (n == 2)
    {
        scanf("%d", &a);
        scanf("%d", &b);
        total = a + b;
        printf("%d", total);
    }
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

class Test
{
    static void Main()
    {
        double[] z = Console.ReadLine().Split().Select(double.Parse).ToArray();
        Console.WriteLine("{0:f8}", Math.Sqrt(Math.Pow(z[0] - z[2], 2) + Math.Pow(z[1] - z[3], 2)));
    }
}


Measured memory_bytes: 18416
#-*- coding:utf-8 -*-

def solver1(N, reds, blues):
	""" 解説を実装
	青点のx座標が最も小さいものは、赤点のy座標の最も大きいものとペアになって良い
	"""
	sorted_reds  = sorted(reds, key=lambda x:x[1], reverse=True)  # y座標で降順ソート
	sorted_blues = sorted(blues, key=lambda x:x[0])  # x座標で昇順ソート
	ans = 0
	for i in range(N):
		for j in range(len(sorted_blues)):
			if (sorted_reds[i][0] < sorted_blues[j][0] and
			    sorted_reds[i][1] < sorted_blues[j][1]):
				ans += 1
				del sorted_blues[j]
				break
	print(ans)

if __name__ == "__main__":
	N = int(input())
	reds  = []
	blues = []
	for i in range(N):
		x, y = list(map(int, input().split()))
		reds.append([x, y])
	for i in range(N):
		x, y = list(map(int, input().split()))
		blues.append([x, y])

	solver1(N, reds, blues)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}


int main() {
    string S;
    cin >> S;
    vector<vector<ll>> dp(S.size(), vector<ll>(4, 0));
    if(S[0]=='?') {
        dp[0][0] = 3;
        dp[0][1] = 1;
    }
    else {
        dp[0][0] = 1;
        if(S[0]=='A') dp[0][1] = 1;
    }
    FOR(i, 1, S.size()-1) {
        if(S[i] == '?') {
            dp[i][0] = dp[i-1][0] * 3 % MOD;
            FOR(j, 1, 3) {
                dp[i][j] = dp[i-1][j-1];
                dp[i][j] = (dp[i][j] + dp[i-1][j] * 3) % MOD;
            }
        } else {
            dp[i][0] = dp[i-1][0];            
            FOR(j, 1, 3) {
                if(S[i]-'A'==j-1) dp[i][j] = dp[i-1][j-1];
                dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD;
            }
        }
    }
    cout << dp[S.size()-1][3] << endl;
	return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define pb push_back
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define endl "\n"
#define pii pair<int,int>
#define mii map<int,int>
#define int long long int
#define fbo find_by_order
#define ook order_of_key
#define in insert
#define F first
#define S second
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a) for(auto ws: a)cout<<ws<<" "; cout<<endl
#define print1(a,b) for(int ws=0;ws<b;ws++) {cout<<a[ws]<<" ";} cout<<endl
#define all(a) a.begin(), a.end()
#define si set<int>
#define print2(a) for(auto ws: a)cout<<"("<<ws.F<<","<<ws.S<<") "; cout<<endl

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

int32_t main()
{

	cout << setprecision(9) << fixed;

	int n, k;
	vi a;
	cin >> n >> k;
	a.resize(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int cost[n];
	cost[0] = 0;
	cost[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; ++i)
	{
		int ans = 1e18;
		for (int j = 1; j <= min(i, k) ; ++j)
		{
			ans = min(cost[i - j] + abs(a[i - j] - a[i]), ans);
		}
		cost[i] = ans;
	}
	cout << cost[n - 1];
	return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;

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

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

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

	vi d(k);
	vector<vector<int>> a;


	rep(i, k) {
		cin >> d[i];
		vi aa(d[i]);
		rep(j, d[i]) {
			cin >> aa[j];
		}
		a.emplace_back(aa);
	}

	int ha[100];
	rep(i, n)ha[i] = 1;


	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < a[i].size(); j++) {
			ha[a[i][j] - 1] = 0;
		}
	}
	int ans = 0;
	rep(i, n) {
		if (ha[i] == 1) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
const int maxn = 500005;
int block,total = 0;
int numbers[maxn];
int a[maxn];

struct query
{
    int L, R,id;
};

bool compare(query x, query y){
    int aux = x.L/block;
    if (aux != y.L/block)
        return x.L < y.L;
    if(aux & 1)
		return x.R < y.R;
	return x.R > y.R;
}
 
void add(int x){
    numbers[x]++;
    if(numbers[x] == 1)
        total++;
}
 
void rem(int x){
    numbers[x]--;
    if(numbers[x] == 0){
        total--;
    }
}
 
void solveMo( int n, vector<query> &q, int m){
    
    block = (int)(sqrt(n));
    vector<int> resultados(m);
    
    sort(q.begin(), q.end(), compare);
    
    int currL = 0, currR = -1;
 
    for (int i=0; i < m; i++){
        int L = q[i].L, R = q[i].R;
        //Add left
        while (currL > L){
            currL--;
            add(a[currL]);
        }

        //Add right
        while (currR < R){
            currR++;
            add(a[currR]);
        }
        //Remove left
        while (currL < L){
            rem(a[currL]);
            currL++;
        }
        //Remove right
        while (currR > R)
        {
            rem(a[currR]);
            currR--;
        }
        resultados[q[i].id] = total; 
    }
 
    for (int i = 0; i < m; ++i)
        cout << resultados[i] << "\n";
}
 
int main(){
    int n,m,x,y;
    ios_base::sync_with_stdio(0);cin.tie(0);
	cout.tie(0);
    cin >> n >> m;
    
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    vector<query> q(m);
    for (int i = 0; i < m; ++i){
        cin >> x >> y;
        query aux;
        aux.L = x-1;
        aux.R = y-1;
        aux.id = i;
        q[i]=aux;
    }

    solveMo(n, q, m);
    return 0;
}



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

int main(){
    int N;
    vector<int> answer(10002,0);
    cin >> N;
    int M = 1000;
    for (int x = 1; x <= M; x++){
        for (int y = 1; y <= M-x-1; y++){
            for (int z = 1; z <= M-x-y; z++){
                if (x*x+y*y+z*z+x*y+y*z+z*x-1 > N) continue;
                else answer[x*x+y*y+z*z+x*y+y*z+z*x-1]++;
            }
        }
    }
    rep(i,N) cout << answer[i] << endl;

}


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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

void solve(std::string s){
  ll n=s.size();
  cout << s[0] << n - 2 << s[n - 1] << endl;
}

int main() {
  std::string s;
    std::cin >> s;
  solve(s);
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << C / A * B << endl;
    // system("pause");
}

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

using namespace std;

int c, n;

int valor[105], peso[105];
long long dp[105][100005];

long long  solve (int p, int cap) {
  if (p >= n) return 0;
  if (dp[p][cap] != -1) return dp[p][cap];
  return dp[p][cap] = max (solve(p + 1, cap), (cap - peso[p] >= 0 ? valor[p] + solve(p + 1, cap - peso[p]) : 0));
}

int main() {
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> peso[i] >> valor[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << solve (0, c) << '\n';
  return 0;
}


Measured memory_bytes: 82304
input()
x = [int(i) for i in input().split(" ")]
steps = []
res, c = 0, 0
for i in range(len(x)-1):
  if x[i] - x[i+1] >= 0:
    c += 1
  else:
    c = 0
  if c > res:
    res = c
print(res)

Measured memory_bytes: 14224
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<queue>
using namespace std;
long long n, a[400000], s[400000], t[400000], cnt, cnt2;
priority_queue<long long, vector<long long>, greater<long long>>Q;
priority_queue<long long, vector<long long>, less<long long>>R;
int main() {
	cin >> n; for (long long i = 0; i < 3 * n; i++)cin >> a[i];
	for (long long i = 0; i < n; i++) { Q.push(a[i]); cnt += a[i]; }s[n] = cnt;
	for (long long i = n; i < 3 * n; i++) {
		Q.push(a[i]); cnt += a[i]; cnt2 += a[i];
		cnt -= Q.top(); Q.pop();
		s[i + 1] = cnt;
	}
	cnt = 0; cnt2 = 0;
	for (long long i = 2 * n; i < 3 * n; i++) { R.push(a[i]); cnt += a[i]; cnt2 += a[i]; }t[2 * n] = cnt;
	for (long long i = 2 * n - 1; i >= 0; i--) {
		R.push(a[i]); cnt += a[i];
		cnt -= R.top(); R.pop();
		t[i] = cnt;
	}
	long long maxn = (-1LL << 60);
	for (long long i = n; i <= 2 * n; i++)maxn = max(maxn, s[i] - t[i]);
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 10100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define repr(i,a,n) for (int i=a;i<n;i++)
#define rrep(i,a,n) for (int i=n-1;i>=a;i--)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define fi first
#define se second
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;

void solve() {
	int a, b, t;
	cin >> a >> b >> t;
	int T = t;
	int j = 1;
	int ans = 0;
	while (1) {
		T = j * a;
		if (T > t)break;

		ans += b;
		j++;
	}

	cout << ans << endl;

}

signed main()
{
	int tc;
	tc = 1;
	//	cin >> tc;
	while (tc--) {
		solve();
	}


}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    short int a,b,x;
    cin>>a>>b;
    x=((a+b)/2);
    double d=((a+b)/2.0);
    if(d>double(x)) cout <<(x+1)<<endl;
    else if(d==double(x)) cout<<d<<endl;

    return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<59;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 5010
ll dp[N];

int main(){
	ll n;
	cin>>n;
	vector<ll> h(n), p(n);
	rep(i, n) cin>>h[i]>>p[i];
	vector<P> a(n);
	rep(i, n) a[i] = P(h[i]+p[i], i);
	sort(all(a));
	fill(dp+1, dp+n+1, INF);
	rep(i, n) for(int j = i; j >= 0; j--){
		ll x = h[a[i].snd], y = p[a[i].snd];
		if(dp[j]<=x) dp[j+1] = min(dp[j+1], dp[j]+y);
	}
	ll res = 0;
	rep(i, n+1) if(dp[i]<INF) res = i;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))
#define rev(vec) reverse(vec_all(vec))
#define revsrt(vec) \
    srt(vec);       \
    rev(vec)

#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;

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

int manhattan_distance(string s1, string s2)
{
    assert(s1.size() == s2.size());

    int ret = 0;
    rep(i, s1.size())
    {
        if (s1[i] != s2[i])
        {
            ret++;
        }
    }

    return ret;
}

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    // i 文字目以下に存在する'.'の数
    vector<int> dot_sum(n + 1, 0);
    int sum = 0;
    rep(i, n) {
        if (s[i] == '.') {
            sum++;
        }
        dot_sum[i + 1] = sum;
    }

    sum = 0;
    // i 文字目以降に存在する'#'の数
    vector<int> sharp_sum(n + 1, 0);
    repextrev(i, 0, n) {
        if (s[i] == '#') {
            sum++;
        }
        sharp_sum[i] = sum;
    }

    int min = n + 1;
    rep(i, n + 1) {
        int left = i - dot_sum[i];
        int right = (n - i) - sharp_sum[i];
        if (min > left + right) {
            min = left + right;
        }
    }

    cout << min << endl;
    return 0;
}

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

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

using namespace std;

//v.push_back(123);
//sort(v.begin(), v.end(),greater<int>());
//for(int x : v) {cout << x << endl;}

//for(int x: v) cout << x << endl;
//vector<vector<char>> v(H, vector<char>(W));
//vector<int> v(1000);
signed main(){
  int N, K;
  cin >> N >> K;
  cout << N-(K-1) << endl;

  return 0;
}


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

import sys


def assign_color():
    _color = 1
    for m in range(vertices_num):
        if vertices_status_list[m] == -1:
            graph_dfs(m, _color)
            _color += 1
    return None


def graph_dfs(vertex, color):
    vertices_stack = list()
    vertices_stack.append(vertex)
    vertices_status_list[vertex] = color
    while vertices_stack:
        current_vertex = vertices_stack[-1]
        vertices_stack.pop()
        for v in adj_list[current_vertex]:
            if vertices_status_list[v] == -1:
                vertices_status_list[v] = color
                vertices_stack.append(v)
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num, relation_num = map(int, _input[0].split())

    relation_info = _input[1:relation_num + 1]

    question_num = int(_input[relation_num + 1])
    question_list = _input[relation_num + 2:]

    adj_list = tuple([[] for _ in range(vertices_num)])
    vertices_status_list = [-1] * vertices_num

    for relation in relation_info:
        key, value = map(int, relation.split())
        adj_list[key].append(value)
        adj_list[value].append(key)

    assign_color()

    # print(adj_list)
    for question in question_list:
        start, target = map(int, question.split())
        if vertices_status_list[start] == vertices_status_list[target]:
            print("yes")
        else:
            print("no")

Measured memory_bytes: 35696
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
ll n, m, a, b, ans;
map<ll, ll> mp;
int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        cin >> a >> b;
        mp[a]++; mp[b]++;
    }
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        if (itr->second % 2) ans++;
    }
    if (ans) cout << "NO" << endl;
    else cout << "YES" << endl;
}


Measured memory_bytes: 5632
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include <functional>
#include <string.h>
#include <numeric>
#include <math.h>

#define LOP(N) for(int i=0; i<N; ++i)
#define LOOP(i, N) for(int i=0; i<N; ++i)
#define LOOP_s(i, start, end) for(int i=start; i<end; ++i)

typedef long long ll;

using namespace std;


int main() {
    int D, G; cin >> D >> G;
    vector<int> p(D), c(D);
    LOOP(i, D) cin >> p[i] >> c[i];
    
    int loop_max = 1 << D;
    vector<int> p_count(D);
    int g, min = 10000;
    LOOP(hash, loop_max) {
        g = G;
        for (int i=0; i<D; ++i) {
            int filter = 1 << i;
            if ((hash & filter) != 0) {
                p_count[i] = p[i];
                g -= p_count[i]*(i + 1)*100 + c[i];
            }
            else {
                p_count[i] = p[i] - 1;
                g -= p_count[i]*(i + 1)*100;
            }
        }
        // cout << hash << " " << g << endl;
        if (g>0) continue;

        LOOP(i, D) {
            if (p_count[i] == p[i]) continue;

            int g_tmp = g + (p[i] - 1)*(i + 1)*100;
            if (g_tmp <= 0) {
                g = g_tmp;
                p_count[i] = 0;
            }
            else {
                p_count[i] -= -g / 100 / (i+1);
                break;
            }
        }

        int p_sum = 0;
        LOOP(i, D) p_sum += p_count[i];
        
        if (min > p_sum) min = p_sum;
    }
    
    cout << min;
}


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

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

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

A_length_max = K-A[N-1]+A[0]
for i in range (N-1): #0, 1, 2, ...N-2
    A_length_max=max(A_length_max, A[i+1]-A[i])
print(K-A_length_max)

Measured memory_bytes: 26444
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  int a, b, t, cnt = 0;
  cin >> a >> b >> t;
  rep(i, 20) {
    if (a*(i+1) <= (t+0.5)) cnt++;
    else break;
  }
  cout  << b * cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char A;
	char B;
	char C;
	scanf("%c %c %c", &A, &B, &C);
	
	if (A!=B || A!=C || B!=C)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

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

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

	if (a == b)
	{
		cout << "Draw" << endl;
	}
	else
	{
		if (a == 1)
		{
			cout << "Alice" << endl;
		}
		else if (b == 1)
		{
			cout << "Bob" << endl;
		}
		else
		{
			if (a < b)
			{
				cout << "Bob" << endl;
			}
			else
			{
				cout << "Alice" << endl;
			}
		}
	}
}


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

int S[200];
int top = 0;

void push(int x) {
  top += 1;
  S[top] = x;
}

int pop() {
  top -= 1;
  return S[top+1];
}

int main() {
  string c;
  int a, b;
  while(cin >> c){
    if (c=="+") {
      a = pop();
      b = pop();
      push(a+b);
    } else if (c=="-") {
      b = pop();
      a = pop();
      push(a-b);
    } else if (c=="*") {
      a = pop();
      b = pop();
      push(a*b);
    } else {
      push(stoi(c));
    }
  }
  cout << pop() << endl;;
  return 0;
}


Measured memory_bytes: 3156
s = input()
if s=='SUN':
    print(7)
if s=='MON':
    print(6)
if s== 'TUE':
    print(5)
if s=='WED':
    print(4)
if s=='THU':
    print(3)
if s=='FRI':
    print(2)
if s=='SAT':
    print(1)


Measured memory_bytes: 2940
p :: Int -> Int -> [Int] -> Int
p n x (y:[])
  | x + y >= 0 = n+x+y+1
  | otherwise = n
p n x (y:ys)
  | x + y >= 0 = m (n+x+y+1) (-1) ys
  | otherwise = m n (x+y) ys

m :: Int -> Int -> [Int] -> Int
m n x (y:[])
  | x + y <= 0 = n-(x+y)+1
  | otherwise = n
m n x (y:ys)
  | x + y <= 0 = p (n-(x+y)+1) 1 ys
  | otherwise = p n (x+y) ys

solve :: [Int] -> Int
solve (x:xs)
  | x < 0 = min (p (-x+1) 1 xs) (m 0 x xs)
  | x > 0 = min (p 0 x xs) (m (x+1) (-1) xs)
  | x == 0 = min (p 1 (x+1) xs) (m 1 (x-1) xs)

main = getContents >>= print . solve . map read . words . last . lines

Measured memory_bytes: 39292
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 100000000;
const int MAX_N = 11;
int main() {
  map<int,int>mp;
  for(int i=0; i<3; i++){
    int a,b;
    cin>>a>>b;
    mp[a]++;
    mp[b]++;
  }
  int x=0,y=0;
  for(auto p:mp){
    if(p.second==1)x++;
    if(p.second==2)y++;
  }
  if(x==2&&y==2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

}
 

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    D, G, *PC = map(int, read().split())
    P = PC[::2]
    C = PC[1::2]

    ans = INF
    for mask in range(1 << D):
        problems = score = 0
        for i in range(D):
            if mask & (1 << i):
                problems += P[i]
                score += 100 * (i + 1) * P[i] + C[i]
            else:
                idx_max = i

        if score >= G:
            if ans > problems:
                ans = problems
            continue

        if score + 100 * (idx_max + 1) * (P[idx_max] - 1) >= G:
            problems += (G - score + 100 * (idx_max + 1) - 1) // (100 * (idx_max + 1))
            if ans > problems:
                ans = problems

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

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

void Main() {
  Cin(int, n);
  cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 256