akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////



int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll p[n];rep(i,0,n-1)cin>>p[i];
    ll c[3];memset(c,0,sizeof(c));
    rep(i,0,n-1){
        if(p[i]<=a)c[0]++;
        else if(p[i]<=b)c[1]++;
        else c[2]++;
    }
    //rep(i,0,2)cout<<c[i]<<" ";cout<<endl;
    ll ans=min(c[0],c[1]);
    ans=min(ans,c[2]);
    cout<<ans<<endl;
    
    
    return 0;
}






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

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 998244353;

const int maxn = 2e3 + 7;
vector<int> graph[maxn];


int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<pair<int, int>> vp;
    for(int i = 1; i <= a; i++)
    {
    	int a;
    	cin >> a;
    	vp.pb({a, 1});
    }
    for(int i = 1; i <= b; i++)
    {
    	int a;
    	cin >> a;
    	vp.pb({a, 2});
    }
    for(int i = 1; i <= c; i++)
    {
    	int a;
    	cin >> a;
    	vp.pb({a, 0});
    }
    sort(vp.begin(), vp.end(), greater<pair<int, int>>());
    int buff = 0;
    int red = x, blue = y;
    int total = 0;
    for(int i = 0; i < vp.size(); i++)
    {
    	if(!vp[i].second)
    		buff++, total += vp[i].first;
    	else
    	{
    		if(vp[i].second == 1 && red > 0)
    			red--, total += vp[i].first;
    		else
    		if(vp[i].second == 2 && blue > 0)
    			blue--, total += vp[i].first;
    	}
    	if(buff >= (red + blue))
    		break;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 10476
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;
#define int LL

const int inf = 1e9;

signed main(){
	int te;scanf("%lld",&te);
	while(te--){
		int a,b;scanf("%lld%lld",&a,&b);
		if(a>b)swap(a,b);
		if(a==b){printf("%lld\n",2*a-2);continue;}
		if(a+1==b){printf("%lld\n",2*a-2);continue;}
		int c=sqrt(1ll*a*b);
		if(c*c==a*b)--c;
		if(c*(c+1)>=a*b)printf("%lld\n",2*c-2);
		else printf("%lld\n",2*c-1);
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

int N, M, x[131072];


int solve(vi a, int n){
	int sum = 0, r = 0;
	for(int i=0;i<a.size();i++){
		sum += a[i];
		r += a[i]%2;
	}
	return (sum-max(r,n))/2;
}




int main(void){
	cin >> N >> M;
	for(int i=0;i<N;i++) cin >> x[i];
	sort(&x[0], &x[N]);
	
	vvi a(M);
	vi v;
	for(int i=0;i<M;i++) a[i] = v;
	int cnt = 0;
	for(int i=0;i<=N;i++){
		if (i==N || (i>0 && x[i-1]!=x[i])){
			a[x[i-1]%M].pb(cnt);
			cnt = 1;
		}else{
			cnt++;
		}
	}
	/*
	for(int i=0;i<M;i++){
		for(int j=0;j<a[i].size();j++){
			cout << " " << a[i][j];
		}cout << endl;
	}*/
	
	int ans = 0;
	for(int i=0;i<M;i++){
		int i1 = i;
		int i2 = (M - i1)%M;
		if (i2 < i1) break;
		if (i2==i1){
			int sum = 0;
			for(int j=0;j<a[i].size();j++) sum += a[i][j];
			ans += sum/2;
		}else{
			int sum1 = 0;
			for(int j=0;j<a[i1].size();j++) sum1 += a[i1][j];			
			int sum2 = 0;
			for(int j=0;j<a[i2].size();j++) sum2 += a[i2][j];			
			if (sum1 < sum2) swap(i1, i2);
			ans += min(sum1, sum2) + solve(a[i1], min(sum1, sum2));
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 6144
#include <stdio.h>

int main(){
	int n,a[200],x=-1,i,flag=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}	
	do{
		x++;
		for(i=0;i<n;i++){
			if(a[i]%2==1){
				flag=1;
			}
			a[i]=a[i]/2;
		}
	}while(flag==0);
	printf("%d",x);
	
	
	return 0;
}


Measured memory_bytes: 128
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const s = next()
    let ans = ""
    for(let i = 0; i<s.length; i++){
        ans += "x"
    }
    console.log(ans)
}
Main()


Measured memory_bytes: 29364
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int n, k, ans = 1;
vector<int> G[100010];

void dfs(int now, int pre){
    int c = k - 2;
    if(now == 0) c = k - 1;
    for(auto i : G[now]){
        if(i == pre) continue;
        ans *= c;
        ans %= mod;
        c--;
        dfs(i, now);
    }
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    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);
    cout << ans * k % mod << endl;
}

Measured memory_bytes: 10368
import java.util.*;
import java.lang.*;
import java.io.*;

public final class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        List<Integer> pos = new ArrayList<>();
        List<Integer> neg = new ArrayList<>();
        
        for(int i =0; i< n; i++) {
        	int x = in.nextInt();
        	if(x>=0) pos.add(x);
        	else neg.add(0,Math.abs(x));
        }  
        
        int min=Integer.MAX_VALUE;
        if(pos.size()>=k)
        	min = Math.min(min, pos.get(k-1));
        if(neg.size()>=k)
        	min = Math.min(min, neg.get(k-1));

        for(int i =0; i< pos.size() && i<k; i++) {
        	int left = k-i-1;
        	if(neg.size()>=left && left>0) {
        		int a = pos.get(i);
        		int b = neg.get(left-1);
        		min= Math.min(min , Math.min(2*a+b, 2*b+a));
        	}
        }
        System.out.println(min);
    }
}


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

int main(){

  int a, b, c;
  int i;
  int cnt = 0;
  
  cin >> a >> b >> c;

  for(i = a; i <= b; i++){
    if(c % i == 0)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3080
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n,k,a[100001],dp[100001];

int main()
{Tie
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++)
	{
		dp[i]=1e9; 
		for(int j=max(i-k,0);j<i;j++)
			dp[i]=min(dp[i],dp[j]+abs(a[j]-a[i]));
	}
	cout << dp[n-1]<<'\n';
}

Measured memory_bytes: 1024
n, i = int(input()), 1
while True:
    x = i
    if x%3 == 0:
        print(" %d" %(i), end='')
    else:
        while True:
            if x%10 == 3:
                print(" %d" % (i), end='')
                break
            x //= 10
            if x == 0:
                break
    i += 1
    if i > n:
        break
print()

Measured memory_bytes: 7972
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var X = ReadLongs();

            for (int i = 0; i < 5; i++)
            {
                if (X[i] == 0)
                {
                    return i + 1;
                }
            }

            return null;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main(void){
   int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if( x>=r && x+r <= W && y >= r && y+r <= H ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int p=0,s=0,ss=0;
  for(int i=0;i<N;i++){
    if(a[i]%4==0){
      ss++;
    }
    else if(a[i]%2==0){
      s++;
    }
    else{
      p++;
    }
  }
  
  string ans="No";
  
  if(ss>=N/2){
    ans="Yes";
  }
  if(ss>=p){
    ans="Yes";
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h> 
#include<queue>
#include<string.h>
#include<stack>


using namespace std;

#define INF 2147483647


int n=1;
int A[300000];

void initRMQ(int size){

	while(n<size){
		n*=2;
	}
	for(int i=0;i<2*n-1;i++){
		A[i]=INF;
	}
}

void updata(int k,int x){
	k+=n-1;
	A[k]=x;
	while(k>0){
		k=(k-1)/2;
		A[k]=min(A[k*2+1],A[k*2+2]);
	}
}

int query(int x,int y,int k,int l,int n){
	if(n<=x||y<=l){
		return INF;
	}
	if(x<=l&&n<=y){
		return A[k];
	}
	int v1=query(x,y,k*2+1,l,(l+n)/2);
	int v2=query(x,y,k*2+2,(l+n)/2,n);
	return min(v1,v2);
}
int query2(int x,int y){
	return query(x,y,0,0,n);
}

int main(){
	int k;
	int q;
	cin>>k>>q;
	initRMQ(k);
	int qu;
	int x,y;
	for(int i=0;i<q;i++){
		cin>>qu>>x>>y;
		if(qu==0){
			updata(x,y);
		}
		else if(qu==1){
			cout<<query2(x,y+1)<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4116
//@source : 
//@create : 23:42:16 Monday 29/06/2020
//@author : nghethuat102
//@status : 
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;
    long long ans = 0;
    map<int, int> a;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a[x]++;
        ans += x;
    }
    int q;
    cin >> q;
    while (q--) {
        int x, y;
        cin >> x >> y;
        ans -= 1LL * x * a[x];
        ans += 1LL * y * a[x];
        a[y] += a[x];
        a[x] = 0;
        cout << ans << "\n";
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    while (t--) {
        solve();
    }
  //  cerr << fixed << setprecision(5) << double(clock()) * 1000 / CLOCKS_PER_SEC << " ms\n";
    return 0;
}

Measured memory_bytes: 8064
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W;
long long A[200005] = {};
long long B[200005] = {};
long long C[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <pl>vpl[20];
vector <string> vs[20];
set<ll> llset;

struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;

int main() {


	cin >> N>>S[0]>>S[1];

	a = 0;

	string sss[2][101];
	sss[0][0] = S[0][N-1];
	sss[1][0] = S[1][0];

	for (int i = 1; i < N; i++) {
		sss[0][i] = sss[0][i-1] + S[0][N-1-i];
		sss[1][i] = sss[1][i - 1] + S[1][i];
	}

	for (int i = N - 1; i >= 0; i--) {
		reverse(sss[0][i].begin(), sss[0][i].end());
		if (sss[0][i] == sss[1][i]) {
			a = i + 1;
			break;
		}
	}
	
	
	cout << S[0].size()+S[1].size()-a << endl;
	
	return 0;

}


Measured memory_bytes: 4352
import sys
from collections import Counter

n = int(input())
if n == 0:
    print(2)
    sys.exit()
elif n == 1:
    print(1)
    sys.exit()
l_list = [2, 1]
i = 2

while True:
    l_list.append(l_list[i-1] + l_list[i-2])
    if len(l_list) - 1 == n:
        print(l_list[-1])
        sys.exit()
    i += 1


Measured memory_bytes: 3316
n=int(input())
mat=[]
dp=[]

for i in range(n):
    l=list(map(int,input().split()))
    mat.append(l)
    dp.append([0]*3)

dp[0][0]=mat[0][0]
dp[0][1]=mat[0][1]
dp[0][2]=mat[0][2]

for i in range(1,n):
    dp[i][0]=max(dp[i-1][1], dp[i-1][2])+mat[i][0]
    dp[i][1]=max(dp[i-1][0], dp[i-1][2])+mat[i][1]
    dp[i][2]=max(dp[i-1][0], dp[i-1][1])+mat[i][2]

print(max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))


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

int main(){
	int64_t n,a,b;
	cin>>n>>a>>b;
	int64_t c,d;
	c=n/(a+b);
	d=n-c*(a+b);
	d=min(a,d);
	cout<<c*a+d<<"\n"s;
}

Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

if K > 40
    puts ([N]*N).join(' ')
    exit
end

[K, 40].min.times do |k|
    imosu = [0] * (N+1)
    0.upto(N-1) do |i|
        l = [i - a[i], 0].max
        r = [i + a[i] + 1, N].min
        # l = i - a[i]
        # l = 0 if l < 0
        # r = i + a[i] + 1
        # r = N if r > N
        imosu[l] += 1
        imosu[r] += -1
    end
    s = 0
    # all_n = true
    0.upto(N-1) do |i|
        s += imosu[i]
        a[i] = s
        # all_n = false if a[i] != N
    end
    # break if all_n
end

puts a.join(' ')

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

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

    vector<int> V(N), C(N);
    for(int i = 0; i < N; i++)
    {
        cin >> V[i];
    }

    int x = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> C[i];
        
        if(V[i] - C[i] > 0)
        {
            x += V[i] - C[i];
        }
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

class STlazy{
private:
    int n;
    vector<int> node, lazy;

public:
    STlazy(vector<int> v){
        int siz = v.size();
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, 0);
        lazy.resize(2*n-1, 1);
        
        for(int i = 0; i < siz; i++)    node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = node[2*i+1] + node[2*i+2];
    }

    void eval(int k, int l, int r){
        if(lazy[k] == 1)    return;
        node[k] *= lazy[k];
        if(r-l > 1){
            lazy[2*k+1] *= lazy[k];
            lazy[2*k+2] *= lazy[k];
        }
        lazy[k] = 1;
    }

    void update(int a, int b, int x, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k, l, r);
        if(r <= a || b <= l)    return;
        if(a <= l && r <= b){
            lazy[k] *= x;
            eval(k, l, r);
            return;
        }
        update(a, b, x, 2*k+1, l, (l+r)/2);
        update(a, b, x, 2*k+2, (l+r)/2, r);
        node[k] = node[2*k+1] + node[2*k+2]; // 自分の全ての子孫の値伝播が終わったら自分を更新する
    }

    int query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        if(r <= a || b <= l)    return 0;
        eval(k, l, r); // 最初の呼び出しが必ずeval(0,0,n)となるので漏れなく上から値の伝播がなされている
        if(a <= l && r <= b)    return node[k];
        int lx = query(a, b, 2*k+1, l, (l+r)/2);
        int rx = query(a, b, 2*k+2, (l+r)/2, r);
        return lx+rx;
    }
};

vector<int> child[100000], euler, l(100000), r(100000);

void euler_tour(int parent, int current, int &cnt){
    l[current] = cnt++;
    for(int i = 0; i < child[current].size(); i++){
        if(child[current][i] != parent) euler_tour(current, child[current][i], cnt);
    }
    r[current] = cnt++;
}

int main(){
    int n, q;
    cin >> n >> q;
    for(int i = 1; i < n; i++){
        int x;  cin >> x;
        child[--x].push_back(i);
    }
    int cnt = 0;
    euler_tour(-1, 0, cnt);
    euler.resize(cnt);

    for(int i = 0; i < n; i++){
        char c; cin >> c;
        euler[l[i]] = euler[r[i]] = (c=='G')*2-1;
    }

    STlazy seg(euler);
    
    while(q-- > 0){
        int t;  cin >> t;
        t--;
        seg.update(l[t], r[t]+1, -1);
        cout << (seg.query(0, cnt+1) > 0 ? "broccoli" : "cauliflower") << endl;
    }
    return 0;
}


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

int main(void){
  int n,m,head,tail;
  cin >> n >> m;
  head = 1; tail = n;
  for(int i = 0; i != m; i++){
    int temp1,temp2;
    cin >> temp1 >> temp2;
    if(temp1 > head)head = temp1;
    if(temp2 < tail)tail = temp2;
  }
  cout << max((tail - head) + 1,0) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

from math import gcd

def solve():
    N = II()
    A = LI()
    
    mx = 1000003
    D = [1] * mx
    for i in range(2, len(D)):
        # if D[i] != 1:
        #     continue
        for j in range(i, len(D), i):
            if D[j] == 1:
                D[j] = i
    # print(D[mx-3])
    # print(D[4], D[6], D[35])

    g = A[0]
    # dct = defaultdict(int)
    # flag = True
    C = [0] * mx
    for a in A:
        g = gcd(g, a)
        # print(a, D[a])
        # if D[a] != 1:
        #     if dct[D[a]] > 0:
        #         flag = False
        #     dct[D[a]] += 1
        d = D[a]
        p = a
        while p != d:
            p = p // d
            d = D[p]
        # print(a, d, p)
        C[p] += 1
    # print(dct, flag, g)
    # flag = False
    if all(C[i] <= 1 for i in range(2, len(C))):
        flag = True
    else:
        flag = False

    if g == 1:
        if flag:
            print('pairwise coprime')
        else:
            print('setwise coprime')
    else:
        print('not coprime')


if __name__ == '__main__':
    solve()



Measured memory_bytes: 127864
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	string S, T;
	cin >> S >> T;

	int ans = 0;
	rep(i, T.length()) {
		if (S[i] != T[i]) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3864
# AOJ 0260: Salary for a Plumber
# Python3 2018.6.26 bal4u

while True:
	n = int(input())
	if n == 0: break
	p = list(map(int, input().split()))
	s = sum(p)
	j = list(map(int, input().split()))
	j.sort(reverse=True)
	ans = s*n
	for i in range(n-1):
		s += j[i]
		ans = max(ans, s*(n-1-i))
	print(ans)


Measured memory_bytes: 8100
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String s_year = s.substring(0,4);
    String date = s.substring(5,10);
    String year = "2018";

    System.out.println(year+"/"+date);

  }

}


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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9 + 7;

    int n, m;
    cin >> n >> m;

    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) rep(j, m) cin >> a[i][j];

    vector<int> b(m + 1, 1);

    int ans = 1000000007;
    rep(i, m) {
        vector<int> memo(m + 1, 0);
        rep(j, n) {
            rep(k, m) {
                if (b[a[j][k]]) {
                    memo[a[j][k]]++;
                    break;
                }
            }
        }
        int mans = 0, mindex = 0;
        rep(j, 1, m + 1) {
            if (mans < memo[j]) {
                mindex = j;
                mans = memo[j];
            }
        }
        ans = min(mans, ans);
        b[mindex] = 0;
    }
    cout << ans << endl;
}


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

using namespace std;
#define eps = (1e-10);
//点
struct Point{
    double x,y;
    Point(double _x=0,double _y=0):x(_x),y(_y){}
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double a){return Point(a*x,a*y);}
    Point operator / (double a){return Point(x/a,y/a);}
    double norm(){return x*x+y*y;}//模的平方
    double ABS() {return sqrt(norm());}//模
};
//线段
struct Segment{
    Point p1,p2;
};
//点积
double dot(Point a,Point b){
    return a.x*b.x+a.y*b.y;
}
//叉积
double cross(Point a,Point b){
    return a.x*b.y-a.y*b.x;
}
Point IntersectPoint(Segment A ,Segment B){
    double a=A.p1.y-A.p2.y;
    double b=A.p2.x-A.p1.x;
    double e=A.p1.x*(A.p1.y-A.p2.y)-A.p1.y*(A.p1.x-A.p2.x);
    double c=B.p1.y-B.p2.y;
    double d=B.p2.x-B.p1.x;
    double f=B.p1.x*(B.p1.y-B.p2.y)-B.p1.y*(B.p1.x-B.p2.x);
    double ansx=(e*d-f*b)/(a*d-c*b);
    double ansy=(a*f-c*e)/(a*d-c*b);
    // if(ansx>=0) ansx=fabs(ansx);
    // if(ansy>=0) ansy=fabs(ansy);
    return {ansx,ansy};  
}
int main(){
    int q;
    scanf("%d",&q);
    while(q--){
        Segment A,B;
        scanf("%lf %lf %lf %lf",&A.p1.x,&A.p1.y,&A.p2.x,&A.p2.y);
        scanf("%lf %lf %lf %lf",&B.p1.x,&B.p1.y,&B.p2.x,&B.p2.y);
        Point ans=IntersectPoint(A,B);
        printf("%.10lf %.10lf\n",ans.x,ans.y);
    }
    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define N 505
using namespace std;

inline bool rd(int &X)
{
    X=0;int w=0;char ch=0;
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while( isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    X=w?-X:X; return 1;
}

int n,m,d;
char s[]={"RGBY"};
signed main()
{
    cin>>n>>m>>d;
		for(int i=0;i<n;i++,cout<<endl)
			for(int j=0;j<m;j++)
			{
				int x=(m+i+j)/d&1;
				int y=(m+i-j)/d&1;
				putchar(s[2*x+y]);
			}
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        //標準入力
        int N = sc.nextInt();
        String[] s = new String[N];
        for(int i = 0; i < N; i++) s[i] = sc.next();
        int M = sc.nextInt();
        String[] t = new String[M];
        for(int i = 0; i < M; i++) t[i] = sc.next();

        //青カードの同一文字を総当たりでカウント。
        //次に、文字列の一致する赤カードを総当たりでカウント。
        //その後、差を取得。
        int maxMoney = Integer.MIN_VALUE;
        for(int i = 0; i < N; i++){
            int countBlue = 0;
            int countRed = 0;
            for(int j = 0; j < N; j++){
                if(s[i].equals(s[j])) countBlue++;
            }
            for(int j = 0; j < M; j++){
                if(s[i].equals(t[j])) countRed++;
            }
            if(maxMoney < countBlue - countRed){
                maxMoney = countBlue - countRed;
            }
        }
        System.out.println(maxMoney > 0 ? maxMoney : 0);
    }
}


Measured memory_bytes: 22868
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int, input().split()))

i = 0
ans = 0
while True:
    if p[i] == i + 1:
        p[i], p[i + 1] = p[i + 1], p[i]
        ans += 1
        i += 1
    else:
        i += 1
    if i == n - 1:
        if p[i] == i + 1:
            ans += 1
        break
print(ans)


Measured memory_bytes: 13880
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;

#define rep(i,N) for (int i = 0; i < N; i++)
#define llong long long
#define ldouble long double

int N, M;
vector<int> ACflags;
vector<int> WAcount;

int main() {
    cin >> N >> M;
    ACflags.resize(N); WAcount.resize(N);
    rep(i,M) {
        int p; string s;
        cin >> p >> s;
        p--;
        if (s == "WA" && !ACflags[p]) {
            WAcount[p]++;
        }else if (s == "AC") {
            ACflags[p] = 1;
        }
    }
    int resAC = accumulate(ACflags.begin(), ACflags.end(), 0);
    int resWA = 0;
    rep(i,N) {
        if (ACflags[i]) resWA += WAcount[i];
    }
    cout << resAC << " " << resWA << endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
a = [int(input()) for i in range(N)]
count = 0
index = 1
end = 2
if not end in a:
    print(-1)
else :
    while(True):
        count += 1
        index = a[index-1]
        if (index == end):
            print(count)
            break
        elif count > N:
            print(-1)
            break

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	string s,t;
	cin >> s >> t;
	map<char, int> mps,mpt;
	rep(i, s.length()) mps[s[i]]++;
	rep(i, t.length()) mpt[t[i]]++;
	string ans = "No";
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	//cout << s << endl << t << endl;

	if(s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	/*rep(i, max(s.length(), t.length())) {
		if(i == s.length()) {
			cout << "Yes" << endl;
			return 0;
		}
		if(i == t.length()) {
			cout << "No" << endl;
			return 0;
		}
		if(s[i] < t[i]) {
			cout << "Yes" << endl;
			return 0;
		}
		if(s[i] > t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}*/

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int x, n; cin >> x >> n;
  set<int> s;
  int p;
  for(int i=0; i<n; i++) {
    cin >> p;
    s.insert(p);
  }

  int d = 1e9;
  int ans = -1;
  for(int i=0; i<=101; i++) {
    if(s.find(i) != s.end()) continue;
    if (d > abs(x-i)) {
      d = abs(x-i);
      ans = i;
    }
  }
  cout << ans << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3644
def solve():
    S = input()
    N = len(S)
    max_length = 0

    for i in range(N):
        for j in range(N):
            if i+j >= N:
                break
            temp_str = S[i:N-j]
            temp_str = temp_str.replace("A", "")
            temp_str = temp_str.replace("C", "")
            temp_str = temp_str.replace("G", "")
            temp_str = temp_str.replace("T", "")
            if (len(S[i:N-j]) > 0 and temp_str == ""):
                if (len(S[i:N-j]) > max_length):
                    max_length = len(S[i:N-j])

    print(max_length)


if __name__ == "__main__":
    solve()

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char s[2][MAXN];
int sum[2][MAXN];

void solve(){
	int q, l1, r1, l2, r2;
	scanf("%s%s%d", &s[0][1], &s[1][1], &q);
	REP(i, 0, 2){
		for(int j = 1; s[i][j]; j++){
			sum[i][j] = sum[i][j - 1] + (s[i][j] == 'A' ? 1 : 2);
		}
	}
	while(q--){
		scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
		if ((sum[0][r1] - sum[0][l1 - 1]) % 3 == (sum[1][r2] - sum[1][l2 - 1]) % 3){
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1536
import sys
k = int(input())
a, b = map(int, input().split())
if k == 1:
    print('OK')
    sys.exit()
if a % k == 0 or b % k == 0:
    print('OK')
    sys.exit()

if (b // k) > (a // k):
    print('OK')
else:
    print('NG')

Measured memory_bytes: 9184
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int half = 1900, full = 100;
            var hCount = nm[0] - nm[1];
            var total = (hCount * full) + (nm[1] * half);
            var par = Math.Pow(2, nm[1]);

            Console.WriteLine(total * par);
        }

    }
}


Measured memory_bytes: 13396
from collections import deque
n = int(input())
l = list(map(int,input().split()))
l.sort()
largest = l[-1]
que = deque(l)
cnt = n
ans = 0
while cnt > 0:
    x = que.pop()
    ans += x
    cnt -= 1
    if cnt != 0:
        ans += x
        cnt -= 1
print(ans-largest)

Measured memory_bytes: 106616
#include<bits/stdc++.h>
using namespace std;
string s,st;
int main()
{
	cin>>s>>st;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=st[st.size()-1-i])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES";
  	return 0;
  	
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>

using namespace std;
int dp[21][50001] = { 0 };
int coin[21] = { 0 };
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1;i <= m;++i) {
		scanf("%d", &coin[i]);
	}

	for (int i = 1;i <= m;++i) {
		for (int q = 1;q <= n;++q) {
			if (i == 1) {
				dp[i][q ] = dp[i][q-1] + 1;
			}
			else if(coin[i] <= q ) {
				dp[i][q] = min(dp[i - 1][q], dp[i][q - coin[i]]+1);
			}
			else {
				dp[i][q] = dp[i - 1][q];
			}
		}
	}
	printf("%d\n", dp[m][n]);
}


Measured memory_bytes: 4936
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

char c;

int main() {
	cin >> c;
	cout << (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ? "vowel" : "consonant") << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
t = 0
def exist_odd(A):
  B = list(map(lambda x : x%2, A))
  return any(B)
  
while exist_odd(A) != True:
  A = list(map(lambda x: x // 2, A))
  t = t+1
print(t)

Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))
c = 0
for i in range(N-1):
    minj = i
    for j in range(i, N):
        if A[minj] > A[j]:
            minj = j
    if minj != i:
        A[i], A[minj] = A[minj], A[i]
        c += 1
print(*A)
print(c)


Measured memory_bytes: 5608
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 998244353;

int main() {
	ios_base::sync_with_stdio(false);

	int n, s;
	cin >> n >> s;
	vi a(n + 1);
	FOR(i, 1, n) cin >> a[i];
	vector<vi> f(n + 1, vi(s + 1, 0));
	ll res = 0;
	f[0][0] = 1;
	FOR(i, 1, n) {
		REP(ss, s + 1) {
			f[i][ss] = f[i - 1][ss];
			if (ss >= a[i]) {
				f[i][ss] = (f[i][ss] + f[i - 1][ss - a[i]]) % mod;
			}
			// printf("f[%d][%d] = %d\n", i, ss, f[i][ss]);
		}
		++f[i][0];
		res = (res + f[i][s]) % mod;
	}
	cout << res << endl;
}

Measured memory_bytes: 35584
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
s = ""
for i in range(n):
    a,b = ip()
    if a == b:
        s += '1'
    else:
        s += '0'
if '111' in s:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61900
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
    }
    println!("{}", n-k+1);
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n;
int x,y,t;

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

  string s; cin>>s;
  s[3]='8';
  out(s);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int e;
    int y;
    cin >> e >> y;
    if(e == 0){
        if(y >= 1868 && y <= 1911){
            cout << "M" << y - 1867 << endl;
        }
        else if(y >= 1912 && y <= 1925){
            cout << "T" << y - 1911 << endl;
        }
        else if(y >= 1926 && y <= 1988){
            cout << "S" << y - 1925 << endl;
        }
        else if(y >= 1989 && y <= 2016){
            cout << "H" << y - 1988 << endl;
        }
    }
    else{
        if(e == 1){
            y += 1867;
        }
        if(e == 2){
            y += 1911;
        }
        if(e == 3){
            y += 1925;
        }
        if(e == 4){
            y += 1988;
        }
        cout << y << endl;
    }
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m%MOD*COM(m-1,n)%MOD*modinv(m-n,MOD)%MOD;
}
 

int main()
{
  ll n,a[100005],q,w,e,r,ans,c,v;
  q=0;
  e=0;
  cin >> n;
  rep(i,n)cin >> a[i];
  sort(a,a+n);
  if(n%2==0)
  {rep(i,n/2-1)q+=a[i];
   w=q+a[n/2-1];
   FOR(i,n/2+1,n)e+=a[i];
   r=e+a[n/2];
   ans=r+e-q-w;
  }
  else
  {rep(i,n/2)q+=a[i];
   FOR(i,n/2,n)e+=a[i];
   c=2*e-2*q-a[n/2]-a[n/2+1];
   q+=a[n/2];
   e-=a[n/2];
   v=2*e-2*q+a[n/2]+a[n/2-1];
   ans=max(c,v);
  }
  printf("%lld",ans);
}


Measured memory_bytes: 1024