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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;


void print_list(list<ll> l) {
    for (auto it = l.begin(); it != l.end(); it++) {
        cout << *it << ' ';
    }
    cout << endl;
}

int main() {
    list<ll> l;
    l.push_front(INF);
    int n;
    cin >> n;

    auto it = l.begin();

    rep(i, n) {
//        print_list(l);
        int q;
        cin >> q;
        if (q == 0) {
            ll x;
            cin >> x;

            it = l.insert(it, x);

        } else if (q == 1) {
            ll d;
            cin >> d;
            if (d < 0) {
                for (ll i = 0; i > d; i--) {
                    it--;
                }
            } else {
                for (ll i = 0; i < d; i++) {
                    it++;
                }
            }
        } else if (q == 2) {
            it = l.erase(it);
        } else {
            __throw_runtime_error("konai");
        }
    }

    for (auto it = l.begin(); it != l.end(); it++) {
        ll a = *it;
        if (a != INF)
            cout << *it << endl;
    }
}


Measured memory_bytes: 18568
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int a,b;
 
  cin>>a>>b;
 
  if(a==b){
    cout<<"Draw"<<endl;
  }
 
  else{
 
    if(a==1){
      cout<<"Alice"<<endl;
    }else if(b==1){
      cout<<"Bob"<<endl;
    }else if(a>b){
      cout<<"Alice"<<endl;
    }else if(b>a){
      cout<<"Bob"<<endl;
    }
  }

  return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lg2 std::__lg
#define ctz __builtin_ctz

const int N = 100054, M = N * 2;

int n, E = 0;
int to[M], first[N], next[M];
int f[N], ans[N];

inline void addedge(int u, int v) {
	to[++E] = v, next[E] = first[u], first[u] = E;
	to[++E] = u, next[E] = first[v], first[v] = E;
}

void dfs(int x, int px = 0) {
	int i, y, s = 0;
	for (i = first[x]; i; i = next[i])
		if ((y = to[i]) != px)
			dfs(y, x), s |= f[x] & f[y], f[x] |= f[y];
	s = lg2(s << 1 | 1), s += ctz(~(f[x] >> s));
	f[x] = (f[x] >> s | 1) << s, ans[x] = s;
}

int main() {
	int i, u, v;
	scanf("%d", &n);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	dfs(1), printf("%d\n", *std::max_element(ans + 1, ans + (n + 1)));
	return 0;
}

Measured memory_bytes: 7552
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  string s;
  while(getline(cin,s)){
    for(int i=0;i<26;i++){
      if(s.find("the")!=string::npos)break;
      if(s.find("that")!=string::npos)break;
      if(s.find("this")!=string::npos)break;
      for(int i=0;i<s.size();i++){
        if(!isalpha(s[i]))continue;
        s[i]++;
        if(s[i]>'z')s[i]-=26;
      }
    }
    cout<<s<<endl;
  }
}

Measured memory_bytes: 1180
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <fstream>
using namespace std;

int n, sum, ans;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		char c;
		cin >> c;
		if (c == 'I') {
			sum++;
		}
		else sum--;
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		String S=sc.next();
		int v[]=new int[26];
		//97
		int a;
		for(int i=0;i<S.length();i++) {
			a=S.charAt(i)-97;
			v[a]+=1;
			//p("a"+a);
		}
		boolean x=true;
		for(int i:v) {
			//p(i);
			if(i%2==1)x=false;
		}
		if(x)p("Yes");
		else p("No");
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 22996
N,A,B = map(int,input().split())
V = list(map(int,input().split()))

V.sort(reverse=True)

sumV = 0
for i in range(A):
    sumV += V[i]
ans1 = sumV/A

# 
cntV0 = 0
for i in range(N):
    if V[i]==V[0]:
        cntV0 += 1
ans2 = 1
if cntV0 > A:
    ans2 = 0
    for i in range(A,min(cntV0,B)+1):
        tmp = 1
        c = cntV0
        r = i
        for j in range(r):
            tmp *= c-j
            tmp //= j+1
        ans2 += tmp
else:
    cntV1,cntV2 = 0,0
    for i in range(N):
        if V[i]==V[A-1]:
            cntV1 += 1
        elif V[i]>V[A-1]:
            cntV2 += 1
    if cntV1+cntV2 > A:
        c = cntV1
        r = A-cntV2
        for i in range(r):
            ans2 *= c-i
            ans2 //= i+1


print(ans1, ans2)

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

const int _mx = 2e6;
int a[_mx+5];

int main() {
    // freopen("in.txt", "r", stdin);

    int n, m;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int mn = a[0], mx = -1100000000;
    for (int i = 1; i < n; i++) {
        mx = max(mx, a[i] - mn);
        mn = min(mn, a[i]);
    }
    cout << mx << endl;

    return 0;
}



Measured memory_bytes: 3896
import sys
input=sys.stdin.readline
n,y=map(int,input().split())
y10,y5,y1=0,0,0
for i in range(n+1):
    for j in range(n+1):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y and k>=0:
            print(i,j,k)
            exit(0)
print(-1,-1,-1)

Measured memory_bytes: 40684
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
  public static void main (String[] args) throws java.lang.Exception
   {
	try{
	    Scanner sc=new Scanner(System.in);
		   int n=sc.nextInt();
		   double m=sc.nextDouble();
		   int a[]=new int[n];
      double sum=0;
		   for(int i=0;i<n;i++)
		      {a[i]=sc.nextInt();
		      sum+=a[i];}
		long count=0;
		  double crit=sum/(4*m);
		  for(int i=0;i<n;i++)
		     {
		        if(a[i]>=crit)
		          count++;
		     }
		 if(count>=m)
		 System.out.println("Yes");
		 else
		 System.out.println("No");
		  }     
	catch(Exception e)
		 {}
	}
}


Measured memory_bytes: 23892
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
typedef pair<int,int> P;
int N,M,L,sx,sy,gx,gy,num;
const int INF = 100000000;
char maze[1100][1100];
int d[1100][1100];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
P s[10];
void bfs()
{
	queue<P> que;
	for(int i=0;i<N;i++)
		for(int j=0;j<M;j++)
			d[i][j]=INF;
		que.push(P(sx,sy));
		d[sx][sy]=0;
	while(que.size())
	{
		P p=que.front() ;que.pop() ;
		if(p.first ==gx && p.second ==gy) break;
		for(int i=0;i<4;i++)
			{
				int nx=p.first +dx[i],ny=p.second +dy[i];
				if(nx>=0 && nx<N && ny>=0 && ny<M && maze[nx][ny]!='X' && d[nx][ny]==INF)
				{
					que.push(P(nx,ny));
					d[nx][ny]=d[p.first ][p.second ]+1; 
				}   
			}
	}
}
void solve()
{
	for(int i=0;i<L;i++)
	{
		sx=s[i].first ,sy=s[i].second;
		gx=s[i+1].first ,gy=s[i+1].second;
		bfs();
		num+=d[gx][gy];
	}
	printf("%d\n",num);
}
int main()
{
	while(~scanf("%d %d %d",&N,&M,&L))
	{
		num=0;
		for(int i=0;i<N;i++)
			for(int j=0;j<M;j++)
			{
				scanf("\n%c",&maze[i][j]);
				if(maze[i][j]=='S')
				s[0].first=i ,s[0].second=j ; 
				else if(maze[i][j]<='9' && maze[i][j] >='1')
				s[maze[i][j]-'0'].first =i,s[maze[i][j]-'0'].second =j;
			}
		solve();
	}
	return 0;
}

Measured memory_bytes: 6584
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n,m;cin>>n>>m;
	cout<<(n*n-n)/2 + (m*m-m)/2<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

const int N=1e5+20;

int n,m,u,v,dp[N][3],source,dest;
queue <pair <int,int>> q;
bool vis[N][3];
vector <int> adj[N];

void add(int node,int mod,int dist)
{
    q.push({node,mod});
    dp[node][mod]=dist;
    vis[node][mod]=true;
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&u,&v);
        adj[u].push_back(v);
    }
    scanf("%d%d",&source,&dest);
    
    add(source,0,0);
    while(not q.empty())
    {
        auto p=q.front();
        q.pop();
        
        int node=p.first,mod=p.second;
        for(auto child:adj[node])
            if(not vis[child][(mod+1)%3])
                add(child,(mod+1)%3,dp[node][mod]+1);
    }
    
    if(not vis[dest][0]) printf("-1");
    else printf("%d",dp[dest][0]/3);
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

static const ll mod = 1e9 + 7;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n, m;
    cin >> n >> m;

    if (abs(n - m) > 1) {
        cout << 0 << endl;
        return 0;
    }

    ll res = 1;
    if ((n + m) % 2 == 0) res *= 2;
    REP(i, 1, n + 1) {
        res = (res * i) % mod;
    }
    
    REP(i, 1, m + 1) {
        res = (res * i) % mod;
    }
    
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
string S;
int cnt[26];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> S;
  REP(i,N) cnt[S[i]-'a']++;
  int ans = 1;
  REP(i,26) (ans *= cnt[i]+1) %= MOD;
  ans--;
  cout << ans << endl;

  return 0;
}


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


int main() {
    int n;
    int t, sw = 0;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    for (int j = 0; j < n-1; j++) {
        int minj = j;
        for (int k = j; k < n; k++) {
            if (A[k] < A[minj]) minj = k;
        }
        if(j != minj){
            t = A[j];
            A[j] = A[minj];
            A[minj] = t;
            sw++;
        }
    }
    for (int k = 0; k < n; ++k) {
        if (k) cout << " ";
        cout << A[k];
    }
    cout << "\n";
    cout << sw << "\n";
    return 0;
}



Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

ll dfs(int i, ll sum, string s){
    // ベースケース
    if(i >= s.length()) return sum;
    // 再起ステップ
    // +を代入しない
    ll sum1 = dfs(i+1, 0, s);
    // +を代入する
    if(i+1 < s.length()) s = s.insert(i+1, "+");
    // 加算
    string tmp;
    int c=0;
    ll sum2=0;
    while(c < s.length()){
        if(s.substr(c, 1) == "+"){
            // +なら加算処理
            sum2+=atoll(tmp.c_str());
            // 加算後は再度数字を連結するのでクリア
            tmp.clear();
        }else{
            // 数字なら文字列を連結
            tmp += s[c];
        }
        c++;
    };
    
    // 最後の数字を加算
    if(tmp.length()>0) sum2+=atoll(tmp.c_str());
    sum2 = dfs(i+2, sum2, s);
        
    return sum1+sum2;
}

int main(int argc, const char * argv[]) {
    string s;
    
    cin >> s;
    
    ll sum = dfs(0, 0, s);

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define N 3000005
using namespace std; 
int n,up,dwn,ans;
char a[N],b[N];
queue<int>q; 
int main()
{
	scanf("%d",&n);
	scanf("%s",(a+1));
	scanf("%s",(b+1));
	int tag=0;
	for(int i=1;i<=n;i++)
	{
		tag+=(a[i]!=b[i]);
	}
	if(tag==0)return puts("0"),0;
	up=dwn=n;
	while(dwn)
	{
		while(dwn>1&&b[dwn]==b[dwn-1])--dwn;
		if(up>dwn)up=dwn;
		while(up>0&&a[up]!=b[dwn])--up;
		if(!up)
		{
			puts("-1");
			return 0;
		}
		while(!q.empty()&&q.front()-q.size()>=dwn)q.pop();
		if(up!=dwn)q.push(up);
		ans=max(ans,(int)q.size()+1);
		--dwn;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7424
import sys
X=int(input())
X2=int(X**0.5)
X5=int(X**0.2)

for i in range(1, X+1):
    if X%i==0:
        for j in range(-i,X+1):
            Xt=(j+i)**5-j**5
            if Xt>X and j>0:
                break
            if Xt==X:
                print(j+i,j)
                sys.exit() 


Measured memory_bytes: 9468
R, G, B, N = list(map(int, input().split()))
ret = 0
for r in range(N//R+1):
    for g in range((N-r)//G+1):
        if N - (R*r+G*g) >= 0:
            if (N - (R*r+G*g)) % B == 0:
                ret += 1
print(ret)


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

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int LOG = 31;
const int N = 5000 + 7;
int n;
int c[N];
LL dp[N][LOG];
int DP[N][LOG];

inline LL get_kth(int v, int k){
	LL ans = 0;
	RFOR(i, LOG, 0) if (k >= (1 << i)){
		ans += dp[v][i];
		v = DP[v][i];
		k -= 1 << i;
	}
	
	return ans;
}


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

	int k;
	cin >> n >> k;
	FOR(i, 1, n + 1) cin >> DP[i][0];
	FOR(i, 1, n + 1) cin >> c[i];

	FOR(i, 1, n + 1) dp[i][0] = c[DP[i][0]];
	FOR(j, 1, LOG) FOR(i, 1, n + 1){
		DP[i][j] = DP[DP[i][j - 1]][j - 1];
		dp[i][j] = dp[i][j - 1] + dp[DP[i][j - 1]][j - 1];
	}

	LL ans = -LINF;
	FOR(i, 1, n + 1) FOR(j, 1, n + 1){
		if (k >= j){
			setmax(ans, get_kth(i, j));
		}else break;
	}

	FOR(i, 1, n + 1) FOR(j, 0, n){
		if (k > j){
			setmax(ans, get_kth(i, k - j));
		}else break;
	}
	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


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

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  vector<int> Erat(1000001);
  for(int C:A){
    if(Erat[C]!=0){
      Erat[C]=2;
      continue;
    }
    for(int i=C;i<1000001;i+=C)Erat[i]+=1;
  }
  int ans=0;
  for(int C:A){
    if(Erat[C]==1)ans+=1;
  }
  cout<<ans<<endl;
  return 0;
}  

Measured memory_bytes: 12756
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    y3 = y2 + (x2 - x1);
    x3 = x2 + (y1 - y2);
    y4 = y1 + (x2 - x1);
    x4 = x1 + (y1 - y2);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
        "math"
)

func solution(n, k int) float64 {

        memo := make([]float64, n+1)

        for i := 1; i < n+1; i++ {
                if i < k {
                        x := helper(i, k)
                        memo[i] = 1 / (float64(n) * math.Pow(2, x))
                } else {
                        memo[i] = 1 / float64(n)
                }
        }

        out := 0.0
        for i := 1; i < n+1; i++ {
                out += memo[i]
        }
        return out
}

func helper(i, k int) float64 {
        x, out := i, 0.0
        for k > x {
                x *= 2
                out++
        }
        return out
}

func main() {
        var n, k int
        fmt.Scan(&n, &k)
        fmt.Println(solution(n, k))
}

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

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int capa = a - b;
	cout << max(0, c - capa) << endl;

	return 0;
}

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

const int INF = 999999999;
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> vW(N, 0), vE(N, 0);
    for(int i=0; i<N; i++){
        if(S[i] == 'W') vW[i]++;
        vW[i+1] += vW[i];
        if(S[i] == 'E') vE[i]++;
        vE[i+1] += vE[i];
    }
    // 大きな値で初期化しておく
    int ans = INF;
    for(int i=0; i<N; i++){
        int now = vW[i-1] + (vE[N-1]-vE[i]);
        if(ans > now) ans = now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  int n;
  scanf("%d",&n);
  int a[3]={0,0,0};
  for(int i=0;i<n;i++){
    int x;
    scanf("%d",&x);
    if(x%2==1)a[0]++;
    else if(x%4==0)a[2]++;
    else a[1]++;
  }
  if(a[2]>=a[0] || (a[0]==a[2]+1 && a[1]==0))puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;

const int N = 200005;

long long a[N],b[N];
long long c[N],d[N];

bool f[35];

int main()
{
	int n;
	
	scanf("%d",&n);
	
	for (int i = 0;i < n;i++)
	{
		scanf("%lld",&a[i]);
	}
	
	for (int i = 0;i < n;i++)
	{
		scanf("%lld",&b[i]);
	}
	
	for (int i = 0;i <= 30;i++)
	{
		long long t = ((long long)1 << i);
		
		for (int j = 0;j < n;j++)
		{
			c[j] = a[j] % (2 * t);
			d[j] = b[j] % (2 * t);
		}
		
		sort(d,d+n);
		
		for (int j = 0;j < n;j++)
		{
			long long y = 2 * t - c[j];
			long long x = t - c[j];
			
			int p1 = lower_bound(d,d+n,x) - d;
			int p2 = lower_bound(d,d+n,y) - d;
			
			if (d[p2] >= y) p2--;
			if (p2 >= n) p2--;
			//if (p1 >= n) p1--;
			
			if (p2 >= p1 && (p2 - p1 + 1) % 2) f[i] = !f[i];
			
			y = 4 * t - c[j];
			x = 3 * t - c[j];
			
			p1 = lower_bound(d,d+n,x) - d;
			p2 = lower_bound(d,d+n,y) - d;
			
			if (d[p2] >= y) p2--;
			if (p2 >= n) p2--;
			//if (p1 >= n) p1--;
			
			if (p2 >= p1 && (p2 - p1 + 1) % 2) f[i] = !f[i];
		}
	}
	
	long long ans = 0;
	
	for (int i = 0;i <= 30;i++)
	{
		if (f[i]) ans |= ((long long)1 << i);
	}
	
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;
const int MAX_N=500010;

int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll r,g,b;
    r=g=b=0;
    ll dame=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            r++;
        }else if(s[i]=='G'){
            g++;
        }else{
            b++;
        }
    }
    for(int i=0;i<n-2;i++){
        ll w=1;
        while(i+w*2<n){
            if(s[i]!=s[i+w] && s[i+w]!=s[i+2*w] && s[i+2*w]!=s[i]){
                dame++;
            }
            w++;
        }
    }
    cout<<r*g*b-dame<<endl;
    return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

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

ll floor(ll A,ll B, ll x){
    ll l = A*x;
    ll r = x/B;
    ll tmp = l/B-r*A;
    return tmp;
}

int main() {

    ll A,B,N;
    cin >> A >> B >> N;
    ll x = N/B;
    ll out = max(floor(A,B,x*B-1),floor(A,B,N));
    if(B==1) out = 0;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(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 all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

int main(void) {
  int k; cin >> k;
  rep(i,k) {
    cout << "ACL";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3596
using System;
class Program
 {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            int X = int.Parse(input[0]);  //数値で受け取りたい場合は変換する
            int Y = int.Parse(input[1]);
            int s = -1;
            if(X % Y != 0){
                s = X;
            }
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
            Console.WriteLine(s);
        }
 }

Measured memory_bytes: 11092
//
//  AOJ0028.c
//  
//
//  Created by 中野 優 on 2014/02/22.
//
//

#include <stdio.h>
int main(void){
    int count[100]={0},temp,max=0;
    while(scanf("%d",&temp)!=EOF) count[temp-1]++;
    for(temp=0;temp<100;temp++){
        if (count[temp]>max) max=count[temp];
    }
    for(temp=0;temp<100;temp++) {
        if (count[temp]==max) printf("%d\n",temp+1);
    }
    return 0;
}

Measured memory_bytes: 596
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;

  const ll n = N / (A + B);
  if (n == 0) {
    cout << ((N >= A) ? A : N) << endl;
  } else {
    const ll rest = N - n * (A + B);
    cout << n * A + min(rest, A) << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int q;

string x, y;

int dp(string x, string y){
  int longest[1051][1051];
  for(int j = 1; j <= y.size(); ++j){
    for(int i = 1; i <= x.size(); ++i){
      if(i <= 0 || j <= 0){
        longest[i][j] = 0;
      }else if(x[i - 1] == y[j - 1]){
        longest[i][j] = 1 + longest[i-1][j-1];
      }else{
        longest[i][j] = max(longest[i][j -1], longest[i - 1][j]);
      }
    }
  }
  //cout << x.size() << endl;
  return longest[x.size()][y.size()];
}

int main(){
  cin >> q;
  while(q != 0){
    q--;
    cin >> x;
    cin >> y;
    
    cout << dp(x, y) << endl;
  }
}


Measured memory_bytes: 7180
#include <iostream>

using namespace std;

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

	for (int i = 0;i < 100;i++) {
		c -= b;
		if (c <= 0) {
			cout << "Yes";
			break;
		}
		else {
			a -= d;
			if (a <= 0) {
				cout << "No";
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3596
n = int(input())
d = []
for i in range(n):
    s,p = map(str,input().split())
    d.append((s,int(p),i+1))

d = sorted(d,key = lambda x:x[1],reverse=True)
d = sorted(d,key = lambda x:x[0])
for D in d:
    print(D[2])

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

#define int long long
const int MOD = 1000000007;

signed main(){

    int n; cin >> n;
    int sum = 0;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
        sum += l[i];
    }

    sort(l.begin(), l.end());
    if(l[n - 1] < sum - l[n - 1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main()
{
    ll n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pll> a;
    ll cnt=0;
    rep(i,n){
        if(i==0){
            cnt++;
            continue;
        }
        if(s[i]==s[i-1]){
            cnt++;
        }
        else{
            a.push_back(make_pair((ll)(s[i-1]-'0'),cnt));
            cnt=1;
        }
    }
    a.push_back(make_pair((ll)(s[n-1]-'0'),cnt));
    ll m=a.size();
    vector<ll> sum(m+1);
    rep(i,m){
        sum[i+1]=sum[i]+a[i].se;
    }
    ll ans=0;
    rep(i,m){
        if(a[i].fi==1){
            ans=max(ans,sum[min(m,i+2*k+1)]-sum[i]);
        }
        else{
            ans=max(ans,sum[min(m,i+2*k)]-sum[i]);
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 2800
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		String str = a.substring(0,1) + b.substring(0,1) + c.substring(0,1);
    	System.out.println(str.toUpperCase());
}
}

Measured memory_bytes: 21844
#include<stdio.h>
typedef long long LL;
int main(){
	
	LL a[90];
	a[0]=2;a[1]=1;
	for(int i=2;i<=87;i++){
		a[i]=a[i-1]+a[i-2];
	}
	int n;
	scanf("%d",&n);
	printf("%lld\n",a[n]);
}

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

typedef long long int ll;

int main()
{
	ll a,b,c,k,count=0;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
	if(k>a)
	{
		count=a;
		k-=a;
		if(k>b)
		{
			k-=b;
			if(k>0)
				count-=k;
		}
	}
	else
		count=k;
	printf("%lld\n",count);
}


Measured memory_bytes: 3828
//2018-1-28
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;
 
#define LL long long
#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)
 
#define N (100000 + 5)
const int P = 1e9 + 7;
 
inline int Mod(int a){return a >= P? a - P: a;}
 
struct node{
	int v, d;	
};
 
int n, m, s, t, fs[N], ft[N];
LL ds[N], dt[N];
vector<node> G[N];
 
bool inq[N];
 
void Spfa(int st, LL *dis){
	For(i, 1, n) dis[i] = 1ll << 60, inq[i] = false;
	queue<int> q;
	
	dis[st] = 0;
	q.push(st); inq[st] = true;
 
	while(!q.empty()){
		int now = q.front(); q.pop();
		inq[now] = false;
 
		For(i, 0, G[now].size() - 1){
			int v = G[now][i].v, md = G[now][i].d;
			
			if(dis[v] > dis[now] + md){
				dis[v] = dis[now] + md;
				if(!inq[v]){
					q.push(v); inq[v] = true;
				}
			}
		}
	}
}
 
vector<node> g[N];
int in[N];
 
void Work(int st, LL *dis, int *f){
	For(i, 1, n) g[i].clear(), in[i] = 0;
	For(u, 1, n) For(i, 0, G[u].size() - 1){
		int v = G[u][i].v, d = G[u][i].d;
		if(dis[u] + d == dis[v]){
			g[u].pb(G[u][i]); ++in[v];
		}
	}
 
	queue<int> q;
 
	f[st] = 1;
	For(i, 1, n) if(!in[i]) q.push(i);
 
	while(!q.empty()){
		int now = q.front(); q.pop();
 
		For(i, 0, g[now].size() - 1){
			int v = g[now][i].v;
			f[v] = Mod(f[v] + f[now]); --in[v];
			if(!in[v]) q.push(v);
		}
	}
}
 
int Solve(){
	int ret = 0;
	LL D = ds[t];
 
	For(i, 1, n) if(2 * ds[i] <= D){
		if(2 * ds[i] == D && 2 * dt[i] == D){
			ret = Mod(ret + 1ll * fs[i] * ft[i] % P * fs[i] % P * ft[i] % P);
			continue;
		}
 
		For(j, 0, G[i].size() - 1){
			int v = G[i][j].v, d = G[i][j].d;
			if(2 * dt[v] >= D) continue;
			if(ds[i] + d + dt[v] != D) continue;
			
			ret = Mod(ret + 1ll * fs[i] * ft[v] % P * fs[i] % P * ft[v] % P);
		}
	}
 
	return ret;
}
 
int main(){
	int u, v, w;
	
	scanf("%d%d%d%d", &n, &m, &s, &t);
	For(i, 1, m){
		scanf("%d%d%d", &u, &v, &w);
		G[u].pb((node){v, w}); G[v].pb((node){u, w});
	}
 
	Spfa(s, ds); Work(s, ds, fs);
	Spfa(t, dt); Work(t, dt, ft);
 
	int ans = 1ll * fs[t] * fs[t] % P - Solve();
	
	if(ans < 0) ans += P;
	printf("%d\n", ans);
 
	return 0;
}

Measured memory_bytes: 17968
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	static int H, W;
	static char[][] map;
	static int[][] num;
	static Queue<Point> que = new ArrayDeque<Point>();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		map = new char[H][W];
		num = new int[H][W];
		int periodCnt = 0;

		for (int i = 0; i < H; i++) {
			String temp = sc.next();
			for (int j = 0; j < W; j++) {
				map[i][j] = temp.charAt(j);
				if (map[i][j] == '.') {
					periodCnt++;
				}
			}

		}
		que.add(new Point(0, 0));
		num[0][0] = 0;
		map[0][0] = 'x';

		while (!que.isEmpty()) {
			Point a = que.poll();
			int n = num[a.x][a.y] + 1;

			solve(a.x + 1, a.y, n);
			solve(a.x - 1, a.y, n);
			solve(a.x, a.y + 1, n);
			solve(a.x, a.y - 1, n);
		}

		if (map[H - 1][W - 1] != 'x') {
			System.out.println(-1);
		} else {
			System.out.println(periodCnt - num[H - 1][W - 1] - 1);
		}
		sc.close();
	}

	public static void solve(int x, int y, int n) {
		if (x < 0 || H <= x || y < 0 || W <= y || map[x][y] == '#' || map[x][y] == 'x') {
			return;
		}
		map[x][y] = 'x';
		num[x][y] = n;
		que.add(new Point(x, y));
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int ans = (B + A - 3) / (A - 1);
    cout << ans << endl;
    return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<int> VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

//Common
typedef long long Weight;
const Weight WEIGHT_INF = std::numeric_limits<Weight>::max()/4;

struct Edge {
    int src, dst;
    Weight weight;
};
bool operator<(const Edge& a, const Edge& b) {
    return (a.weight < b.weight);
};
bool operator>(const Edge& a, const Edge& b) {
    return (a.weight > b.weight);
};
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;

//Dijkstra
Graph g;
std::vector<Weight> costs;
std::vector<int> trace;
void dijkstra(int start){
    int n = g.size();
    costs.resize(n, WEIGHT_INF);
    costs[start] = 0;
    trace.resize(n, -2);

    std::priority_queue<Edge, std::vector<Edge>, std::greater<Edge>> q;
    q.push((Edge){-1, start, 0});
    while(!q.empty()) {
        Edge e = q.top();
        q.pop();

        if(trace[e.dst] != -2) continue;
        trace[e.dst] = e.src;
        EACH(it, g[e.dst]) {
            if(costs[it->dst] > e.weight + it->weight){
                costs[it->dst] = e.weight + it->weight;
                q.push((Edge){it->src, it->dst, e.weight + it->weight});
            }
        }
    }
}

int main(void){
    int v, e, r;
    std::cin >> v >> e >> r;
    g.resize(v);
    REP(i, e){
        int s, t, d;
        std::cin >> s >> t >> d;
        Edge edge{s, t, d};
        g[s].pb(edge);
    }

    dijkstra(r);
    REP(i, v){
        if(costs[i] != WEIGHT_INF){
            std::cout << costs[i] << std::endl;
        } else {
            std::cout << "INF" << std::endl;
        }
    }
}

Measured memory_bytes: 19756
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int main(){
	int n;
	cin >> n;
	vector<PP> va;
	vector<int> x1(n), y1(n), x2(n), y2(n);
	for(int i = 0; i < n; i++){
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
		if(y1[i] == y2[i]){
			if(x1[i] > x2[i]) swap(x1[i], x2[i]);
			va.push_back(PP(x1[i], P(-1, y1[i])));
			va.push_back(PP(x2[i], P(1, y1[i])));
		}else if(x1[i] == x2[i]){
			if(y1[i] > y2[i]) swap(y1[i], y2[i]);
			va.push_back(PP(x1[i], P(0, i)));
		}
	}
	sort(va.begin(), va.end());
	int res = 0;
	set<int> seta;
	set<int>::iterator itr, last;
	for(int i = 0; i < va.size(); i++){
		if(va[i].second.first == -1){
			seta.insert(va[i].second.second);
		}else if(va[i].second.first == 1){
			seta.erase(va[i].second.second);
		}else if(va[i].second.first == 0){
			itr = seta.lower_bound(y1[va[i].second.second]);
			last = seta.upper_bound(y2[va[i].second.second]);
			while(itr != last){
				itr++;
				res++;
			}
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 9612
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  string a,b,c;
  cin >> a >> b >> c;
  cout << "A" << b[0] <<  "C" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	string s;

	cin>>s;

	cout<<yn(s[0]==s[2])<<endl;

}



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

int main()
{
	int R, G, x;
    while(scanf("%d %d", &R, &G) != EOF)
	{
		x = 2 * G - R;
		printf("%d\n", x);
	}
	return 0;
}





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

int main() {
    double n,m;
    cin >> n >> m;
    double sum = 0;
    double can = pow(1/2.l,m);
    double cannot = 1 - can;
    for (int i=0;i<1e5;i++){
        sum+=(100*(n-m)+m*1900)*(i+1)*can*pow(cannot,i);
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
n = input()
a_ls = list(map(int, input().split()))
a_ls.sort()
min_value = a_ls.pop(0)
max_value = a_ls.pop(len(a_ls)-1)
output_ls = []
for i in range(len(a_ls)):
    hoge = []
    if a_ls[i] > 0:
        hoge.append(min_value)
        hoge.append(a_ls[i])
        output_ls.append(hoge)
        min_value = min_value - a_ls[i]
    else:
        hoge.append(max_value)
        hoge.append(a_ls[i])
        output_ls.append(hoge)
        max_value = max_value - a_ls[i]
hoge = []
hoge.append(max_value)
hoge.append(min_value)
output_ls.append(hoge)
print(max_value - min_value)
for j in range(len(output_ls)):
    print(str(output_ls[j][0]) + ' ' + str(output_ls[j][1]))

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

int main(){
	int a;
	int b;
	char op;
	int c;
	while(true) {
		cin >> a >> op >> b;
		if ( op == '+' ) {
			c=a+b;
		}else if ( op == '-' ) {
			c=a-b;
		}else if ( op == '*' ) {
			c=a*b;
		}else if ( op == '/' ) {
			c=a/b;
		}else {
			break;
		}
		cout << c << endl;
	}
    return 0;
}

Measured memory_bytes: 1160
from collections import Counter

def main():
    # n:人数, a:身長リスト
    n = int(input())
    a = list(map(int, input().split()))
    # Li=i+Ai, Ri=i-Aiを満たすL,Rを作成
    L = [0]*n
    R = [0]*n
    for i,ai in enumerate(a):
        L[i] = i+ai
        R[i] = i-ai
    # Li=X=Rj,i<jを満たす組が存在する時count+=1
    count = 0
    c = Counter(R)
    for Li in L:
        count += c.get(Li,0)

    print(count)

main()


Measured memory_bytes: 50524
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 300;
const int mod = 1e9 + 7;

int n, k;
string str;
lint fact[MAXN], invf[MAXN];

lint ipow(int x, int p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

lint bino(int x, int y){
	if(x < y) return 0;
	return fact[x] * (invf[y] * invf[x-y] % mod) % mod;
}

int f(int x){ return 2 * max(x - 1, 1); }

int solve(vector<int> v){
	int sum = 0;
	int ptr = 0;
	reverse(v.begin(), v.end());
	queue<int> que;
	for(auto &i : str){
		if(i == 'r'){
			if(ptr < v.size()){
				if(v[ptr] > 1){
					que.push(v[ptr] - 2);
				}
				ptr++;
			}
			else{
				if(sum) sum--;
			}
		}
		if(i == 'b'){
			if(!que.empty()){
				sum += que.front();
				que.pop();
			}
			else if(sum) sum--;
		}
	}
	if(ptr != v.size() || sum || que.size()) return 0;
	if(v.empty()) return 1;
	lint ret = fact[v.size()];
	for(int i=0; i<v.size(); ){
		int e = i;
		while(e < v.size() && v[i] == v[e]) e++;
		ret *= invf[e - i];
		ret %= mod;
		i = e;
	}
	{
		int canZero = 2;
		int canAny = v.size() + 1;
		for(int i=0; i<v.size(); i++){
			canAny += 2 * v[i] - 1;
			canZero += (v[i] > 1) * 2;
		}
		ret *= bino(n + canZero - 1, canAny - 1);
	}
	return ret % mod;
}

vector<vector<int> > canon;

void dfs(int x, int l, vector<int> v){
	canon.push_back(v);
	for(int i=l; x + f(i) <= n; i++){
		v.push_back(i);
		dfs(x + f(i), i, v);
		v.pop_back();
	}
}

int main(){
	fact[0] = invf[0] = 1;
	for(int i=1; i<MAXN; i++){
		fact[i] = fact[i-1] * i % mod;
		invf[i] = ipow(fact[i], mod - 2);
	}
	cin >> n >> k >> str;
	vector<int> v;
	dfs(-1, 1, v);
	lint ret = 0;
	for(auto &i : canon){
		ret += solve(i);
	}
	cout << ret % mod << endl;
}


Measured memory_bytes: 38952
#include<iostream> 

using namespace std; 

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

	if(a + b + 1 > c) 
		cout << c + b << "\n"; 
	else 
		cout << a + 2 * b + 1 << "\n"; 

	return 0; 
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    string s;
    string t;
    cin>>s>>t;
    ll n=s.length();
    ll ans=0;
    rep(i,n)
    {
      if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


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

typedef long long ll;

int main()
{
	ll H, N;
	cin >> H >> N;

	ll damage = 0;
	for(int i = 0 ; i < N ; i++){
		int a;
		cin >> a;
		damage += a;
	}
	if(damage >= H)
		cout << "Yes";
	else cout << "No";
	cout << '\n';
	return 0;

}

Measured memory_bytes: 3628