akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(x,y) for (int (x) = 0;(x) < (y);++(x))
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int max_n = 100000;
int n;
int a[max_n+1];
ll ans[max_n+1];

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];

  vector<pll> vp(n);
  for (int i = 1; i <= n; ++i) {
    vp[i-1].fi = a[i]; vp[i-1].sc = i;
  }
  sort(all(vp));
  reverse(all(vp));


  ll sum = 0;
  int i = 0;
  while (i != n-1 && vp[i].fi == vp[i+1].fi) ++i;

  if (i == n-1) {
    ans[vp[i].sc] = vp[i].fi * n;
  }

  while (i != n-1) {
    sum = vp[i].fi * (i+1);
    int t = i+1;

    while (true) {
      while (t != n-1 && vp[t].fi == vp[t+1].fi) { 
        sum += vp[t].fi;
        ++t;
      }
      sum += vp[t].fi;
      if (t == n-1) break;
      if (vp[t].sc < vp[i].sc) break;
      ++t;
    }

    if (t == n-1) {
      if (vp[i].sc > vp[t].sc) {
        ans[vp[i].sc] = sum - vp[t].fi*(t+1);
        ans[vp[t].sc] = vp[t].fi * n;
        break;
      } else {
        ans[vp[i].sc] = sum;
        break;
      }
    }

    ans[vp[i].sc] = sum - vp[t].fi * (t+1);
    i = t;
  }

  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << endl;
  }
  
  return 0;
}


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

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

x = [0]*9

for i in a:
    if 1<= i <=399:
        x[0]=1
    elif 400 <= i <= 799:
        x[1]=1
    elif 800 <= i <= 1199:
        x[2]=1
    elif 1200 <= i <= 1599:
        x[3]=1
    elif 1600 <= i <= 1999:
        x[4]=1
    elif 2000 <= i <= 2399:
        x[5]=1
    elif 2400 <= i <= 2799:
        x[6]=1
    elif 2800 <= i <= 3199:
        x[7]=1
    else:
        x[8]+=1

#min_res = max(sum(x[:-1]),1)


res = sum(x[:-1])

if res > 0:
    print("{} ".format(res),end="")
else:
    if x[8] == 0:
        print("0 ")
    else:
        print("1 ")

print(res+x[8])


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

char str[1000];
int a[1000];
int b[1000];

int main() {
  int n;
  while (scanf("%d", &n), n) {
    scanf("%s", str);
    REP(i, n) {
      scanf("%d %d", &a[i], &b[i]);
      a[i]--; b[i]--;
    }
    for (int i = n - 1; i >= 0; i--) {
      int diff = b[i] - a[i];
      swap(str[a[i]], str[b[i]]);
      str[a[i]] = (26 + str[a[i]] - 'a' + diff) % 26 + 'a';
      str[b[i]] = (26 + str[b[i]] - 'a' + diff) % 26 + 'a';
    }
    cout << str << endl;
  }
}

Measured memory_bytes: 0
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll as(n);
  rep(i, n) {
    ll a;
    cin >> a;
    a--;
    as[i] = a;
  }

  vector<bool> vis(n, false);
  ll ans = 0;
  ll cur = 0;
  while (true) {
    vis[cur] = true;
    cur = as[cur];
    ans++;
    if(vis[cur]) {
      puts("-1");
      return 0;
    } else if(cur == 1){
      cout << ans << endl;
      return 0;
    }
    
  }
  return 0;
}


Measured memory_bytes: 1024
'use strict'
const main = (input: string) => {
    const std: string[] = input.split('\n')
    const n: number = ~~std.shift()
    const xy = std.map(v => v.split(' ').map(Number))
    let sum: number = 0
    if (n === 2) {
        const x = (xy[0][0] - xy[1][0])**2
        const y = (xy[0][1] - xy[1][1])**2
        return console.log(Math.sqrt(x + y))
    }
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < n; j++) {
            if (i === j) continue
            const x = (xy[i][0] - xy[j][0])**2
            const y = (xy[i][1] -xy[j][1])**2
            sum += Math.sqrt(x + y)
        }
    }
    console.log(sum/n)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
using namespace std;

#define Rep(i,l,r) for (int i = (l); i <= (r); ++ i)
#define RepD(i,r,l) for (int i = (r); i >= (l); -- i)
#define RepG(i,x) for (int i = hd[x]; i; i = e[i].nxt)
#define qusi {puts ("Impossible"); return 0;}
#define haha {puts ("Possible"); return 0;}

const int N = 10005;
int n, a[N];

int main () {
	int x, k = 0; scanf ("%d", &n);
	Rep (i,1,n) {
		scanf ("%d", &x); ++ a[x]; k = max (k, x);
	}
	Rep (i,1,(k-1)/2) if (a[i]) qusi;
	Rep (i,k/2+1,k) if (a[i]<2) qusi;
	if (k&1) if (a[(k+1)/2]!=2) qusi;
	if (k&1^1) if (a[k/2]!=1) qusi;
	haha;
	return 0;
}


Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
map = Array.new(h)
h.times do |i|
  map[i] = gets.chomp.chars
end
 
nmap = []
 
map.each do |line|
  nmap << line if line.include?('#')
end
 
map = []
nmap = nmap.transpose
nmap.each do |line|
  map << line if line.include?('#')
end

 nmap = map.transpose
nmap.each do |n|
    puts n.join
end

Measured memory_bytes: 2300
#include <vector>
    #include <string>
    #include <tuple>
    #include <iostream>
    #include <sstream>
    #include <algorithm>
    #include <set>
    #include <map>
    #include <cmath>
    #include <numeric>
    #include <queue>

    #define ll long long
    #define ld long double

    using namespace std;

    vector<ll> vert;

    int main() {
        ll n;
        cin >> n;
        map<pair<char, char>, ll> m;
        for(ll i = 1; i <= n; ++i) {
            string s = to_string(i);
            char a = s[0];
            char b = s[s.size() - 1];
            //cout << s << " : " << a << ' ' << b << endl;
            ++(m[make_pair(a, b)]);
        }
        ll result = 0;
        for(char a = '0'; a <= '9'; ++a) {
            for(char b = '0'; b <= '9'; ++b) {
                ll an = m[make_pair(a, b)];
                ll bn = m[make_pair(b, a)];
            //cout << a << ' ' << b << ':' << an << ' '<< bn << endl;
                result += an * bn;
            }
        }
        cout << result;
    }


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

int main()
{
  long long int h,w=0;
  
  scanf("%lld",&h);
  scanf("%lld",&w);
 
  if(h == 1 || w == 1){
    printf("1");
  }else if(h*w%2==0){
    printf("%lld",h*w/2);
  }else{
    printf("%lld",(h*w)/2+1);
  };
  return 0;
};



Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    struct rectangle{
        int h,w;
    };

    struct rectangle rect[300];
    int n=0;
    int i,j,k;

    while(1){
        int a,b;
        scanf("%d %d",&a,&b);

        if(a==0&&b==0) break;
        
        rect[n].h=a;
        rect[n].w=b;

        n++;
    }

    for(i=0;i<n;i++){

        for(j=0;j<rect[i].h;j++){
            for(k=0;k<rect[i].w;k++){
                printf("#");
            }
            printf("\n");
        }

        printf("\n");
    }

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    v[i] = i + 1;
  }
  int num = 0;
  int m, M;
  do {
    if (v == p) {
      m = num;
    } 
    if (v == q) {
      M = num;
    }
    num++;
  } while (next_permutation(all(v)));
  cout << abs(M - m) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text.RegularExpressions;
namespace AtCoder_Core
{
    class Program
    {
        private static int max = 0;
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (Console.ReadLine().Remove(s.Length) == s)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

    }
}


Measured memory_bytes: 25880
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define N 1005
#define M 200005
using namespace std;
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
int n,m,a[N][N],x[M],y[M],vis[N];
vector<int> e[N];
void dfs(int st,int u,int now){
	if (st==u) return;
	if (a[st][u]>=2) return;
	if (a[st][u]==1 && vis[u]==now) return;
	if (a[st][u]==0) vis[u]=now;
	a[st][u]++;
	rep (i,0,(int)e[u].size()-1) dfs(st,e[u][i],now);
}
int main(){
	n=read(); m=read();
	rep (i,1,m){
		x[i]=read(),y[i]=read();
		e[x[i]].push_back(y[i]);
		
	}
	rep (i,1,n){
		memset(vis,-1,sizeof(vis));
		rep (j,0,(int)e[i].size()-1) dfs(i,e[i][j],e[i][j]);
	}
	rep (i,1,m){
		bool f1=a[y[i]][x[i]]>=1;
		bool f2=a[x[i]][y[i]]>=2;
		if (f1==f2) puts("same"); else puts("diff");
	}
	return 0;
}

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

int main (){
    int A,B,C;
    cin >> A >> B >> C;

    int tmp = 0;

    tmp = A;
    A = B;
    B = tmp;

    tmp = 0;

    tmp = A;
    A = C;
    C = tmp;

    cout << A << " " << B << " " << C << endl;

    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))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int n; int k;
	while(~scanf("%d%d", &n, &k)) {
		ll ans = 0;
		if(n >= 3) {
			rep(i, 11) rer(j, 1, 7 - 2) {
				if((63 * (i + 1) + 9 * j + 9) % 11 == k) {
					ans += (n - 3) / 11 + ((n - 3) % 11 >= i);
				}
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 384
//omajinai c++ atcoder
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
#define yes() printf("Yes")
#define no() printf("No")
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;
int main() {

int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  int cnt=1;
  char c='n'; //i or d or  n
  for(int i=1;i<n;i++){
   
      
        
       
     if(c=='i'){
        if(a[i-1]>a[i]){
          cnt++;
          c='n';
        }
     }
       else if(c=='d'){
        if(a[i-1]<a[i]){
          cnt++;
          c='n';
        }
       }
       
       else{
        if(a[i-1]>a[i]){
          c='d';
        }
        else if(a[i-1]<a[i]){
          c='i';
        }
    }
    
  }
  cout<<cnt;
}
    
  


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


    vector<int> ans(N,-1);

    rep(i,M)
    {
        int s,c;
        cin >> s >> c;
        if( ans[s-1] == -1 ) ans[s-1] = c;
        else if( ans[s-1] == c ) continue;
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    //rep(i,M) cout << ans[i];
    //cout << endl;

    
    if( ans[0] == -1 ) ans[0] = 1;
    
    if( (N == 1 && M == 0) || (N == 1 && ans[0] == 0) )
    {
        cout << 0 << endl;
        return 0;
    }

    if( ans[0] == 0 )
    {
        cout << -1 << endl;
        return 0;
    }

    rep(i,N)
    {
        if( ans[i] == -1 ) cout << 0;
        else cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long int A[N];
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  if(N == 1){
    cout << A[0]/2LL << endl;
    return 0;
  }
  long long int ans = 0LL;
  for(int i = 0; i < N-1; ++i){
    ans += A[i]/2LL;
    A[i] %= 2LL;
    if(A[i] > 0LL && A[i+1] > 0LL){
      ++ans;
      --A[i+1];
    }
  }
  ans += A[N-1]/2LL;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    ll x,y;
    cin>>n>>k>>x>>y;
    for(ll i=1;i<=n;i++){
        if(i<=k) sum+=x;
        else sum+=y; 
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S>>T;
	for(i=0;i<=S.size();i++) {
		string R=S.substr(0,i)+T;
		if(R.size()<S.size()) continue;
		if(R.substr(0,S.size())==S) {
			cout<<R.size()<<endl;
			return;
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	

	
	ll x;
	ll y;

	bool goodx[110] = { false };
	bool goody[110] = {false};

	string board[110];

	cin >> x >> y;
	rep(i, 0, x) {
		cin >> board[i];
	}
	rep(i, 0, x) {
		rep(j, 0, y) {
			if (board[i][j] == '#') {
				goodx[i] = true;
				goody[j] = true;
			}
		}
	}
	rep(i, 0, x) {
		if (goodx[i] == true) {
			rep(j, 0, y) {
				if (goody[j]) {
					cout << board[i][j];
				}
			}
			cout << endl;
		}
	}
	
}
	

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;
typedef double db;
typedef long double ldb;

const int INF = 0x3f3f3f3f;
const int64 INF64 = 0x3f3f3f3f3f3f3f3fLL;

const int MOD = 1000000007;


int solve(){

	int ret = 0;

	return ret;
}


int main(){
	char c;	cin >>c;
	if(c <= 'Z' && c >= 'A')	puts("A");
	else						puts("a");
}





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

int main(void)
{
    int N;
    cin >> N;
    int a[N+1];
    int b = 0;
    for( int i = 1; i <= N; i++){
        cin >> a[i];
    }
    b = a[1];
    for( int i = 1; i <= N; i++){
        if(b == 2){
            cout << i;
            return 0;
        }
        b = a[b];
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 640
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

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

int main() {
    int h,w,m; cin >> h >> w >> m;
    vector<Pii> da(m);
    vector<int> hh(h), ww(w);
    rip(i,m,0) {
        cin >>da[i].first >> da[i].second;
        --da[i].first;
        --da[i].second;
        hh[da[i].first] ++;
        ww[da[i].second] ++;
    }
    int hm = 0, wm = 0;
    rip(i,h,0) chmax(hm, hh[i]);
    rip(i,w,0) chmax(wm, ww[i]);
    vector<int> hi(0), wi(0);
    set<Pii> mp;
    rip(i,m,0) mp.insert(da[i]);
    rip(i,h,0) if(hh[i] == hm) hi.push_back(i);
    rip(i,w,0) if(ww[i] == wm) wi.push_back(i);
    int ans = hm+wm;
    rip(i,hi.size(), 0) {
        rip(j, wi.size(), 0) {
            if(mp.count({hi[i], wi[j]})) {
                ans *= 1;
            }
            else {
                cout << ans << '\n';
                return 0;
            }
        }
    } 
    cout << ans-1 << '\n';
}

Measured memory_bytes: 26128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main(){
  int N, M;
  cin >> N >> M;
  priority_queue<double> pque;
  rep(i, N) {
    int A;
    cin >> A;
    pque.push(A);
  }
  rep(i, M) {
    double tmp = pque.top();
    pque.pop();
    tmp /= 2;
    pque.push(tmp);
  }
  ll ans = 0;
  rep(i, N) {
    ans += pque.top();
    pque.pop();
  }
  cout << ans << endl;
  return 0;
}

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

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

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int h = get<int>();
    get<int>();
    for (int i = 0; i < h; i++) {
        string s = get<string>();
        cout << s << endl << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

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

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            long[] lucas = new long[N + 1];
            lucas[0] = 2;
            lucas[1] = 1;
            for (int i = 2; i < N + 1; i++) {
                lucas[i] = lucas[i - 1] + lucas[i - 2];
            }
            out.println(lucas[N]);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

Measured memory_bytes: 23380
#include<stdio.h>
long long int gcd(long long int a,long long int b){
  long long int i;
  while(a!=0 && b!=0){
    i=b;
    b=a%b;
    a=i;
  }
  return a;
}

int main(){
  long long a,b,c,d;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  printf("%lld\n",b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d-b/(c*d/gcd(c,d))+(a-1)/(c*d/gcd(c,d))));
}


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

const int INF = 1e9 + 5;

struct Node {
    int val;
    int x, y;

    Node (int _val, int _x, int _y) {
        val = _val;
        x = _x;
        y = _y;
    }
};

void max_self(Node &a, Node b) {
    if (a.val < b.val) {
        a = b;
    }
}

int is_first_row_col(Node node) {
    return (node.x == 0 || node.y == 0);
}

int main() {

    string s, t;
    cin >> s >> t;

    int n = s.length(), m = t.length();

    vector<vector<Node>> dp(n+1, vector<Node>(m+1, Node(-INF,0,0)));

    dp[0][0].val = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (s[i] == t[j])  {
                max_self(dp[i+1][j+1], Node(1+dp[i][j].val, i, j));
            }

            max_self(dp[i+1][j], Node(dp[i][j].val, i, j));
            max_self(dp[i][j+1], Node(dp[i][j].val, i, j));
        }
    }

    Node node(0,0,0);

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            max_self(node, Node(dp[i][j].val, i, j));
            // cout << "(" << dp[i][j].val << " " << dp[i][j].x << " " << dp[i][j].y << "),";
        }
        // cout << endl;
    }

    string ans = "";

    while (!is_first_row_col(node)) {
        int i = node.x;
        int j = node.y;
        Node prev = dp[i][j];
        
        if (prev.x == i-1 and prev.y == j-1) ans += s[i-1];

        node = prev;
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;

}

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

const int MOD = 1e9 + 7;
int N;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}//modinv(i,mod)でi^-1のmodをとる。

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll sum = 0;
vector<vector<int> > G;

ll dfs(int idx, int par){
    ll psum = 1;
    for(auto &to: G[idx]){
        if(to == par) continue;

        psum += dfs(to, idx);
    }
    sum += (modpow(2,psum, MOD) - 1 + MOD) % MOD * ((modpow(2, N - psum, MOD) - 1 + MOD) % MOD);
    sum %= MOD;
    cerr << idx << " " << psum << " " <<  sum << endl;
    return psum;
}

int main(){
    cin >> N;
    G.resize(N);
    rep(i, 0, N - 1){
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0, -1);
    ll ans = (sum * modpow(modinv(2,MOD), N, MOD) % MOD) + (1 + MOD - modpow(modinv(2,MOD), N, MOD) % MOD) - N * modinv(2,MOD) % MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 17920
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int n = 3;
  vector<int> a(n);
  for(int i = 0; i < n; ++i)cin >> a[i];
  sort(a.begin(),a.end());
  string ans = "NO";
  if(a[0]==5&&a[1]==5&&a[2]==7)ans = "YES";
  cout << ans << endl;
}


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


int main() {
  int n;
  cin >> n;
  long long max_v = -pow(10, 9);
  long long min_v;
  for (int i=0; i<n; ++i) {
    long long r;
    cin >> r;
    if (i == 0) {
      min_v = r;
    } else {
      max_v = max(max_v, r - min_v);
      min_v = min(min_v, r);
    }
  }
  cout << max_v << endl;
}


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

int main(){
    int A, B;
    char op;

    cin >> A >> op >> B;
    if (op == '+'){
        cout << A + B << endl;
        return 0;
    }

    if (op == '-'){
        cout << A - B << endl;
    }
    
    return 0;
}

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

int stk(string s,int p,int q,int r){
    int count=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='(')count++;
        else if(s[i]==')')count--;
        if(!count){
            if(s[i]=='*'){
                return min(stk(s.substr(0,i),p,q,r),stk(s.substr(i+1,s.size()-i-1),p,q,r));
            }
            if(s[i]=='+'){
                return max(stk(s.substr(0,i),p,q,r),stk(s.substr(i+1,s.size()-i-1),p,q,r));
            }
        }
    }
    if(s[0]=='('){
        count=1;
        for(int i=1;i<s.size();i++){
            if(s[i]=='(')count++;
            else if(s[i]==')')count--;
            if(!count){
                return stk(s.substr(1,i-1),p,q,r);
            }
        }
    }
     if(s[0]=='-'){
        return 2-(stk(s.substr(1,s.size()-1),p,q,r));
    }
    else if(s[0]=='0'){
        return 0;
    }
    else if(s[0]=='1'){
        return 1;
    }
    else if(s[0]=='2'){
        return 2;
    }
    else if(s[0]=='P'){
        return p;
    }
    else if(s[0]=='Q'){
        return q;
    }
    else if(s[0]=='R'){
        return r;
    }
    return 0;
}

void solve(string str){
    int ans=0;
    for(int p=0;p<3;p++){
        for(int q=0;q<3;q++){
            for(int r=0;r<3;r++){
                if(stk(str,p,q,r)==2){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

int main(void){
    string s;
    while(cin>>s,s[0]!='.'){
        solve(s);
    }    
    
    
    
}

Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>                                               //scanf,printf
#include <algorithm>                                            //max,min
#include <string>                                               //string
#include <cstring>                                              //strlen,strcat
#include <cctype>                                               //isalpha,tolower
#include <cmath>                                                //sqrt,sin
#include <stack>                                                //top,push
#include <queue>                                                //front,push
#include <vector>                                               //push_back,sort
#include <set>                                                  //insert,begin
#include <map>                                                  //insert,find
#include <list>                                                 //push_front,begin
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>                                               //pow,powf
#define INF (1<<21)
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  int n[3];
  n[0]=a;n[1]=b;n[2]=c;
  sort(n, n+3);
  
  int ans;
  if(n[2]>n[0]&&n[0]==n[1]){
    ans=n[2]-n[1];
  }else if(n[2]==n[1]&&n[0]<n[1]){
    if((n[2]-n[0])%2==0){
      ans=(n[2]-n[0])/2;
    }else{
      ans=(n[2]-n[0])/2+2;
    }
  }else{
    if((n[1]-n[0])%2==0){
      ans=(n[1]-n[0])/2+(n[2]-n[1]);
    }else{
      ans=(n[1]-n[0]-1)/2+1+n[2]-n[1]+1;
    }
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
N=int(input())
if N==3:
    print(2,5,63)
    sys.exit()
if N==4:
    print(2,5,20,63)
    sys.exit()
S=[]
L=[0,2,3,4]
for i in range(1,30001):
    j=i%6
    if j in L:
        S.append(i)
    if len(S)==N-1:
        break
s=sum(S)
def f(L):
    return print(' '.join(map(str,L)))
if s%6==0:
    f(S+[30000])
elif s%6==2:
    f(S+[29998])
elif s%6==3:
    f(S+[29997])
elif s%6==5:
    f(S[1:]+[29997,30000])
#print(len(S),s%6)

Measured memory_bytes: 42608
#include <cstdio>
using namespace std;

int A[20];
int m;
int n;
bool dfs(int i, int s){
  if (s == m)
    return true;
  if (s > m || i>=n )
    return false;
  return dfs(i+1, A[i]+s) || // Using A[i]
         dfs(i+1, s);        // Not use A[i]
}

int main(){
  scanf("%d", &n);
  for (int i=0;i<n;i++)
    scanf("%d", A+i);

  int mi[2000];
  int q;
  scanf("%d", &q);
  for (int i=0;i<q;i++){
    scanf("%d", mi+i);
  }
  for (int i=0;i<q;i++){
    m = mi[i];
    printf("%s\n",dfs(0,0)?"yes":"no");
  }
  return 0;
}



Measured memory_bytes: 2620
#include<bits/stdc++.h>
using namespace std;
int n, a[100], b[100], c = 0;
int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
    sort(a, a + n);
    for(int i = 0; i < n; i++) if(a[i] != b[i]) c++;
    if(c <= 2) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){

   long n;
   cin >> n;
   long s=0;
   for(int i=1; i<=n; i++){
      if(i%3==0||i%5==0){
         continue;
      }
      else{
         s+=i;
      }
   }
   cout << s << endl;
   
}   

Measured memory_bytes: 3636
import Control.Monad

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve [t1, x1, y1] [t2, x2, y2]
    | t < d        = False
    | even (t - d) = True
    | otherwise    = False
    where d = abs (x1 - x2) + abs (y1 - y2)
          t = t2 - t1

main = do 
    n <- read <$> getLine :: IO Int
    c <- replicateM n getInts
    let x = [0, 0, 0] : c 
    let ans = and $ zipWith solve x (tail x)
    putStrLn $ if ans then "Yes" else "No"
    


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

int main(void){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    if(t>s)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}


Measured memory_bytes: 256
N, Q = map(int, input().split())
G = [tuple(map(int, input().split())) for _ in range(N-1)]
W = [tuple(map(int, input().split())) for _ in range(Q)]


# 親に付いている重み
r = [0,] * (N+1)
for p, x in W:
    r[p] += x



# 木の隣接関係
M = [[] for _ in range(N+1)]
for g in G:
    M[g[0]].append(g[1])
    M[g[1]].append(g[0])

# print(M)

# 木の親子関係
P = [[] for _ in range(N+1)]
visited = [0,] * (N+1)

def dfs(start):
    q = []
    q.append(start)
    while q:
        now = q.pop()
        visited[now] = 1
        for child in M[now]:
            if not visited[child]:
                r[child] += r[now]
                q.append(child)


dfs(1)

print(*r[1:])


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= (ll)a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T, class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<char c = ' ',class T> void write(T a){cout << setprecision(12) << a << endl;}
template<char c = ' ',class T,class ...Args> void write(T a, Args... args){cout << setprecision(12) << a << c; write<c>(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    int a[20];
    rep(i,10)read(a[i]);
    sort(a,a+10);
    rep(i,3)write(a[9-i]);
    return 0;
}

Measured memory_bytes: 3080
#pragma warning (disable: 6031)
#pragma warning (disable: 26451)

#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <map>


//const int mod = 1000000007;
const int mod = 998244353;
int maximum(int a, int b) { return a < b ? b : a; }
int minimum(int a, int b) { return a > b ? b : a; }
using std::pair;



class SegTree {
	int** c;
	int level;
	int (*func)(int, int);
	int outval;
public:
	SegTree(int (*func)(int, int), int n, int t = 0, int outval = 0) :func(func), outval(outval) {
		for (int i = 0; i < 30; i++) {
			if (1 << i >= n) {
				level = i + 1;
				break;
			}
		}
		c = new int* [level];
		for (int i = 0; i < level; i++) {
			c[i] = new int[1 << (level - 1 - i)];
			for (int j = 0; j < 1 << (level - 1 - i); j++) {
				if (i == 0) {
					c[0][j] = j < n ? t : outval;
				}
				else {
					c[i][j] = func(c[i - 1][j << 1], c[i - 1][(j << 1) + 1]);
				}
			}
		}
	}
	SegTree(int (*func)(int, int), int n, int* t, int outval = 0) :func(func), outval(outval) {
		for (int i = 0; i < 30; i++) {
			if (1 << i >= n) {
				level = i + 1;
				break;
			}
		}
		c = new int* [level];
		for (int i = 0; i < level; i++) {
			c[i] = new int[1 << (level - 1 - i)];
			for (int j = 0; j < 1 << (level - 1 - i); j++) {
				if (i == 0) {
					c[0][j] = j < n ? t[j] : outval;
				}
				else {
					c[i][j] = func(c[i - 1][j << 1], c[i - 1][(j << 1) + 1]);
				}
			}
		}
	}
	void modval(int ind, int val) {
		c[0][ind] = val;
		for (int i = 1; i < level; i++) {
			c[i][ind >> 1] = func(c[i - 1][ind], c[i - 1][ind ^ 1]);
			ind >>= 1;
		}
	}
	int valInc(int from, int to) {
		int fv = c[0][from];
		int tv = c[0][to];
		for (int i = 0; i < level; i++) {
			if (from >> 1 == to >> 1)break;
			if (!(from & 1)) {
				fv = func(fv, c[i][from ^ 1]);
			}
			from >>= 1;
			if (to & 1) {
				tv = func(tv, c[i][to ^ 1]);
			}
			to >>= 1;
		}
		return func(fv, tv);
	}
};

int search(pair<int, int>* p, int t, int n) {
	int r = 0;
	for (int i = 30; i >= 0; i--) {
		int c = r | (1 << i);
		if (c >= n)continue;
		if (p[c].first < t)r = c;
	}
	return r;
}

int main() {
	int N;
	scanf("%d", &N);
	auto p = new pair<int, int>[N];
	for (int i = 0; i < N; i++) {
		int X, D;
		scanf("%d %d", &X, &D);
		p[i] = pair<int, int>{ X,X + D };
	}
	std::sort(p, p + N);
	SegTree st(maximum, N);
	auto dp = new long long[N + 1];
	dp[N] = 1;
	for (int i = N - 1; i >= 0; i--) {
		int r = search(p, p[i].second, N);
		r = maximum(st.valInc(i, r), r);
		st.modval(i, r);
		dp[i] = dp[i + 1] + dp[r + 1];
		dp[i] %= mod;
	}
	printf("%lld", dp[0]);
	return 0;
}

Measured memory_bytes: 5504
A,B = map(int, input().split())

h,w = (100, 100)
print(h, w)

G = [[ '#' if i < 30 else '.' for j in range(w)] for i in range(h)]
A -= 1
B -= 1
for i in range(A // 50):
    for j in range(50):
        G[2*i][j*2] = '.'
for j in range(A % 50):
    G[2*(A // 50)][2*j] = '.'

for i in range(B // 50):
    for j in range(50):
        G[2*i + 40][j*2] = '#'
for j in range(B % 50):
    G[40 + 2*(B // 50)][2*j] = '#'

for line in G:
    print("".join(line))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <pair <ll, ll>> v(n, pair <ll, ll> ());
  rep(i, n) {
    cin >> v.at(i).second >> v.at(i).first;
  }
  sort(v.begin(), v.end());
  bool flag = 1;
  ll time = 0;
  rep(i, n) {
    if (time+v.at(i).second > v.at(i).first) flag = 0;
    time += v.at(i).second;
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

ll cal(ll a){
	ll res = 0;
	for(int i = 0; i < 50; i++){
		ll t = (1LL<<(i+1)),cnt = (a/t)*(t/2);
		cnt += max(0LL,a%t-t/2);
		if(cnt%2) res |= (1LL<<i);
	}
	return res;
}

int main()
{
	ll a,b;
	cin >> a >> b;
	ll ans = cal(b+1)^cal(a);
	cout << ans << endl;
	return 0;
}

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

int main(){
    int N, a, b;
    cin >> N;
    a = N/100;
    b = N%10;
    cin >> a >> b;
    if (a == b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main() {
  int N, T;
  cin >> N >> T;
  struct Data {int A, B;};
  vector<Data> food(N);
  for(auto& f: food) cin >> f.A >> f.B;
  sort(begin(food), end(food), [](auto l, auto r) {return (l.A!=r.A) ? (l.A<r.A) : (l.B>r.B);});
  int ans = 0;
  vector<int> dp(6000+1);
  for(auto f: food) {
    auto a = f.A, b = f.B;
    for(int i=T-1; 0<=i; --i) {
      dp[i+a] = max(dp[i+a], dp[i]+b);
      ans = max(ans, dp[i+a]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>

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

using namespace std;

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

int main() {
	int n, i;
	cin >> n;
	vector<double> v(n);
	roop(i, n) {
		cin >> v.at(i);
	}

	sort(v.begin(), v.end());
	roop(i, n - 1) {
		v.at(i+1) = (v.at(i) + v.at(i + 1)) / 2;
	}

	cout << v.at(n - 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	string s;
	cin>>s;
    int a;
	bool f[2]={0,0};
	for(int i=0;i<s.size();i++)
	if(s[i]=='C'){ 
		f[0]=1;
		a=i;
		}
    if(f[0]) for(int i=a;i<s.size();i++) if(s[i]=='F') f[1]=1;
    if(f[0]&&f[1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

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

const int p=1e9+7;
int mod_pow(int a,int N){
	if(N==0)return 1;
	if(N%2==1)return (a*mod_pow(a,N-1))%p;
	int tmp=mod_pow(a,N/2);
	return (tmp*tmp)%p;
}

signed main(){
    int N; cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int keta=0,tmp=*max_element(A.begin(),A.end());
    while(tmp>0){tmp/=2; keta++;}
    //keta = 61;
    vector<pair<int,int>> dig(keta,make_pair(0,0));
    //dig[i]: firstにi桁目の1の数、secondに0の数
    for(int i=0;i<N;i++){
        for(int j=0;j<keta;j++){
            if(A[i] & (1LL<<j))dig[j].first++;
            else dig[j].second++;
        }
    }
    int ans=0;
    for(int i=0;i<keta;i++){
        assert(ans >= 0);
        int tmp=mod_pow(2,i);
        tmp*=dig[i].first; tmp%=p;
        tmp*=dig[i].second; tmp%=p;
        assert(tmp >= 0);
        ans+=tmp; ans%=p;
    }
    cout<<ans%p<<endl;
}


Measured memory_bytes: 2560