akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
typedef long long ll;
typedef pair<ll,int> pli;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)
#define pb push_back

int n;
pli v[N];
ll d[N];
int fa[N];
int siz[N];
map<ll,int> vis;

vector<int> edge[N];
ll val;

void dfs(int x,int fa,int dep){
   val += dep;
   fr(i,0,(int)edge[x].size()-1){
      int y = edge[x][i];
      if(y == fa)continue ;
      dfs(y,x,dep+1);
   }
}

int main(){
   val = 0;
   scanf("%d",&n);
   fr(i,1,n){
      scanf("%lld",d+i); v[i] = pli(d[i],i);
      vis[d[i]] = i;
   }

   sort(v+1,v+n+1,greater<pli>());
   fr(i,1,n-1){
      siz[v[i].second]++;
      ll w = v[i].first+siz[v[i].second]*2-n;
      if(!vis[w]){
         puts("-1"); return 0;
      } else {
         fa[v[i].second] = vis[w]; siz[vis[w]] += siz[v[i].second];
         edge[vis[w]].pb(v[i].second);
      }
   }

   dfs(v[n].second,0,0);
   if(val != v[n].first){
      puts("-1"); return 0;
   }
   
   fr(i,1,n-1){
      printf("%d %d\n",v[i].second,fa[v[i].second]);
   }
   return 0;
}


Measured memory_bytes: 20096
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x *= f;
}

const int maxn = 2e5 + 5;
int n;
char s[maxn];
int pre[maxn], suf[maxn];
int ans;

int main(){
  rd(n);
  ans = n;
  scanf("%s", s + 1);
  rep(i, 1, n) pre[i] = pre[i - 1] + (s[i] == '#');
  per(i, n, 1) suf[i] = suf[i + 1] + (s[i] == '.');
  rep(i, 0, n) ans = min(ans, pre[i] + suf[i + 1]);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	vector<int> garage;
	vector<int> outgoing;
	int data;
	int train;
	while(cin>>train)
	{
		if(0==train)
		{
			outgoing.push_back(garage.back());
			garage.pop_back();
		}
		else
		{
			garage.push_back(train);
		}
	}
	for(int i=0;i<outgoing.size();++i)
	{
		cout<<outgoing[i]<<endl;
	}
}

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

int MAX = 1e9+7;

int dispatch(int total, vector<int>& criterias){

    if(total == 0)
        return 1;
    
    int n = criterias.size();

    vector<vector<int> > records = vector<vector<int> >(total+1, vector<int>(n+1, 0));

    records[0][0] = 1;
    for(int candies = 1; candies <= total; candies++)
        records[candies][0] = records[candies-1][0];
    for(int people = 1; people <= n; people++)
        records[0][people] = 1;

    for(int people = 1; people <= n; people++){
        for(int candies = 1; candies <= total; candies++){

             int low = (candies-criterias[people-1]-1 >= 0)?records[candies-criterias[people-1]-1][people-1]:0;

             int sum = (records[candies][people-1]-low) % MAX;
             records[candies][people] = (records[candies-1][people] + sum) % MAX;

//             cout << "candies=" << candies << " people=" << people << " result=" << records[candies][people]-records[candies-1][people] << "\n";
        }
    }

    return (records[total][n]-records[total-1][n]+MAX*2ll) % MAX;
}


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

    vector<int> criterias = vector<int>(n);

    for(int i = 0; i < n; i++)
        cin >> criterias[i];

    int result = dispatch(k, criterias);

    cout << result << "\n";

    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	map<int, int> m;
	for (int i = 1; i <= n; ++i) {
		int in;
		cin >> in;
		m[in] = i;
	}
	for (auto item : m) {
		cout << item.second << " ";
	}
	return 0;
}

Measured memory_bytes: 5504
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int dish = 0;
    	int dish_min = 0;
    	int dish_nokori= 0;
    	int sum = 0;

    	for(int i=0; i< 5; i++){
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	}

		if (dish_min != 0){
			dish_nokori = 10 - dish_min;
	    	sum -= dish_nokori;
		}

    	// 出力
    	System.out.println(sum);
    }
}

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

const int MOD = 998244353;

string s;
vector<int> v;
int l;
int mod3_s;
map<vector<int>, bool> used;

int solve1(vector<int> now) {
  if ( used[now] ) return 0;
  used[now] = true;
  
  int ret = 1;
  for ( int i = 0; i < l-1; i++ ) {
    if ( now[i] != now[i+1] ) {
      vector<int> nxt = now;
      nxt[i] = nxt[i+1] = 3-now[i]-now[i+1];
      ret += solve1(nxt);
    }
  }
  
  return ret;
}

int dp[200001][3][4][2]; //dp[idx][mod 3][bool]
int solve2(int now, int mod3, int pre, int flag) {
  if ( now == l ) {
    if ( flag && mod3 == mod3_s ) return 1;
    else return 0;
  }
  if ( dp[now][mod3][pre][flag] >= 0 ) return dp[now][mod3][pre][flag];
  
  int ret = 0;
  for ( int i = 0; i < 3; i++) {
    ret += solve2(now+1, (mod3+i)%3, i, flag|(pre==i));
    ret %= MOD;
  }

  return dp[now][mod3][pre][flag] = ret%MOD;
}

int main() {
  cin >> s;
  l = s.size();
  for ( int i = 0; i < l; i++ ) v.push_back(s[i]-'a'), mod3_s += v[i];
  mod3_s %= 3;  

  if ( (((int)s.find("a") >= 0) + ((int)s.find("b") >= 0) + ((int)s.find("c") >= 0)) == 1 ) {
    cout << 1 << endl;
  } else if ( l <= 3 ) {
    cout << solve1(v) << endl;
  } else {
    fill_n(***dp, 200001*3*4*2, -1);
    int ans = solve2(0, 0, 3, 0);
    if ( !((int)s.find("aa") >= 0 || (int)s.find("bb") >= 0 || (int)s.find("cc") >= 0) ) ans++;
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 35704
import copy

sd = str(input())
t = str(input())
s = copy.deepcopy(sd)

flg = False
pin = -1
for i in reversed(range(len(sd)-len(t)+1)):
    for j in range(len(t)):
        if sd[i+j] != t[j] and sd[i+j] != '?':
            break
        elif j == len(t)-1:
            flg = True
            pin = i
            break
    if flg:
        break
if flg:
    s = s[0:pin] + t + s[pin+(len(t)):]
    s = s.replace('?', 'a')
    print(s)
else:
    print('UNRESTORABLE')

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int H,W,m;cin >>H>>W>>m;
    int mxh=0,mxw=0;
    ll MX=300010;
    vector<int>ch(MX,0);
    vector<int>cw(MX,0);
    map<P,bool>mp;
    for (int i = 0; i < m; ++i) {
        int h,w;cin >>h>>w;
        h--;w--;
        ch[h]++;cw[w]++;
        mxh=max(mxh,ch[h]);
        mxw=max(mxw,cw[w]);
        mp[{h,w}]=true;
    }
    vector<int>x;
    vector<int>y;
    for (int i = 0; i <=H; ++i) {
        if(mxh==ch[i])x.push_back(i);
    }
    for (int j = 0; j <=W; ++j) {
        if(mxw==cw[j])y.push_back(j);
    }
    ll ans=mxh+mxw;
    bool exist=false;
    ll k=x.size()*y.size();//交点の数
    if(k>m){
        cout <<ans<<endl;
        return 0;
    }
    for(auto i:x){
        for(auto j:y){
            if(!mp[{i,j}])exist=true;
        }
    }
    if(!exist)ans--;
    cout <<ans <<endl;
}


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

long long n,a,m,k,q,b,c=1;
float qq,ww,ff=2,qs;
string ss,s1,s2;
int main(){
    cin>>n;
    vector<int>v(n,0);
    for (int i=0; i<n; i++){
        cin>>v[i];
    }
    for (int i=0; i<n; i++){
        a=max(a,v[i]*1ll);
        if (v[i]>=a){
            b++;
        }
    }
    cout<<b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ses   "\n"
#define whp   " "
#define mxi 99999
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define PI acos(-1)
#define sz(a) long long(a.size())
#define ff first
#define ss second
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)
//ostringstream str1;
 //       str1 << z;
  //      string c=str1.str();
///priority_queue <int, vector<int>, greater<int>> g
#define MS(a,b) memset(a,b,sizeof(a));

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll fx[4]= {1,-1,0,0};
ll fy[4]= {0,0,1,-1};

typedef vector<ll> vll;
typedef vector<string> vss;
typedef vector<pair<ll,ll > > vpr;
typedef vector<pair<string,ll > > vspr;
typedef list<ll> li;
typedef list<string> ls;
typedef list<pair<ll,ll> > lpr;
typedef list<pair<string,ll> > lspr;
bool rs(ll a, ll b){return(a>b);}
ll spd(ll n){ if(n%2==0)return 2; for(ll i=3; i*i<=n; i++){if(n%i==0)return i;}return n;}

int main(){
    string s;cin>>s;
    ll sum=0;
    for(ll i=0; i<s.length(); i++){
        ll k=s[i]-'0';
        sum+=k;
    }
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 3704
//前置き
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//偶数 ->　true :: 奇数　-> false
bool EVEN(ll a);

//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main(){
    // ========================================================
    string a,b;
    int cnt = 0;
    cin >> a >> b;
    REP(i, 3){
        if(a[i] == b[i]) cnt++;
    }
    cout << cnt << endl;
}

//偶数 ->　true :: 奇数　-> false
bool EVEN(ll a){
    return a%2;
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
    sort(arr,arr+n);
    ll cnt=0;
	for(ll i=n-1;i>=0;i--)
	{
		sum+=arr[i];
		cnt++;
		if(cnt==k)
		{
			break;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll mod_power(ll x, ll n) {  //繰り返し二乗法
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

ll extgcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    else {
        ll d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
        return d;
    }
}


ll mod_inv(ll a, ll m = MOD) {  // a^-1 mod m
    return mod_power(a, m-2);
}

ll nCk(ll n, ll k) {
    if (k == 0)
        return 1;
    else
        return nCk(n, k - 1) * (n - k + 1) % MOD * mod_inv(k) % MOD;
}

int main() {
    ll n, m, k, tmp = 0, ans = 0;
    cin >> n >> m >> k;
    // y
    for(ll i = 0; i<n; i++){
        tmp += i*(n-i);
        tmp %= MOD;
    }
    tmp *= nCk(n*m-2,k-2);
    tmp %= MOD;
    tmp *= m*m;
    ans += tmp;
    // x
    tmp = 0;
    for(ll i = 0; i<m; i++){
        tmp += i*(m-i);
        tmp %= MOD;
    }
    tmp *= nCk(n*m-2,k-2);
    tmp %= MOD;
    tmp *= n*n;
    ans += tmp;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def f(m):
    res = 0
    r_m = math.sqrt(m)
    for i in range(1, int(r_m) + 1):
        for j in range(1, int(r_m) + 1):
            for k in range(1, int(r_m) + 1):
                if i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i == m:
                    print(f'{(m, i, j, k)=}')
                    res += 1
    return res


n = I()
cnt = [0] * 10001
r_n = int(math.sqrt(n)) + 1
for x in range(1, r_n):
    for y in range(1, r_n):
        for z in range(1, r_n):
            v = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if v <= n:
                cnt[v] += 1

for i in range(1, n + 1):
    print(cnt[i])


Measured memory_bytes: 9292
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>

#define INF 1000000005

using namespace std;


int dp[4000][4000];
int tab[4000][4000];

string c1, c2;
string score = "";

int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin >> c1 >> c2;
    
    for(int i = 0; i < c1.size(); i++){
        for(int j = 0; j < c2.size(); j++){
            if(c1[i] == c2[j]){
                tab[i][j]++;
            }
        }
    }
    
    for(int i = 1; i <= c1.size(); i++){
        for(int j = 1; j <= c2.size(); j++){
            dp[i][j] = max(max(dp[i][j - 1], dp[i - 1][j - 1] + tab[i - 1][j - 1]), dp[i - 1][j]);
            
            
        }
    }
    //cout<<dp[c1.size()][c2.size()];
    
    
    //recover string
    int point1 = c1.size();
    int point2 = c2.size();
    
    while(score.size() < dp[c1.size()][c2.size()]){
        if(dp[point1][point2] == dp[point1][point2 -1]){//nic nie bralem wiec continue
            point2--;
            continue;
            
        }
        else if(dp[point1][point2] == dp[point1 - 1][point2 - 1] + tab[point1 - 1][point2 - 1]){
            point2--;
            point1--;
            score += c1[point1];
        }
        else{
            point1--;
        }
    }
    //score.reverse()
    reverse(score.begin(), score.end());
    cout << score;
    
    
}



Measured memory_bytes: 96512
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    long long N,A,B,C,D,E;
    cin >> N >> A >> B >> C >> D >> E;
    
    long long MIN = min({A,B,C,D,E});
    
    long long ans = 0;
    
    ans = (N+MIN-1)/MIN+4;
    
    
    cout << ans << endl;
    return 0;
}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T1> bool chmax(T1 &a, const T1 &b) { if (a < b) { a = b; return true; } return false; }
template<class T1> bool chmin(T1 &a, const T1 &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

struct Cube
{
	int w,s,v;
	Cube(int w,int s,int v):w(w),s(s),v(v){}
	Cube():Cube(0,0,0){}
	bool operator<(const Cube& other)const
	{
		return w+s<other.w+other.s;
	}
};

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

	int N;
	cin>>N;
	vector<Cube> C(N);
	rep(i,0,N)cin>>C[i].w>>C[i].s>>C[i].v;

	sort(all(C));
	vector<int> DP(20010,0);

	rep(i,0,N)
	{
		rrep(j,0,200010)
		{
			if(j>=C[i].w&&j-C[i].w<=C[i].s)
			{
				chmax(DP[j],DP[j-C[i].w]+C[i].v);
			}
		}
	}

	int ans=0;
	rep(i,0,20010)chmax(ans,DP[i]);

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 512
import math
from fractions import gcd
from functools import reduce
def gcds(*numbers):
    return reduce(gcd, numbers)

def resolve():
    N = int(input())
    As = list(map(int, input().split(" ")))
    
    left = [0] * (N + 1)
    right = [0] * (N + 1)
    for i in range(N):
        left[i + 1] = (gcd(left[i],As[i]))
        right[N - 1 - i] = (gcd(right[(N - 1) - i + 1], As[(N - 1) - i]))

    gcdmax = 0
    for i in range(N):
        gcdmax = max(gcdmax, gcd(left[i], right[i+1]))
    return gcdmax

if '__main__' == __name__:
    print(resolve())

Measured memory_bytes: 16140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define ll long long
using namespace std;

int main(){
	string a,b,c,x,s;

	cin>>a>>b>>c;
	
	s+=a.substr(0,1);
	s+=b.substr(0,1);
	s+=c.substr(0,1);

	transform(s.begin(), s.end(), s.begin(), ::toupper);

	cout<<s<<endl;
   	return 0;
}


Measured memory_bytes: 256
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

#A, B = map(int,input().split())
K = int(input())
S = str(input())
s = len(S)

if(s<=K):
    print(S)
else:
    ans = S[:K]
    print(ans+"...")


Measured memory_bytes: 74868
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
const long long MAXN=100005,INF=4223372036854775807ll;
long long n;
long long d[MAXN][3];
long long a;
int main()
{
	scanf("%lld",&n);
	char s[100];
	scanf("%lld",&a);
	for(long long i=0;i<=n+1;i++)
	{
		d[i][0]=d[i][1]=d[i][2]=-INF;
	}
	d[1][0]=a;
	for(long long i=2;i<=n;i++)
	{
		scanf("%s",s);
		scanf("%lld",&a);
		if(s[0]=='+')
		{
			d[i][0]=max(d[i-1][0],d[i-1][1])+a;
			d[i][1]=d[i-1][1]-a;
			d[i][2]=d[i-1][2]+a;
		}
		if(s[0]=='-')
		{
			d[i][0]=-INF;
			d[i][1]=max(d[i-1][0],d[i-1][1])-a;
			d[i][2]=max(d[i-1][1],d[i-1][2])+a;
		}
	}
	printf("%lld\n",max(max(d[n][0],d[n][1]),d[n][2]));
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int num[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
  int k;
  cin >> k;
  cout << num[k];

}

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

int main(){
    string s,t;
    cin >> s >> t;
    int count = 0;
    rep(i,s.length()){
        if(s.at(i)!=t.at(i)){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3920
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        String output="";
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='B'){
                if(output.length()!=0){
                    output=output.substring(0,output.length()-1);
                }
            }else{
                output+=s.substring(i,i+1);
            }
        }
        System.out.println(output);
        
    }
    
 
}

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

int main() {
	int a = 0;
	int N = 0;
	int ans = 0;
	int A[3][3] = { 0 };
	int B[10] = { 0 };

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (B[i] == A[j][k]) {
					A[j][k] = 0;
				}
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		if (A[i][0] == A[i][1] && A[i][0] == A[i][2]&&A[i][0]==0){
			ans = 1;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (A[0][i] == A[1][i] && A[0][i] == A[2][i] && A[0][i] == 0) {
			ans = 1;
		}
	}

	if (A[0][0] == A[1][1] && A[0][0] == A[2][2]) {
		ans = 1;
	}
	if (A[0][2] == A[1][1] && A[0][2] == A[2][0]) {
		ans = 1;
	}
	if (ans == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stdio.h>
#include <string>
#include <typeinfo>
#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++)
using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;
  int sumYard;
  sumYard = A * B - (A * 1) - (B * 1) + 1;
  cout << sumYard << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
X = int(input())
def func(X, i):
    a_i, X = X//i, X - X//i * i
    return a_i, X
a_500, X = func(X, 500)
#a_100, X = func(X, 100)
#a_50, X = func(X, 50)
#a_10, X = func(X, 10)
a_5, X = func(X, 5)
#a_1, X = func(X, 1)
print(a_500 * 1000 + a_5 * 5)


Measured memory_bytes: 3060
// 2020-07-18 10:41:19
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct mint {
  ll divisor = 1000000007;
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % divisor) {
    if (val < 0) val += divisor;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = divisor, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += divisor;
    u %= divisor;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= divisor) val -= divisor;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += divisor;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % divisor;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % divisor;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
  friend std::string debug_s (mint a) noexcept {
    return std::to_string(a.val);
  }
};

void answer() {
  int n, k;
  cin >> n >> k;
  vector<mint> mp(k+1);
  mint ans = 0;
  REPCM(x, k, 1) {
    mp[x] = modpow(mint(k/x), n);
    int y = x + x;
    while(y <= k) {
      mp[x] -= mp[y];
      y += x;
    }
    ans += mp[x] * x;
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4724
Program Frog1;
uses math;
var F,H:Array[-1000..100005] of longint;
    i,n,k,j :longint;
    minn:int64;
    fi,fo:text;
//--------------------------------
begin
//assign(fi,'Frog1.inp');reset(Fi);
readln(n,k);
for i:=1 to n do begin
                 Read(H[i]);
                 end;
F[1]:=0;
F[0]:=0;
for i:=0 downto -1000 do begin
                         H[i]:=1000000;
                         end;
for i:=2 to n do begin
                 F[i]:=1000000000;
                 for j:=1 to k do begin
                                  F[i]:=min(F[i],F[i-j]+abs(H[i]-H[i-j])); 
                                  end;
                 end;
Writeln(F[n]);
//readln;
end.


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 1e5 + 10;
int n, K, Q, a[N], t[N];

int main() {
    cin >> n >> K >> Q;
    // rep(i, 1, n) t[i] = K;
    rep(i, 1, Q) {
        scanf("%d", &a[i]);
        if (a[i] > 1) {
            t[1]--, t[a[i]]++;
        }
        if (a[i] < n) {
            t[a[i] + 1]--, t[n + 1]++;
        }
    }
    rep(i, 1, n) t[i] += t[i - 1];
    rep(i, 1, n) {
        if (t[i] + K <= 0) puts("No");
        else puts("Yes");
    }
    return 0;
}


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


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int d = 100  * a + 10 * b + c;
	if (d % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, q, l, r;
	cin>>n>>q;
	string s;
	cin>>s;
	vector<int> table(n, 0);
	for(int i = 1; i < n; ++i){
		if(s[i]=='C' && s[i - 1] == 'A')table[i] = table[i - 1] + 1;
		else table[i] = table[i - 1];		
	}
	for(int i = 0; i < q; ++i){
		cin>>l>>r;
		l--, r--;
		cout<<table[r] - table[l]<<endl;
	}
	
	return 0;
}


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

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;

#define pb push_back

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
   string s;
   cin >> s;
   int n = s.size(), k = 0;
   vector<int> block(n, 0);
   for (int i = 0; i < n; i++) {
   	if (s[i] == 'S') continue;
   	if (i > 0 && s[i - 1] != s[i]) ++k;
   	block[k]++;
   }
   cout << *max_element(block.begin(), block.end());
   return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n,s=0;
int a[1000000];
int b[1000000];
int c[1000000];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];s=s+b[i];
	}
	for(int i=1;i<=n-1;i++)
	{
		cin>>c[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==a[i+1]-1) s=s+c[a[i]];
	}
	cout<<s;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    int q;
    cin>>q;
    int f[100010]={};
    for(int i=2;i<=100000;i++){
        for(int j=i+i;j<=100000;j+=i) f[j]++;
    }
    int ans[100010]={};
    int cnt = 0;
    for(int i=0;i<=100000;i++){
        if(f[i]>=3) cnt++;
        ans[i] = cnt;
    }
    while(q--){
        ll n;
        cin>>n;
        cout << ans[n] << "\n";

    }
}


Measured memory_bytes: 3968
N,W = map(int,input().split())
Value = []
weight = []
inf=float("inf")
dp=[[-inf for i in range(W+1)] for j in range(N+1)]
for i in range(W+1): dp[0][i]=0

for i in range(N):
    v,w = map(int,input().split())
    Value.append(v)
    weight.append(w)


for i in range(N):
  for w in range(W+1):
    if w>=weight[i]:
      dp[i+1][w] = max(dp[i][w-weight[i]]+Value[i],dp[i][w])
    else:
      dp[i+1][w] = dp[i][w]

print(dp[N][W])


Measured memory_bytes: 42472
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
#include <bitset>
using namespace std;
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define sld(n) scanf("%lld",&n)
#define sldd(n,m) scanf("%lld%lld",&n,&m)
#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define sf(n) scanf("%lf",&n)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ansn() printf("%d\n",ans)
#define lansn() printf("%lld\n",ans)
#define r0(i,n) for(int i=0;i<(n);++i)
#define r1(i,e) for(int i=1;i<=e;++i)
#define rn(i,e) for(int i=e;i>=1;--i)
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define lowbit(a) (a&(-a))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mp(aa,bb) make_pair(aa,bb)
#define lrt rt<<1
#define rrt rt<<1|1
#define X first
#define Y second
#define PI (acos(-1.0))
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000007 ;
const double eps=1e-9;
const int inf=0x3f3f3f3f;
//const ll infl = 10000000000000000;
const int maxn=  5e4+10;
const int maxm = 1e3+10;
//Pretests passed
int in(int &ret)
{
    char c;
    int sgn ;
    if(c=getchar(),c==EOF)return -1;
    while(c!='-'&&(c<'0'||c>'9'))c=getchar();
    sgn = (c=='-')?-1:1;
    ret = (c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0');
    ret *=sgn;
    return 1;
}

int main()
{
#ifdef LOCAL
    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif // LOCAL


    ll x,y;
    sldd(x,y);
    int ans = 0;
    ull now = x;
    while(now<=y)
    {
        now<<=1;
        ++ans;
    }
    ansn();
    return 0;
}


Measured memory_bytes: 256
#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))
//-------------------------------------------------------

ll N,S;

ll f(ll b,ll n) {
	if(n<b) return n;
	return f(b,n/b)+(n%b);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	if(S>N) return _P("-1\n");
	if(N==S) return _P("%lld\n",N+1);
	set<ll> SS;
	for(ll b=2;b*b<=N;b++) {
		if(f(b,N)==S) SS.insert(b);
	}
	for(ll p=1;p*p<N && p<=S;p++) {
		ll m=S-p;
		if(N-m>=0 && (N-m)%p==0) {
			ll b=(N-m)/p;
			if(b>p && b>m) SS.insert((N-m)/p);
		}
		
	}
	
	
	if(SS.size()) return _P("%lld\n",*SS.begin());
	return _P("-1\n");
}


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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
inline bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s.at(i);
	vector<vector<int>> dp(h + 1,vector<int>(w + 1, 1000000000));
	dp[0][0] = 0;
	if(s[0][0] == '#') dp[0][0] = 1;
	rep(i,h){
		rep(j,w){
			if(i < h - 1) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + ((s[i][j] == s[i + 1][j] || s[i + 1][j] == '.') ? 0 : 1));
			if(j < w - 1) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + ((s[i][j] == s[i][j + 1] || s[i][j + 1] == '.') ? 0 : 1));
		}
	}
	cout << dp[h - 1][w - 1] << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());
		Dictionary<int,int> dict = new Dictionary<int,int>(N);

		string[] args = Console.ReadLine().Split(' ');
		for(int i = 0; i < N; i++)
		{
			int a = Int32.Parse(args[i]);
			int num = 0;
			dict.TryGetValue(a, out num);
			dict[a] = num + 1;
		}

		int ans = 0;
		foreach(int a in dict.Keys)
		{
			int num = dict[a];
			if(num < a)
			{
				ans += num;
			}
			else if(num > a)
			{
				ans += num - a;
			}
		}

		Console.WriteLine(ans);
	}	
}





Measured memory_bytes: 31328
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.concurrent.LinkedBlockingDeque;

public class Main {
    static final int MX = 100_000;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();

        int edge[][] = new int[m][2];
        for (int i = 0; i < m; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            edge[i][0] = a;
            edge[i][1] = b;
        }

        int notBridge = 0;
        for (int i = 0; i < m; i++) {
            P p[] = new P[n];
            for (int j = 0; j < n; j++) {
                p[j] = new P(j);
            }

            for (int j = 0; j < m; j++) {
                if (i == j) continue;
                p[edge[j][0]].adj.add(p[edge[j][1]]);
                p[edge[j][1]].adj.add(p[edge[j][0]]);
            }

            boolean reach[] = new boolean[n];
            Arrays.fill(reach, false);
            Queue<P> q = new LinkedBlockingDeque<>();
            q.add(p[0]);
            while (q.size() > 0) {
                P next = q.poll();
                if (reach[next.n] == true) {
                    continue;
                }
                reach[next.n] = true;
                for (P p2 : next.adj) {
                    q.add(p2);
                }
            }
            reach[0] = true;

            int total = 0;
            for (int j = 0; j < n; j++) {
                if (reach[j] == false) {
                    break;
                }
                total++;
            }
            if (total == n) {
                notBridge++;
            }
        }
        System.out.println(m - notBridge);
    }
}

class P {
    int n;
    List<P> adj = new ArrayList<P>();
    public P(int n)  {
        this.n = n;
    }
}

Measured memory_bytes: 36908
def main():
    N = int(input())
    S = list(input())
    
    R = [0]
    x = 0
    for s in S:
        if s == "I":
            x += 1
        else:
            x -= 1
        R.append(x)
    R.sort()
    print(R[-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int hako[555][555];


int main(){
  int n,m,q;

  cin>>n>>m>>q;

  int l,r;
  for(int i=0;i<m;i++){
    cin>>l>>r;
    hako[l][r]++;
  }

  for(int i=1;i<=n+1;i++){
    for(int j=1;j<=n;j++){
      hako[i][j]+=hako[i][j-1];
    }
  }

  for(int i=0;i<q;i++){
    cin>>l>>r;
    int res=0;
    for(int i=l;i<=r;i++){
      res+=hako[i][r]-hako[i][l-1];
    }
    cout<<res<<endl;
  }

  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    vector<vector<int>> c(3,vector<int>(3));
    cin>>c;
    REP(a1,101) {
        vector<int> b(3);
        REP(j,3) {
            b[j]=c[0][j]-a1;
        }
        vector<int> a(3);
        REP(i,3) {
            a[i]=c[i][0]-b[0];
        }
        bool ok=true;
        REP(i,3) {
            REP(j,3) {
                if(c[i][j]!=a[i]+b[j]) {
                    ok=false;
                }
            }
        }
        if(ok) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
program fifty_fifty
  implicit none
  character(4) :: s
  integer :: a(26), i
  a = 0
  read(*,*) s
  do i = 1, 4
    a(ichar(s(i:i))-64) = a(ichar(s(i:i))-64)+1
  end do
  if (maxval(a).eq.2.and.minval(a,a.gt.0).eq.2) then
    write(*,'(a)') "Yes"
  else
    write(*,'(a)') "No"
  end if
  stop
end program fifty_fifty

Measured memory_bytes: 640
from collections import deque
n, q = list(map(int, input().split()))
que = deque([])
for i in range(n):
  n, t = input().split()
  que.append((n, t))

e = 0
while len(que)>0:
  n, t = que.popleft()
  if int(t)<=q:
    e += int(t)
    print(n, e)
  else:
    e += q
    que.append((n, int(t)-q))


Measured memory_bytes: 12536
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;
import java.util.Set;
import java.util.HashMap;
import java.util.Map;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    /* 標準入力数値配列用 long */
    static long[] inputLongArr() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        long[] longarray = new long[strarray.length];
        for (int i = 0; i < longarray.length; i++) {
            longarray[i] = Integer.parseInt(strarray[i]);
        }
        return longarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer 降順ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    /*標準入力long*/
    static long inputLong() throws Exception {
        return Long.parseLong(br.readLine());
    }

    /*標準入力long*/
    static int inputInt() throws Exception {
        return Integer.parseInt(br.readLine());
    }

    
    public static void main(String[] args) throws Exception {
        // write your code here
        int n = inputInt();
        long [] al = inputLongArr();
        boolean increase = false;
        boolean decrease = false;
        long ans = 0;

        for (int i = 0; i<(n-1); i++){
            if (al[i] > al [i+1]){
                decrease = true;
                if (increase){
                    ans ++;
                    increase = false;
                    decrease = false;
                }
            }else if (al[i] < al [i+1]){
                increase = true;
                if(decrease){
                    ans ++;
                    increase = false;
                    decrease = false;
                }
            }

        }

        System.out.println(ans+1);

    }

}



Measured memory_bytes: 47144
#include <cstdio>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

typedef long long ll;
const int N = 200010;

int n, m, tot, a[N], b[N], c[N], d[N * 3];
ll h[N * 3], f[N], ans;

void ins(int x, ll y) {for(; x <= m; x += x & -x) h[x] += y;}
ll find(int x) {ll ans = 0; for(; x; x -= x & -x) ans += h[x]; return ans;}

int main()
{
    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d", &a[i]), d[++tot] = a[i];
    FOR(i, 1, n) scanf("%d", &b[i]), d[++tot] = b[i];
    FOR(i, 1, n) scanf("%d", &c[i]), d[++tot] = c[i];
    sort(d + 1, d + tot + 1);
    m = unique(d + 1, d + tot + 1) - d - 1;
    FOR(i, 1, n) a[i] = lower_bound(d + 1, d + m + 1, a[i]) - d;
    FOR(i, 1, n) b[i] = lower_bound(d + 1, d + m + 1, b[i]) - d;
    FOR(i, 1, n) c[i] = lower_bound(d + 1, d + m + 1, c[i]) - d;
    FOR(i, 1, n) ins(a[i], 1LL);
    FOR(i, 1, n) f[i] = find(b[i] - 1);
    FOR(i, 1, m) h[i] = 0;
    FOR(i, 1, n) ins(b[i], f[i]);
    FOR(i, 1, n) ans += find(c[i] - 1);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 7936
#include <stdio.h>

int main(void) {
	unsigned long long prm[78499]={};
	unsigned long long int n,i,num=0,cnt=0;
	for(n=2;n<=1000003;n++) {
		for(i=2;i*i<=n;i++) {
			if(n%i==0) {
				cnt=1;
				break;
			}
		}
		if(cnt==0){
			prm[num]=n;
			num++;
		}
		cnt=0;
	}
	
	while (scanf("%lld",&n)!=EOF) {
		for(i=0;i<78499;i++) {
			if(n>=prm[i]) {
				cnt++;
			}
			else {
				printf("%lld\n",cnt);
				cnt=0;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long int;
using ld = long double;

 
int main() {
    
     int n,m;
     cin>>n>>m;
     map<int,int>mp;
     int res=0,pen=0;
     for(int i=0;i<m;i++)
     {
        int x;string s;
        cin>>x>>s;
        if(mp[x]!=1)
        {
        if(s[0]=='W'){mp[x]--;}
        if(s[0]=='A')
        {
            int y=mp[x];
            y=abs(y);
            res++;pen+=y;
            mp[x]=1;
        }
        }
         
     }
     
     cout<<res<<" "<<pen;
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

#define N 14

int main() {
    int num, n, i, j, card[4][N];       //0 = S, 1 = H, 2 = C, 3 = D
    char c;

    for (i = 0; i < 4; i++) {
        for (j = 0; j < N; j++) {
            card[i][j] = 0;
        }
    }

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%*c%c%d", &c, &num);

        if (c == 'S') {
            card[0][num] = 1;
        }
        else if (c == 'H') {
            card[1][num] = 1;
        }
        else if (c == 'C') {
            card[2][num] = 1;
        }
        else if (c == 'D') {
            card[3][num] = 1;
        }
    }

    for (i = 0; i < 4; i++) {
        for (j = 1; j < N; j++) {
            if (card[i][j] == 0) {
                if (i == 0) {
                    printf("S %d\n", j);
                }
                else if (i == 1) {
                    printf("H %d\n", j);
                }
                else if (i == 2) {
                    printf("C %d\n", j);
                }
                else if (i == 3) {
                    printf("D %d\n", j);
                }
            }
        }
    }

    return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
using ll = long long;

ll rt(const ll n)
{
    ll inf = -1;
    ll sup = 2 * sqrt(n);
    while (sup - inf > 1) {
        const ll mid = (sup + inf) / 2;
        if (mid * mid == n) {
            return mid;
        } else if (mid * mid > n) {
            sup = mid;
        } else {
            inf = mid;
        }
    }
    return inf;
}

int main()
{
    ll W, H, V, T, x, y, p, q;
    cin >> W >> H >> V >> T >> x >> y >> p >> q;
    const ll D = V * T;
    const ll INF = x - D;
    const ll SUP = x + D;
    ll ans = 0;
    for (int i = 0; i < 2; i++) {
        const ll X = (i == 0 ? p : 2 * W - p);
        const ll Xinf = ceil((double)(-X + INF) / (2 * W)) * (2 * W) + X;
        const ll Xsup = floor((double)(-X + SUP) / (2 * W)) * (2 * W) + X;
        for (int j = 0; j < 2; j++) {
            const ll Y = (j == 0 ? q : 2 * H - q);
            for (ll px = Xinf; px <= Xsup; px += 2 * W) {
                const ll dx = abs(px - x);
                if (dx > V * T) {
                    continue;
                } else {
                    const ll dy = rt(D * D - dx * dx);
                    const ll Yinf = y - dy;
                    const ll Ysup = y + dy;
                    const ll kinf = (ll)ceil((double)(Yinf - Y) / (2 * H));
                    const ll ksup = (ll)floor((double)(Ysup - Y) / (2 * H));
                    // cerr << "(" << i << ", " << j << ")" << endl;
                    // cerr << px << endl;
                    // cerr << Yinf << " " << Ysup << endl;
                    // cerr << kinf << " " << ksup << endl;
                    ans += ksup - kinf + 1;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3088