akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<unordered_map>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {

    ll N, K;
    cin >> N >> K;

    ll a, b;
    unordered_map<ll, ll> m;
    for (ll i = 0; i < N; ++i) {
        cin >> a >> b;
        m[a] += b;
    }

    // pq?
    vector<ll> keys;
    for (const auto& p : m) {
        keys.push_back(p.first);
    }

    sort(keys.begin(), keys.end(), less<ll>());

    ll cnt = 0;
    for (auto key : keys) {
        cnt += m[key];
        if (cnt >= K) {
            cout << key << endl;
            return 0;
        } 
    }
    
    return 0;
}

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};

int main()
{
   int n, m;
   cin >> n >> m;
   vector<int> table(n);
   rep(i,n)
   {
       cin >> table[i];
       table[i]--;
   }
   UnionFind ui(n);

   rep(i,m)
   {
      int x, y;
      cin >> x >> y;
      --x; --y;
      ui.unite(x,y);
   }

   int ans = 0;
   rep(i,n) if(table[i] == i || ui.same(i,table[i])) ans++;
   cout << ans << endl;
}

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


ll count_number(ll A, ll B, ll d)
{
    ll res;
    res = B / d - A / d;
    if (A % d == 0)
        res++;
    return res;
}

ll gcd(ll a, ll b)
{
    ll big = max(a, b);
    ll mini = min(a, b);
    ll res = big % mini;
    while (res != 0)
    {
        big = mini;
        mini = res;

        res = big % mini;
    }
    return mini;
}
int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = 0;
    ll common = C * D / gcd(C, D);

    ans = count_number(A, B, C) + count_number(A, B, D) - count_number(A, B, common);
    // cout << count_number(A, B, C)  << endl;
    // cout << count_number(A, B, D)  << endl;
    // cout << count_number(A, B, C * D)  << endl;

    ans = B - A + 1 - ans;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  for(int i=max(a,b);i>0;i--){
    if(a%i==0&&b%i==0){
      c--;
      if(c==0)cout<<i;
    }
  }
}


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

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

LL N;

int main() {
    cin >> N;
    LL ans = N;
    for (LL i = 1; i <= sqrt(N); i++) {
        if (N % i == 0) {
            LL tmp = (i - 1) + (N / i - 1);
            if (tmp < ans) {
                ans = tmp;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int x,hoges[30],hoget[30];
char s[210000],t[210000];

int main() {

    cin >> s >> t;

    for( x=0 ; s[x] != 0 ; x++ ) {
        s[x] -= 96;
        t[x] -= 96;
    }

    for( x=0 ; s[x] != 0 ; x++ ){
        if( hoges[s[x]] == 0){
            hoges[s[x]] = t[x];
        }
        else if( hoges[s[x]] != t[x] ){
            cout << "No\n";
            return 0;
        }
        if( hoget[t[x]] == 0){
            hoget[t[x]] = s[x];
        }
        else if( hoget[t[x]] != s[x] ){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

int n;
int a[100010];
int d[100010];
const int mod = 1e9 + 7;

long long mod_pow(long long x,long long n){
    if(n == 0) return 1;
    long long res = mod_pow(x*x % mod, n / 2);
    if(n & 1) res = res*x % mod;
    return res;
}

signed main(){
    cin >> n;
    rep(i, 0, n){
        cin >> a[i];
        d[a[i]]++;
    }
    int ans = mod_pow(2, n / 2);
    bool f = true;
    int l = n / 2;
    if(n % 2 == 0){
        rep(i, 0, n){
            if(i % 2 == 1 && i <= 2 * l - 1 && d[i] == 2) continue;
            else if(d[i] != 0){
                f = false;
                break;
            }
        }
    }else{
        rep(i, 0, n){
            if(i == 0 && d[0] == 1) continue;
            else if(i % 2 == 0 && i <= 2 * l && d[i] == 2) continue;
            else if(d[i] != 0){
                f = false;
                break;
            }
        }
    }
    cout << (f ? ans : 0) << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

//????????????????§???????
struct Card{
  char mark;
  int num;
};

typedef struct Card card;




int main(void){
  int n,i,j,min,flag=0;
  card c1[36],c2[36],temp;
  char a;

  //??\???
  scanf("%d%c",&n,&a);
  for(i=0;i<n;i++){
    scanf("%c%d%c",&c1[i].mark,&c1[i].num,&a);
    c2[i]=c1[i];
  }
  
  //?????????
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(c1[j].num < c1[j-1].num){
	temp=c1[j];
	c1[j]=c1[j-1];
	c1[j-1]=temp;
      }
    }
  }

    
  //?????¬????????§???
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(c2[j].num < c2[min].num) min=j;
    }
    temp=c2[min];
    c2[min]=c2[i];
    c2[i]=temp;
  }


  for(i=0;i<n;i++){
    if(i==n-1) printf("%c%d\n",c1[i].mark,c1[i].num);
    else  printf("%c%d ",c1[i].mark,c1[i].num);
  }
  printf("Stable\n");
  
  for(i=0;i<n;i++){
    if(i==n-1) printf("%c%d\n",c2[i].mark,c2[i].num);
    else  printf("%c%d ",c2[i].mark,c2[i].num);
  }
  
  for(i=0;i<n;i++){
    if(c1[i].mark != c2[i].mark) flag=1;
  }
  if(flag==1)printf("Not stable\n");
  else printf("Stable\n");
  
  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define F(i, a, b)  for(int i = a;i < b;i++)
#define RF(i, a, b) for(int i = a-1;i >= b;i--)
#define FIT(i, v)   for(auto i: v)
#define FRIT(i, v)  for(auto &i: v)

class graph{
	int n;
	list<int> *adj;
	vi in_degree;
public:
	graph(int x):n(x+1){
		adj = new list<int> [n];
		in_degree.resize(n, 0);
	}
	~graph(){
		delete[] adj;
	}
	void add_edges(int u, int v){
		adj[u].push_back(v);
		in_degree[v]++;
	}
	int longest_path();
};

int graph::longest_path(){
	vector<int> dist(n, 0);
	queue<int> q;
	q.push(0);

	while(!q.empty()){
		int u = q.front();
		q.pop();

		for(auto v: adj[u]){
			dist[v] = max(dist[v], dist[u] + 1);
			--in_degree[v];
			
			if(in_degree[v] == 0)
				q.push(v);
		}
	}

	int longest_dist = *max_element(dist.begin(), dist.end());

	return longest_dist-1;
}

int main(){
	int n, m;
	cin >> n >> m;
	int u, v;
	graph g(n);

	F(i, 0, m){
		cin >> u >> v;
		g.add_edges(u, v);
	}
	// add a fake vertex which connects all other vertices
	F(i, 1, n+1){
		g.add_edges(0, i);
	}

	cout << g.longest_path() << endl;

	return 0;
}

Measured memory_bytes: 8960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var h = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        Console.WriteLine(h.OrderByDescending(x => x).Skip(nk[1]).Sum());
    }
}

Measured memory_bytes: 41216
#include <stdio.h>
int main(void){
    // Your code here!
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    m=(S%3600)/60;
    s=(S%3600)%60;
    printf("%d:%d:%d\n",h,m,s); 
}


Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int func(int x) {
  int sum = 0;
  while(x/10 != 0) {
    sum+=x%10;
    x/=10;
  }
  sum+=x;

  return sum;
}

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

  int N, A, B; cin >> N >> A >> B;
  int res = 0;
  reps(i, 1, N+1) {
    int v = func(i);
    if(A <= v && v <= B)res+=i;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   long long int X;
   long long int h=100,i;
   cin >> X;
   for(i=1;;i++){
       h = h + 0.01*h;
       if(h>=X){
           cout << i;
           break;
       }
   }
   
   return 0;
}

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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 100005;

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

    int h, w, a, b;
    cin >> h >> w >> a >> b;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (j < a) {
                cout << (i < b ? 1 : 0);
            } else {
                cout << (i < b ? 0 : 1);
            }
        }
        cout << endl;
    }

    return 0;
%>

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=1000005;
char s1[maxn],s2[maxn];
int n,Queue[maxn];
int main(){
	read(n);
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	if(!strcmp(s1+1,s2+1)){
		puts("0");return 0;
	}int last=n,ans=0,l=1,r=0;
	per(i,n,1)if(s2[i]!=s2[i-1]){
		while(last&&(last>i||s1[last]!=s2[i]))last--;
		if(last==0){
			puts("-1");
			return 0;
		}
		while(l<=r&&Queue[l]>=r-l+1+i)l++;
		if(last<i)Queue[++r]=last;
		ans=max(ans,r-l+1);
	}cout<<ans+1<<endl;
	return 0;
}


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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    ll n;
    cin >> n;
    ll b,r;
    cin >> b >> r;
    string br="";
    ll count = 0;

    if(b+r<n){
        if(n%(b+r)<b){
            cout << (n/(b+r))*b+n%(b+r);
            return 0;
        }else{
            cout << (n/(b+r))*b+b;
            return 0;
        }
        
    }
    if(b+r==n){
        cout << b;
        return 0;
    }
    if(b+r>n && b<n){
        cout << b;
        return 0;
    }
    if(b+r>n && b>n){
        cout << n;
        return 0;
    }



}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String line;
		while ((line = br.readLine()) != null) {
			for (int i = 0; i <= 25; i++) {
				char[] temp = line.toCharArray();
				for (int j = 0; j < temp.length; j++) {
					if ('a' <= temp[j] && temp[j] <= 'z') {
						temp[j] += i;
						if (temp[j] > 'z') temp[j] -= 'z' - 'a' + 1;
					}
				}
				String henkango = new String(temp);
				if (henkango.contains("the") || henkango.contains("this") || henkango.contains("that")) {
					System.out.println(henkango);
					break;
				}
			}
		}
	}

}

Measured memory_bytes: 23972
from itertools import combinations

n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = map(int, input().split())

s = set()
for i in range(1, n + 1):
    for j in combinations(a, i):
        s.add(sum(j))
for ans in m:
    print('yes' if ans in s else 'no')

Measured memory_bytes: 6732
#include <stdio.h>

int main() {
  int enemy_hp;
  int num = 0;
  int i;
  scanf("%d", &enemy_hp);
  scanf("%d", &num);
  for (i = 0; i < num; i++) {
  	  int bear_at;
    scanf("%ld", &bear_at);
    enemy_hp -= bear_at;
  }
  if (enemy_hp <= 0)
    puts("Yes");
  else
    puts("No");
  return 0;
}

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

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  if (g%2==0 && b%4==0) cout << "YES" << endl;
  else if (g%2==1 && b%4==2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005],z[100005];
int main()
{
	std::ios::sync_with_stdio(false);
	for(int i=2;i<=100000;i++)
    {
        for(int j=2*i;j<=100000;j+=i)
            a[j]=1;
    }
    a[1]=1;
    a[2]=0;
	int q;
	cin>>q;
	for(int i=1;i<=100000;i++)
	{
		if(!a[i]&&i!=2&&!a[(i+1)/2])
		z[i]=z[i-1]+1;
		else z[i]=z[i-1];
	}
	for(int i=1;i<=q;i++)
	{
		int l,r;
		cin>>l>>r;
		//cout<<z[r]<<" "<<z[l]<<endl;
		cout<<z[r]-z[l-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	string S;
	cin>>S;
	lli K;
	cin>>K;
	int con=0;
	int x=0;
	while(S[x]=='1'){
		con++;
		x++;
	}
	if(K<=con) cout<<1;
	else cout<<S[con];
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define ll long long int
#define ull unsigned long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
const ll INF = 1e18L + 5;
int main()
{
    fast;
    ll n,W;
    cin>>n>>W;
    ll a[n+2][2];
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1];
        sum += a[i][1];
    }
    vector<ll> dp(sum+1,INF);
    //a[i][0] -> wt
    //a[i][1] -> val
    dp[0]=0;
    // cout<<"sum: "<<sum<<"\n";
    for(int i=0;i<n;i++)
    {        
        // cout<<a[0][0] + dp[0]<<"\n";
        for(int j=sum-a[i][1];j>=0;j--)
        {
            {
                dp[j+a[i][1]]=min(a[i][0] + dp[j] , dp[j+a[i][1]]);
            }
        }
        
        // dp=ndp;
    }
    ll ans=-1;
    for(ll i=0;i<=sum;i++)
    {
        if(dp[i]<= W)
        {
            ans=max(ans,i);
        }
    }
    // for(int j:dp)cout<<j<<" ";cout<<"\n";
    cout<<ans;
return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;

int main(){
  ll n,k; cin >> n >> k; vector<long double> exp(n);
  vector<long double> sum(n+1); sum[0] = 0; long double expmax = 0;
  
  rep(i,n){
    ll x; 
    cin >> x; 
    exp[i] = (x+1)/2.0; 
    sum[i+1] = sum[i] + exp[i];
  }
  //rep(i,n+1){
    //debug(exp[i],sum[i]);
  //}
  
  for(ll i=0; i < n - k + 1; i++){
    expmax = max(expmax,sum[k+i] - sum[i]);
  }
  
  cout <<fixed << setprecision(6)<< expmax << endl;
}
                 
  


Measured memory_bytes: 6528
# local search is all you need
# 「日付 d とコンテストタイプ q をランダムに選び、d 日目に開催するコンテストをタイプ q に変更する」を実装する

from time import time
t0 = time()

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from random import randint


def score(D, C, S, T):
    last = [-1] * 26
    # scores = [0]
    score = 0
    for d in range(D):
        # scores.append(scores[-1] + S[d][T[d]])
        score += S[d][T[d]]
        last[T[d]] = d
        for i in range(26):
            # scores[-1] -= C[i] * (d - last[i])
            score -= C[i] * (d - last[i])  # この場で一番罰則が大きいやつを使うとか？
    return score


D = a_int()
C = ints()
S = read_tuple(D)


def maximizer(newT, bestT, bestscore):
    tmpscore = score(D, C, S, newT)
    if tmpscore > bestscore:
        return newT, tmpscore
    else:
        return bestT, bestscore


def ret_init_T():
    '''greedyで作ったTを初期値とする。
    return
    ----------
    T, score ... 初期のTとそのTで得られるscore
    '''
    def _make_T(n_days):
        # editorialよりd日目の改善は、改善せずにd+n_days経過したときの関数にしたほうが
        # 最終的なスコアと相関があるんじゃない？
        T = []
        last = [-1] * 26
        for d in range(D):
            ma = -INF
            for i in range(26):
                tmp = S[d][i]
                for j in range(n_days):
                    tmp += C[i] * (d + j - last[i])
                if tmp > ma:
                    t = i
                    ma = tmp
            last[t] = d  # Tを選んだあとで決める
            T.append(t)
        return T

    T = _make_T(0)
    sco = score(D, C, S, T)
    for i in range(1, 20):
        T, sco = maximizer(_make_T(i), T, sco)
    return T, sco


bestT, bestscore = ret_init_T()


def add_noise(T):
    '''日付dとコンテストqをランダムに選びd日目に開催するコンテストのタイプをqに変更する'''
    ret = T.copy()
    d = randint(0, D - 1)
    q = randint(0, 25)
    ret[d] = q
    return ret


while time() - t0 < 1.925:
    bestT, bestscore = maximizer(add_noise(bestT), bestT, bestscore)

# print(bestscore)
# print(score(D, C, S, T))
print(*mina(*bestT, sub=-1), sep='\n')


Measured memory_bytes: 87080
import sys

n = int(input())
before_t, before_x, before_y = 0, 0, 0
for i in range(n):
	txy_strs = input().split()
	t, x, y = tuple(map(int, txy_strs))
	
	movable = t - before_t
	min_move = abs(x - before_x) + abs(y - before_y)

	remaining = movable - min_move
	if 0 <= remaining and remaining % 2 == 0:
		before_t, before_x, before_y = t, x, y
	else:
		print("No")
		sys.exit()
print("Yes")

Measured memory_bytes: 3188
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

c = Counter(A)


ans = [0, 0]
for i, j in c.items():
    if j >= 2:
        ans.append(i)
    if j >= 4:
        ans.append(i)

ans.sort()    

print(ans[-1]*ans[-2])

Measured memory_bytes: 18592
public class Hello{
    public static void Main(){
        
        var line = System.Console.ReadLine();
        if(line.Substring(2,1) == line.Substring(3,1) && line.Substring(4,1) == line.Substring(5,1))
        {
            System.Console.WriteLine("Yes");
        }
        else
        {
            System.Console.WriteLine("No");
        }
        
    }
}


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

const int N = 100 + 5;

int dp[5][N], a[5][N], n;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= 2; i++) {
		for(int j = 1; j <= n; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for(int j = 1; j <= n; j++) {
		for(int i = 1; i <= 2; i++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];
		}
	}
	printf("%d\n", dp[2][n]);
	return 0;
}

Measured memory_bytes: 128
s = input()

alphabet = 'abcdefghijklmnopqrstuvwxy'

ans = 'AC'

C_count = s.count('C')
if C_count == 1 and s[0] == 'A' and s[1] != 'C' and s[-1] != 'C':
    s = s.replace('C', 'c')

    for i in range(1, len(s)):
        if s[i] in alphabet:
            pass
        else:
            ans = 'WA'
            break
else:
    ans = 'WA'

print(ans)


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {

	private static final String SEPARATOR = " ";

	public static void main(String[] args) {
		Scanner s = null;
		try {
			s = new Scanner(System.in);
			Integer[] weight = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };

			while (s.hasNextInt()) {
				int gram = s.nextInt();
				List<Integer> weightList = new ArrayList<Integer>();

				Arrays.sort(weight, Collections.reverseOrder());
				for (int x : weight) {
					if (x <= gram) {
						gram -= x;
						weightList.add(x);
					}
				}
				Collections.sort(weightList);
				System.out.println(punctuate(weightList, SEPARATOR));
			}
		} finally {
			s.close();
		}
	}

	public static StringBuffer punctuate(List<Integer> list, String s) {
		StringBuffer sb = new StringBuffer();;
		for (int i = 0; i < list.size(); i++) {
			sb.append(list.get(i));
			if (i < list.size() - 1) sb.append(s);
		}
		return sb;
	}
}

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

vector<char> ops{'+', '-', '*', '/'};


auto is_op(char c) -> bool {
  auto&& it = find(ops.begin(), ops.end(), c);
  return it != ops.end();
}

auto eval(int a, char op, int b) -> int {
  // cout << a << " " << op << " " << b << endl;
  if(op == '+') return a + b;
  else if(op == '*') return a * b;
  else if(op == '-') return a - b;
  else if(op == '/') return a / b;
}

auto expr(set<int> a, set<int> b, char op) -> set<int> {
  set<int> res;
  for(auto it = a.begin(); it != a.end(); ++it) {
    for(auto b_it = b.begin(); b_it != b.end(); ++b_it) {
      if(*b_it == 0 && op == '/') continue;
      res.insert(eval(*it, op, *b_it));
      // cout << eval(*it, op, *b_it) << endl;
    }
  }
  return res;
}

auto calc(string s) -> set<int> {
  set<int> result[11][11];
  vector<int> op_pos;
  vector<char> expr_ops;
  set<int> nums[256];

  string num = "";
  // cout << "s => " << s << endl;

  int idx = 0;
  for(int i=0; i<s.size(); ++i) {
    // cout << "s[i] " << s[i] << endl;
    if(s[i] == '(') {
      int cnt = 1;
      for(int j=i+1;j<s.size(); ++j) {
        if(s[j]=='(') cnt++;
        if(s[j]==')') cnt--;
        if(s[j]==')' && cnt==0) {
          nums[idx++] = calc(s.substr(i+1, j-i-1));
          i = j;
          break;
        }
      }
    }
    else if(is_op(s[i])) {
      op_pos.push_back(i);
      expr_ops.push_back(s[i]);
      // cout << "num " << num << endl;
      if(num != "")
        nums[idx++].insert(stoll(num));
      num = "";
    } else num += s[i];
  }
      // cout << "num " << num << endl;
  if(num != "") nums[idx++].insert(stoll(num));

  for(int i = 0; i<idx; ++i){
    result[i][i] = nums[i];
  }
  for(int j=1; j<idx; ++j) {
    for(int i=0; i<idx; ++i) {
      if(i+j >= idx)break;
      for(int k=0; k<j; ++k) {
        //cout << "i" << i << " i+k" << i+k << "     i+k+1" << i+k+1 << " i+j: " << i+j << " k " << k << endl;
        //cout << result[i][i+k].size()<< " , " << result[i+k+1][i+j].size() << endl;
        auto&& tmp = expr(result[i][i+k], result[i+k+1][i+j], expr_ops[i+k]);
        for(auto e : tmp) result[i][i+j].insert(e);
        //cout << "result: " << result[i][i+j].size() << endl;
      }
    }
  }

  // for(int i= 0; i < idx; ++i){
  //   cout << "i: " << i << endl;
  //   for(int j = i; j < idx; ++j){
  //     cout << result[i][j].size() << endl;
  //   }
  // }

  return result[0][idx-1];
}

auto rec(string target) -> void {
}

auto main() -> signed {
  string s;
  while(cin>>s, s!="#") {
    cout << calc(s).size() << endl;
  }
}

Measured memory_bytes: 3408
#include <iostream>
#include <string>

using namespace std;

int main() {

	string s;
	cin >> s;

	string abc = "abcdefghijklmnopqrstuvwxyz";

	if (s[0] == 'A') {
		int bb = 0;
		for (int i = 2; i+1 < s.size(); i++) {
			if (s[i] == 'C') {
				bb++;
			}
		}
		if (bb == 1) {
			bool hh = true;
			for (int i = 1; i < s.size(); i++) {
				if (s[i] == 'C') {

				}
				else {
					hh = false;
					for (int j = 0; j < abc.size(); j++) {
						if (s[i] == abc[j]) {
							hh = true;
						}
					}
					if (!hh) {
						break;
					}
				}
			}
			if (hh) {
				cout << "AC" << endl;
			}
			else {
				cout << "WA" << endl;
			}
		}
		else {
			cout << "WA" << endl;
		}
	}
	else {
		cout << "WA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
                   JAY KHODIYAR MAA
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.      IIT PATNA      ADITI GOEL IS LOVE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// while(scanf("%d",&n)!=EOF)

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ii int64_t
#define lli long long int
#define li long int
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define mod 1000000007
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    fio;
    ii i,j,l,f=0,x,y;
    string s;
    cin>>s;
    s='#'+s;
    l=s.length()-1;
    
    j=(l-1)/2;
    i=1;
    while(s[i]==s[j])
    {
        i++;j--;
    }
    x=1;y=l;
    while(s[x]==s[y]){x++;y--;}
    
    if(x>y && i>j)
        cout<<"Yes";
    else cout<<"No";
    
    
    
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a << endl;
    return 0;
}

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

const int N = 2e5 + 10, mod = 1e9 + 7;



int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    //scanf("%d", &tc);
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    while(tc--) {
        int k; cin >> k;
        cout << v[k - 1] << '\n';
    }    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;


int main(){
    int N;
    cin >> N;
    vector<LL> p(N), ind(N+1);
    multiset<LL>    s;
    for(int i = 0;i < N;i++){
        scanf("%d", &p[i]);
        p[i]--;
        ind[p[i]] = i;
    }
    s.insert(N);
    s.insert(N);
    s.insert(-1);
    s.insert(-1);
    LL ans = 0;
    LL l, ll, r, rr, cur;
    for(LL i = N-1;i >= 0;i--){
        cur = ind[i];
        auto curitr = s.lower_bound(cur);
//        l = *(--curitr);
//        ll = *(--curitr);
//        curitr = curitr2;
//        r = *(++curitr);
//        rr = *(++curitr);
        r = *curitr;
        curitr++;
        rr = *curitr;
        curitr--;
        curitr--;
        l = *curitr;
        curitr--;
        ll = *curitr;
        LL p1 = (rr - r) * (cur - l);
        LL p2 = (r - cur) * (l - ll);
        ans += (p1 + p2) * (i + 1);
        s.insert(cur);
    }
    printf("%lld", ans);
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
//ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE


int main() {
    auto start = chrono::high_resolution_clock::now();
    fio;
    ll t=1; 
   // cin>>t;
    while(t--)
    {
		
		ll n; cin>>n;
		ll sum=0;
		for(ll i=1;i<=n;i++)
		{
			if(i%3!=0 && i%5!=0)
			{
				sum+=i;
			}
		}
		
		
		cout<<sum<<"\n";
		
    }

    auto finish = chrono::high_resolution_clock::now();
    cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
    return 0;
        
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n'
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	string  s = "";
	while(n){
		--n;
		int x = n%26;
		s += x+ 'a';	
		n/=26;
	}
	reverse(s.begin(), s.end());
	cout<<s<<endl;
	return 0;
}


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

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


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

int main(){
	int n;
	cin>>n;
	long long arr[n+1]={0};
	for(int i=1; i<=n; i++) cin>>arr[i];
	long long ret = 0;
	long long front_mx = 0;
	for(int i=1; i<=n; i++){
		ret+=max((long long)0,front_mx-arr[i]);
		front_mx = max(front_mx,arr[i]);
	}
	cout<<ret;
}

Measured memory_bytes: 5184
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int p[100000];
int y[100000];
int z[100000];
int ans[100000];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int  Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}


int main() {
	char s[200001];
	scanf("%s", s);

	int w[200001] = { 0 };
	int cnt = -1;

	REP(i, strlen(s)) {
		if (s[i] == 'B') {
			cnt++;
			continue;
		}
		else if(cnt!=-1){
			w[cnt]++;
		}
	}
	ll ans = 0;
	RREP(i, cnt+1) {
		w[i] += w[i + 1];
		ans += w[i];
	}
	PRINTL(ans);
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a[1000];
  for(int i = 0; i < 1000; ++i){
    a[i] = -1;
  }

  bool check = true;
  
  for(int i = 0; i < s.size(); ++i){
    if(a[s[i]] > 0){
      cout << "no" << endl;
      check = false;
      break;
    }

    a[s[i]] = 1;
  }
  
  if(check){
    cout << "yes" << endl;
  }

  return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

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

	vector<int> t(N + 1), x(N + 1), y(N + 1);

	for (int i = 1; i < N + 1; i++)
	{
		cin >> t[i] >> x[i] >> y[i];
	}

	for (int i = 1; i < N + 1; i++)
	{
		int num = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);

		//cout << num << ":" << t[i] << endl;

		if (t[i] - t[i - 1] >= num)
		{
			if ((t[i] - t[i - 1]) % 2 != num % 2)
			{
				cout << "No" << endl;
				return 0;
			}
		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}


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

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

	int pre;
	cin >> pre;
	int h;
	int count = 0;
	int ret = 0;
	for (int i = 1; i < n; ++i) {
		cin >> h;
		if (pre < h) {
			if (ret < count) {
				ret = count;
			}
			count = 0;
		}
		else {
			++count;
		}
		pre = h;
	}

	if (ret < count) {
		ret = count;
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <sstream>

#include <boost/range/irange.hpp>
using boost::irange;

#include <boost/utility/string_ref.hpp>
using boost::string_ref;

using namespace std;

template<class T, size_t N, class F>
struct compare_n
{
    F f;
    bool operator() (const T& t1, const T& t2)
    {
        return f(get<N>(t1), get<N>(t2));
    }
};
 
template<size_t N, class T>
auto make_less_n(const T&)
{
    using t = typename T::value_type;
    using less = std::less<typename tuple_element<N, t>::type>;
    return compare_n<t, N, less>();
}

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

    string s;
    cin >> s;
    const int a = s[0] - '0';
    const int b = s[1] - '0';
    const int c = s[2] - '0';
    const int d = s[3] - '0';
    
    for(int i = 0; i < 8; ++i)
    {
        int x = a;
        x += i & 1 ? b : -b;
        x += i & 2 ? c : -c;
        x += i & 4 ? d : -d;
        if(x == 7)
        {
            cout
              << a
              << (i & 1 ? '+' : '-')
              << b
              << (i & 2 ? '+' : '-')
              << c
              << (i & 4 ? '+' : '-')
              << d
              << "=7\n";
            return 0;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>

void Trace(int *A, int N, int cnt){
	//?????????????????????????????????N-1??¨??????
	for (int i = 0; i < N - 1; i++){
		printf("%d ", A[i]);
	}
	printf("%d\n", A[N - 1]);
	printf("%d\n", cnt);
}

int SelectionSort(int *A, int N){
	int cnt = 0;

	for (int i = 0; i < N; i++){

		int minj = i;

		for (int j = i; j < N; j++){
			if (A[minj] > A[j]){
				minj = j;
			}
		}

		if (minj != i) {
			int t = A[i];
			A[i] = A[minj];
			A[minj] = t;
			cnt++;
		}
	}

	return cnt;
}

int main(int argc, char *argv[]){
	int N;

	scanf("%d", &N);

	int *A = (int*)malloc(sizeof(int) * N);

	//??\???
	for (int i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}

	int cnt = SelectionSort(A, N);
	Trace(A, N, cnt);

	free(A);

	return 0;
}

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

int main(){
    map<string, int> MAP;
    int N,M;
    cin >> N;
    string S;
    for(int i=0;i<N;i++){
        cin >> S;
        MAP[S]++;
    }
    cin >> M;
    for(int i=0;i<M;i++){
        cin >> S;
        MAP[S]--;
    }
    map<string,int>::iterator it;
    int ans=0;
    for(it=MAP.begin();it!=MAP.end();it++){
        pair<string,int> item=*it;
        ans=max(ans,item.second);
    }
    cout << ans << endl;
}

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

using namespace std;

int check(int x){
	int res = 0; 
	while(x){
		x /= 10;
		res++;
	}
	return res % 2;
}

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n;
	cin >> n;
	int res = 0;
	for(int i = 1; i <= n; ++i){
		res += check(i);
	}

	cout << res;
    return 0;
}


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

int main(){
  string str;
			
  while(getline(cin, str)){
	if(str == ".") break;
	//cout << str << endl;
	bool flag  = false;
	stack<char> s;
	
	for(int i = 0; i < str.size(); i++){
	  if(str[i] == '(') s.push(str[i]);
	  else if(str[i] == '[') s.push(str[i]);
	  else if(str[i] == ')'){
		if(s.empty()){
		  flag = true;
		  break;
		}
		
		char tmp = s.top(); s.pop();
		//cout << "if ')' then tmp = " << tmp << endl;
		if(tmp != '('){
		  flag = true;
		  break;
		}
	  }
	  else if(str[i] == ']'){
		if(s.empty()){
		  flag = true;
		  break;

		}
		char tmp = s.top(); s.pop();
		//cout << "if ']' then tmp  = " << tmp << endl;
		if(tmp  != '['){
		  flag = true;
		  break;
		}
	  }
	}
	
	if(flag || !s.empty()) cout << "no" << endl;
	else cout << "yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <unordered_set>
int main() {
    int n;
    std::unordered_set<std::string> s;
    std::string t, u;
    std::cin >> n;
    while (n-- > 0) {
        std::cin >> t >> u;
        if (t == "insert") {
            s.insert(u);
        } else {
            std::cout << ((s.find(u) == s.end()) ? "no" : "yes") << std::endl;
        }
    }
}



Measured memory_bytes: 32136
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q, H, W, D, L, R,K;
ll A;
ll B[200001];
ll ans;
string S;
char s[52][52];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
char a[100][100];
ll Hcount[100];
ll Wcount[100];
int main() {
	cin >> H >> W;
	rep(i, 0, H) {
		rep(j, 0, W) {
			cin >> a[i][j];
			if (a[i][j] == '.') {
				Hcount[i]++;
				Wcount[j]++;
			}
		}
	}
	rep(i, 0, H) {
		rep(j, 0, W) {
			if (Hcount[i]!=W && Wcount[j]!=H)
				cout << a[i][j];
		}
		if(Hcount[i] != W)
			cout << endl;
	}
	cin >> N;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    long mod = 1000000000+7;
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        // use i-indexed here
        long a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong(), d = sc.nextLong();
        long lcm = c*d/gcd(c,d);
        long mc = MultipleInRange(a,b,c);
        long md = MultipleInRange(a,b,d);
        long repeat = MultipleInRange(a,b,lcm);
        return (b-a+1)-(mc+md-repeat);
    }
    long MultipleInRange(long lo, long hi, long x){
        return hi/x-(lo-1)/x;
    }
    long gcd(long x, long y){
        // first find gcd
        if(x<y){
            long c = x;
            x = y; y = c;
        }
        while(x%y!=0){
            long c = y;
            y = x%y;
            x = c;
        }
        return y;
    }
}



Measured memory_bytes: 22732
def main():
    data = list(map(int, input().split()))
    Xn = data[0]
    Yn = data[1]
    X = data[2]
    Y = data[3]

    Xs = list(map(int, input().split()))
    Ys = list(map(int, input().split()))

    mergin = list(range(X, Y))
    flag = False
    if not mergin:
        mergin.append(0)
        flag = True
    x_line = min(mergin)
    y_line = max(mergin)

    max_x = max(Xs)
    min_y = min(Ys)

    if (max_x < min_y):
        if ((max_x + min_y) // 2 in mergin):
            if flag:
                print('War')
            else:
                print('No War')
        else:
            if flag:
                print('No War')
            else:
                print('War')
    else:
        if flag:
            print('No War')
        else:
            print('War')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int N;
    int t[100000],x[100000],y[100000];
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d%d%d",&t[i],&x[i],&y[i]);
    }
    int can=1;
    for(int i=0;i<N;i++){
        int can2=0;
        for(int n=0;x[i]+y[i]+2*n<=t[i];n++){
            if(x[i]+y[i]+2*n==t[i]){
                can2=1;
            }
        }
        if(can2==0){
            can=0;
            break;
        }
    }
    if(can==1)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}

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

int main()
{
    int n;
    double ans = 0;
    cin >> n;
    vector<double> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) ans += 1 / a[i];
    ans = 1 / ans;
    cout << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256