akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const int MAX = 510000; //nCrのr
const int MOD = 1000000007;

typedef long long ll;
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;
}

int main(){
  int N, K; cin >> N >> K;
  COMinit();
  for (int i = 1; i <= K; ++i){
    cout << (COM(N-K+1, i) * COM(K-1, i-1) + MOD) % MOD << endl;
  }
}


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

int main() {
  int n, q;
  queue<pair<string, int>> Q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    string p;
    int t;
    cin >> p >> t;
    Q.push(make_pair(p, t));
  }
  int time = 0;
  while (!Q.empty()) {
    string p = Q.front().first;
    int re_time = Q.front().second;
    if (re_time > q) {
      Q.push(make_pair(p, re_time - q));
      time += q;
    } else {
      time += re_time;
      cout << p << " " << time << endl;
    }
    Q.pop();
  }
}



Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  string s, t, u = "";
  cin >> s >> t;
  int a = -1;
  rrep(i, s.size()-t.size()+1){
    bool b = 1;
    rep(j, t.size()){
      if(t[j] != s[i+j] && s[i+j] != '?'){
        b = 0;
        break;
      }
    }
    if(b){
      a = i;
      break;
    }
  }
  if(a < 0) u = "UNRESTORABLE";
  rep(i, s.size()){
    if(i < a){
      if(s[i] == '?') u += 'a';
      else u += s[i];
    }
    else if(i - a < t.size()) u += t[i-a];
    else if(s[i] == '?') u += 'a';
    else u += s[i];
  }
  if(a < 0) u = "UNRESTORABLE";
  cout << u << "\n";
  return 0;
}

Measured memory_bytes: 256
n = str(input())
if len(n) <= 2:
    print(0)
else:
    a = n[0:-2]
    tens = int(n[-2])
    need = tens*2
    ones = int(n[-1])
    if ones == 0:
        need +=0
    elif ones <= 5:
        need += 1
    else:
        need +=2
    if need <= int(a):
        print(1)
    else:
        print(0)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int holiday = sc.nextInt();
		int homework = sc.nextInt();
		int days = 0;
		for (int i = 0; i < homework; i++) {
			days += sc.nextInt();
		}
		sc.close();

		if (holiday < days) {
			System.out.print(-1);
		} else {
			System.out.print(holiday - days);
		}
	}

}


Measured memory_bytes: 46348
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
int n,m;
cin>>n>>m;
V<V<ll>> a(n,V<ll>(m));
V<bool> use(m,true);
for(int i=0;i<n;i++)for(int j=0;j<m;j++){
cin>>a[i][j];
a[i][j]--;
}
int ans=INT_MAX;
for(int i=0;i<m;i++){
    V<int> cnt(m,0);V<bool> ch(n,false);
    for(int j=0;j<m;j++){
        for(int k=0;k<n;k++){
            if(!use[a[k][j]])continue;
            if(ch[k])continue;
            ch[k]=true;
            cnt[a[k][j]]++;
        }
    }
    ll sum=0;
    for(int j=0;j<m;j++)sum+=cnt[j];
    if(sum<n)break;
    int imax,ma=0;
    for(int j=0;j<m;j++){
        if(chmax(ma,cnt[j]))imax=j;
    }
    use[imax]=false;
    chmin(ans,ma);
}
cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

int main()
{
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<pair<char, char>> v(q);
	for (int i = 0; i < q; ++i)
	{
		char t, d;
		cin >> t >> d;
		v[i] = {t,
				d};
	}
	//右からあふれるものを探す。
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = n; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	auto ngR = [&](int now) {
		for (int i = 0; i < q; ++i)
		{
			if (v[i].first == s[now])
			{
				if (v[i].second == 'R')
				{
					now++;
				}
				else
				{
					now--;
				}
			}
			if (now >= n)
			{
				return true;
			}
			if (now < 0)
			{
				return false;
			}
		}
		return false;
	};
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1)
	{
		int mid = left + (right - left) / 2;

		if (ngR(mid))
			right = mid;
		else
			left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	int ng_r = right;

	//左からあふれるものを探す。
	left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	right = n; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	auto ngL = [&](int now) {
		for (int i = 0; i < q; ++i)
		{
			if (v[i].first == s[now])
			{
				if (v[i].second == 'R')
				{
					now++;
				}
				else
				{
					now--;
				}
			}
			if (now >= n)
			{
				return false;
			}
			if (now < 0)
			{
				return true;
			}
		}
		return false;
	};
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1)
	{
		int mid = left + (right - left) / 2;

		if (!ngL(mid))
			right = mid;
		else
			left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	int ng_l = right;
	//cout << ng_r << endl;
	cout << n - (ng_l + (n - ng_r)) << endl;
}

Measured memory_bytes: 900
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PII;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** Problem2589 : North North West **/
string dir;

ll _gcd(ll a, ll b)
{
	while (a) {
		b%=a;
		swap(a, b);
	}
	return b;
}

PII reduction(PII a)
{
	ll gcd = _gcd(a.first, a.second);
	a.first /= gcd;
	a.second /= gcd;
	if (a.second<0) {
		a.first *= -1; a.second *= -1;
	}
	return a;
}

PII operator -(PII a)
{
	return PII(-a.first, a.second);
}

ll lcm(ll a, ll b)
{
	return a*b/_gcd(a, b);
}

PII add(PII a, PII b)
{
	PII res;
	
	res.second = lcm(a.second, b.second);
	res.first = a.first*res.second/a.second + b.first*res.second/b.second;
	
	return reduction(res);
}

PII solve(int pos)
{
	if (pos == dir.size()-1)
		return PII((dir[pos]=='n'?0:90), 1);
	
	int n = (int)dir.size()-pos-1;
	
	PII res, a=solve(pos+1), b=PII(90, pow(2.0, n));
	
	return (dir[pos]=='w' ? add(a, b) : add(a, -b));
}

int main()
{
	string S;
	
	while (cin>>S, S!="#") {
		dir = "";

		for (int i=0; i<S.size(); i++) {
			if (S[i] == 'w' || S[i] == 'n') dir+=S[i];
		}
		
		PII ans = reduction(solve(0));
		
		if (ans.first == 0 || ans.second==1) {
			cout << ans.first << endl;
		} else {
			cout << ans.first << "/" << ans.second << endl;
		}
	}
}

Measured memory_bytes: 1196
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int N=nextInt();
		boolean bool[]=new boolean[N];
		int L[]=new int[N+2];
		int R[]=new int[N+2];
		int min=0;
		String a=next();
		for(int i=0;i<N;i++){
			if(a.charAt(i)=='R')
				bool[i]=true;
		}
		for(int i=0;i<N;i++){
			L[i+1]=L[i];
			R[N-i]=R[N+1-i];
			if(bool[i]==false)
				L[i+1]++;
			if(bool[N-i-1])
				R[N-i]++;
		}
		min=100000000;
		for(int i=1;i<N+2;i++){
			if(min>Math.max(L[i-1],R[i]))
				min=Math.max(L[i-1],R[i]);
		}
		System.out.println(min);
	}
	static boolean isOK(int index,int key,int[]a){
		if (a[index]>=key) return true;
	    else return false;
	}
	static int binary_search(int key,int[] a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.length; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



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

int main(void){

    char S[100];
    char tmpS[105];
    int K = 0;
    scanf("%d", &K);
    scanf("%s", S);

    if (strlen(S) <= K) {
        printf("%s\n", S);
    } else {
        strncpy(tmpS, S, K);
        tmpS[K] = '\0';
        printf("%s...\n", tmpS);
    }

    return 0;
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n;
    cin >> n;

    ll sum[2] = {1, 1};
    rep(i, n){
        ll t, a;
        cin >> t >> a;
        ll base = max((sum[0] - 1 + t) / t, (sum[1] - 1 + a) / a);
        sum[0] = t * base;
        sum[1] = a * base;
    }

    cout << sum[0] +  sum[1] << endl;
}

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

//vector<vector<int> > dp(200000,vector<int>(105,0));



vector<int> dp(200000);

int main(){
    int N;
    int K;
    int h[200000];
    cin>>N>>K;
    for(int i=1;i<=N;i++){
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=abs(h[1]-h[2]);
    for(int i=3;i<=N;i++){
        int MIN=1e9;
        for(int j=1;j<=K;j++){
            if(i>j)
            MIN=min(MIN,dp[i-j]+abs(h[i-j]-h[i]));
        }
        dp[i]=MIN;
    }
    cout<<dp[N]<<endl;

}

Measured memory_bytes: 1536
#include<stdio.h>

void run(void){
  int y,m,d;
  scanf("%d/%d/%d",&y,&m,&d);
  int k=10000*y+100*m+d;
  puts(k<=20190430?"Heisei":"TBD");

}

int main(void){
  run();
  return 0;
}

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

using namespace std;


bool prime (int n){

    for(int i=2;i*i<=n;i++){
        if(n%i==0)  return false;
    }

    return true;
}


int main() {

   int n,m;
   cin>>n>>m;

   if(n==m)cout<<"Draw"<<endl;
   else if(n==1)cout<<"Alice"<<endl;
   else if(m==1)cout<<"Bob"<<endl;
   else if (n>m)cout<<"Alice"<<endl;
   else cout<<"Bob"<<endl;

    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll N, K;

double prob(ll init){
  ll val = init;
  double ans = 1.0;

  while(val < K){
    val *= 2;
    ans *= 0.5;
  }

  return ans;
}

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

  double ans = 0.0;

  rep2(i, 1, N + 1) ans += prob(i);

  ans /= (double)N;

  cout << setprecision(15) << fixed << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>


int main(){
  char calc[6];
  int stack[101];
  int top=0;
  while(scanf("%s",calc)!=EOF){
    switch(calc[0]){
    case '+':
      stack[top-1]+=stack[top];
      --top;
      break;
  
    case '-':
      stack[top-1]-=stack[top];
      --top;
      break;

    case '*':
      stack[top-1]*=stack[top];
      --top;
      break;
      
    default:
      top++;
      stack[top]=atoi(calc);

    }
  }
    printf("%d\n",stack[1]);
      return 0;
}

Measured memory_bytes: 548
#include<iostream>
#include<algorithm>

using namespace std;
#define debug(n) cerr << #n << ':' << n << endl;
#define ll long long

int main(){
  ll n;cin >> n;
  ll sum=0,cntm=0,minn=1e+9;
  for(ll i = 0; i < n; ++i){
    ll x; cin >> x;
    if(x < 0)cntm++;
    x = abs(x);
    sum += x;
    minn = minn > x ? x : minn;
  }
  debug(sum);
  debug(cntm);
  debug(minn);
  ll ans = cntm % 2 ? sum- minn*2:sum;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a,n,k,count,m,answer,index;
		Map <Integer,Integer> mapA= new TreeMap<Integer,Integer>();
		float ans;
		String s,t;
		
			// 整数の入力
		
		n = sc.nextInt();
		count=0;
		
		for(index=0;index<n;index++) {
			a = sc.nextInt();
			mapA.put(a, index);
		}
		sc.close();

		for(Integer a2 : mapA.keySet()) {
			index = mapA.get(a2);
			System.out.print(index+1);
			System.out.print(" ");
		}

			// 出力
 
	}
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	int a,b,c;
	cin>>a>>b>>c;
	int p=0,q=0;
	if(a==5) p++;else if(a==7) q++;
	if(b==5) p++;else if(b==7) q++;
	if(c==5) p++;else if(c==7) q++;
	if(p==2&&q==1) cout<<"YES\n"; else cout<<"NO\n";
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



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

int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  for(int i=1;i<n;i++){
    if(s[i-1][s[i-1].size()-1]!=s[i][0]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i!=j&&s[i]==s[j]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    
    public static void main(String [] args){
        Scanner in=new Scanner(System.in);
        int[]x=new int [3];
        for(int i=0;i<x.length;i++){
            x[i]=in.nextInt();
        }
        Arrays.sort(x);
        System.out.println(x[0]+" "+x[1]+" "+x[2]);
        in.close();

    }    
}


Measured memory_bytes: 26292
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    ll a,b,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << '\n';
    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}
const ll inf = 1LL<<60;



int main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  string s;cin>>s;
  ll mod = pow(10,9)+7;
  vector<vector<ll>> dp(s.size()+1,vector<ll>(13,0));
  dp[0][0]=1;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<13;j++){
      if(s[i]=='?'){
        for(int k=0;k<10;k++){
          dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%mod;
        }
      }else{
        int k=s[i]-'0';
        dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%mod;
      }
    }
  }
  cout<<dp[s.size()][5]%mod<<endl;

}


Measured memory_bytes: 16648
n,a,b = map(int, input().split())

t = n%(a+b)

if n < a:
    print(n)
else:
    if a > t > 0:
        print(n//(a+b)*a+t)
    elif t >= a:
        print(n//(a+b)*a+a)
    else:
        print(n//(a+b)*a)

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

using namespace std;

struct SegmentTree {
  const int INF = numeric_limits<int>::max();
  int n;
  vector<int> node;
  vector<int> snode;

  SegmentTree(vector<int> v) {
    int sz = (int)v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, INF);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; 0 <= i; i--)
      node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
  }

  SegmentTree(vector<int> v, int x) {
    int sz = (int)v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, x);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; 0 <= i; i--)
      node[i] = node[i * 2 + 1] + node[i * 2 + 2];
  }

  SegmentTree(string s) {
    int sz = s.size();
    n = 1;
    while (n < sz) n *= 2;
    snode.resize(2 * n - 1, 0);
    for (int i = 0; i < sz; i++) {
      snode[i + n - 1] |= 1 << (s[i] - 'a');
    }
    for (int i = n - 2; 0 <= i; i--) {
      snode[i] = (snode[i * 2 + 1] | snode[i * 2 + 2]);
    }
  }

  // x番目の要素をvalに更新する
  void update(int x, int val) {
    x += (n - 1);
    node[x] = val;
    while (x > 0) {
      x = (x - 1) / 2;
      node[x] = min(node[2 * x + 1], node[2 * x + 2]);
    }
  }

  // 区間[a, b)の要素の最小値を返す. k := 自分がいるノードのインデックス
  int getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return node[k];

    int vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
    int vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(vl, vr);
  }

  void add(int k, int val) {
    k += (n - 1);
    node[k] += val;
    while (k > 0) {
      k = (k - 1) / 2;
      node[k] = node[2 * k + 1] + node[2 * k + 2];
    }
  }

  int getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return node[k];

    int vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
    int vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
    return vl + vr;
  }

  // x番目の要素をvalに変更する
  void change(int x, char val) {
    x += (n - 1);
    snode[x] = 1 << (val - 'a');
    while (x > 0) {
      x = (x - 1) / 2;
      snode[x] = snode[x * 2 + 1] | snode[x * 2 + 2];
    }
  }
  int getkinds(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return snode[k];

    int vl = getkinds(a, b, 2 * k + 1, l, (l + r) / 2);
    int vr = getkinds(a, b, 2 * k + 2, (l + r) / 2, r);
    return (vl | vr);
  }
};

int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;
  SegmentTree seg(s);
  while (q--) {
    int com;
    cin >> com;
    if (com == 1) {
      int i;
      char c;
      cin >> i >> c;
      i--;
      seg.change(i, c);

    } else {
      int l, r;
      cin >> l >> r;
      l--, r--;
      int ret = seg.getkinds(l, r + 1);
      int res = 0;
      for (int i = 0; i < 26; i++) {
        if (ret >> i & 1) res++;
      }
      cout << res << endl;
    }
  }

  return 0;
}

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


int main() {

    string s; cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#include <set>
using namespace std;
int a[105][105],b[10050];
int main ()
{
    int h,w;
    while(scanf("%d %d",&h,&w)!=EOF)
    {
        int i,j,t,k=0;
        cin>>t;
        for(i=0;i<t;i++)
            scanf("%d",&b[i]);
        for(i=0;i<h;i++)
        {
            if(i%2==0)
                for(j=0;j<w;j++)
                {
                    a[i][j]=k+1;
                    b[k]--;
                    if(b[k]==0)
                        k++;
                }
            if(i%2==1)
                for(j=w-1;j>=0;j--)
                {
                    a[i][j]=k+1;
                    b[k]--;
                    if(b[k]==0)
                        k++;
                }
        }
        for(i=0;i<h;i++)
        {
            for(j=0;j<w-1;j++)
                printf("%d ",a[i][j]);
            printf("%d\n",a[i][w-1]);
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define llu unsigned long long int
#define ll long long
#define ld long double
#define foi(a, n) for (int i = a; i < n; i++)
#define foj(a, n) for (int j = a; j < n; j++)
#define foin(a, n) for (int i = n; i >= a; i--)
#define fojn(a, n) for (int j = n; j >= a; j--)
#define isp2(x) x && (!(x & (x - 1)))
#define ee 1000000007
#define fio                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)
#define cases                                                                  \
  long long t;                                                                 \
  cin >> t;                                                                    \
  while (t--)

using namespace std;

int main() {
  ll n;
  cin >> n;
  cout << (n * n * n) << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flag = true;
    rep(i, n / 2){
        if (s[i] != s[n - i - 1]) flag = false;
    }
    int k = (n - 1) / 2;

    rep(i, k){
        if (s[i] != s[k - i - 1]) flag = false;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc
 
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
 
        //input
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(n*n*n);
        //System.out.println(String.format("%.0f",answer));
    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()

int main()
{
    int n, d;
    cin >> n >> d;
    int x[n][d];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            ll count = 0;
            for (int k = 0; k < d; k++)
            {
                count += abs(x[i][k] - x[j][k])*abs(x[i][k] - x[j][k]);
            }
            int a = sqrt(count);
            double b = sqrt(count);
            if (a == b)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll cnt;
ll a[200010];
ll ch;
int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]-a[i-1]<=1){
        ch++;
        }
    }
    if(a[0]==0&&ch==n)
    {
        for(int i=0; i<n; i++)
        {
            if(a[i-1]<a[i]){
            cnt+=abs(a[i]-a[i-1]);
            }else{
            cnt+=a[i];
            }
        }
        cout<<cnt;
    }
    else
    {
        cout<<-1;
    }
}


Measured memory_bytes: 1792
from itertools import accumulate
from bisect import bisect_right

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

accA = list(accumulate(A, initial=0))
accB = list(accumulate(B, initial=0))

ans = 0
for c, a in enumerate(accA):
    if K - a < 0:
        continue
    ans = max(ans, c + bisect_right(accB, K - a) - 1)
print(ans)


Measured memory_bytes: 47476
n,c=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
L=[[0 for i in range(10**5+1)] for i in range(c)]
for i in range(n):
  for j in range(l[i][0],l[i][1]+1):
    L[l[i][2]-1][j]=1
ans=[]
for i in range(10**5+1):
  ct=0
  for j in range(c):
    ct+=L[j][i]
    ans.append(ct)
print(max(ans))

Measured memory_bytes: 187764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mo = 1e9 + 7;
const int MAXM = 2e5 + 10;
inline ll fpm(ll a, ll b = mo - 2)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1) ans = ans * a % mo;
        a = a * a % mo;
        b >>= 1;
    }
    return ans;
}
const ll inv2 = fpm(2);
ll fact[MAXM], invfac[MAXM];
#define sum(x) ((x)*(x+1)%mo*inv2%mo)
template <class T>
inline void _read(T &x)
{
    x = 0;
    char t = getchar();
    while (!isdigit(t) && t != '-') t = getchar();
    if (t == '-')
    {
        _read(x);
        x *= -1;
        return ;
    }
    while (isdigit(t))
    {
        x = x * 10 + t - '0';
        t = getchar();
    }
}
inline void pre()
{
    fact[0] = invfac[0] = 1;
    fact[1] = invfac[1] = 1;
    for(int i = 2; i < MAXM; ++i) fact[i] = 1ll * i * fact[i - 1] % mo, invfac[i] = fpm(fact[i]);
}
inline ll C(ll n, ll r)
{
    if(n < r || r < 0 || n < 0) return 0;
    return fact[n] * invfac[r] % mo * invfac[n - r] % mo;
}
ll n, m, k;
int main()
{
	pre();
	_read(n), _read(m), _read(k);
	ll ans = 0;
	for (ll i = 0; i < n; ++i)
	{
		for (ll j = 0; j < m; ++j)
		{
			ans = (ans + ((sum(i) + sum(n - i - 1)) % mo) * m % mo) % mo;
			ans = (ans + ((sum(j) + sum(m - j - 1)) % mo) * n % mo) % mo;
		}
	}
	ans = ans * C(n * m - 2, k - 2) % mo * inv2 % mo;
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

template<typename Monoid>
struct SegmentTree{
  using F = function<Monoid(Monoid, Monoid)>;

  int sz;
  vector<Monoid> seg;

  const F f;
  const Monoid M1;
  /* 
   * int n: size
   * const F f: binary operation
   * const Monoid &M1: initial element
   * 
   * example
   * Range Minimun Query: SegmentTree<int> seg(n, [](int a, int b){return min(a, b);}, INT_MAX);
   * Range Max Query: SegmentTree<int> seg(n, [](int a, int b){return max(a, b);}, 0);
   */
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) { // set x to k-th element
    seg[k + sz] = x;
  }

  void build() { // build up the tree
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) { // update k-th element to x
    k += sz;
    seg[k] = x;
    while(k >> 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) { // get result of [a, b)
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>=1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const { // return k-th element
    return seg[k + sz];
  }
};

map<int, int> m;

ll solve(SegmentTree<ll> &st, int l, int r, int i, int x) {
  if(r - l == 1) return st.query(l, r);
  if(r - l == 0) return 0;
  ll Ll = l, Lr = r;
  ll ans = (i - Ll + 1) * (Lr - i) * x;
  int tmp = st.query(i+1, r);
  ans += solve(st, i+1, r, m[tmp], tmp);
  tmp = st.query(l, i);
  ans += solve(st, l, i, m[tmp], tmp);
  return ans;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  SegmentTree<ll> st(n, [](ll a, ll b){return min(a, b);}, INT_MAX);
  
  REP(i, n) {
    ll tmp; cin >> tmp;
    m[tmp] = i;
    st.set(i, tmp);
  }
  st.build();

  int tmp = st.query(0, n);
  cout << solve(st, 0, n, m[tmp], tmp) << endl;
}


Measured memory_bytes: 66816
s, k = input(), int(input())
r = 0
f = True
fir = 0
las = 0

for i in range(len(s)):
    if s[i] == s[0]:
        fir += 1
    else:
        break

for i in range(len(s) - 1, -1, -1):
    if s[i] == s[0]:
        las += 1
    else:
        break

i = 1
tmp = 1
while i < len(s):
    if s[i] == s[i - 1]:
        tmp += 1
    else:
        f = False
        r += tmp // 2
        tmp = 1
    i += 1
r += tmp // 2

if f:
    print(len(s) * k // 2)
else:
    print(r * k - (k - 1) * (fir // 2 + las // 2 - (fir + las) // 2))


Measured memory_bytes: 38384
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define LL long long
using namespace std;
char s1[200005],s2[200005];
int a1,a2,vst1[27],vst2[27],cnt1,cnt2;
int len;
int main()
{
	scanf("%s %s",s1+1,s2+1);
	if(strlen(s1+1)!=strlen(s2+1)){puts("No");return 0;}
	int len=strlen(s1+1);
	for(int i=1;i<=len;i++)
	{
		if(!vst1[s1[i]-'a'+1])vst1[s1[i]-'a'+1]=++cnt1;
		a1=vst1[s1[i]-'a'+1];
		if(!vst2[s2[i]-'a'+1])vst2[s2[i]-'a'+1]=++cnt2;
		a2=vst2[s2[i]-'a'+1];
		if(a1!=a2){puts("No");return 0;}
	}
	puts("Yes");
	return 0;
}



Measured memory_bytes: 640
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 110;
ll n, W;

ll w[N] , v[N];
ll dp[N][100005];

ll go(ll i , ll weight)
{
	if(i > n)
		return 0;
	ll &ans = dp[i][weight];
	if(ans != -1)
		return ans;
	if(weight + w[i] <= W)
		ans = max( go(i+1 , weight) , v[i] + go(i+1 , weight + w[i]) );
	else
		ans = go( i+1 , weight );

	return ans;
}

signed main()
{
	fast;
	memset(dp , -1 , sizeof dp);
////////////////////////////////////////////////////////////////////////////////////////////
	cin >> n >> W;
	rep(i,1,n+1)
		cin >> w[i] >> v[i];

	cout<<go(1 , 0)<<endl;

////////////////////////////////////////////////////////////////////////////////////////////

	
	return 0;
}


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

static const int TOTAL = 0;
static const int RIGHT = 1;
static const int ACUTE = 2;
static const int OBTUSE = 3;

bool isTriangle(int *ary) {	return ary[0] < ary[1] + ary[2]; }

void sort(int *ary, int n) {
	for (int i = n - 1; i > 0; i--) {
		for (int j = 0; j < i; j++) {
			if (ary[j] < ary[j + 1]) {
				swap(ary[j], ary[j + 1]);
			}
		}
	}
}

void judgeAndSet(int *ary,int *count) {
	int d = ary[1] * ary[1] + ary[2] * ary[2] - ary[0] * ary[0];
	if (d == 0) count[RIGHT]++;
	else if (d > 0) count[ACUTE]++;
	else count[OBTUSE]++;
	count[TOTAL]++;
}


int main() {
	int ary[3];
	int count[4] = { 0,0,0,0 };
	int num = 0;
	while (true) {
		cin >> ary[0] >> ary[1] >> ary[2];
		sort(ary, 3);
		if (!isTriangle(ary)) break;
		judgeAndSet(ary, count);
	}

	for (int i = 0; i < 4; i++) {
		if (i) cout << " ";
		cout << count[i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3088
using System;
using System.Linq;

namespace abc147_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string r = string.Concat(s.Reverse());

            int change = 0;
            for (int i = 0; i < s.Length / 2; i++)
            {

                if (s[i] != r[i])
                {
                    change++;
                }

            }
            Console.WriteLine(change);
        }
    }
}

Measured memory_bytes: 13268
// IOI 2021
 
#include <bits/stdc++.h>

using namespace std;

#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5, LG = 61;

int X[N], Y[N], PAR[LG][N];

int GetPar(int v, ll h) {
	for (int i = 0; i < LG; i++) if ((1LL << i) & h) v = PAR[i][v];
	return v;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> X[i];
	for (int i = 0; i < n - 1; i++) Y[i] = X[i + 1] - X[i], PAR[0][i] = i;
	int m; cin >> m;
	ll k; cin >> k;
	for (int i = 0; i < m; i++) {
		int a; cin >> a; a--;
		swap(Y[a - 1], Y[a]);
		swap(PAR[0][a - 1], PAR[0][a]);
	}
	for (int pw = 1; pw < LG; pw++) for (int i = 0; i < n - 1; i++) PAR[pw][i] = PAR[pw - 1][PAR[pw - 1][i]];
	ll last = X[0];
	for (int i = 0; i < n - 1; i++) {
		cout << last << endl;
		int p = GetPar(i, k);
		last += X[p + 1] - X[p];
	}
	cout << last << endl;

	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll cnt = n / (a + b);
  ll res = n % (a + b);
  ll ans = a * (cnt) + min(a, res);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
S=[input()[0] for _ in range(N)]
C=[S.count(c) for c in "MARCH"]
print(C[0]*C[1]*C[2]+C[0]*C[1]*C[3]+C[0]*C[1]*C[4]+C[0]*C[2]*C[3]+C[0]*C[2]*C[4]+C[0]*C[3]*C[4]+C[1]*C[2]*C[3]+C[1]*C[2]*C[4]+C[1]*C[3]*C[4]+C[2]*C[3]*C[4])


Measured memory_bytes: 3924
def gcd(x, y):
  while(y): 
       x, y = y, x % y   
  return x 

def solve():
  n = int(raw_input())
  a = map(int, raw_input().split())
  left = [0] * (n + 1)
  right = [0] * (n + 1)
  for i in range(1,n + 1):
    left[i] = gcd(left[i - 1], a[i - 1])
  for i in range(n - 1, 0, -1):
    right[i] = gcd(right[i + 1], a[i])
  max_gcd = 0
  for i in range(n):
    max_gcd = max(max_gcd, gcd(left[i], right[i + 1]))
  print max_gcd
        
if __name__ == '__main__':
    solve()

Measured memory_bytes: 12964
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

int main(void) {
    long long int x;
    long long int p,q;
    
    cin>>x;
    p=x%100;
    q=x/100;

    if(q*5>=p){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }

}


Measured memory_bytes: 384
import math
n,d=map(int,input().split())
a=[0]*n
for i in range(n):
  a[i]=list(map(int,input().split()))
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    chklen=0
    wk=0
    for k in range(d):
      wk+=abs(a[i][k]-a[j][k])**2
    chklen=math.sqrt(wk)
    if chklen==chklen//1:
      ans+=1
print(ans)

Measured memory_bytes: 3064
n, k = map(int, input().split())
h = [int(_) for _ in input().split()]

inf = 10**10
dp = [inf]*n

dp[0] = 0

for i in range(n):
    for j in range(i+1, min(n, i+k+1)):
        dp[j] = min(dp[j], dp[i]+abs(h[i]-h[j]))

print(dp[n-1])


Measured memory_bytes: 52464
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll W, a, b;
  cin >> W >> a >> b;
  ll mi = min(a, b);
  ll ma = max(a, b);
  ll ans = max(0ll, ma - (W + mi));
  ANS;
  return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);
typedef pair<int, int> pii;

map<pii, int> a;

void ass(bool ex) {
    if (!ex) {
        cout << -1 << '\n';
        exit(0);
    }
}

pii operator+(pii a, pii b) {
    return pii{a.first + b.first, a.second + b.second};
}

pii operator-(pii a, pii b) {
    return pii{a.first - b.first, a.second - b.second};
}

pii nx(pii a) {
    return a + pii{1, -1};
}

int main() {
    #ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    int d;
    forn (i, n) {
        int x, y;
        cin >> x >> y;
        if (i == 0) {
            ass(x == 0);
            d = y;
        }
        if (i == 1)
            ass(y == 0 && d == x);
        ass(x + y >= d);
        ass(x >= 0 && y >= 0);
        if (i != 0)
            ass(x != 0);
        if (i != 1)
            ass(y != 0);
        a[pii(x, y)]++;
    }
    for (auto p: a) {
        auto c = p.first;
        if (c.second != 0)
            ass(a.count(c + pii(0, -1)) || a.count(c + pii(-1, -1)) || a.count(c + pii(1, -1)));
        if (c.first != 0)
            ass(a.count(c + pii(-1, 0)) || a.count(c + pii(-1, -1)) || a.count(c + pii(-1, 1)));
    }
    //cerr << "YES\n";
    vector<pair<pii, int>> v;
    for (auto A: a)
        v.push_back(A);
    sort(v.begin(), v.end(), [](pair<pii, int> a, pair<pii, int> b) {
                int sa = a.first.first + a.first.second;
                int sb = b.first.first + b.first.second;
                if (sa != sb)
                    return sa < sb;
                return a.first < b.first;
            });
    int res = 2 * n - 2;

    int carry = 0;
    forn (ii, sz(v)) {
        auto c = v[ii].first;
        int cnt = v[ii].second;
        carry = min(carry, cnt);
        if (a.count(c + pii{-1, -1})) {
            int k = cnt - carry;
            res -= k;
            cnt -= k;
        }
        res -= carry;
        if (ii + 1 < sz(v) && v[ii + 1].first == nx(c))
            carry = cnt;
        else
            carry = 0;
    }
    cout << res << '\n';
}


Measured memory_bytes: 8184
#include<stdio.h>
int main(void){
    int a,b;
    int d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %lf\n",d,r,f);
    return 0;
}

Measured memory_bytes: 636
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	long x = Long.parseLong(scan.next());

	long ans;
	long a = x / 11;
	if(a == 0) {
	    ans = (x > 6 ? 2 : 1);
	} else {
	    ans = 2 * a;
	    long b = x % 11;
	    if(b != 0) ans += (b > 6 ? 2 : 1);
	}
	
	System.out.println(ans);
	scan.close();
    }
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
#define INF 1000000000

int n, W;
ll V[120];
int Wt[120];
ll dp[100050];

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


  cin>>n>>W;
  for(int i=0; i<n; i++){
    int a, b;
    cin>>a>>b;
    Wt[i] = a;
    V[i] = b;
  }

  memset(dp, 0, sizeof(dp));

  for(int p=0; p<n; p++){
    for(int wt=W; wt>=0; wt--){
      if(wt-Wt[p]>=0)dp[wt] = max(dp[wt], V[p]+dp[wt-Wt[p]]);
    }
  }

  cout<<dp[W]<<"\n";

  return 0;
}


Measured memory_bytes: 4444