akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> PII;
class comp{
public:
	bool operator()(const int & a,const int &b) const{
		return a>b;
	}
};
int main(){
	int A,B,C,D,E,F;
	cin>>A>>B>>C>>D>>E>>F;
	
	vector<int> water;
	for(int i=0;i<=30;i++){
		for(int j=0;j<=30;j++){
			int w = A*100*i+B*100*j; 
			if ( w<= F ){
				water.pb(w);
			}
		}

	}
	set<int,comp> sugar; 
	for(int i = 0;i<= F/C;i++){
		for(int j=0;j<=F/D;j++){
			sugar.insert(i*C+j*D);
		}
	}
	double max_dens = 0;
	int max_water = 0;
	int max_sugar = 0;
	for(int i:water){
		int sugar_max = i/100 * E;
		sugar_max = min(sugar_max,F-i);
		auto it = sugar.lower_bound(sugar_max);
		int s = *it;
		if ( it!= sugar.end()  && s*1.0/(s+i) >max_dens){
			max_dens = s*1.0/(s+i);
			max_water=  i;
			max_sugar = s;
		}
	}
	if (max_sugar  == 0)
	max_water = 100*A;
	cout<<(max_water+max_sugar)<<" "<<max_sugar<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if((a+b)%2)
    cout<<"IMPOSSIBLE";
    else
    cout<<(a+b)/2;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> G[100000];
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int v4(0),v6(0);
    for(int i=0;i<N;i++){
        if(G[i].size()>=6){
            v6++;
        }else if(G[i].size()==4){
            v4++;
        }
        if(G[i].size()%2==1){
            v4=-1e6;
            v6=-1e6;
        }
    }
    if(v6>0 || v4>=3){
        cout<<"Yes"<<endl;
    }else if(v4==2){
        int a,b;
        for(int i=0;i<N;i++){
            if(G[i].size()==4){
                a=i;
                break;
            }
        }
        for(int i=a+1;i<N;i++){
            if(G[i].size()==4){
                b=i;
                break;
            }
        }
        //aからbへの経路の数をカウントする．
        queue<int> q;
        q.push(a);
        int d[100000]={};
        d[a]=1;
        while(!q.empty()){
            int v=q.front(); q.pop();
            for(int j=0;j<G[v].size();j++){
                int u=G[v][j];
                if( u!=b && d[u]==0 ){
                    q.push(u);
                    d[u]=1;
                }else if(u==b){
                    d[b]++;
                }
            }
        }
        if(d[b]==2){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin>>n;
  long long int sum=0;
  for(int i=1;i<=n;i++)
    if(i%3!=0 && i%5!=0) sum+=i;
  cout<<sum;
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, X; cin >> N >> X;
    vec L(N); cin >> L;
    int ans = 1;
    int tmp = 0;
    REP(i, N){
        tmp += L[i];
        if(tmp <= X) ans++;
        else break;
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
import sys



def cul1(s,i,j):
    if s[i][j]==1: return "."
    else: return "#"

def cul2(s,i,j):
    if s[i][j]==1: return "#"
    else: return "."

a,b=map(int,input().split())
print("100 100")

s=[[0 for j in range(100)] for i in range(50)]
for i in range(1,a):
    k=(i*2//100)*2
    l=(i*2)%100
    s[k][l]=1

for i in range(50):
    d=""
    for j in range(100):
        d+=cul1(s,i,j)
    print(d)


s=[[0 for j in range(100)] for i in range(50)]
for i in range(1,b):
    k=(i*2//100)*2
    l=(i*2)%100
    s[k][l]=1

for i in range(49,-1,-1):
    d=""
    for j in range(100):
        d+=cul2(s,i,j)
    print(d)

Measured memory_bytes: 3188
#include <stdio.h>

#define N 20000

int main()
{
  int n,q,i,j,k,l,S[N],T[N];

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&S[i]);
   
  scanf("%d",&q);

  for(j=0;j<q;j++) scanf("%d",&T[j]);

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i] == S[j]){
	k++;
	j = n;
      }
    }
  }

  printf("%d\n",k);

  return 0;
}

      



Measured memory_bytes: 2052
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> ts(n), vs(n);
    for(int i = 0; i < n; i++){
        cin >> ts[i];
    }
    for(int i = 0; i < n; i++){
        cin >> vs[i];
    }
    vs.push_back(0);
    // vs[0] = vs[n + 1] = 0;
    // for(size_t i = 0; i < ts.size(); i++){
    //     auto& t = ts[i];
    // }
    vector<vector<double>> dp(41000, vector<double> (210, -1));
    // vector<vector<double>> dp(60, vector<double> (40, -1));
    dp[0][0] = 0;
    int time = 0;
    for(int i = 0; i < n; i++){
        auto& t = ts[i];
        for(int j = 0; j < t * 2; j++){
            time++;
            int vlast = 2 * (j == t * 2 - 1 ? min(vs[i], vs[i + 1]) : vs[i]);
            for(int v = 0; v <= vlast; v++){
                for(int v0 = v + 1; v0 >= v - 1 && v0 >= 0; v0--){
                    if(dp[time - 1][v0] != -1){
                        dp[time][v] = dp[time - 1][v0] + double(v0 + v) / 2 / 4;
                        break;
                    }
                }
            }
        }
    }
    // printw(5, dp);
    cout << fixed << dp[time][0] << '\n';
}


Measured memory_bytes: 69120
N = int(input())
A, B = map(int, input().split())
p = list(map(int, input().split()))
oneCnt = 0
twoCnt = 0
treeCnt = 0
for i in p:
    if i <= A:
        oneCnt += 1
    elif A + 1 <= i <= B:
        twoCnt += 1
    else:
        treeCnt += 1

print(min(oneCnt, twoCnt, treeCnt))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include <numeric>
using namespace std;
int main(){
string S;
cin>>S;
int n=0,w=0,s=0,e=0; 
for (int i = 0; i < S.size(); i++){
if (S[i] == 'N') {n++;}
if (S[i] == 'S') {s++;}
if (S[i] == 'W') {w++;}
if (S[i] == 'E') {e++;}
}
if(n>0&&s>0&&w>0&&e>0)
cout<<"Yes"<<endl;
else if(n>0&&s>0&&w==0&&e==0)
cout<<"Yes"<<endl;
else if(n==0&&s==0&&w>0&&e>0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, q;
	cin >> n >> q;
	if(q == 0){
		for(int i = 1; i <= n; i++) cout << 1 << endl;
		return 0;
	}
	vector<long long> op(q);
	op[0] = n;
	for(int i = 1; i < q; i++) cin >> op[i];
	long long x; cin >> x;
	map<long long, long long> o;
	o[x] = 1;
	for(int i = q - 1; i >= 0; i--){
		long long p = op[i];
		while(true){
			auto it = o.lower_bound(p + 1);
			if(it == o.end()) break;
			long long val, occ; tie(val, occ) = *it; o.erase(it);
			if(val / p) {
				o[p] += (val / p) * occ;
			}
			if(val % p) {
				o[val % p] += occ;
			}
		}
	}
	vector<long long> ans(n + 1, 0);
	for(auto e : o){
		ans[0] += e.second;
		ans[e.first] -= e.second;
	}
	for(int i = 1; i <= n; i++) ans[i] += ans[i - 1];
	for(int i = 0; i < n; i++){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 9088
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Map;
import java.util.TreeMap;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        String s;
        Map<String, Integer> map = new TreeMap<>();
        int max = 0;
        for (int i = 0; i < n; i++) {
            s = br.readLine();
            int val = map.containsKey(s) ? map.get(s) + 1 : 1;
            map.put(s, val);
            max = Math.max(max, val);
        }

        br.close();

        for (String key : map.keySet()) {
            if (map.get(key) == max) {
                bw.write(key + "\n");
            }
        }

        bw.flush();

    }
}

Measured memory_bytes: 69768
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
  lli n;
  cin>>n;
  if(n%2==0 || n%5==0)
    	cout<<-1;
  else
  {
  	lli val = 7;
    for(int i=1;i<=1e7;i++)
    {
      if(val%n==0)
      {	cout<<i;
      	return 0;}
      val = (val*10+7)%n;
    }
    cout<<-1;
  }
return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll x[90010],y[90010],co[90010];
int main() {
	ll h,w,d;
	cin>>h>>w>>d;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			ll now;
			cin>>now;
			now--;
			x[now]=i;
			y[now]=j;
		}
	}
	for(ll i=0;i+d<h*w;i++){
		co[i]=abs(x[i]-x[i+d])+abs(y[i]-y[i+d]);
	}
	for(ll i=h*w;i-d>=0;i--){
		co[i-d]=co[i]+co[i-d];
	}
	ll q;
	cin>>q;
	for(ll i=0;i<q;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		cout << co[x]-co[y]<<endl;
	}
	// your code goes here
	return 0;
}

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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N, M, R;
vector<int> r;
vector<vector<int>> g;
// vector<vector<pair<int, int>> g;

int main(){
  cin >> N >> M >> R;
  r.resize(R);
  REP(i, R){
    cin >> r[i];
    r[i]--;
  }
  sort(r.begin(), r.end());
  // g.resize(N);
  g.resize(N, vector<int>(N, INF));
  REP(i, M){
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    // g[a].push_back(make_pair(b,c));
    // g[b].push_back(make_pair(a,c));
    g[a][b] = c;
    g[b][a] = c;
  }
  REP(k, N){
    REP(i, N){
      REP(j, N){
        if(g[i][j] > g[i][k]+g[k][j]){
          g[i][j] = g[i][k]+g[k][j];
        }
      }
    }
  }
  int ans = INF, sum;
  do{
    sum = 0;
    REP(i, R-1){
      sum += g[r[i]][r[i+1]];
    }
    ans = min(ans, sum);
  }while(next_permutation(r.begin(), r.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define MOD                 1000000007LL
#define EPS                 1e-9
#define io                  ios_base::sync_with_stdio(false);cin.tie(NULL);

const int MAXN = 1e5+5;

int main(){
	io;
	ll x, y;
	cin >> x >> y;
	ll ans = 0;
	ll curr = x;
	while(curr <= y){
		ans++;
		curr = curr*2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if (a==b&&b==c) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int A,X,Y;
    cin >> A;


    if(A==1){
        cout << "Hello World"<< endl;
    }else{
        cin >> X >> Y;
        Int ans =X+Y;
        cout << ans<< endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

ll power(ll a,ll n){ll ret=1;for(;n>0;n>>=1,a=a*a%MOD)if(n%2==1)ret=ret*a%MOD;return ret;}
ll comb(ll n,ll r){ll x=1,y=1;rep(i,0,r){x=x*(n-i)%MOD;y=y*(i+1)%MOD;}return x*power(y,MOD-2)%MOD;}

void solve() {
  VAR(ll, N);
  VEC(ll, A, N);
  map<ll, ll> m;
  each(x, A) {
    m[x]++;
  }

  ll sum = 0;

  each(x, m) {
    sum += (x.second * (x.second - 1)) / 2;
  }

  each(x, A) {
    print(sum - (m[x] * (m[x] - 1)) / 2 + ((m[x] - 1) * (m[x] - 2)) / 2);
  }
}


Measured memory_bytes: 11136
import sys
readline = sys.stdin.readline
from collections import deque


def main():
    while True:
        N, M = map(int, readline().rstrip().split())
        if N == M == 0:
            break
        _, *A = map(int, readline().rstrip().split())
        _, *B = map(int, readline().rstrip().split())
        _, *C = map(int, readline().rstrip().split())

        A = [0] + A
        B = [0] + B
        C = [0] + C
        N += 1

        que = deque([(A, B, C, 0, -1)])   # pre: 1: A->B, 2: B->A, 3: B->C, 4: C->B
        res = -1
        while que:
            A, B, C, t, pre = que.popleft()
            if t > M:
                break
            if len(A) == N or len(C) == N:
                res = t
                break
            
            # A -> B
            if A[-1] > B[-1] and pre != 2:
                que.append((A[:-1], B + [A[-1]], C, t + 1, 1))

            # B -> A
            if B[-1] > A[-1] and pre != 1:
                que.append((A + [B[-1]], B[:-1], C, t + 1, 2))
            
            # B -> C
            if B[-1] > C[-1] and pre != 4:
                que.append((A, B[:-1], C + [B[-1]], t + 1, 3))
            
            # C -> B
            if C[-1] > B[-1] and pre != 3:
                que.append((A, B + [C[-1]], C[:-1], t + 1, 4))
            

        print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6012
use std::io::prelude::*;

fn main() {
    let stdin = std::io::stdin();
    let mut reader = std::io::BufReader::new(stdin.lock());

    let mut s = String::new();
    reader.read_line(&mut s).unwrap();
    let mut s: Vec<char> = s.trim().chars().collect();
    
    s.dedup();
    
    println!("{}", s.len() - 1);
}


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

int main(){
	int ans[1000000];
	int count=2;
	
	for(int i=4;i<1000000;i++){
		bool p=true;
		double sqrti = i;
		for(int j=2;j<=sqrt(sqrti);j++){
			if(i % j == 0){
				p=false;
				break;
			}
		}
		if(p){
			count++;
			ans[i]=count;
			}
		else ans[i]=count;
	}
	ans[1] = 0;
	ans[2] = 1;
	ans[3] = 2;
	
	int n;
	
	while(scanf("%d",&n)==1){
		printf("%d\n",ans[n]);
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii > vii;
typedef vector<pair<int, pair<int, int> > > viii;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<vii> vvii;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define MEM(a,b) memset(a,(b),sizeof(a))
#define all(a) a.begin(),a.end()
#define loop(x,a,b) for(int (x) = (a);(x)<(b);(x)++)
#define rep(x,n)   for(int (x)=0;(x)<(n);(x)++)
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ain(a,n) int ((a)[(n)]); for(int i=0; i<(n); i++) cin>>((a)[i])  
#define md 1000000007
#define MAXN 200005

int main()
{   
    ios::sync_with_stdio(false);
    long long int p = 100LL, x, ans = 0;
    cin >> x;
    while(p < x) {
    	p = (long long int)p*1.01;
    	ans++;
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    int N;
    cin >> N;
    
    const long long INF = 1LL << 60;
    long long dp[N];
    long long h[N];
    rep(i,N) {
        cin >> h[i];
        dp[i] = INF;
    }
    
    dp[0] = 0;
    
    rep(i,N){
        dp[i] = min(dp[i - 2] + abs(h[i] -h[i - 2]),min(dp[i],dp[i - 1] + abs(h[i] -h[i - 1])));
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n;
long a[3];
long l[8];

long dfs(long depth, std::vector<long> b){
	if(depth == n){//attachment ended
		std::sort(b.begin(), b.end());
		long ret = 0;
		for(int i = 0; i < 3; i++){
			if(b[i] == 0){//nothing can't be added
				return LINF;
			}
			ret += std::abs(b[i] - a[i]);
		}
		return ret;
	}
	long ret = LINF;
	for(int i = 0; i < 3; i++){
		std::vector<long> c = b;
		c[i] += l[depth];
		if(c[i] == l[depth]){
			ret = std::min(dfs(depth+1, c), ret);
		}else{
			ret = std::min(dfs(depth+1, c) + 10, ret);
		}
	}
	ret = std::min(dfs(depth+1, b), ret);
	return ret;
}

int main(){
	scanf("%ld", &n);
	for(int i = 0; i < 3; i++){
		scanf("%ld", &a[i]);
	}
	std::sort(a, a+3);
	for(int i = 0; i < n; i++){
		scanf("%ld", &l[i]);
	}
	printf("%ld\n", dfs(0, std::vector<long>(3, 0)));
	return 0;
}


Measured memory_bytes: 632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
 * 境界部分には気をつける(そこだけ別で処理するというのもあり)
 * 逆再生することで簡単になることもある
 */
public class Main {
    public Main() {
    }

    public static void main(String[] args ) {
    		Main main = new Main();
    		main.exec();
    }

    public void exec() {
        BufferedReader bf = null;
        try{
            bf = new BufferedReader(new InputStreamReader(System.in));
            exec_body(bf);
        } catch (IOException e) {
			e.printStackTrace();
		}
        finally{
            if( bf != null ) {
                try {
					bf.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
            }
        }
    }

    public void exec_body( BufferedReader bf ) throws IOException {
    		bf.readLine();
    		int[] sAry = toList(bf.readLine(),true);
    		bf.readLine();
    		int[] tAry = toList(bf.readLine(),false);

    		int cnt = 0;
    		for( int tval : tAry ) {
    			int index = 0;
    			sAry[sAry.length -1] = tval;
    			while(sAry[index] != tval ) {
    				index++;
    			}
    			if( index != sAry.length -1 ) {
    				cnt++;
    			}
    		}

    		System.out.println(cnt);
    }

    public int[] toList( String str, boolean isBanhei ) {
    		String[] elements = str.split(" ");
    		int arysize = elements.length + ( (isBanhei) ? 1 : 0 );
    		int[] ret = new int [arysize];
    		for( int i = 0; i < elements.length; i++ ) {
    			ret[i] = Integer.valueOf(elements[i]);
    		}

    		return ret;
    }
}


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

using namespace std;

int main()
{
	long long a, b,nowA,nowB,ans;
	cin >> a >> b;

	nowA = a, nowB = b;
	
	for (long long i = 0; i < a*b; i++)
	{
		if (nowA == nowB)
		{
			ans = nowA;
			break;
		}
		else if (nowA < nowB)
			nowA += a;
		else
			nowB += b;
	}
	
	cout << ans << std::endl;
}

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

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

	int ways = 0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50 == x) ways++;
			}
		}
	}
	cout<<ways;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,C,K;cin>>N>>C>>K;
  if(C==1){cout<<N<<endl;return 0;}
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(A.begin(),A.end());
  int ans=1,count=0,c=1;
  bool a=true;
  for(int i=1;i<N;i++){
    if(!a){ans++;c=1;a=true;}
    else{
      count+=A[i]-A[i-1];
      if(count>K){count=0;a=false;i--;continue;}
      c++;
      if(c==C){count=0;a=false;continue;}
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3792
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{   long long n,i,a,b,c,sum=0,ka;
    cin>>n;
    long long value[n+1][3];
    value[0][0]=0;
    value[0][1]=0;
    value[0][2]=0;
    for(i=1;i<=n;i++){
        ka=0;
        cin>>a>>b>>c;
        value[i][0]=max(value[i-1][1]+a,value[i-1][2]+a);
        value[i][1]=max(value[i-1][0]+b,value[i-1][2]+b);
        value[i][2]=max(value[i-1][1]+c,value[i-1][0]+c);
        ka=max(value[i][0],value[i][1]);
        sum=max(ka,value[i][2]);
    }
    cout<<sum;

    return 0;
}


Measured memory_bytes: 2688
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String S[] = s.split("/");

        if(S[0].equals("2019") != true)
            System.out.println("Heisei");

        else{
            if(S[1].equals("01") || S[1].equals("02") || S[1].equals("03") || S[1].equals("04"))
                System.out.println("Heisei");
            else
                System.out.println("TBD");
        }
        
    }
}

Measured memory_bytes: 21204
n=int(input())
s=input()
v=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
ans=[]
for i in range(len(s)):
    for j in range(len(v)):
        if s[i]==v[j]:
            ans.append(v[(j+n)%26])

print("".join(map(str, ans)))

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

string S;

int main(){
  cin >> S;
  
  for(int i = 0; i < 3 ;i++){
    if(S[i] == '1') S[i] = '9';
    else S[i] = '1';
  }
  
  cout << S << endl;
}

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

correctNum = [0] * N
for i in range(Q):
    Ax = int(input())
    correctNum[Ax-1] += 1

for i in range(N):
    #print(str(i+1) + ":correctNum:" + str(correctNum[i]))
    if K-Q+correctNum[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4680
#include<bits/stdc++.h>
using namespace std ; 
typedef long long ll;
#define forn(i,e) for(ll i=0; i<e; i++)
#define endl "\n"
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PB push_back 
#define MP make_pair
#define F first
#define S second
 
 
int main()
{
 
 
zoom;
 
char a ; cin >> a ; 
if( (int) a < 97) cout << 'A' << endl ; 
  else cout << 'a' <<endl ; 
 
 
 
}

Measured memory_bytes: 3636
def ifif(s):
  if s:
    print("Yes")
  else:
    print("No")

###senkei

def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(map(str, input().split()))
def pl(a): print(" ".join(list(map(str, a))))
def ma():return map(int,input().split())
from itertools import accumulate as acc
import operator as op
import copy as cp
import math; import numpy
from bisect import bisect_left as bisl
from bisect import bisect_right as bisr
###
n=ri()
a=[]
for i in range(1,n+1):
    if i%3==0 or i%5==0:
        a.append(0)
    else:
        a.append(i)

print(sum(a))

Measured memory_bytes: 51484
main :: IO ()
main = print . solve . map (map read . words) . lines =<< getContents

solve :: [[Int]] -> Int
solve [_,as,bs,cs] = sum [bs !! (a-1) | a <- as] +
  sum [ cs !! (i-1) | (i, j) <- zip as (tail as), i == j - 1]


Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1000010,P=998244353;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
}
int n,i,a[N];
int main(){
	//freopen("1.out","w",stdout);
	n=read();
	for(i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	if(a[n]-a[1]>1)goto fuck;
	if(a[n]==a[1]){
		i=n/2;if(a[n]!=n-1&&i<a[n])goto fuck;
	}else{
		for(i=1;a[i+1]==a[1];i++);
		if(i>=a[n])goto fuck;
		i=i+(n-i)/2;if(i<a[n])goto fuck;
	}puts("Yes");
	return 0;fuck:puts("No");
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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

    vector<pair<ll,ll>> a(n);
    REP(i, n) cin >> a[i].first >> a[i].second;
 
    // 偏角ソート
    sort(all(a),[&](pair<ll,ll> s, pair<ll,ll> t){
        complex<double> x,y;
        x = complex<double>{(double)s.first, (double)s.second};
        y = complex<double>{(double)t.first, (double)t.second};
        return arg(x) < arg(y);
    });
 
    ll ans = 0;
    REP(i,n){
        ll x = 0, y = 0;
        REP(j, n){
            x += a[(i + j) % n].first;
            y += a[(i + j) % n].second;
            ans = max(ans, x * x + y * y);
        }
    }
    
    printf("%.12lf\n", sqrt(ans));

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=10000010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
struct edge{int to,cost;};
vector<edge> G[30];
int d[30];
void dijkstra(int s){
	fill(d,d+25,INF);
	priority_queue<P,vector<P>,greater<P>> q;
	q.push(P(0,s));
	d[s]=0;
	while(!q.empty()){
		P p=q.top();
		int v=p.second;
		q.pop();
		for(auto e:G[v]){
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
	}
}
int main(){
	int n,m;cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b,c,d;scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		a--;b--;
		G[a].push_back({b,c});
		G[b].push_back({a,d});
	}
	int s,g,v,p;
	scanf("%d,%d,%d,%d",&s,&g,&v,&p);s--;g--;
	int ans=v-p;
	dijkstra(s);
	ans-=d[g];
	dijkstra(g);
	ans-=d[s];
	cout<<ans<<endl;
}



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

void cookie(int *p1,int *p2){
	if(*p1 % 2)	--(*p1);
	*p1 /= 2;
	*p2 += *p1;
}

int main(int argc, char const *argv[])
{	
	int a,b,k;
	cin >> a >> b >> k;
	for (int i = 1; i <= k; ++i)
	{
		if(i % 2)	cookie(&a,&b);
		else cookie(&b,&a);
	}
	cout << a << " " << b << endl;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())

stack = ""
mi = ord('A')
mx = ord('Z')

for i in S :
    if ord(i)+N <= mx:
        stack = stack + chr(ord(i)+N)
    else:
        mem = ord(i)+N
        while mem > mx:
            mem = mem-26
        stack = stack + chr(mem)

print(stack)

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

int main()
{
    int H, N, A, sum = 0;
    scanf("%d %d", &H, &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A);
        sum += A;
    }
    if (sum < H)
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }

    return 0;
}

Measured memory_bytes: 256
# 問題文： 大きさ N の順列 ((1, 2, ..., N) を並び替えてできる数列) P, Q があります。大きさ N の順列は N! 通り考えられます。
#         このうち、P が辞書順で a 番目に小さく、Q が辞書順で b 番目に小さいとして、|a−b| を求めてください。
# 注記： 2 つの数列 X, Y について、ある整数 k が存在して Xi=Yi (1≤i<k) かつ Xk<Yk が成り立つとき、X は Y より辞書順で小さいと定義されます。
# 制約: 2≤N≤8　P,Qは大きさNの順列である。入力は全て整数である。

import math

# 数列が何番目かを返却するメソッド
def junban(N, str):
    int_list = str.split() # 入力文字を配列化
    int_list = [int(i) for i in int_list]
    yet_list = str.split() # まだ出てきていない数字のリスト
    yet_list = [int(i) for i in yet_list]

    num = 1 # 何番目か保持する
    keta = 0 # 上から何桁目か保持する

    while keta < N:
        # 該当桁の数字を確保する
        now_int = int_list[keta]

        # 未出数値のリストを更新する
        yet_list.remove(now_int)

        # 順番をカウント
        # 該当桁以下の階乗 * 未出数値の内、現在より数値の小さいものの個数
        num += math.factorial(len(yet_list)) * len([i for i in yet_list if i < now_int])
        keta += 1

#    print('{}番目'.format(num))
    return num

# 大きさNを受け取る
N = int(input())

# 数列Pを受け取る
P = input()

# 数列Qを受け取る
Q = input()

# それぞれが何番目か求める
p_int = junban(N, P)
q_int = junban(N, Q)

print(abs(p_int - q_int))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
    vector<P> res;
    for (long long p = 2; p * p <= n; ++p)
    {
        if (n % p != 0)
            continue;
        int num = 0;
        while (n % p == 0)
        {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1)
        res.push_back(make_pair(n, 1));
    return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return gcd(y, x % y);
    }
}
const int MOD = 1000000007;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    map<int, int> map;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j++)
        {
            int dist = min(abs(i - j), min(abs(i - x) + 1 + abs(j - y), abs(j - x) + 1 + abs(i - y)));
            map[dist]++;
        }
    }
    for (int i = 1; i < n; i++)
    {
        cout << map[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define fi first
//#define endl "\n"
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define initialize(array,size,value) for(ll i=0;i<size;i++) array[i]=value
#define couta(array,size) for(ll i=0;i<size;i++) cout<<array[i]<<" "
#define debug(x) cout<<"x: "<<x<<endl
#define dbug(x,y) cout<<"x: "<<x<<"    "<<"y: "<<y<<endl
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
#define mod 1000000007
#define MAXN 100001
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
ll ceil(ll a, ll b);
vl getFactorization(ll x);
void getZarr(string str, ll Z[]);
vector<ll> prefix_function(string s);


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
        
    ll n;
    cin>>n;
    ll a[n];
    loop(i,0,n){
        cin>>a[i];
    }
    ll ans=0;
    loop(i,0,n){
        bool done=true;
        loop(j,0,i){
            if(a[j]>a[i]){
                done=false;
            }
        }
        if(done==1) ans++;
    }
    cout<<ans<<endl;
}

ll gcd(ll a, ll b){
    if (a == 0)   return b;
    if(b==0)      return a;
    if (a == b)   return a;
    if (a > b)    return gcd(a%b, b);
    return gcd(a, b%a);
}

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void sieve() { 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc046/tasks/abc046_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    set<int> st;
    REP(i, 3) {
        int t;
        cin >> t;
        st.insert(t);
    }
    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n,k;
    cin>>n>>k;
    if(n==k){
        cout<<0<<endl;
        return 0;
    }

if(n>k){
    n=n-k*(n/k);
}

        in ans=min(n,k-n);
        cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


  int dp[101][101];

int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


    int n;
    cin >> n;
    string s;
    cin >> s;


    int l = 0;

    int ans = 0;

    for(int i = 0; i < s.size();i++)
    {
        if(s[i] == 'I')l++;
        else l--;

        ans = max(ans,l);
    }

    cout << ans;

    return 0;   
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5;
vector<int> G[N];
bool vis[N];
int f[N];
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 0, u, v; i < m; i++) {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    queue<int> qu;
    qu.push(1), vis[1] = true;
    while(!qu.empty()) {
        int u = qu.front();
        qu.pop();
        for(auto v : G[u]) {
            if(vis[v]) continue;
            f[v] = u;
            qu.push(v), vis[v] = true;
        }
    }
    bool flag = false;
    for(int i = 1; i <= n; i++) {
        if(!vis[i]) flag = true;
    }
    if(flag) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    for(int i = 2; i <= n; i++) {
        printf("%d\n", f[i]);
    }
    return 0;
}

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

int main() {
    string str;
    cin >> str;
    if(str[0] == 'Y' && str[1] == 'A' && str[2] == 'K' && str[3] == 'I'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

long long N, wa, K, W, ans,k[5];
string s[100000];

int main() {
	cin >> N >> K;
	for (int i = N; i < K + 1; i++) {
		W = i;
		wa = 0;
		while (W != 0) {
			k[wa] = W % 10;
			W = W / 10;
			wa++;
		}
		if (k[0] == k[4] && k[1] == k[3]) {
			ans++;
		}
	}
		cout << ans << endl;
	

	return 0;
}




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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

ll n,m,q;
ll a[50],b[50],c[50],d[50];
ll ans;

void dfs(vi &vec,int cc){
    if (cc==n){
        ll score=0;
        rep(i,q){
            if (vec[b[i]-1]-vec[a[i]-1]==c[i]){
                score+=d[i];
            }
        }
        ans=max(ans,score);
    }
    else{
        if (cc==0){
            for (int i=1;i<m+1;i++){
                vec[cc]=i;
                dfs(vec,cc+1);
            }
        }
        else{
        for (int i=vec[cc-1];i<m+1;i++){
            vec[cc]=i;
            dfs(vec,cc+1);
        }
        }
    }
}

int main() {
    cin>>n>>m>>q;
    rep(i,q){
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
        cin>>d[i];
    }
    ans=0;
    vi vec(n,0);
    for (int i=1;i<m+1;i++){
        dfs(vec,0);
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll> > matrix;
// const ll S = 3e5 + 20;
// const ll N = 1e6 + 1;
// const ll PRIME = 1e9 + 7;
// const ll MAX = 1e6;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    map<int, int> mp;
    int sum = 0;
    fr(i, n)
    {
        cin >> a[i];
        mp[a[i]]++;
        sum += a[i];
    }
    int q;
    cin >> q;
    fr(i, q)
    {
        int b, c;
        cin >> b >> c;
        if (mp[b] > 0)
        {
            sum += mp[b] * (c - b);

            mp[c] += mp[b];
            mp[b] = 0;
          
        }
        cout << sum << "\n";
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
}


Measured memory_bytes: 10040
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    // Your code here!
    string s;
    std::cin >> s;
    char* cs = new char[s.size() + 1];
    strcpy(cs, s.c_str());
    bool flag = cs[0]=='A';
    int count = 1;
    for(int i = 2; i < s.size()-1; i++){
        if(cs[i]=='C'){
            count--;
        }
    }
    for(int i = 1; i < s.size(); i++){
        flag = flag && ((cs[i] >= 'a' && cs[i] <= 'z') || cs[i]=='C');
    }
    if(flag && !count){
        std::cout << "AC" << std::endl;
    } else {
        std::cout << "WA" << std::endl;
    }
}


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

int main(void){
    long long n;
    cin >> n;
    
    if(n == 0){
        cout << 0 << endl;
    }
    
    string s;
    long long p = 1;
    
    while(n){
        if(abs(n) % (abs(p * -2)) == 0){
            s = "0" + s;
        }else{
            s = "1" + s;
            n -= p;
        }
        
        p *= -2;
    }
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int 
#define MOD 1e9 + 7 
#define INF 1<<30
using namespace std ;

map<long , int > exist ;  
int main() {
        ios::sync_with_stdio(false);
        int n ;
        cin >> n ;  
        long temp ;  
        long count = 0 ;  
        for(int i = 0 ; i < n ; i++) {
                cin >> temp ;  
                if(exist[temp] == 0) {
                        exist[temp] = 1 ;
                        count++ ;  
                }
                else {
                 count-- ;  
                 exist[temp] = 0 ; 
}
        }
        cout << count << endl ;
        
} 

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int64_t N;
  cin >> N;
  int64_t end = sqrt(N);
  for (int i = end; i > 0; --i) {
    if (N % i == 0) {
      cout << (i + N / i - 2) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef std::pair<int, int> int_pair;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {

	int n = 0, m = 0, c = 0;
	int tmp = 0,ans = 0;
	cin >> n >> m >> c;
	int b[20] = {}, a[20][20] = {};
	rep(i, m) {
		cin >> b[i];
	}
	rep(i, n) {
		rep(j, m) {
			cin >> a[i][j];
		}
	}

	rep(i, n) {
		rep(j, m) {
			tmp +=  a[i][j] * b[j];
		}
		tmp += c;
		if (tmp > 0) {
			ans++;
		}
		tmp = 0;
	}

	cout << ans << endl;

	tmp = 0;

}


Measured memory_bytes: 256