akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
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; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 1010101;
int main() {
	/*
	int n;
	cin >> n;
	VE<P<ll>> info(n);
	ll ans = 0;
	ll Maxi = 0;
	ll Mini = UPPER;
	rep(i, n) {
		cin >> info[i].first >> info[i].second;
		ans += info[i].second;
		chmax(Maxi, info[i].first);
		chmin(Mini, info[i].first);
	}
	// cout << Maxi << " " << Mini << endl;
	sort(all(info));
	reverse(all(info));
	rep(i, n - 1) {
		if (info[i].first == info[i + 1].first) {
			swap(info[i].second, info[i + 1].second);
		}
	}
	int l = 0;
	ll sa = 0;
	rep(i, n) {
		ll diff = Maxi - info[i].first;
		ll 
		if (chmax(sa, diff)) l = i;
	}
	Maxi = info[l].first;
	for (int r = n - 1; r >= l; r--) {
		ll diff = info[r].first - Mini;

	}
	cout << ans - (Maxi - Mini) << endl;
	*/
	int n; // 全部偶数の盤面渡されたら負け？
	cin >> n;
	bool f = false;
	rep(i, n) {
		int x;
		cin >> x;
		if (x % 2 == 1) f = true;
	}
	puts(f ? "first" : "second");
	return 0;
}

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

using namespace std;

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

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

	long long Xor = 0;
	for(int i = 2; i < n; ++i) {
		Xor ^= a[i];
	}

	long long S = a[0] + a[1];
	long long d = S - Xor;

	if(d % 2 != 0) {
		cout << -1 << '\n';
		exit(0);
	}

	d >>= 1;

	long long x = 0;
	long long y = 0;

	bool small = false;
	long long must = 0;

	for(int i = 62; i >= 0; --i) {
		if(Xor >> i & 1) {
			must += 1LL << i;
		}
	}

	long long sum = 0;

	for(int i = 60; i >= 0; --i) {
		if(!(Xor >> i & 1)) {
			if(sum + 2LL * (1LL << i) + must <= S) {
				x += 1LL << i;
				y += 1LL << i;
				sum += 2LL * (1LL << i);
			}
		}
	}

	for(int i = 62; i >= 0; --i) {
		if(Xor >> i & 1) {
			if(x + (1LL << i) <= a[0]) {
				x += 1LL << i;
			} else {
				y += 1LL << i;
			}
		}
	}

	if(x <= 0 || y <= 0 || x + y != S || (x ^ y) != Xor || x > a[0]) {
		cout << -1 << '\n';
	} else {
		cout << a[0] - x << '\n';
	}

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  for(int i=0; i<=n; ++i){
    int x = i *108 /100;
    if(x == n){
      cout << i << endl;
      return 0;
    }
    else if(x > n) break;
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 
  ll x,y;
  cin >> x >> y;
  if(y%2) cout << "No" << endl;
  else if(y-2*x<0) cout << "No" << endl;
  else if(4*x-y<0) cout << "No" << endl;
  else cout << "Yes" << endl;
  
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3644
class Node:
    def __init__(self,z):
        self.key=z
        self.left=None
        self.right=None

def insert(z):
    global root
    if root==None:
        root=Node(z)
    else:
        x=root
        while True:
            if z<x.key:
                if x.left:
                    x=x.left
                else:
                    x.left=Node(z)
                    break
            else:
                if x.right:
                    x=x.right
                else:
                    x.right=Node(z)
                    break
def inorder(z):
    if z==None:
        return []
    else:
        return inorder(z.left)+[z.key]+inorder(z.right)
def preorder(z):
    if z==None:
        return []
    else:
        return [z.key]+preorder(z.left)+preorder(z.right)
root=None
n=int(input())
for _ in range(n):
    p=input()
    if p[0]=="i":
        insert(int(p[7:]))
    else:
        print("",*inorder(root))
        print("",*preorder(root))


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int max = 0;
    for(int i = 1; i<=2; i++){
      if(a>b){
        max+=a;
        a-=1;
      } else {
        max+=b;
        b-=1;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 21204
#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 rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
const int N=2e5+5;
int n,a[N],f[N];
ll k;
list<int>v;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    ll t=k;
    int cur=1,cnt=1;
    while(233&&t){
        if(f[cur]){
            while(v.front()!=cur)v.pop_front(),cnt++;
            break;
        }
        v.pb(cur);
        f[cur]=1;
        int nx=a[cur];
        t--;
        cur=nx;
    }
    if(t==0)pf(cur);
    else{
        k-=(cnt-1);
        int cir=v.size();
        k%=cir;
        while(k--)v.pop_front();
        cout<<v.front()<<endl;
    }
    return 0;
}
/*
6 6
6 5 2 5 3 2
*/


Measured memory_bytes: 10232
// ※※※ 解答不能 ※※※
// ksun48氏
// https://atcoder.jp/contests/agc041/submissions/9192801
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int T;
    scanf("%d", &T);
    vector<int> x(m), y(m);
    rep(i, m){
        scanf("%d %d", &x[i], &y[i]);
        x[i]--; y[i]--;
    }
    if(T == 1){
        using B = bitset<50000>;
        vector<B> cur(n);
        rep(i, n) cur[i][i].flip();
        rep(i, m){
            cur[x[i]] |= cur[y[i]];
            cur[y[i]] |= cur[x[i]];
        }
        rep(i, n){
            if((int)cur[i].count() == n){
                vector<int> where(n, 0);
                where[i] = 1;
                string st(m, '.');
                repr(j, m - 1, 0){
                    st[j] = "^v"[where[x[j]] < where[y[j]]];
                    where[x[j]] |= where[y[j]];
                    where[y[j]] |= where[x[j]];
                }
                printf("%s\n", st.c_str());
                return 0;
            }
        }
        puts("-1");
    }else if(T == 2){
        if(n == 2){
            puts("-1");
            return 0;
        }
        string st(m, '^');
        vector<int> reach(3, 1);
        int last = -1;
        rep(i, m){
            if(y[i] >= 3) continue;
            int other = 3 - x[i] - y[i];
            if(!reach[other]){
                assert(last >= 0);
                st[last] ^= ('^' ^ 'v');
                reach[other] = true;
            }
            st[i] = '^';
            reach[x[i]] = true;
            reach[y[i]] = false;
            last = i;
        }
        printf("%s\n", st.c_str());
    }
    return 0;
}

Measured memory_bytes: 306944
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i<b; i++)
#define dep(i,a,b) for(int i = a-1; i>=b; i--)
#define makeUnique(vec) sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin())
#define LOG_vec(vec, sep) for (int fl = 0; fl < vec.size(); fl++) { cout << vec[fl]<< sep; } cout << "\n";
#define LOG_ints(vec, sep) for (int fl = 0; fl < MAXSIZE; fl++) { cout << vec[fl]<< sep; } cout << "\n"
#define all(x) (x).begin(), (x).end()
#define ll long long
#define LSB(i) ((i) & -(i))
#define vvi vector<vector<int>>
#define vi vector<int>
#define MAXSIZE 100000000
using namespace std;

int main(){
	double x;
	cin >> x;
	x /= 3;
	x = pow(x, 3);
	printf("%9.10f", x);
}

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

int N, D[100100][3];
int main()
{
	scanf("%d", &N);

	for (int i=1;i<=N;i++){
		int a,b,c; scanf ("%d %d %d",&a,&b,&c);
		int p = a + max(D[i-1][1], D[i-1][2]);
		int q = b + max(D[i-1][0], D[i-1][2]);
		int r = c + max(D[i-1][1], D[i-1][0]);
		D[i][0] = p;
		D[i][1] = q;
		D[i][2] = r;
	}
	/*for(int i=1;i<=N;i++)
	{
		for(int j=0;j<3;j++)
		{
			cout<<D[i][j]<<' ';
		}
		cout<<endl;
	}*/
	printf("%d\n",max(D[N][0],max(D[N][1],D[N][2])));
	return 0;
}


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

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

using vl=vector<ll>;
int main(){
    ll N,K;
    cin>>N>>K;
    vl a(N);
    ll sum=0;
    REP(i,N){
        cin>>a[i];
        sum+=max(0LL,a[i]);
    }
    vl plus(N+1,0),minus(N+1,0);
    REP(i,N){
        plus[i+1]=plus[i]+max(0LL,a[i]);
        minus[i+1]=minus[i]+max(0LL,-a[i]);
    }
    ll tmp=INF;
    REP2(i,K,N+1){
        tmp=min(tmp,minus[i]-minus[i-K]);
        tmp=min(tmp,plus[i]-plus[i-K]);
    }
    sum-=tmp;
    cout<<sum<<endl;
    
}

Measured memory_bytes: 5628
import           Control.Applicative
import           Control.Monad
import           Data.List

type Dice=[Int]

rotate:: Dice -> Char -> Dice
rotate [u,f,r,l,b,d] 'E' = [l,f,u,d,b,r]
rotate [u,f,r,l,b,d] 'N' = [f,d,r,l,u,b]
rotate [u,f,r,l,b,d] 'S' = [b,u,r,l,d,f]
rotate [u,f,r,l,b,d] 'W' = [r,f,d,u,b,l]
rotate xs _              = xs

search :: [Dice]->[Dice]->Dice->Bool
search dices searched target
  | null dices =  False
  | not $ null found = True
  | otherwise = search next (searched ++ dices) target
  where
    found = [dice | dice<-dices, dice == target]
    next = filter (`notElem` searched) [rotate d opt | d <-dices, opt<-"ENSW" ]

main :: IO ()
main = do
  dice1 <- map read . words <$> getLine
  dice2 <- map read . words <$> getLine
  putStrLn $ if search [dice1] [] dice2 then "Yes" else "No"


Measured memory_bytes: 3740
//package abc134;
import java.io.*;
import java.util.*;

public class Main {
	// ------------------------
	
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		// ------------------------
		int n=sc.nextInt();
		int[]a=new int[n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();
		int max=a[0],sMax=-1;
		for(int i=1;i<n;i++){
			if(a[i]>max){
				sMax=max;
				max=a[i];
			}else if(a[i]>sMax)
				sMax=a[i];
		}
		for(int i=0;i<n;i++)
			out.println(a[i]==max?sMax:max);
		// ------------------------
		out.close();
	}
	//------------------------
	
	public static PrintWriter out;
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 46696
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	for(int i=0;i<=1000000;i++)
		if(a-i*100<=i*5&&a-i*100>=0)
		{
			cout<<1;
			return 0;
		}
	cout<<0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	int n,i,r=0;
	scanf("%i",&n);
	char s[n];
	scanf("%s",&s);
	for(i=0;i<n;i++)
	{
		if(s[i]==s[i+1])
		{
			r++;
		}
	}
	printf("%i",n-r);
	return 0;
}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    char a,b;
    cin >> a >> b;
    if (a < b) {
        cout << "<" << endl;
    }else if (a > b){
        cout << ">" << endl;
    }else{
        cout << "=" << endl;
    }

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (i + 4 < s.size() && s.at(i) == 'd'
        && s.at(i + 1) == 'r' && s.at(i + 2) == 'e'
        && s.at(i + 3) == 'a' && s.at(i + 4) == 'm') {
      if (i + 6 < s.size() && s.at(i + 5) == 'e'
          && s.at(i + 6) == 'r') {
        if (i + 7 < s.size() && s.at(i + 7) == 'a') {
          i += 4;
          continue;
        }
        else {
          i += 6;
          continue;
        }
      }
      else {
        i += 4;
        continue;
      }
    }
    else if (i + 4 < s.size() && s.at(i) == 'e'
             && s.at(i + 1) == 'r' && s.at(i + 2) == 'a'
             && s.at(i + 3) == 's' && s.at(i + 4) == 'e') {
      if (i + 5 < s.size() && s.at(i + 5) == 'r') {
        i += 5;
        continue;
      }
      else {
        i += 4;
        continue;
      }
    }
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc= new Scanner(System.in);
		while(true) {
			int H =sc.nextInt();
			int W = sc.nextInt();
			if(H==0 && W==0) {
				break;
			}
			for(int i=0;i<H;i++) {
				for(int j=0;j<W;j++) {
					if((j+i)%2==0) {
						System.out.printf("#");
					}else {System.out.printf(".");
					}
				}System.out.printf("\n");
			}System.out.printf("\n");
		}sc.close();

	}

}


Measured memory_bytes: 59708
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N; string S;
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
	if (N % 2 == 1) return no;

	string A = S.substr(0, N / 2);
	string B = S.substr(N / 2);

	if (A == B) return yes;
	return no;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> S;
	cout << solve() << endl;
}







Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    int n;
    cin>>n;
    V<string> s(n);
    cinf(n,s);
    map<string,int> mp;
    set<string> st;
    rep(i,n) mp[s[i]]++;
    int cnt=0;
    rep(i,n) chmax(cnt,mp[s[i]]);
    rep(i,n){
        if(mp[s[i]]==cnt) st.insert(s[i]);
    }
    while(!st.empty()){
        string t=*begin(st);
        st.erase(t);
        cout<<t<<'\n';
    }
}


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

#define int ll
#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define pb push_back
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
constexpr int inf = 1ll<<61;

struct node {
  ll v, d;
  node(ll _a, ll _b):v(_a),d(_b){}
  bool operator<(const node &n) const { return d > n.d; }
};
struct edge {
  ll to, d;
  edge(ll _to, ll _d):to(_to),d(_d){}
};
class dijkstra{
public:
  ll ans;

  dijkstra(ll s,ll t,vector<vector<edge>> &g,vector<vector<edge>> &f){ // sからtへの最短経路
    vector<vector<vector<edge>>> G(2);
    G[0] = move(g);
    G[1] = move(f);
    vvi dist(2,vi(G[0].size(),inf));
    vector<vector<bool>> visit(2,vector<bool>(G[0].size(),false));
  
    vector<priority_queue<node>> que(2);
    que[0].push(node(s,0));
    que[1].push(node(t,0));
    dist[0][s] = 0;
    dist[1][t] = 0;
    ll mu = inf;

    while(!que[0].empty() and !que[1].empty()){
      if(que[0].top().d + que[1].top().d >= mu) break;
      ll k = (que[0].top().d <= que[1].top().d)?0:1;      
      ll v = que[k].top().v, d = que[k].top().d;
      que[k].pop();

      if(visit[k^1][v]) goto L;
      visit[k][v] = true;

      rep(i, G[k][v].size()){
	auto n = G[k][v][i];
	ll tmp = d + n.d;
	if(dist[k][n.to] > tmp){
	  mu = min(mu, dist[k][v] + n.d + dist[k^1][n.to]);
	  dist[k][n.to] = tmp;
	  que[k].push(node(n.to, tmp));
	}
      }
    }
  L:
    g = move(G[0]);
    f = move(G[1]);

    ans = inf;
    rep(i,g.size()) ans = min(ans, dist[0][i]+dist[1][i]);
  }
};

main(){
  int k; cin >> k;
  vector<vector<edge>> g(k),f(k);
  rep(i,k){
    g[i].pb(edge((i+1)%k,1));
    g[i].pb(edge((i*10)%k,0));
    
    f[(i+1)%k].pb(edge(i,1));
    f[(i*10)%k].pb(edge(i,0));
  }
  dijkstra d(1,0,g,f);
  cout << d.ans+1 << endl;
}

Measured memory_bytes: 18416
#include <stdio.h>
#include <string.h>

char str[65536];
char tmp[65536];

int main(void)
{
	int n;
	while(scanf("%d", &n), n){
		int i;
		scanf("%s", str);
		
		for(i=0; i<n; ++i){
			int m = strlen(str);
			int read = 0;
			int write = 0;
			while(read<m){
				char num = str[read];
				int cnt;
				
				for(cnt=0; str[read+cnt]==num; ++cnt);
				sprintf(tmp+write, "%d\0", cnt);
				
				while(tmp[write] != '\0')
					++write;
				
				tmp[write] = num;
				++write;
				read += cnt;
			}
			tmp[write] = '\0';
			strcpy(str, tmp);
		}
		puts(str);
	}
	
	return 0;
}

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

int main() {
  int a,b,c; cin >> a >> b >> c;
  cout << (c/a)*b << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if(A==B&&A==C&&B==C) printf("No\n");
	else if(A!=B&&A!=C&&B!=C) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1652
#include <stdio.h>
 
int v(int n, int N);

int main(){
	int i, N, content;
 
	scanf("%d", &N);

	if(N == 1) {
		printf("1");
	}

	else {

		i = 2;
		content = v(i, N);
		printf("%d", content / 2);

	}
}

int v(int n, int N) {
	int m;
	if(N < n) {
		return n;
	}
	m = v(2*n, N);
	return m;
}


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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++) {
        cin>>arr[i];
    }   
    int dp[n];
    dp[0]=0;
    for(int i=1;i<n;i++) {
        int c=1e15;
        for(int j=1;j<=min(k, i);j++) {
            c=min(c, dp[i-j]+abs(arr[i]-arr[i-j]));
        }
        dp[i]=c;
    }

    cout<<dp[n-1];

    return 0;
}

Measured memory_bytes: 1792
import sys
N, K, Q = map(int, input().split())
A = (int(x) for x in sys.stdin.read().split())
score = [K - Q] * (N + 1)
for a in A:
  score[a] += 1
print("\n".join('Yes' if s > 0 else 'No 'for s in score[1:]))


Measured memory_bytes: 12624
A,B,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(m):
    x,y,c=map(int,input().split())
    x-=1
    y-=1
    ans=min(ans,a[x]+b[y]-c)
print(ans)

Measured memory_bytes: 18740
A,B,C,D = map(int,input().split())

a = []
for i in range(A,B+1):
    a.append(i)
b = []
for i in range(C,D+1):
    b.append(i)
c = set(a)&set(b)
if c ==set():
    print(0)
else:
	print(len(c)-1)


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

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.length() / 2; i++){
        if(s[i] != s[s.length() - i - 1]){
            cout << "No";
            return 0;
        }
    }
    s = s.substr(0, s.length() / 2);
    for(int i = 0; i < s.length() / 2; i++){
        if(s[i] != s[s.length() - i - 1]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

int main(void){
	int n,i,cnt[334334],tmp,ans=INF;
	string s;
	fill(cnt,cnt+334334,0);
	cin >> n;
	cin >> s;
	for(i=0; i<n; ++i){
		if(s[i]=='E'){
			++cnt[i];
		}
	}
	for(i=1; i<n; ++i){
		cnt[i] += cnt[i-1];
	}
	for(i=0; i<n; ++i){
		tmp = cnt[n-1] - cnt[i];
		tmp += (i+1) - cnt[i] - ((s[i]=='W')?1:0);
		ans = min(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int a, b;
    cin >> a >> b;
    rep1(i, 1010) {
        if (int(i*0.08) == a and int(i*0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
int main(){long double a,b,x;std::cin>>a>>b>>x;std::cout<<std::fixed<<(b>2*x/(a*a)?atan(b/(2*x/(a*b)))*180/acos(-1):atan((b-x/(a*a))/(a/2))*180/acos(-1));}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TEST ll t;cin>>t;while(t--)
ll sizes[100001];
ll arr[100001];

bool ok=true;
ll A[100001];
pll B[100001];

ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
bool prime[10000000];
vector<ll> v;
void era(){
    memset(prime,true,sizeof prime);
    for(int p=2;p*p<=10000000;p++){
        if(prime[p]){
            if(p%5==1) v.push_back(p);
            for(int q=p*p;q<=10000000;q+=p){
                prime[q]=false;
            }
        }
    }
    return;
}
ll power[11];

int main(){
    IO
    ll N;
    cin>>N;
    if(N==3 || N==5 || N==7) cout<<"YES";
    else cout<<"NO";
    return(0);
}


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

#define mk make_pair

const int MAXN = 112345;
const double PI = atan(1) * 4;
const int MOD = 1e9 + 7;

//first = a - second = b
pair<int, int> sum_s[MAXN], sum_t[MAXN];

int main() {

	string s, t;
	cin >> s >> t;
	
	for(int i = 1; i <= s.size(); i++) {
		sum_s[i].first = (s[i-1] == 'A' ? 1 : 0);
		sum_s[i].second = (s[i-1] == 'B' ? 1 : 0);
		
		if(i > 0) {
			sum_s[i].first += sum_s[i-1].first;
			sum_s[i].second += sum_s[i-1].second;
		}
		
	}
	
	for(int i = 1; i <= t.size(); i++) {
		sum_t[i].first = (t[i-1] == 'A' ? 1 : 0);
		sum_t[i].second = (t[i-1] == 'B' ? 1 : 0);
		
		if(i > 0) {
			sum_t[i].first += sum_t[i-1].first;
			sum_t[i].second += sum_t[i-1].second;
		}
	}
	
	int query;
	cin >> query;
	
	while(query--) {
		
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		
		int sum_a = sum_s[b].first - sum_s[a-1].first + 2*(sum_s[b].second - sum_s[a-1].second);
		int sum_b = sum_t[d].first - sum_t[c-1].first + 2*(sum_t[d].second - sum_t[c-1].second);;
		
		if(sum_a % 3 == sum_b % 3) cout << "YES\n";
		else cout << "NO\n";
		
	}

    return 0;
}


Measured memory_bytes: 5248
package main

// https://atcoder.jp/contests/agc011/tasks/agc011_b

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N int
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt(sc)
	}
	sort.Ints(A)
	sum := make([]int, N+1) // 累積和
	for i := 0; i < N; i++ {
		sum[i+1] = sum[i] + A[i]
	}
	// fmt.Println("N", N, "A", A, "sum", sum)
	t := 0
	for i := N - 1; i > 0; i-- {
		if A[i] > 2*sum[i] {
			t = i
			break
		}
	}
	fmt.Println(N - t)
}


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

int R, G, B, N, ans;

int main() {    
    cin >> R >> G >> B >> N;
    rep(r, N+1) {
        rep(g, N+1) {
            int rem = N - R * r - G * g;
            if (rem < 0) break;
            if (rem % B != 0) continue;
            
            ans++;
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back



ll gcd(ll a , ll b){
    ll bigger=max(a,b);
    ll smaller=min(a,b);
    if (bigger%smaller==0){
        return smaller;
    }
    else {
        return gcd(smaller, bigger%smaller);
    }

}

    






int main(){

    string s;
  	cin>>s;

    if ("a"<=s and s<="z"){
        cout<<"a"<<endl;
    }
    else {
        cout<<"A"<<endl;
    }








}

Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		long k = sc.nextInt();

		int a[] = new int[n];
		int b[] = new int[m];

		long sumA[] = new long[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();

			sumA[i] = a[i];
			if(i != 0){
				sumA[i] += sumA[i - 1];
			}

//			System.out.print(sumA[i] +" ");
		}
//		System.out.println();

		long sumB[] = new long[m];
		for(int i = 0; i < m; i++){
			b[i] = sc.nextInt();
			sumB[i] = b[i];
			if(i != 0){
				sumB[i] += sumB[i - 1];
			}
//			System.out.print(sumB[i] +" ");
		}
//		System.out.println();

		int result = 0;
		for(int i = 0; i < n; i++){
			if(sumA[i] > k){
				break;
			}

			long remain = k - sumA[i];

			int index = Arrays.binarySearch(sumB, remain);

//			System.out.println(remain+" "+index);

			if(index < 0){
				index = -index - 2;
			}

			result = Math.max(result, i + 1 + index + 1);
		}

		for(int i = 1; i <= m; i++){
			if(sumB[i - 1] <= k){
				result = Math.max(result, i);
			}
		}
		System.out.println(result);

//		long sum = 0;
//		int indexA = 0;
//		int indexB = 0;
//		int count = 0;
//		while (sum <= k && (indexA < n || indexB < m)){
//			if(indexA == n){
//				sum += b[indexB];
//				indexB++;
//			}
//			else if(indexB == m){
//				sum += a[indexA];
//				indexA++;
//			}
//			else if(a[indexA] <= b[indexB]){
//				sum += a[indexA];
//				indexA++;
//			}
//			else {
//				sum += b[indexB];
//				indexB++;
//			}
//
////			System.out.println("A "+indexA+" B "+indexB+" sum "+sum);
//			if(sum <= k){
//				count++;
//			}
//		}
//
//		System.out.println(count);
	}
}

Measured memory_bytes: 56704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll phi(ll n) 
{ 
    ll result = n; // Initialize result as n 
  
    // Consider all prime factors of n and subtract their 
    // multiples from result 
    for (ll p = 2; p * p <= n; ++p) { 
          
        // Check if p is a prime factor. 
        if (n % p == 0) { 
              
            // If yes, then update n and result 
            while (n % p == 0) 
                n /= p; 
            result -= result / p; 
        } 
    } 
  
    // If n has a prime factor greater than sqrt(n) 
    // (There can be at-most one such prime factor) 
    if (n > 1) 
        result -= result / n; 
    return result; 
}




ll powM(ll a,ll b ,ll m)
{
    ll ans=1;
    a%=m;
    while(b>0)
    {
        if(b&1)ans=ans*a%m;
        a=a*a%m;
        b>>=1;
    }
    return ans;
}

int main()
{
  ll n,k,i,j,count=0,m=1000000007;
cin>>n>>k;
ll cnt[k+1]={0};
for(i=k;i>0;i--)
{
    ll nm=k/i;
    cnt[i]=powM(nm,n,m);
    for(j=i*2;j<=k;j+=i)cnt[i]=(cnt[i]-cnt[j]+m)%m;
    
    count=count+(i*cnt[i])%m;
    count%=m;
}

cout<<count<<endl;

return 0;

}






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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

int H,W;
int M;
vector<int> row[300005];
vector<int> col[300005];
vector<int> maxw;
int numh[300005]; 

signed main(){
    cin>>H>>W>>M;
    for(int i=0;i<M;++i){
        int h,w;
        cin>>h>>w;
        h--,w--;
        row[h].push_back(w);
        col[w].push_back(h);
    }
    for(int i=0;i<H;++i){
        if(row[i].size()==0)continue;
        sort(row[i].begin(),row[i].end());
    }
    int ma=0;
    for(int i=0;i<W;++i){
        if(col[i].size()==0)continue;
        sort(col[i].begin(),col[i].end());
        chmax(ma,(int)col[i].size());
    }
    for(int i=0;i<W;++i){
        if(ma==col[i].size())maxw.push_back(i);
    }
    for(auto i:maxw){
        for(auto u:col[i]){
            numh[u]++;
        }
    }
    int ans=0;
    for(int y=0;y<H;++y){
        if(numh[y]==maxw.size())chmax(ans,ma+(int)row[y].size()-1);
        else chmax(ans,ma+(int)row[y].size());
    }
    cout<<ans<<endl;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h[i];
  }
  vector<int> dp(N);
  dp[1] = abs(h[1]-h[0]);
  for(int i = 2; i < N; i++){
    vector<int> range = {};
    int m = 1000000000;
    for(int j = 0; j < K; j++){
      if(i-1-j < 0) break;
      m = min(m,dp[i-1-j]+abs(h[i-1-j]-h[i]));
    }
    dp[i] = m;
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 4048
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
//        long readhp = long.Parse(ReadLine());
        string[] reader = ReadLine().Split(' ');
//        int monster = int.Parse(reader[0]);
//        int wazasu = int.Parse(reader[1]);
//        string[] readerhp = ReadLine().Split(' ');
//        long total = 0;
//        int leng = readerhp.Length;
        int a= int.Parse(reader[0]);
        int b = int.Parse(reader[1]);
        if(a>b){
            int temp =a;
            a=b;
            b=temp;
        }
        for(int i=0;i<b;i++){
            Write(a);
        }
        WriteLine();


    }
}

Measured memory_bytes: 11092
K,S = (int(x) for x in input().split())
count = 0

for x in range(K+1):
    if x > S:
        break
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= K:
            count += 1
        elif x + y > S:
            break


print(count)

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

int main(){
    long long n;
    long long trips[5];
    scanf("%lld", &n);
    if(n == 0){
        printf("0");
        return 0;
    }
    scanf("%lld", &trips[0]);
    for(int i = 1; i < 5; i++){
        scanf("%lld", &trips[i]);
        trips[i] = min(trips[i], trips[i-1]);
        //printf("%lld", trips[i]);
    }
    //printf("%lld", trips[4]);
    printf("%lld", 5+(n-1)/trips[4]);
}


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

using namespace std;

int main(void){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int sum = 0;
    for(int i = 1; i < n-1; i++){
        if(a[i] != min(a[i-1],min(a[i],a[i+1])) && a[i] != max(a[i],max(a[i-1],a[i+1]))){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
	int a;
	int b;
	int sum;

	while (cin >> a >> b){
		sum = a + b;
		int count = 0;
		while (true)
		{
			count++;
			sum = sum / 10;
			if (sum == 0) break;
		}
		cout << count << endl;
	}

	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    double a,b;
    cin >> a >> b;
    double c = 1/a + 1/b;
     cout << fixed << setprecision(10);
    cout << 1/c << endl;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int nxt[200001],head[200001],to[200001],cnt;
int a[200001],num1=0,num2=0,N=1,x,y;
int ans1[200001],ans2[200001];
int book[200001];
void add(int u,int v)
{
	cnt++;
	nxt[cnt]=head[u];
	head[u]=cnt;
	to[cnt]=v;
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++) 
	{
		cin>>x>>y;
		add(x,y);
		add(y,x);
	} 
	if(m==1)
	{
		cout<<"2"<<endl;
		cout<<x<<" "<<y<<" ";
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		if(head[i]!=0&&nxt[head[i]]!=0)
		{
			int y=i,x;
			num1++;
			ans1[num1]=y;
			book[y]=1;
			while(N==1)
			{
				N=0;
				for(int j=head[y];j!=0;j=nxt[j])
				{
					if(book[to[j]]==0)  { y=to[j];N=1;break;}
				}
				if(N==1)
				{
					num1++;
					ans1[num1]=y;
					book[y]=1;	
				}
			}
			N=1;
			y=0;
			for(int j=head[i];j!=0;j=nxt[j])
			{
				if(book[to[j]]==0){
					y=to[j];
					num2++;
					ans2[num2]=y;
					book[y]=1;
					break;
				}
			}
			while(N==1)
			{
				N=0;
				for(int j=head[y];j!=0;j=nxt[j])
				{
					if(book[to[j]]==0)  {y=to[j];N=1;break;}
				}
				if(N==1)
				{
					num2++;
					ans2[num2]=y;
					book[y]=1;
				}
			}
			break;
		}
	}
	cout<<num1+num2<<endl;
	for(int i=num1;i>=1;i--)  cout<<ans1[i]<<" ";
	for(int i=1;i<=num2;i++)  cout<<ans2[i]<<" ";
	return 0;
}

Measured memory_bytes: 4608
#include<iostream>
#include<vector>
using namespace std;
	
int main(){
	long long n;
	long long maxc;
	cin >> n >> maxc;
	vector<long long>candies;
	for(long long i = 0;i<n;++i){
		long long temp;
		cin >>temp;
		candies.push_back(temp);
	}
	long long sum = 0;
	for(long long j = 0;j<n-1;++j){
		if(candies[j]+candies[j+1]>maxc){
		if(candies[j]>=maxc){
		sum+=candies[j+1]+candies[j]-maxc;
		candies[j+1]=0;
		}else{
			long long temp=maxc-candies[j];

			long long temp2 = candies[j+1]-temp;

			candies[j+1]=temp;
			sum+= temp2;
		}
		}
	}
	cout <<sum;
	return 0;

}


Measured memory_bytes: 1400
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int l , r , d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; i++) {
        if(i % d == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
local s=io.read()
local t=io.read()
local n=#s
local m=#t

local dp={}
for i=1,n+1 do
    dp[i]={}
    for j=1,m+1 do
        dp[i][j]=0
    end
end

for i=1,n do
    for j=1,m do
        if s:byte(i)==t:byte(j) then
            dp[i+1][j+1]=math.max(dp[i][j]+1,dp[i+1][j],dp[i][j+1])
        else
            dp[i+1][j+1]=math.max(dp[i+1][j],dp[i][j+1])
        end
    end
end

local length=dp[n+1][m+1]
local answer={}
while length>0 do
    if s:byte(n)==t:byte(m) then
        answer[length]=s:sub(n,n)
        n=n-1
        m=m-1
        length=length-1
    elseif dp[n+1][m+1]==dp[n][m+1] then
        n=n-1
    else
        m=m-1
    end
end
print(table.concat(answer))

Measured memory_bytes: 102800
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);		
		int n = in.nextInt(); // 県の個数
		int m = in.nextInt(); // 市の個数

		// 県、年でソート
		PriorityQueue<City> city = new PriorityQueue<>(m, new Comparator<City>() {
			@Override
			public int compare(City o1, City o2) {
				if ( o1.pref != o2.pref ) {		// 県でソート
					return o1.pref - o2.pref;
				} else {						// 同じ県の時は年でソート
					return o1.year - o2.year;
				}
			}
		});
		for ( int id = 1; id <= m; id++ ) {
			city.add(new City(id, in.nextInt(), in.nextInt()));
		}

		// 県ごとに年でナンバー付けしてidでソート
		PriorityQueue<City> city2 = new PriorityQueue<>(m, new Comparator<City>() {
			@Override
			public int compare(City o1, City o2) {
				return o1.id - o2.id;
			}
		});
		int p = 0;
		int num = 0;
		while ( city.size() > 0 ) {
			City c = city.poll();
			// 新出の県の場合
			if ( p != c.pref ) {
				p = c.pref;
				num = 1;
			} else {
				num++;
			}

			c.num = num;
			city2.add(c);
			// System.out.println("id:" + c.id + " pref:" + c.pref + " year:" + c.year);
		}

		PrintWriter pw = new PrintWriter(System.out);
		while ( city2.size() > 0 ) {
			City c = city2.poll();
			// System.out.println("id:" + c.id + " pref:" + c.pref + " num:" + c.num);
			pw.print(String.format("%06d", c.pref));
			pw.println(String.format("%06d", c.num));
		}
		pw.flush();
		in.close();
	}
}

class City {
	int	id		= 0;
	int	pref	= 0;
	int	year	= 0;
	int	num		= 0;

	public City(int id, int pref, int year) {
		this.id = id;
		this.pref = pref;
		this.year = year;
	}
}


Measured memory_bytes: 161392
<>;map{push@$_,$_[--$|]for@_=glob}<>;sub f{my($x,$b,$w)=($_,1,1);$_-"@_"and($c,$d)=f($x),$b=$b*$c%($==1e9+7),$w=$w*$d%$=for@$x;$w,$b+$w}print+(f)[$_=1]%$=

Measured memory_bytes: 190080
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  int n;
  cin>>n;
  int k = 0;
  bool ok = false;
  REP(i,2*n+1) {
    if (i*(i+1) > 2*n) break;
    if (i*(i+1) == 2*n) {
      k = i+1;
      ok = true;
    }
  }
  if (!ok) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  vector<vector<int>> g(k, vector<int>(k));
  int cnt = 0;
  REP(i,k)REP(j,i) {
    g[i][j] = ++cnt;
    g[j][i] = cnt;
  }
  cout << k << endl;
  REP(i,k) {
    cout << (k-1);
    REP(j,k) {
      if (i==j) continue;
      cout << ' ' << g[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
using System;
using System.CodeDom.Compiler;
using System.Linq;
using System.Text.RegularExpressions;

class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();

		int len = s.Length - 2;
		string ans = s.Substring(0, 1) + len + s.Substring(len + 1, 1);

		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
// C - Go to School

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct Student {
	int num;
	int order;
};

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

	vector<Student> students;
	int A;
	for (int i=1; i<=N; i++) {
		cin >> A;
		students.push_back(Student{i, A});
	}

	sort(students.begin(), students.end(), [](const Student &a, const Student &b) {
		return a.order < b.order;
	});


	for (int i=0; i<N; i++) {
		if (i != 0) cout << " ";
		cout << students[i].num;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <random>
#include <iomanip>
#include <functional>
#include <list>
using namespace std;

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

	int cnt = 0;
	for (int m = 1; m <= n; m++)
	{
		if (m & 1)
		{
			int cnt_divisors = 0;
			for (int d = 1; d <= m; d++)
				cnt_divisors += m % d == 0;
			cnt += cnt_divisors == 8;
		}
	}

	cout << cnt;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{	
public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
         StringBuilder sb=new StringBuilder();
         BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
         int n=s.nextInt(),w=s.nextInt();
        int[][] arr=new int[n+1][2];
        long[][] dp=new long[n+1][w+1]; 
        for(int i=1;i<=n;i++){
            arr[i][0]=s.nextInt(); arr[i][1]=s.nextInt();
        }

        for(int i=1;i<=n;i++){
            for(int j=1;j<=w;j++){
                if(arr[i][0]>j){
                    dp[i][j]=dp[i-1][j];
                }
                else{
                    dp[i][j]=Math.max(dp[i-1][j],arr[i][1]+dp[i-1][j-arr[i][0]]);
                }
            }
        }

        System.out.println(dp[n][w]);
    }
}

Measured memory_bytes: 126420
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1000000007
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'
 
ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//

void solve()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	while(k--)
	{
		if(b<=a)
			b=b*2;
		else if(c<=b)
			c=c*2;
	}
	if(c>b && b>a)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

int main()
{
	fastio;
	int T;
//    cin>>T;
//    while(T--)
        solve();
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  ll r = N / (A + B);
  ll rest = N - r * (A + B);
  cout << r * A + min(rest, A) << endl;
  return 0;
}


Measured memory_bytes: 256