akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
#define LATTE 1000000000

int main(){
	char con1[32][9]={"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
	char S[200],con2[32];
	for(int i=0;i<26;i++) con2[i] = 'A'+i;
	con2[26]=' '; con2[27]='.'; con2[28]=','; con2[29]='-'; con2[30]='\'',con2[31]='?';
	while(true){
		int r,c;
		char cons[1000]={};
		for(int i=0;r=scanf("%c",&S[i]),S[i]!='\n';i++){
			if(r==EOF) return 0;
			if(S[i]==' ') c = 0;
			else if(S[i]=='\'') c = 1;
			else if(S[i]==',') c = 2;
			else if(S[i]=='-') c = 3;
			else if(S[i]=='.') c = 4;
			else if(S[i]=='?') c = 5;
			else c = S[i]-'A'+6;
			strcat(cons,con1[c]);
		}
		int len = strlen(cons);
		while(len%5!=0){
			cons[len]='0'; cons[++len]='\0';
		}
		for(int i=0;i<len;){
			int latte=0;
			for(int j=0;j<5;i++,j++){
				//printf("%c",cons[i]);
				latte = latte<<1;
				if(cons[i]=='1') latte += 1;
			}//printf(" ");
			printf("%c",con2[latte]);
		}puts("");
	}
	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<pair<ll,int>> apples;
  ll p;
  rep(_,a){
    cin >> p;
    apples.push_back(make_pair(p,1));
  }
  rep(_,b){
    cin >> p;
    apples.push_back(make_pair(p,2));
  }
  rep(_,c){
    cin >> p;
    apples.push_back(make_pair(p,0));
  }
  sort(all(apples));
  int r=0;
  int d=0;
  int w=0;
  int i = apples.size()-1;
  ll ans = 0;
  while(r+d+w < x+y){
    if(r == x){
      while(apples[i].sc == 1) i--;
      if(apples[i].sc == 0){
        w++;
      }else{
        d++;
      }
    }else if(d == y){
      while(apples[i].sc == 2) i--;
      if(apples[i].sc == 0){
        w++;
      }else{
        r++;
      }
    }else{
      if(apples[i].sc == 0){
        w++;
      }else if(apples[i].sc == 1){
        r++;
      }else if(apples[i].sc == 2){
        d++;
      }
    }
    ans += apples[i].fs;
    i--;
  }
  cout << ans << endl;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextInt();
        long a = sc.NextInt();
        long b = sc.NextInt();

        long answer = (b - a) * (n - 2) + 1;

        if (a > b)
        {
            answer = 0;
        }

        if (n == 1 && a != b)
        {
            answer = 0;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

typedef long long ll;
const int MAXN=1e5+5;
int n,x,a[MAXN];

int main(){
    scanf("%d%d",&n,&x);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    ll ans=0,sum,res;
    for(int i=1;i<n;i++){
        sum=a[i]+a[i-1];
        res=max(sum-x,0ll);
        ans+=res;a[i]=max(a[i]-res,0ll);
    }
    printf("%lld\n",ans);
}

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

int main(void){
    int N,A,B;
    cin>>N>>A>>B;
    
    if(abs(A-B)==1){
        cout<<"Borys"<<endl;
        return 0;
    }
    
    bool turn=true;
    while(A>0&&B>0&&A<=N&&B<=N){
        if(turn){
            if(A-B>1)A--;
            else if(A-B<-1)A++;
            else{
                if(A>B)A++;
                else A--;
            }
            turn=false;
        }else{
            if(B-A>1)B--;
            else if(B-A<-1)B++;
            else{
                if(B>A)B++;
                else B--;
            }
            turn=true;
        }
        
    }
    
    if(A==0||A>N)cout<<"Borys"<<endl;
    else cout<<"Alice"<<endl;
}

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

int dp[10000000];
int main()
{
    int n;
    cin >> n;
    int inp[n+10];

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

    memset(dp,1000000,sizeof dp);

    dp[0]=0;

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<i+3;j++)
        {

            if(j<n)
            {
                dp[j]=min(dp[j],dp[i]+abs(inp[i]-inp[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 39680
#include<iostream>
using namespace std;
int main()
{const int size=2e+5;
int a[size],b[size];
int n;
cin>>n;

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

for(int i=n-1,j=0,k=n-1;i>-1;i--)
{
	
	
	b[j++]=a[i--];
	
	if(i<0)
	break;
	
	b[k--]=a[i];

}


for(int i=0;i<n;i++)
{cout<<b[i]<<" ";
}
return 0;
 } 

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

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

using ll = long long;

const ll INF=1LL<<60;

ll dp[410][410];
bool memo[410][410];
ll s[410][410];
bool memos[410][410];

ll f(const vector<ll> &v,int x, int y){
  if(memo[x][y]) return dp[x][y];
  memo[x][y] = true;
  if(!memos[x][y]) {
    memos[x][y] = true;
    for(int i = x; i <=y; i++) {
      s[x][y]+=v.at(i);
    }
  }
  for(int i = x; i <= y-1; i++) {
    chmin(dp[x][y], f(v,x,i)+f(v,i+1,y)+s[x][y]);
  }
  return dp[x][y];
}

int main() {
  for ( int i = 0; i < 410; i++) {
    for (int j = 0; j < 410; j++) {
      dp[i][j] = INF;
    }
  }
  int N;
  cin >> N;
  vector<ll> v(N);
  for(int i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  for(int i = 0; i < N; i++) {
    memo[i][i]=true;
    dp[i][i]=0;
  }
  for(int i = 0; i < N-1; i++) {
    memo[i][i+1] =true;
    dp[i][i+1] = v.at(i) +v.at(i+1);
  }
  cout << f(v,0,N-1) << endl;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    int i;
    int n;
    long long int d;
    scanf("%d%lld", &n, &d);
    long long int *x = malloc(sizeof(long long int) * n);
    long long int *y = malloc(sizeof(long long int) * n);
    for (i = 0; i < n;i++){
        scanf("%lld%lld", &x[i], &y[i]);
    }
    long long int cnt = 0;

    long long int p;
    for (i = 0; i < n;i++){
        p = x[i] * x[i] + y[i] * y[i];
        if(p<=d*d){
            cnt++;
        }
    }
    printf("%lld", cnt);
    return 0;
}

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

int main(){
    int N, M;
    cin >> N;
    cin >> M;
    vector<int> A(N);
    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum += A[i];
    }
    int n_stan = 0;
    for(int i=0; i<N;i++){
        if(A[i]*4*M >= sum){
            n_stan++;
        }
        if(n_stan >= M){
            break;
        }
    }
    if(n_stan>=M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    string S;
    cin >> S;
    cout << S.at(0) << S.at(1) << S.at(2) << endl;
}

Measured memory_bytes: 3628
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S;
    cin >> S;

    ll ans = 0;
    REP(i, 3)
    {
        if (S[i] == '1')
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
def main():
    N = int(input())
    S = input()
    ch = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q","R","S", "T", "U", "V", "W", "X", "Y", "Z"]
    ans=""
    for i in S:
        #print(i)
        ind = ch.index(i)+N
        ans+= ch[ind%26]
    print(ans)


if __name__=="__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void draw_rect(int h,int w)
{
	rep(i,h)rep(j,w)
	{
		if(i==0 || i == h-1 || j == 0 || j == w-1)cout << '#';
		else cout << '.';
		if(j == w-1)cout << endl;
	}
	return;
}

void solve()
{
	vector<int> hs,ws;
	while (true)
	{
		int h, w; cin >> h >> w;
		if(!h && !w)break;
		hs.push_back(h);
		ws.push_back(w);
	}
	rep(i,sz(hs))
	{
		draw_rect(hs[i],ws[i]);
		cout << "\n";
	}
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



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

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

  int ans = 0;
  for ( int a = 0; a < n-2; a++ ) {
    for ( int b = a+1; b < n-1; b++ ) {
      for ( int c = b+1; c < n; c++ ) {
        if ( l[a] == l[b] || l[b] == l[c] || l[c] == l[a] ) { continue; }
        if ( l[a]+l[b] > l[c] && l[a]+l[c] > l[b] && l[b]+l[c] > l[a] ) { ans++; }
      }
    }
  }

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<int,int>
#define debug(a) cout<<a<<'\n'
#define maxn 309 /// Still trying to be gray
#define MOD 1000000007
#define rep(i, n) for(ll i = 0; i < (ll)(n); i ++)
#define rep1(i, n) for(ll i = 1; i <= (ll)(n); i ++)
#define per(i, n) for(ll i = (ll)(n)-1;i>=0;i--)
#define per1(i, n) for(ll i = (ll)(n);i>=1;i--)
using namespace std;
const ll INF = 1e17 + 9;
ll mat[maxn][maxn];
ll mat2[maxn][maxn];
int main(){

    ios::sync_with_stdio(false);
    // cin.tie(0);
    int n,m,l;
    cin>>n>>m>>l;
    rep(i,maxn){
        rep(j,maxn){
            mat[i][j]=INF;
            mat2[i][j]=INF;
        }
    }
    rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        --a;
        --b;
        mat[a][b]=c;
        mat[b][a]=c;
    }
    rep(k,maxn){
        rep(i,maxn){
            rep(j,maxn){
                mat[i][j]=min(mat[i][j],mat[i][k]+mat[k][j]);
                if(mat[i][j]<=l)mat2[i][j]=1;
            }
        }
    }
    rep(k,maxn){
        rep(i,maxn){
            rep(j,maxn){
                mat2[i][j]=min(mat2[i][j],mat2[i][k]+mat2[k][j]);
            }
        }
    }
    ll q;
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        --a,--b;
        if(mat2[a][b]<INF)cout<<mat2[a][b]-1<<'\n';
        else cout<<-1<<'\n';
    }
    return 0;
}           



Measured memory_bytes: 2048
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

V<ll> a(3001);
V<V<ll>> dp(3001, V<ll>(3001));

V<V<ll>> vs(3001, V<ll>(3001,0));

ll rec(int l,int r,int k){
	if (vs[l][r]) return dp[l][r];
	if (l==r){
		return (k==0?1:-1)*a[l];
	}
	if (k == 0) {
		vs[l][r] = 1;
		dp[l][r] = max(rec(l, l, k) + rec(l + 1, r, k + 1), rec(l, r - 1, k+1) + rec(r, r, k));
		return dp[l][r];
	}
	if (k == 1) {
		vs[l][r] = 1;
		dp[l][r] = min(rec(l, l, k) + rec(l + 1, r, k - 1), rec(l, r - 1, k - 1) + rec(r, r, k));
		return dp[l][r];
	}
}

int main() {
	int N; cin >> N;
	REP(i, N) cin >> a[i];
	cout << rec(0, N - 1, 0) << endl;
	return 0;
}

Measured memory_bytes: 141440
using System;



public class Test
{

	
	public static void Main()
	{
		string line;
        line = Console.ReadLine();
		
		
	
		while(line.Contains("erase")){
			if(line.Contains("eraser")){
				line = line.Replace("eraser", " ");
			} else if(line.Contains("erase")) {
			line = line.Replace("erase", " ");
			}
		}
		
		while(line.Contains("dream")){
			if(line.Contains("dreamer")){
			 	line = line.Replace("dreamer", " ");
			} else if(line.Contains("dream")){
				line = line.Replace("dream", " ");
			}
		}
	
		line = line.Replace(" ", "");
		if (line.Equals(""))
		{
    		Console.WriteLine("YES");
		} else {
			Console.WriteLine("NO");
		}
	} 
	
	
}

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

typedef long long ll;

int main(){

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

    int n;
    cin>>n;
    ll A,B,C=0;
    cin>>A>>B;
    for(int i=3;i<=n;i++){
        ll tmp;
        cin>>tmp;
        C^=tmp;
    }
    ll D=A+B-C>>1;
    if(A+B-C&1||D<0||D>A||D&C){
        cout<<"-1\n";
        return 0;
    }
    ll a=D;
    for(int i=60;i>=0;i--){
        if(C>>i&1&&D>>i&1^1&&(a|1ll<<i)<=A){
            a|=1ll<<i;
        }
    }
    if(a==0){
        cout<<"-1\n";
        return 0;
    }
    cout<<A-a<<endl;

    return 0;
}

Measured memory_bytes: 3652
N,M=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(M)]

EDGELIST=[[] for i in range(N+1)]

for x,y in EDGE:
    EDGELIST[x].append(y)
    EDGELIST[y].append(x)


import itertools

ITER=list(itertools.permutations(range(2,N+1),N-1))
ANS=0

for ite in ITER:
    ROUTE=(1,)+ite

    for j in range(1,N):
        if ROUTE[j] in EDGELIST[ROUTE[j-1]]:
            continue
        else:
            break
    else:
        ANS+=1

print(ANS)

Measured memory_bytes: 3572
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;


int main()
{
    int n, m;
    cin >> n >> m;
    int ansl = 0, ansr = inf;
    for(int i = 1; i <= m; i++){
        int l, r;
        cin >> l >> r;
        if(l >= ansl)
            ansl = l;
        if(r <= ansr)
            ansr = r;
    }
    cout << max(ansr-ansl+1,0) << endl;
    return 0;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

signed main(){
/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/
  int A, B, C, K;
  cin >> A >> B >> C;
  cin >> K;
  string res = "No";

  for (int i = 0; i < K; i++) {
    if (C <= B) C *= 2;
    else if (B <= A) B *= 2;

    if (C > B && B > A) {
      res = "Yes";
      break;
    }
  }

  cout << res << endl;
  return 0;
}

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

/*sortの仕方
 * ■ string s の場合
 * 昇順: sort(s.begin(), s.end())
 * 降順:  sort(s.rbegin(), s.rend())
 *
 * ■ int a[N] の場合
 * 昇順: sort(a, a+N)
 * 降順: 不明
 */

int alph2int(char character) {
    int x = character - 'a';
    return x;
}


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

    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        cout << A+B << endl;
    }
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

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

void Main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n+1, 0);
  rep(i, n-1) REP(j, i+1, n) {
    int cost = min(j-i, abs(x-i)+abs(y-j)+1);
    ans[cost]++;
  }
  REP(i, 1, n) cout << ans[i] << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
LL mp[100009];
vector<LL>v,cycle;
int main()
{
    LL n,x,m;
    cin>>n>>x>>m;
    while(true)
    {
        if(mp[x]==0)
            v.pb(x);
        mp[x]++;
        if(mp[x]>2)
            break;
        x=(x*x)%m;
        if(x<0)
            x+=m;
    }
//    cout<<v.size()<<endl;
    for(LL i=0; i<v.size(); i++)
    {
        if(mp[v[i]]>1)
            cycle.pb(v[i]);
    }
    LL ans=0;
    if(v.size()>n)
    {
        for(LL i=0; i<n; i++)
            ans+=v[i];
        cout<<ans;
        return 0;
    }
    for(LL i=0; i<v.size(); i++)
        ans+=v[i];
//        cout<<ans<<endl;
    n-=v.size();
    LL cycle_sum=0;
    for(LL i=0; i<cycle.size(); i++)
        cycle_sum+=cycle[i];
    ans+=(n/cycle.size())*cycle_sum;
    n=n%cycle.size();
    for(LL i=0; i<n; i++)
        ans+=cycle[i];
    cout<<ans;

}


Measured memory_bytes: 4988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string str;

int main()
{
    int i,ans=0;
    cin>>str;
    for(i=0;i<str.size();i++)
    {
        if(str[i]=='R')
        {
            int j=i;
            while(i<str.size() && str[i]=='R')i++;
            ans=max(ans,i-j);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3644
def is_prime(X):
    if X <= 1:
        return False
    else:
        for i in range(2, int(X**0.5) + 1):
            if X % i == 0:
                return False
        return True


X = int(input())
num = X

while True:
    if is_prime(num):
        print(num)
        exit()
    else:
        num += 1


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

int main() {
        int n,a,b;
        int p1;
        cin >> n >> a >> b;

        p1 = n * a;

        if(p1 < b){
        cout << p1 << endl;
        }else if(b < p1){
        cout << b << endl;
        }else{
        cout << b << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ref(i,n) for(int i=1;i<=n;i++)

int n,c[500][500],used[500][500];




void upd(int x,int y){
    if(x-1>=0&&c[x][y]+1-used[x][y]<c[x-1][y]) {c[x-1][y]=c[x][y]+1-used[x][y];upd(x-1,y);}
    if(y-1>=0&&c[x][y]+1-used[x][y]<c[x][y-1]) {c[x][y-1]=c[x][y]+1-used[x][y];upd(x,y-1);}
    if(y+1<n&&c[x][y]+1-used[x][y]<c[x][y+1]) {c[x][y+1]=c[x][y]+1-used[x][y];upd(x,y+1); }
    if(x+1<n&&c[x][y]+1-used[x][y]<c[x+1][y]) {c[x+1][y]=c[x][y]+1-used[x][y];upd(x+1,y); }
}

int main()
{
    cin>>n;

    int nn=pow(n,2);

    ref(i,nn) {

        int u=(i-1)%n,v=(i-1)/n;
        c[u][v]=min(min(u,n-1-u),min(v,n-1-v));

    }

    int ans=0;
    ref(i,nn){
        int y;
        cin>>y;


        int u=(y-1)%n,v=(y-1)/n;


        used[u][v]=1;
        ans+=c[u][v];
        upd(u,v);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 24708
_,*a=map(str.split,open(0))
U,R,D,L="URDL"
d={i:[]for i in"URDL"}
for *z, u in a:d[u]+=[*map(int, z)],
N=9e9
P,M="x+y,","x-y,"
for A,B,S in(U,D,"x,y,"),(R,L,"y,x,"),(R,U,P+M),(D,L,P+M),(U,L,M+P),(R,D,M+P):
 n=p=-9e9
 for x,y,r in sorted(eval(f"[({S}Q)for P,Q in[(A,1),(B,0)]for x,y in d[P]]")):
  if x!=n:
   if r:n,p=x,y
  elif r:p=y
  else:N=min(N,(y-p)*5)
print(["SAFE",N][N!=9e9])

Measured memory_bytes: 131096
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

string S;
int l,r;

int main(){
    cin>>S;
    rep(i,S.length()){
        if(S[i]=='A'){
            l=i;
            break;
        }
    }
    for(int i=S.length()-1;i>=0;i--){
        if(S[i]=='Z'){
            r=i;
            break;
        }
    }
    out(r-l+1);
}


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

#define ll long long

typedef pair< int, int > ii;
typedef vector< ii > vii;

void solve(){
	int n; cin>>n; 
	vector< ii > v;
	for(int i = 0; i<n; i++){
		int a; cin>>a;
		v.push_back(ii(a, i + 1));
	}
	sort(v.begin(), v.end());
	for(ii i : v){
		cout<<i.second<<" ";
	}
	cout<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}



Measured memory_bytes: 4260
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			char[] str = scan.nextLine().toCharArray();
			for(int i = 0; i < str.length;i++){
				if(Character.isLowerCase(str[i])){
					System.out.print(Character.toUpperCase(str[i]));
				}else if(Character.isUpperCase(str[i])){
					System.out.print(Character.toLowerCase(str[i]));
				}else
					System.out.print(str[i]);
			}
			System.out.println();
		}finally{
			if(scan !=null)scan.close();
		}
	}
}

Measured memory_bytes: 17252
def ncr(n,r,z):
  x=1
  y=1
  for i in range(min(r,n-r)):
    x=(x*(n-i))%z
    y=(y*(i+1))%z
  y=pow(y,z-2,z)
  return x*y%z

n,a,b=map(int,input().split())
mod=10**9+7
A=ncr(n,a,mod)
B=ncr(n,b,mod)
ans=pow(2,n,mod)-1-A-B
while ans<0:
  ans+=mod
print(ans)

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

int main(){
    int K,N;
    cin >>K>>N;
    int A[N];
    for (int i=0;i<N;i++) cin >>A[i];
    int M = -1000;
    for (int i=0;i<N;i++){
      if(i==0) M = max(K-(abs(A[i]-A[N-1])),M);
      else{
        M = max(abs(A[i]-A[i-1]),M);
      }
    }
    cout << K-M <<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int gcd(int x, int y){int r;while((r=x%y)!=0)x=y,y=r;return y;}

int main(void){

    long int n,m;
    scanf("%ld %ld",&n,&m);
    printf("%ld\n",(--m?--m:1)*(--n?--n:1));
}


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

using namespace std;

#define int long long
#define u64 unsigned long long
#define u32 unsigned int
#define reg register
#define Raed Read
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(reg int i=(G).Head[x]; i; i=(G).Nxt[i])

inline int Read() {
	int res = 0, f = 1;
	char c;
	while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
	do res = (res << 3) + (res << 1) + (c ^ 48);
	while (c = getchar(), c >= 48 && c <= 57);
	return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a < b ? a = b, 1 : 0;
}

const int N = 1e4+5,M = 2e5 + 5,mod = 99999997;

bool MOP1;

char S[15];

map<string,int>V;

bool MOP2;

inline void _main(void) {
	int n=Raed(),Ans=0;
	rep(i,1,n) {
		scanf("%s",S);
		sort(S,S+10);
//		cout<<S<<endl;
		Ans+=V[S],V[S]++;
	}
	cout<<Ans;
}

signed main() {
#define offline1
#ifdef offline
	freopen("truck.in", "r", stdin);
	freopen("truck.out", "w", stdout);
	_main();
	fclose(stdin);
	fclose(stdout);
#else
	_main();
#endif
	return 0;
}

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

int main()
{
    int n,l;

    cin>>n;

    if(n<=1000){
        l = 1000-n;
    }
    else{
        for(int i=2; ;i++){
            if(i*1000>=n){
                l = i*1000-n;
                break;
            }
        }
    }

    cout<<l<<endl;

    return 0;

}


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

typedef long long ll;
typedef vector<long long> vecll;
typedef vector<string> vecstr;

#define rep0(i, n) for(ll i=0; i<(ll)(n); i++)
#define rep1(i, n) for(ll i=1; i<=(ll)(n); i++)
#define rep(i, a, b) for(ll i=(ll)a; i<=(ll)(b); i++)
#define rep0r(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rep1r(i, n) for(ll i=(ll)(n); i>0; i--)
#define repr(i, a, b) for(ll i=(ll)b; i>=(ll)(a); i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / __gcd(a, b)
#define len(x) x.size()
#define Sort(x) sort(x.begin(), x.end())
#define rSort(x) sort(x.begin(), x.end(), greater<ll>())

const ll mod_const = 1000000007;

ll modpow(ll a, ll n, ll m) {
    ll result = 1;
    while(n > 0) {
        if(n&1) {
            result = result * a % m;
        }

    a = a * a % m;
    n >>= 1;
    }

    return result;
}

ll modinv(ll a, ll n) {
    if(a <= 1) {
        return 1;
    } else {
        return  n - modinv(n%a, n) * (n/a) % n;
    }
}

ll comb(ll n, ll r, ll m = mod_const) {
    vecll fac = {1, 1};
    vecll inv ={1, 1};
    vecll facinv = {1 , 1};

    rep(i, 2, n) {
        fac.push_back(fac[i-1] * i % m);
        inv.push_back(modinv(i, m));
        facinv.push_back(facinv[i-1] * inv[i] % m);
    }

    if (n<r || n<0 || r<0) {
        return 0;
    } else {
        return fac[n] * (facinv[r] * facinv[n-r] % m) % m;
    }
}
void solve() {
    int k;
    string s;
    cin >> k >> s;

    if(len(s) <= k) {
        cout << s << endl;
    } else {
        rep0(i, k) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
}


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

Measured memory_bytes: 3652
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
for i in range(n):
    if i > 0:
        if a[i-1] == 1 and a[i] > 0:
            ans += 1
            a[i] -= 1

    ans += a[i] // 2
    a[i] %= 2

print(ans)

Measured memory_bytes: 7072
from collections import deque, defaultdict
import sys


def input():
    return sys.stdin.readline().strip()


N, M = map(int, input().split())
graph = defaultdict(set)
for _ in range(M):
    A, B = map(lambda x: int(x) - 1, input().split())
    graph[A].add(B)
    graph[B].add(A)
if len(set(graph.keys())) != N:
    print('No')
    exit()

tokens = [-1] * N
tokens[0] = N
q = deque([0])
while q:
    v = q.popleft()
    for nv in graph[v]:
        if tokens[nv] < 0:
            tokens[nv] = v
            q.append(nv)

print('Yes')
[print(t + 1) for t in tokens[1:]]


Measured memory_bytes: 72768
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a, b;
    cin >> a >> b;

    if (a > 0) {
        cout << "Positive" << endl;
        return 0;
    }
    if (a == 0) {
        cout << "Zero" << endl;
        return 0;
    }
    if (a < 0 && b >= 0) {
        cout << "Zero" << endl;
        return 0;
    }

    if (abs(b - a + 1) % 2 == 0) {
        cout << "Positive" << endl;
    }
    else {
        cout << "Negative" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  map<ll,ll> memo;
  REP(i,1,N+1){
    memo[i%K]++;
  }

  ll ret = 0;
  rep(i,K){
    int j = (K-i)%K;
    if(i == j) ret += (ll)memo[i] * (ll)memo[i] * (ll)memo[i];
  }

  cout << ret << endl;
  
  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    b = abs(b - a);
    a = 0;
    REP(i,n-1){
        int32 x = i;
        int32 y = n - 1- i;
        if(c * x - d * y <= b && b <= d * x - c * y){
            YES(true);
            return 0;
        }
    }
    YES(false);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
flag = True
while(flag):
    flag = False
    A.sort()
    first = A[0]
    for index,i in enumerate(A):
        A[index] = i%first if i%first!=0 else first
    for i in A:
        if(first != i):
            flag = True
print(A[0])

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

using namespace std;
typedef long long int lli;
typedef pair<int,int> pii;

const int MAXN = 3010;
const int MOD = 998244353;

int n, s;

int v[MAXN];

lli ans;

lli dp[MAXN][2];
lli sumDp[MAXN][2];

void knapsack(int l, int r, int ind)
{
	for(int k = 0 ; k <= s ; k++)
	{
		dp[k][ind] = 0;
		sumDp[k][ind] = 0;
	}

	dp[0][ind] = 1;

	int c = ( l <= r ) ? 1 : -1;

	for(int i = l ; i != r + c ; i += c)
	{
		for(int k = s ; k >= v[i] ; k--)
		{
			dp[k][ind] += dp[ k - v[i] ][ind];
			dp[k][ind] %= MOD;
		}

		for(int k = 0 ; k <= s ; k++)
		{
			sumDp[k][ind] += dp[k][ind];
			sumDp[k][ind] %= MOD;
		}
	}
}

void DivAndConquer(int l, int r)
{
	if( l > r ) return;

	if( l == r )
	{
		if( v[l] == s ) ans++;
		return;
	}

	int mid = ( l + r )/2;

	DivAndConquer( l , mid );
	DivAndConquer( mid + 1 , r );

	knapsack( mid , l , 0 );
	knapsack( mid + 1 , r , 1 );

	for(int k = 0 ; k <= s ; k++)
	{
		ans += sumDp[k][0]*sumDp[s - k][1];
		ans %= MOD;
	}
}

int main()
{
	scanf("%d %d",&n,&s);

	for(int i = 1 ; i <= n ; i++)
		scanf("%d",&v[i]);

	DivAndConquer( 1 , n );

	printf("%lld\n",ans);
}

Measured memory_bytes: 384
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'

function main(input: string[]) {
  let [D, T, S] = input[0].split(' ').map( _ => parseInt(_))

  let ans = D <= T * S ? "Yes" : "No"
  console.log(ans)
}

let lines: string[] = [];
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', function (line: string) {
  lines.push(line);
});
reader.on('close', function () {
  main(lines)
});


Measured memory_bytes: 30072
// 解き直し.
// ARC094/ABC093解説
// https://img.atcoder.jp/arc094/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

int main() {

    // 1. 入力情報取得.
    int Q;
    scanf("%d", &Q);
    
    // 2. 各クエリに解答.
    // 解説通り.
    for(int i = 0; i < Q; i++){
        LL a, b;
        scanf("%llu %llu", &a, &b);
        if(a > b) swap(a, b);
        
        // 2-1. A = B の 場合.
        if(a == b){
            printf("%llu\n", 2 * a - 2);
            continue;
        }
        
        // 2-2. A + 1 = B の 場合.
        if(a + 1 == b){
            printf("%llu\n", 2 * a - 2);
            continue;
        }
        
        // 2-3. 上記以外 の 場合.
        if(a != b && a + 1 != b){
            LL c = sqrt(a * b);
            if(c * c == a * b) c--;
            
            // C * (C + 1) >= A * B の 場合.
            if(c * (c + 1) >= a * b){
                printf("%llu\n", 2 * c - 2);
                continue;
            }
            
            // C * C < A * B の 場合.
            if(c * c < a * b){
                printf("%llu\n", 2 * c - 1);
                continue;
            }
        }
    }
    
    // 3. 後処理.
    return 0;

}

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

int main() {
  int N,K;
  cin>>N>>K;
  int sum=1;
  for(int i=0;i<N;i++){
  	if(sum*2>=sum+K){
  		sum+=K;
  	}
  	else{
  		sum*=2;
  	}
  }
  cout<<sum<<endl;
}

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

int main(){

  int n;
  scanf("%d",&n);
  double v[n];
  for(int i=0;i<n;++i){
    scanf("%lf",&v[i]);
  }
  std::sort( v,v+n );
  double answer = 0.0;
  answer = (v[0]+v[1])/2;
  for(int i=2;i<n;++i){
    answer = (answer+v[i])/2;
  }
  printf("%f\n",answer);

  return 0;
}



Measured memory_bytes: 128
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 #include<bits/stdc++.h>
 #define int long long
 using namespace std;

vector<string> s;
void permute(string a, int l, int r)  
{
    if (l == r)  
    {
        s.push_back(a);
    }
    else
    {  
        for (int i = l; i <= r; i++)  
        {  
  
            swap(a[l], a[i]);  
  
            permute(a, l+1, r);  
  
            swap(a[l], a[i]);  
        }  
    }  
}  

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

    int n;
    cin>>n;
    string str="";
    for(int i=1;i<=n;i++)
    {
        str+=to_string(i);
    }

    permute(str,0,n-1);
    
    int x,y;
    pair<long double,long double>p[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        p[i]={x,y};
    }
    long double z=0;
    for(auto i:s)
    {
        for(int j=1;j<i.size();j++)
        {
            z+=(sqrt(pow(p[i[j]-'0'].first-p[i[j-1]-'0'].first,2)+pow(p[i[j]-'0'].second-p[i[j-1]-'0'].second,2)));
        }
    }

    for(int j=1;j<=n;j++)
    {
        z/=j;
    }
    cout<<fixed<<setprecision(8)<<z;
     clock_t clk;
 	clk = clock();
 
// -------------------------------------Code starts here--------------------------------------------------------------------- 
    

// -------------------------------------Code ends here------------------------------------------------------
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

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

int main(){
	long p, q;
	while(cin >> p >> q){
		long r[10000];
		int ans[10000];
		int now=1;
		
		bool flag=true;
		long start=-1, end=-1;
		
		r[0]=p;
		ans[0]=-1;
		
		while(flag){
			p*=10;
		
			long s=p/q;
			p=p%q;
			r[now]=p;
			ans[now]=s;
			//printf("s=%ld\n", s);
			now++;
			
			for(long i=0; i<now-1; ++i){
				if(r[i]==p){
					start=i;
					end=now;
					flag=false;
					break;	
				}
			}
			
			if(flag){	
				if(p==0){
					flag=false;
					break;
				}
			}		
		
		}
		
		for(long i=1; i<now; ++i) printf("%d", ans[i]);
		printf("\n");
		
		if(start!=-1){
			for(long i=1; i<=start; ++i) printf(" ");
			for(long i=start+1; i<end; ++i) printf("^");
			printf("\n");	
		}
		
		/*
		for(long i=0; i<now; ++i){
			printf("r[%ld]=%ld\n", i, r[i]);
		}
		*/
		
	}
}

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

int main(){
    string w,ans="";
    int n=0;
    map<string,int> s;
    while(cin>>w){
        s[w]++;
        n=max(n,s[w]);
        if(ans.size()<w.size()){ans=w;}
    }
    for(auto p=s.begin();p!=s.end();++p){
        if(p->second==n){cout<<p->first<<' ';}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3168
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n,k;
deque<char>q;
char calc(char c,bool inv){
	if(inv)return 'A'+'B'-c;
	else return c;
}
void show(deque<char>&q,bool inv){
	for(auto c:q)if(inv)putchar('A'+'B'-c);else putchar(c);putchar('\n');
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		char c;cin>>c;q.push_back(c);
	}
	if(k&1)k=min(k,4*n+1);
	else k=min(k,4*n);
	bool inv=0;
	while(k--){
		if(calc(q.front(),inv)=='A'){
			q.front()='A'+'B'-q.front();
		}else{
			inv^=1;q.push_back(q.front());q.pop_front();
		}
	}
	if(inv)for(char &c:q)c='A'+'B'-c;
	for(int i=0;i<n;i++)putchar(q[i]);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main(){
  int N;
  cin >> N;
  int h[N+1];
  for(int i = 1; i <= N; i++) cin >> h[i];
  int c[N+1];
  c[1] = 0;
  c[2] = c[1] + abs(h[2] - h[1]);
  for(int i = 3; i <= N; i++)
    c[i] = min(c[i-1] + abs(h[i-1] - h[i]),c[i-2] + abs(h[i-2] - h[i]));

  cout << c[N] << endl;
  return 0;
}

Measured memory_bytes: 1024
S = input()

def func(s, split_list):
#     print("Start:",s, split_list)
    l = len(s)
    if l == 0:
        result = 0
        for sl in split_list:
            result += int(sl)
        return result
    
    result = 0
    for i in range(1,l+1):
        result += func(s[i:], split_list[:]+[s[:i]])
#         print(result)
#     print("End:",s, split_list, result)
    return result
        
# func(S)
result = func(S,[])
print(result)

Measured memory_bytes: 3060
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
ls = []
for i in range(n-1):
    c, s, f = MAP()
    ls.append([c, s, f])
for i in range(n-1):
    ans = 0
    for j in range(i, n-1):
        ans = max(ans, ls[j][1])
        ans = ls[j][0] + ( ans + ls[j][2] - 1 )// ls[j][2] * ls[j][2]
    print(ans)
print(0)

Measured memory_bytes: 10304