akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

struct CARD {
	int num;
	char sym;
};

void PrintCARD(struct CARD a[], int N) {
	int i;
	for (i = 0; i < N; i++) {
		printf("%c%d", a[i].sym, a[i].num);
		if (!(i - N + 1)) break;
		printf(" ");
	}
	printf("\n");
}

void swap(struct CARD a[], int i, int j) {
	struct CARD buff = a[i];
	a[i] = a[j];
	a[j] = buff;
}

void BubbleSort(struct CARD a[], int N) {
	int i, j;
	for (i = 0; i < N; i++) {
		for (j = N - 1; j > i; j--) {
			if (a[j].num < a[j - 1].num) swap(a, j, j - 1);
		}
	}
}

void SelectionSort(struct CARD a[], int N) {
	int min;
	for (int i = 0; i < N; i++) {
		min = i;
		for (int j = i + 1; j < N; j++) {
			if (a[min].num > a[j].num) min = j;
		}
		if (min - i)
		{
			swap(a, i, min);
		}
	}
}


int main() {
	struct CARD a[36];
	struct CARD b[36];
	int N, flag = 1;
	char ch;
	scanf("%d", &N);
	ch = getchar();
	for (int i = 0; i < N; i++) {
		scanf("%c%d",&a[i].sym, &a[i].num);
		ch = getchar();
	}
	for (int i = 0; i < N; i++)b[i] = a[i];
	BubbleSort(a, N);
	SelectionSort(b, N);
	for (int i = 0; i < N; i++) {
		if (a[i].sym != b[i].sym) { 
			flag = 0;
			break;
		}
	}
	PrintCARD(a, N);
	printf("Stable\n");
	PrintCARD(b, N);
	if (flag == 1)printf("Stable\n");
	else printf("Not stable\n");

	return 0;
}


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

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String str = in.next();
        char ch = str.charAt(0); //to check the char placed at index no 0 of the string

        if(isUpperCase(ch)==true) //default function to check whether the given character of the string is uppercase or not
        {
            System.out.println('A');
        }
        else
            {
                System.out.println('a');
            }
            }
    }


Measured memory_bytes: 35544
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,K;
  cin>>N>>K;
  int A[200001];
  for(int i=1;i<=N;i++){
    cin>>A[i];
  }
  int temp=1;
  if(K<=200000){
    for(int i=1;i<=K;i++){
      temp=A[temp];
      //cout<<i<<" "<<temp<<endl;;
    }
    cout<<temp<<endl;
    return 0;
  }
  map<int,int>mp;
  vector<int>v;
  int cnt=1;
  int flag1=-1;
  int flag2=-1;
  while(1){
    mp[temp]++;
    v.push_back(temp);
    if((flag1==-1)&&(mp[temp]==2)){
      flag1=cnt;
    }
    if(mp[temp]==3){
      flag2=cnt;
      break;
    }
    temp=A[temp];
    cnt++;
  }
  //cnt-v.size()+1 繰り返しはじめまでのカウント
  //v.size()-1 繰り返し数
  
  cout<<v[(K-flag1-(flag2-flag1))%(flag2-flag1)+flag1-(flag2-flag1)] <<endl;
  
  /*cout<<cnt<<" "<<temp<<" "<<v.size()<<endl;
  cout<<flag1<<" "<<flag2<<endl;*/
  /*for(auto a: v){
    cout<<a<<" "<<endl;
    }*/
  
  
  return 0;
}


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

int power(int a, int b, int m) 
{
	int p = 1, q = a;
	for (int i = 0; i < 30; i++) 
	{
		if ((b & (1LL << i)) != 0) 
		{ 
			p *= q; 
			p %= m; 
		}
		q *= q; q %= m;
	}
	return p;
}
 
int fact[1 << 20], factinv[1 << 20];
int mod = 1000000007;

int ncr(int n, int r) {
	return (fact[n] * factinv[r] % mod) * factinv[n - r] % mod;
}


signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    

	fact[0] = 1;
	for (int i = 1; i < (1 << 20); i++) fact[i] = (fact[i - 1] * i) % mod;
	for (int i = 0; i < (1 << 20); i++) factinv[i] = power(fact[i], mod - 2, mod);

    //int t=1 ; cin>>t ; while(t--)
    {
    	int x, y;
    	cin >> x >> y;

    	int ans = 0;
    	if((x + y) % 3 == 0)
    	{
    		int n = (x + y) / 3;
			int m = x - n;
			if (0 <= m && m <= n) 
				ans = ncr(n, m);
		}

		cout << ans << '\n';
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 16640
n,a,b=map(int,input().split())
s=list(input())
i=0
j=0
for c in s:
    if c=="a":
        if i+j<a+b:
            i+=1
            print("Yes")
        else:
            print("No")
    elif c=="b":
        if i+j<a+b and j<b:
            j+=1
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 9932
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    len_set = len(set(A))
    print([len_set-1,len_set][(N-len_set) % 2 == 0])
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 58768
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int f(int b, int n) {
  int ret = 0;
  while (n) {
    ret += n % b;
    n /= b;
  }
  return ret;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, s;
  cin >> n >> s;
  if (s == n) {
    cout << n + 1 << endl;
    return 0;
  } else {
    rep(b, 2, 1 + sqrt(n + 1)) {
      if (f(b, n) == s) {
        cout << b << endl;
        return 0;
      }
    }
    int ans = INF;
    rep(p, 1, 1 + sqrt(n)) {
      if ((n - s) % p == 0) {
        int b = 1 + (n - s) / p;
        if(!(b>=2))continue;
        if (f(b, n) == s) {
          chmin(ans, b);
        }
      }
    }
    if (ans == INF)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
vector <int> v(3);
cin >>v[0]>>v[1]>>v[2];
sort(all(v));
cout <<v[0]+v[1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin >>n;
  string a,b,c;
  cin >>a >>b >>c;
  for(int i=0;i<n;i++){
    if(a[i]!=b[i] && (b[i]!=c[i] &&a[i]!=c[i]))ans+=2;
    else if (a[i]!=b[i] || (b[i]!=c[i] || a[i]!=c[i]))ans+=1;
    cerr<<ans<<endl;
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k,q=map(int, readline().rstrip().split())
    score=[k-q]*n
    for i in range(q):
        x=int(readline())-1
        score[x]+=1
    
    for i in range(n):
        if score[i]>0:
            print("Yes")
        else:
            print("No")

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Measured memory_bytes: 9220
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
	public Main() {
		FastScanner scanner = new FastScanner();
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		
		int[] P = new int[N];
		for (int i = 0; i < N; i++) {
			P[i] = scanner.nextInt();
		}
		
		Arrays.sort(P);
		
		int ans = 0;
		for (int i = 0; i < K; i++) {
			ans += P[i];
		}
		
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}
	
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 32436
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <limits>

using namespace std;

int main() {
  int D;
  int T;
  int S;
  cin >> D;
  cin >> T;
  cin >> S;
  if(D <= T*S){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  
  
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200010
#define ll long long
using namespace std;

int n, nxt[N], d, len[2];
ll L, R, ans[26], D[1010][2], s[2], s1[2][26];
char S[N];

inline void kmp(){
	nxt[0]=nxt[1]=0; int j;
	for(int i=2; i<=n; i++){
		j=nxt[i-1]; while(j&&S[i]!=S[j+1])j=nxt[j];
		if(S[i]==S[j+1])j++; nxt[i]=j;
	}
}

inline void solve(ll m, int f){
	len[0]=n; len[1]=d;
	memset(D, 0, sizeof(D)); D[1][0]=1; D[2][1]=1;
	if(m<=n+d){
		for(int i=1; i<=n; i++)if(i<=m)ans[S[i]-'a']+=f;
		for(int i=1; i<=d; i++)if(n+i<=m)ans[S[i]-'a']+=f;
		return;
	}
	memset(s1, 0, sizeof(s1));
	for(int i=1; i<=n; i++)s1[0][S[i]-'a']++;
	for(int i=1; i<=d; i++)s1[1][S[i]-'a']++;
	
	s[0]=1; s[1]=0; ll now=n+d; int p;
	for(int i=3; i<=1000; i++){
		D[i][0]=s[0]; D[i][1]=s[1];
		now+=D[i][0]*len[0]+D[i][1]*len[1];
		s[0]+=D[i-1][0]; s[1]+=D[i-1][1];
		if(now>=m){
			while(m>n+d){
				for(int j=1; j<=i; j++)if(m>=D[j][0]*len[0]+D[j][1]*len[1]){
					for(int k=0; k<=25; k++)ans[k]+=s1[0][k]*D[j][0]*f;
					for(int k=0; k<=25; k++)ans[k]+=s1[1][k]*D[j][1]*f;
					m-=D[j][0]*len[0]+D[j][1]*len[1];
				}
			}
			for(int j=1; j<=n; j++)if(j<=m)ans[S[j]-'a']+=f;
			for(int j=1; j<=d; j++)if(n+j<=m)ans[S[j]-'a']+=f;
			return;
		}
	}
}

int main(){
	scanf("%s", S+1); n=strlen(S+1); n>>=1;
	scanf("%lld%lld", &L, &R);
	kmp(); d=n-nxt[n];
	memset(ans, 0, sizeof(ans)); solve(R, 1); solve(L-1, -1);
	for(int i=0; i<=24; i++)printf("%lld ", ans[i]); printf("%lld", ans[25]);
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s;
	cin >> s;
	if (s[0] == s[s.size() - 1]) {
		if (s.size() % 2) cout << "Second\n";
		else cout << "First\n";
	}
	else {
		if (s.size() % 2) cout << "First\n";
		else cout << "Second\n";
	}
}

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

typedef long long ll;
ll n, a, b;
int main()
{
	ll i;
	cin >> n >>a >> b;
	if (a > b || a != b && n == 1) {
		cout << 0;
		return 0;
	}
	cout << (b - a) * (n - 2) + 1;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

int main() {
    int n;
    cin >> n;
    int ans[26];
    fill(ans, ans + 26, 10000);
    string s;
    int now[26];
    for (int i = 0; i < n; i++) {
        cin >> s;
        int len = s.size();
        fill(now, now + 26, 0);
        for (int j = 0; j < len; j++) {
            now[s[j] - 97]++;
        }
        for (int j = 0; j < 26; j++) {
            ans[j] = min(ans[j], now[j]);
        }
    }
    string ansstr = "";
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < ans[i]; j++) {
            ansstr += 'a' + i;
        }
    }
    cout << ansstr << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mod 1000000007
#define ft cout<<"for test"<<endl;
#define pi 2*acos(0.0)
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,i,j;
    cin>>n;
    vi v(n+1);
    for(i=0; i<n-1; i++)
    {
        cin>>j;
        v[j]++;
    }
    for(i=1; i<=n; i++)
    {
        cout<<v[i]<<endl;
    }
}


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




int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)   cin >> a[i];


    vector<ll> sumL(n, 0);
    vector<ll> sumR(n, 0);
    sumL[0] = a[0];
    sumR[n-1] = a[n-1];
    rep(i, n-1){
        sumL[i+1] = sumL[i] + a[i+1];
        sumR[n-2-i] = sumR[n-1-i] + a[n-2-i];
    }

    ll minn = 1e15;
    rep(i, n-1){
        ll v = abs(sumL[i] - sumR[i+1]);
        if(v < minn)    minn = v;
    }

    cout << minn << endl;


 
    return 0;
}



Measured memory_bytes: 4992
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0

for b in B:
    if b <= A[0] or b >= C[N-1]:
        continue
    # Aに対して
    l, r = -1, N
    while abs(l - r) > 1:
        mid = (l + r) // 2
        if A[mid] < b:
            l = mid
        else:
            r = mid
    # Bに対して
    l2, r2 = -1, N
    while abs(l2 - r2) > 1:
        mid = (l2 + r2) // 2
        if C[mid] > b:
            r2 = mid
        else:
            l2 = mid
    ans += (l+1) * (N - r2)
print(ans)

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

int main() {
    int n, k;
    cin >> n >> k;
    int x[n];
    int m = -1;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        if (x[i] < 0) m = i;
    }
    int neg = m + 1;
    int pos = n - neg;
    
    int ans = 1000000000;
    for (int i = 0; i <= k; i++) {
        if (i > neg || k - i > pos) continue;
        int t;
        if (i == 0) t = x[m + k - i];
        else if (i == k) t = - x[m - i + 1];
        else {
            t = min(- x[m - i + 1], x[m + k - i]) + x[m + k - i] - x[m - i + 1];
        }
        ans = min(ans, t);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long ans = 0;
		long a,b;
		for(int i = 0;i < N; i++) {
			a = sc.nextLong();
			b = sc.nextLong();
			ans += b - a;
		}
		System.out.println(ans + N);
	}
}

Measured memory_bytes: 24788
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
using namespace std;
int sx, sy, tx, ty;
int main(void){
    // Your code here!
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    cout << string(dx, 'R') << string(dy, 'U');
    cout << string(dx, 'L') << string(dy, 'D');
    cout << 'D' << string(dx + 1, 'R') << string(dy + 1, 'U') << 'L';
    cout << 'U' << string(dx + 1, 'L') << string(dy + 1, 'D') << 'R';
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int ans = 0;
    string s; cin >> s;
    loop(i, s.size() / 2)
        if (s[i] != s[s.size() - i - 1])
            ++ans;
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3616
#!/usr/bin/env python3
import copy

N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

a_list = sorted(a_list)


def judge(w_list, k):
    w_list = sorted(w_list)

    for i in range(len(w_list) - 1):
        w_list += [abs(w_list[i] - w_list[i + 1])]

    if k in w_list:
        return True, w_list
    w_list = sorted(list(set(w_list)))
    ww_list = set([w + K for w in w_list])
    if ww_list & set(w_list):
        return True, w_list
    else:
        return False, w_list


w_list = a_list

while True:
    org_w_list = copy.copy(w_list)
    is_ok, w_list = judge(w_list, K)
    if is_ok:
        break
    else:
        if abs(w_list[0] - w_list[-1]) < K:
            # 操作によって作れる差分よりKの方が大きいので
            # これ以上操作してもKを作れない
            break
        if w_list == org_w_list:
            # これ以上操作しても変化がない
            break

ans = "POSSIBLE" if is_ok else "IMPOSSIBLE"

print(ans)


Measured memory_bytes: 26248
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 3e3 + 9;
const ll mod = 1e9 + 7;
typedef pair<ll,ll> LL;
priority_queue<ll,vector<ll>,greater<ll>> pq;
ll n,k,a[N],i,j,l;
ll maxx;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n>>k;
    for (i = 1;i <= n;i++) cin>>a[i];
    for (i = 0;i <= min(n,k);i++){
        for (j = 0;j <= min(n,k) - i;j++){
            if (!i&&!j) continue;
            l = 1;
            while(l <= i) pq.push(a[l]),l++;
            l = n;
            while(l >= n - j + 1) pq.push(a[l]),l--;
            ll p = i + j;
            while(p < k&&!pq.empty()){
                if (pq.top() > 0){

                    break;
                }
                pq.pop(); p++;
            }
            ll cnt = 0;
            while(!pq.empty()) cnt += pq.top(),pq.pop();
            maxx = max(maxx,cnt);

        }
    }
    cout<<maxx;
}



Measured memory_bytes: 3600
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;

void main() {
    immutable long MOD = 10^^9 + 7;

    auto N = readln.chomp.to!int;
    auto A = N.iota.map!(_ => readln.chomp.to!long).array;
    auto X = A.reduce!"a^b"();

    auto B = new bool[](40);
    foreach (a; A) B[bsf(a)] = true;

    int ans = 0;
    foreach_reverse (i; 0..33) {
        if ((X >> i) & 1) {
            if (!B[i]) {
                writeln(-1);
                return;
            }
            ans += 1;
            X ^= (1L << (i + 1)) - 1;
        }
    }

    writeln(X == 0 ? ans : -1);
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;cin>>s;
    for(auto &c:s)
        if(c=='?') c='D';
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3744
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
	int N;
	cin >> N;
	vector<int> a(N+1);
	a[0] = -1;//
	for(int i=1; i<=N; i++) cin >> a[i];

	vector<int> ans(N+1, 0);
	ans[0] = -1;

	for(int i=N; i>0; i--){
		int sum = 0;
		// N <= 10^5なのでO(N^2)解だと間に合わない
		// for(int j=i+1; j<=N; j++){
		// 	if(j%i == 0){
		// 		if(ans[j] == 1) sum++;
		// 	}
		// }

		//調和級数 なら O(NlogN)なので間に合う
		for(int j=i+i; j<=N; j+=i){
			if(ans[j] == 1) sum++;
		}
		sum %= 2;
		if(a[i] == sum) ans[i] = 0;
		else ans[i] = 1;
	}



	// cout << " ans:"; print_vec(ans);
	int num = 0;
	for(int i=1; i<=N; i++) if(ans[i] == 1) num++;
	cout << num << endl;
	for(int i=1; i<=N; i++) if(ans[i] == 1) cout << i << " ";
	cout << endl;
}



Measured memory_bytes: 4720
#include <iostream>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
    if (b == 0) return a >= 0 ? a : -a;
    return gcd(b, a % b);
}
int main() {
    int N, g;
    cin >> N >> g;
    for (int i = 1, A; i < N; i++) {
        cin >> A;
        g = gcd(g, A);
    }
    cout << g << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    R,S,P=map(int,input().split())
    T=list(input())
    l=['']*N
    ans=0
    for i in range(N):
        if i<K:
            if T[i]=='r':
                l[i]='p'
                ans+=P
            elif T[i]=='p':
                l[i]='s'
                ans+=S
            else:
                l[i]='r'
                ans+=R
        else:
            if T[i]=='r':
                if l[i-K]=='p':
                    l[i]='z'
                else:
                    l[i]='p'
                    ans+=P
            elif T[i]=='p':
                if l[i-K]=='s':
                    l[i]='z'
                else:
                    l[i]='s'
                    ans+=S
            else:
                if l[i-K]=='r':
                    l[i]='z'
                else:
                    l[i]='r'
                    ans+=R
    print(ans)

if __name__ == '__main__':
    main()


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

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;

const int N = 1000006;

ll n, k, arr[N];
ll dp[N];

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> arr[i];
}

void process()
{
    dp[0] = 0;
    for(int i = 1; i < n; i++)
    {
        ll mn = (1ll << 60);
        for(int j = max(0ll, i-k); j < i; j++) mn = min(mn, dp[j] + abs(arr[i]-arr[j]));
        dp[i] = mn;
    }
    cout << dp[n-1] << endl;
}



Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e6+5,M=5e3+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
ll f[N],n,s[N];
int main(){
	read(n);f[1]=s[1]=n;f[2]=1ll*n*n%mod;s[2]=(s[1]+f[2])%mod;
	rep(i,3,n){
		f[i]=f[i-1];
		(f[i]+=1ll*(n-1)*(n-1)%mod)%mod;
		f[i]=(f[i]+s[i-3])%mod;
		f[i]=(f[i]+n-i+2)%mod;
		s[i]=(s[i-1]+f[i])%mod;
	}
	cout<<f[n]<<endl;
}

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

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

    int x;
    vector<int> a(N);
    int j = 0, k = 0;
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }

    int alice = 0, bob = 0;
    for (int i = 0; i < N; i++) {
        int curr_max_index = 0;
        for (int j = 0; j < N; j++) {
            if (a.at(curr_max_index) < a.at(j)) {
                curr_max_index = j;
            }
        }
        if (i % 2 == 0) {
            // Alice
            alice += a.at(curr_max_index);
        } else {
            // Bob
            bob += a.at(curr_max_index);
        }
        a.at(curr_max_index) = 0;
    }

    cout << alice - bob << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,K;
int main(){
	int ma=0,d=0;
	scanf("%d%d",&n,&K);
	for (;n;n--){
		int k1; scanf("%d",&k1);
		d=__gcd(k1,d); ma=max(ma,k1);
	}
	if (ma>=K&&K%d==0) printf("POSSIBLE\n"); else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i;
	char in[20];
	
	scanf("%s", in);
	
	for(i = 19; i > -1; i--){
		if(in[i] != '\0'){
			printf("%c", in[i]);
		}
	}
	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 0
$N=<>;
for($h=1;$h<=3500;$h++){
    next if(4*$h<=$N);
    $nn = int($N*$h / (4*$h-$N));
    $n=($nn>1)?$nn:1;
    for(;$n<=3500;$n++){
        next if ($t=4*$h*$n-$N*$h-$N*$n)==0;
        $w=($N*$h*$n)/$t;
        if ($w>0and$w==int($w)){
            print"$n $h $w";
            exit; 
        }
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
ll N,K;
  cin>>N>>K;
ll A[N];
for(ll i=0;i<N;i++){ 
  cin>>A[i];
}
//int ans=0;

  for(ll i=0;i<N-K;i++){
  if(A[i]<A[i+K]){
  cout<<"Yes"<<endl;
  }
  else {cout<<"No"<<endl;}
  }
  
  
  //cout<<"No"<<endl;

  
}


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

long long solve(long long n)
{
    if(n==1) return 1;
    else return (1 + 2*solve(n/2));
}

int main()
{
    long long n;
    cin>>n;
    cout<<solve(n)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    long long a,b,x;
    scanf("%lld%lld%lld",&a,&b,&x);
    long long s=b/x-a/x;
    if(a%x==0)s++;
    cout << s;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	int A, B, C;
	A = sc.nextInt();
	B = sc.nextInt();
	C = sc.nextInt();

	int ans = -1 * (A - B - C);
	if (ans > 0)
	    System.out.println(ans);
	else
	    System.out.println(0);
    }
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define maxLoop 1000

vi a;
int n;

ll f(ll x){
  ll res = 0;
  rep(i,n) res += abs(a[i] - (x + i + 1));
  return -res;
}

ll search(ll left, ll right)
{
	for (int loop = 0; loop < maxLoop; ++loop){
		if (f((left * 2 + right) / 3) > f((left + right * 2) / 3)){
			right = (left + right * 2) / 3;
		} else {
			left = (left * 2 + right) / 3;
		}
	}
	return (right + left) * 0.5;
}

int main(){
#define int ll
  cin >> n;
  a.resize(n); rep(i,n) cin >> a[i];
  cout << -f(search(-1e9,1e9)) << endl;
}

Measured memory_bytes: 1792
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int t[64];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}

void Solve() {

	string x;
	cin >> x;
	int t[3];
	t[0] = 0;
	t[1] = 0;
	for (size_t i = 0; i < x.size(); i++)
	{
		if (x[i] == 'S') {
			t[0]++;
		}
		else {
			if (t[0] > 0) t[0]--;
			else t[1]++;
		}
	}

	cout << (t[0] + t[1]) << endl;
}


int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  =1e6+1 , limit = 1e17 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int32_t main(){
    boost;
   int dp[maxx+1];

   dp[0] = 0;
   for(int i=1;i<=maxx;i++){
       if(i%3!=0 && i%5!=0){
           dp[i] = dp[i-1]+i;
       }else{
           dp[i] = dp[i-1];
       }
   }
   
//   for(int i = 0 ; i < 15  ; i++ ){
//       cout<<dp[i]<< " ";
//   }
   int x;
   cin>>x;
   cout<<dp[x]<<endl;
    
}


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

int main(){
  int n, q, b, e, k;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> b >> e >> k;
    int cnt = 0;
    for(int j = b; j < e; j++){
      if(a[j] == k) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
signed main(){
    IOS;
    int n,d;
    cin>>n>>d;
    int ans=0;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        x=abs(x)*abs(x);
        y=abs(y)*abs(y);
        if(x+y<=d*d)ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3652
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 998244353;
// static const int MAX = 100005;
// static const int ls = 101;
// static const int NMAX = 5005;
// static const lli INFTY = 1000000000000;

// typedef priority_queue<int, greater<int>> RevQ;
int n;
int x, y;
string s;
// lli l, r;
// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }



int main(){
  cin >> s;
  if (s == "SUN") cout << 7 << endl;
  if (s == "MON") cout << 6 << endl;
  if (s == "TUE") cout << 5 << endl;
  if (s == "WED") cout << 4 << endl;
  if (s == "THU") cout << 3 << endl;
  if (s == "FRI") cout << 2 << endl;
  if (s == "SAT") cout << 1 << endl;
  
}


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

#define INF 999999999.0

typedef pair< double,vector<int> > P;

int n;
int name[15],x[15],w[15];
P dp[15][1<<15];

P solve(int idx,int used,int weight){
  P res(0,vector<int>());
  res.second.push_back(name[idx]);

  if(used == (1<<n)-1) return res;
  if(dp[idx][used].first != INF) return dp[idx][used];

  res.first = INF;
  for(int i=0;i<n;i++){
    if((used & (1<<i)) == 0){
      P tmp = solve(i,used|(1<<i),weight+w[i]);
      tmp.first += abs(x[i] - x[idx]) / (2000.0 / (70+weight));
      if(res.first > tmp.first){
        res = tmp;
      }
    }
  }

  res.second.insert(res.second.begin(),name[idx]);

  return dp[idx][used] = res;
}

int main(void){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>name[i]>>x[i]>>w[i];
    w[i] *= 20;
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<(1<<n);j++){
      dp[i][j] = P(INF,vector<int>());
    }
  }

  P ans(INF,vector<int>());
  for(int i=0;i<n;i++){
    P tmp = solve(i,1<<i,w[i]);
    if(ans.first > tmp.first) ans = tmp;
  }

  for(int i=0;i<n-1;i++) cout<<ans.second[i]<<" ";
  cout<<ans.second[n-1]<<endl;

  return 0;
}

Measured memory_bytes: 27628
#include <random>

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr ll mod = 1e9 + 7;
mt19937_64 rnd{random_device()()};

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (cnt[a[i]] > 1) continue;
    if (a[i] != 1 && cnt[1]) continue;
    if (a[i] == 1 && cnt[1] > 1) continue;
    bool ok = true;
    for (int j = 2; j * j <= a[i]; j++) {
      if (a[i] % j) continue;
      if (cnt.count(j) || cnt.count(a[i] / j)) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 13492
import sys
sys.setrecursionlimit(10**5+10)
input=sys.stdin.readline

N,M=map(int, input().split())
A=[list(map(int, input().split())) for i in range(M)]
G=[[]for i in range(N)]
for a,b in A:
  G[a-1].append(b-1)
dp=[-1]*N

def rec(v):
  if dp[v]!=-1:
    return dp[v]
  ans=0
  for i in G[v]:
    ans=max(ans,rec(i)+1)
  dp[v]=ans
  return dp[v]

ans=0
for i in range(N):
  ans=max(ans,rec(i))
print(ans)

Measured memory_bytes: 78796
import java.util.*;

public class Main {
    private static final Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        if (calc()) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
    
    private static boolean calc() {
        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if (r*2 > w || r*2 > h) return false;
        if (x < r || w - r < x) return false;
        if (y < r || h - r < y) return false;
        return true;
    }
}

Measured memory_bytes: 26212
def solve(s)
  len = s.length
  fst = 0
  snd = s.count(?E)
  ar = []
  0.upto(len-1){|i|
    if s[i] == ?E then snd-=1 end
    if i!=0 && s[i-1] == ?W then fst+=1 end
    ar.push(fst+snd)
  }
  ar.min
end

gets
p solve gets


Measured memory_bytes: 4484
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1,0);
    for(int i=1;i<=N;i++) cin >> A[i];
    map<int,int> m;
    int ans = 0;
    for(int i=1;i<=N;i++){
        if(m.empty()){
            m[-A[i]]++;
            ans++;
        }else{
            map<int,int>::iterator it = m.upper_bound(-A[i]);
            if(it==m.end()){
                m[-A[i]]++;
                ans++;
            }else{
                m[it->first]--;
                if(m[it->first]==0) m.erase(it);
                m[-A[i]]++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

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


    int n;
    cin>>n;
    vector<int> a(n), b(n), c(n);

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

    vector<int> dpA(n), dpB(n), dpC(n);         /// dpA[i] = A was done in i-th day

    dpA[0] = a[0];
    dpB[0] = b[0];
    dpC[0] = c[0];

    for(int i = 1; i<n; i++){
        dpA[i] = a[i] + max(dpB[i-1], dpC[i-1]);
        dpB[i] = b[i] + max(dpA[i-1], dpC[i-1]);
        dpC[i] = c[i] + max(dpA[i-1], dpB[i-1]);
    }


    int ans = max({dpA[n-1], dpB[n-1], dpC[n-1]});

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 5524
#include <stdio.h>
#define SWAP(type,a,b) {type temp=a; a=b; b=temp;}
int Partition(int *, int);

int main(){
  int i, j, n;

  // Input n
  scanf("%d", &n);

  // Create A[n]
  int A[n];

  // Input A[n]
  for(i = 0; i < n; i++) scanf("%d", &A[i]);

  // Partition A[n]
  j = Partition(A, n-1);

  // Output A[n]
  for(i = 0; i < n; i++){
    if(j == i) printf("[%d]", A[i]);
    else printf("%d", A[i]);
    if(i < n-1) printf(" ");
  }
  printf("\n");

  return 0;
}

// Partition function
int Partition(int *A, int r){
  int x, i, j;
  // i is <, j is |

  // Set x, i
  x = A[r];
  i = -1;

  // Partition
  for(j = 0; j < r; j++){

    if(A[j] <= x){
      i++;
      SWAP(int, A[i], A[j]);
    }
  }
  SWAP(int, A[i + 1], A[r]);

  return i + 1;
}

Measured memory_bytes: 992
while True:
    s = input().split(" ")
    H = int(s[0])
    W = int(s[1])
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if j == W-1:
                print("#")
            else:
                print("#",end="")
    print("")

Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N; cin >> N;
    vector<int> a(N);
    int count = 0;
    for(int i=0;i<N;i++){
        int n; cin >> n;
        if(n == count+1) count++;
    }
    if(count == 0) cout << -1 << endl;
    else cout << N-count << endl;
}



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

typedef vector<int>  vi;
typedef set<char> setchar;
typedef set<int> sett;
typedef deque <int> dq;
typedef long long ll;
#define INF 1<<30
#define vec(a)  a.begin(),a.end()
#define pb     push_back
#define pf     push_front
#define mem(a,b) memset(a,b,sizeof(a));
#define inI(a)  scanf("%d",&a);
#define inL(a)  scanf("%lld",&a);
#define uff ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
//int fx[]={+0,-1,-1,-1,+0,+1,+1,+1};
//int fy[]={-1,-1,+0,+1,+1,+1,+0,-1};
int fx[]= {0,-1,0,+1};
int fy[]= {-1,0,+1,0};
int main()
{
     uff
    //freopen("input.txt","r",stdin);
    int n,k;
    cin>>n>>k;
    vector<int> arr(n+10,0);
    vector<int> dp(n+10,INF);
    for(int i=0;i<n;i++)
    { cin>>arr[i];
    }
    dp[0]=0;
    for(int i=0;i<n;i++)
    {  int j;
        for( j=1;j<=k && (i+j)<n;j++)
        {
            dp[j+i]=min(dp[i+j],abs(arr[i+j]-arr[i])+dp[i]);
            
        }
    }
    cout<<dp[n-1]<<endl;



    return 0;

}







Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
	int A, B, T;
	cin >> A >> B >> T;
	
	int limit = (int)((float)T+0.5);
		
	int out = 0;
	for( int ii = 1; ii <= limit ; ++ii ){
		if(ii % A == 0){
			out += B;
		}
	}
		
	cout << out << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
a_min = min( int(x/500) ,a)
for ai in range(a_min+1):
    rem_a = x - (ai * 500)
    if rem_a == 0:
        cnt+=1
        break
    b_min = min( int(rem_a/100) ,b)
    for bi in range(b_min+1):
        rem_b = rem_a - (bi * 100)
        if rem_b == 0:
            cnt+=1
            break
        c_min = min( int(rem_b/50) ,c)
        for ci in range(c_min+1):
            rem_c = rem_b - (ci * 50)
            if rem_c == 0:
                cnt+=1
                break

print(cnt)

Measured memory_bytes: 9228
import java.util.Scanner;

public class Main {
	int n;
	int array[];
	long cnt;
	public static void main(String args[]) {
		new Main().run();
	}
	Main() {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = scan.nextInt();
		}
	}
	void run() {
		mergeSort(0,n);
		System.out.println(cnt);
	}
	void mergeSort(int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right ) / 2;
			mergeSort(left, mid);
			mergeSort(mid, right);
			merge(left, mid, right);
		}
	}
	void merge(int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		int l[] = new int[n1+1];
		int r[] = new int[n2+1];
		for (int i = 0; i < n1; i++) {
			l[i] = array[left + i];
		}
		for (int i = 0; i < n2; i++) {
			r[i] = array[mid + i];
		}
		l[n1] = Integer.MAX_VALUE;
		r[n2] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		for (int k = left; k < right; k++) {
			if (l[i] <= r[j]) {
				array[k] = l[i];
				i++;
			} else {
				array[k] = r[j];
				j++;
				cnt +=  n1 - i;
			}
		}
	}

}



Measured memory_bytes: 102604