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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;typedef pair<ll,ll> pii;
const int mod = (int)1e9 + 7;


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n,m;
	cin >>n >>m;
	
	ll ans=0;
	
	if(2*n <= m){
		ans = n; ll mm = m-2*n;
		ans += mm/4;
	}else{
		ll mn= min(n,m/2);
		ll mm = m - 2*mn;
		ans = mn;
		if(mm>0) ans += mm/4;
	}

	ans = min(ans, m/2);
	
	cout << ans <<endl;
	
	return 0;

}


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

using namespace std;

struct UnionFind{
  vector<int> parent;
  
  UnionFind(int n) : parent(n){
    for(int i = 0; i < n; i++) parent[i] = i;
  }
  
  int root(int x){
    if(parent[x] == x) return x;
    else return parent[x] = root(parent[x]);
  }
  
  void unite(int x, int y){
    int root_x = root(x);
    int root_y = root(y);
    if(root_x != root_y) parent[root_x] = root_y;
  }
  
  bool same(int x, int y){
    return root(x) == root(y);
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  
  int ans = 0;
  
  struct UnionFind tree(n);
  
  for(int j = 0; j < m; j++){
    int x, y, z;
    cin >> x >> y >> z;
    tree.unite(x - 1, y - 1);
  }
  
  for(int i = 0; i < n; i++) if(tree.parent[i] == i) ans++;
  
  cout << ans << '\n';
  
  return 0;
}

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

int main(){
	int N,h[100],m[100];
	int M,k[100],g[100];
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d %d",&h[i],&m[i]);
	scanf("%d",&M);
	for(int i=0;i<M;i++)scanf("%d %d",&k[i],&g[i]);
	vector<int> t;
	for(int i=0;i<N;i++) t.push_back(h[i]*60+m[i]);
	for(int i=0;i<M;i++) t.push_back(k[i]*60+g[i]);
	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());
	for(int i=0;i<t.size();i++){
		printf("%d:%02d",t[i]/60,t[i]%60);
		if(i!=t.size()-1)printf(" ");
	}
	printf("\n");
}

Measured memory_bytes: 1228
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=2010;
ll f[N];
int a[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,x;
    ll ans=1LL<<60;
    cin>>n>>x;
    for(int i=0;i<n;i++) a[i]=gi();
    for(int i=0;i<n;i++) {
	int s=a[i];f[0]+=s;
	for(int j=1;j<n;j++)
	    s=min(s,a[(i-j+n)%n]),f[j]+=s;
    }
    for(int i=0;i<n;i++) ans=min(ans,f[i]+1LL*i*x);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<int,pair<int,int> > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 3005
typedef long long int ll;
ll dp[N][N];
int main()
{
    int n,m,i,j,k;
    string s,t;
    inl(s);
    inl(t);
    n=s.size(),m=t.size();
    lp(i,1,n+1)
    {
        lp(j,1,m+1)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans;
    ans.resize(dp[n][m]);
    i=n,j=m,k=0;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
            ans[k++]=s[i-1],i--,j--;
        else
        {
            if(dp[i][j]==dp[i-1][j])
                i--;
            else
                j--;
        }
    }
    reverse(all(ans));
    outl(ans);
}


Measured memory_bytes: 70656
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

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

const ll mod = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//








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

        int mx = (N-1)*(N-2)/2;
        if (mx < K) {
                cout << -1 << endl;
                return 0;
        }

        vector<P> ans;
        for(int i = 1; i < N; i++)
        {
                ans.push_back({i,N});
        }
        
        int add = mx - K;

        vector<P> cnt;
        for(int i = 1; i < N; i++)
        {
                for(int j = 1; j < i; j++)
                {
                        cnt.push_back({i,j});
                }
        }

        for(int i = 0; i < add; i++)
        {
                ans.push_back(cnt[i]);
        }

        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i++)
        {
                cout << ans[i].first << " " << ans[i].second << endl;
        }
        return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int32_t main() 
{ 
    fastio
    int n;
    cin>>n;
    vector<ll> vec(n);
    for(auto& it : vec) cin>>it;
    vector<ll> pref(n);
    ll tot = 0;
    for(int i = 0; i<n; ++i) {
        tot ^= vec[i];
    }
    for(int i = 0; i<n; ++i) {
        cout<<(tot^vec[i])<<" ";
    }
    cout<<endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100000], b[100000];

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d%d", a + i, b + i);
    LL ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        int cur = (a[i] + ans) % b[i];
        if (cur != 0) {
            ans += b[i] - cur;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
# 2019/12/01
# 三井住友信託銀行プログラミングコンテスト2019 - A

# Input
m1, d1 = map(int,input().split())
m2, d2 = map(int,input().split())

# Calc
if m1 != m2:
    ans = 1
else:
    ans = 0

# Output
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define rint register int
#define gc() getchar()
inline int read(){int r=0,s=0,c=gc();for(;!isdigit(c);s=c,c=gc());for(;isdigit(c);(r*=10)+=c-48,c=gc());return s^45?r:-r;}
int f[16][32768], g[32768], w[16][16], n, E, Sum;
int main()
{
	n = read(), E = 1<<n; for(rint m = read(), a, b; m--; a = read()-1, b = read()-1, Sum += (w[a][b]=w[b][a]=read())); for(rint i = 0; i < n; fill(f[i],f[i]+E,-INF), i++);
	for(rint S = 1, T, i, j; S < E; S&1 ? f[0][S] = g[S] : 0, S++) for(g[S] = g[T=S-(S&-S)], i = ilogb(S&-S), j = 0; j < n; j++) if(T&1<<j) g[S] += w[i][j];
	for(rint S = 1, T, i, j; S < E; S++) for(T = ~-S&S; T; --T&=S) for(i = 0; i < n-1; i++) if((S^T)&1<<i&&f[i][S^T]>=0)
		for(j = 1; j < n; T&1<<j&&w[i][j] ? f[j][S] = max(f[j][S],f[i][S^T]+g[T]+w[i][j]) : 0, j++); printf("%d\n",Sum-f[~-n][~-E]); return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)((a).size()))
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    fori (i, SZ(a))
        out << a[i] << vector<string>{", ", "}"}[i + 1 == SZ(a)];
    return out;
}

void smain();

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


#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#define cerr cout
#else
#define cerr if (0) cerr
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\n";
    cout << "TOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}

const int N = 16;
const ll oo = 1e18;
ll dp[1 << N];
ll cost[1 << N];

int n;
ll a[N][N];

void smain() {



    cin >> n;
    fori (i, n) fori (j, n) cin >> a[i][j];

    for (int mask = 0; mask < (1 << n); ++mask) {
        for (int i = 0; i < n; ++i) if ((mask >> i) & 1) {
            for (int j = 0; j < i; ++j) if ((mask >> j) & 1) {
                cost[mask] += a[i][j];
            }
        }
    }

    fill(dp, dp + (1 << N), -oo);
    dp[0] = 0;
    for (int mask = 1; mask < (1 << n); ++mask) {
        for (int m2 = mask; ; m2 = (m2 - 1) & mask) {
            inmax(dp[mask], dp[m2 ^ mask] + cost[m2]);
            if (!m2) break;
        }
    }
    cout << dp[(1 << n) - 1];
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program {
    static void Main() {
        var N = NextInt();
        var A = new long[N];
        var B = new long[N];
        var ans = 0L;

        foreach (var i in Enumerable.Range(0, N)) {
            A[i] = NextInt();
            B[i] = NextInt();
        }

        for (var i = N - 1; i >= 0; i--) {
            A[i] += ans;
            if (A[i] % B[i] != 0) {
                ans += Math.Abs(A[i] % B[i] - B[i]);
            }
        }
        WriteLine(ans);
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

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

int N, M, A, B;
char result[1024][1024];

void init(void) {
	int i, j;
	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) result[i][j] = '.';
	}
}

void success(void) {
	int i;
	puts("YES");
	for (i = 0; i < N; i++) puts(result[i]);
	exit(0);
}

void try1(int mode) {
	int i, j, Aleft = A, Bleft = B;
	init();
	for (j = 0; j < M && Bleft > 0; j += 2) {
		for (i = 0; i + 1 < N && Bleft > 0; i += 2) {
			result[i][j] = '^';
			result[i + 1][j] = 'v';
			Bleft--;
			if (Bleft > 0 && j + 1 < M && result[i][j+1] == '.' && result[i + 1][j + 1] == '.' &&
			(M % 2 == mode || j > 0)) {
				result[i][j + 1] = '^';
				result[i + 1][j + 1] = 'v';
				Bleft--;
			}
		}
		if (M % 2 != mode && j == 0) j--;
	}
	if (Bleft > 0) return;
	for (i = 0; i < N && Aleft > 0; i++) {
		for (j = M - 2; j >= 0 && result[i][j] == '.' && Aleft > 0; j -= 2) {
			result[i][j] = '<';
			result[i][j + 1] = '>';
			Aleft--;
		}
	}
	if (Aleft > 0) return;
	success();
}

/*
(mode = 0)
3 3 2 2
*/
void try2(int mode) {
	int i, j, Aleft = A, Bleft = B;
	init();
	if (Bleft > 0 && N >= 2) {
		result[N - 2][M - 1] = '^';
		result[N - 1][M - 1] = 'v';
		Bleft--;
	}
	for (j = 0; j < M && Bleft > 0; j += 2) {
		for (i = 0; i + 1 < N && result[i][j] == '.' && result[i + 1][j] == '.' && Bleft > 0; i += 2) {
			result[i][j] = '^';
			result[i + 1][j] = 'v';
			Bleft--;
			if (Bleft > 0 && j + 1 < M && result[i][j+1] == '.' && result[i + 1][j + 1] == '.' &&
			(M % 2 == mode || j > 0)) {
				result[i][j + 1] = '^';
				result[i + 1][j + 1] = 'v';
				Bleft--;
			}
		}
		if (M % 2 != mode && j == 0) j--;
	}
	if (Bleft > 0) return;
	for (i = 0; i < N && Aleft > 0; i++) {
		for (j = result[i][M - 1] == '.' ? M - 2 : M - 3; j >= 0 && result[i][j] == '.' && Aleft > 0; j -= 2) {
			result[i][j] = '<';
			result[i][j + 1] = '>';
			Aleft--;
		}
	}
	if (Aleft > 0) return;
	success();
}

void try3(int mode) {
	int i, j, Aleft = A, Bleft = B;
	init();
	if (Aleft > 0 && M >= 2) {
		result[0][0] = '<';
		result[0][1] = '>';
		Aleft--;
	}
	for (j = 0; j < M && Bleft > 0; j += 2) {
		for (i = result[0][j] == '.' ? 0 : 1; i + 1 < N && result[i][j] == '.' && result[i + 1][j] == '.' && Bleft > 0; i += 2) {
			result[i][j] = '^';
			result[i + 1][j] = 'v';
			Bleft--;
			if (Bleft > 0 && j + 1 < M && result[i][j+1] == '.' && result[i + 1][j + 1] == '.' &&
			(M % 2 == mode || j > 0)) {
				result[i][j + 1] = '^';
				result[i + 1][j + 1] = 'v';
				Bleft--;
			}
		}
		if (M % 2 != mode && j == 0) j--;
	}
	if (Bleft > 0) return;
	for (i = 0; i < N && Aleft > 0; i++) {
		for (j = result[i][M - 1] == '.' ? M - 2 : M - 3; j >= 0 && result[i][j] == '.' && Aleft > 0; j -= 2) {
			result[i][j] = '<';
			result[i][j + 1] = '>';
			Aleft--;
		}
	}
	if (Aleft > 0) return;
	success();
}

int main(void) {
	if (scanf("%d%d%d%d", &N, &M, &A, &B) != 4) return 1;
	try1(0);
	try2(0);
	try3(0);
	try1(1);
	try2(1);
	try3(1);
	puts("NO");
	return 0;
}

/*
7 7 2 22

YES
^^^^^^^
vvvvvvv
^^^^^^^
vvvvvvv
^^^^^^^
vvvvvvv
..<><>v

invalid (overlap)

*/


Measured memory_bytes: 2176
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();
            if(N <= 111){
              System.out.println(111);
            } else if(N <= 222){
              System.out.println(222);
            } else if(N <= 333){
              System.out.println(333);
            } else if(N <= 444){
              System.out.println(444);
            } else if(N <= 555){
              System.out.println(555);
            } else if(N <= 666){
              System.out.println(666);
            } else if(N <= 777){
              System.out.println(777);
            } else if(N <= 888){
              System.out.println(888);
            } else {
              System.out.println(999);
            }
          }
}

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

long long sum,n;

void mysum(int i,long long dsum,const vector<int> num,long long temp){
  if(i == n-1){ 
    dsum += temp + num.at(i);
    sum += dsum;
  }
  else{
    temp += num.at(i);
    mysum(i+1,dsum+temp,num,0);
    
    temp*=10;
    mysum(i+1,dsum,num,temp);
  }
}
  

int main(){
  string s;
  cin >> s;
  n =s.size();
  sum = 0;
  
  vector<int> num(n);
  
  for(int i=0;i<n;i++){
    num.at(i) = s.at(i) - '0';
  }
  
  mysum(0,0,num,0);
  
  cout << sum << endl;
}


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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a > b ? a - b : b - a; }
template<class T> T &anth(T &a, const T &b){ return a = ant(a, b); }
template<class T> T &onth(T &a, const T &b){ return a = ont(a, b); }

int main(){
	int a, b, c;
	std::cin >> a >> b >> c;
	if(a == b && b == c){
		std::cout << "Yes" << std::endl;
	}else{
		std::cout << "No" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
chars = "abcdefghijklmnopqrstuvwxyz"
result = []

while N != 0:
    temp = N % 26

    result.append(chars[temp - 1])
    if temp == 0:
        N = N // 26 - 1
    else:
        N = N // 26

print("".join(reversed(result)))

Measured memory_bytes: 9172
using System;

class Program
{
    static void Main()
    {
        Console.ReadLine(); //１行目を無視
        var line = Console.ReadLine().Split(' ');
        for (var i = 0; i < (line.Length-1)-i; i++) SwapStrings(ref line[i], ref line[(line.Length-1) - i]);
        string str = string.Join(" ", line);
        foreach (var s in str) Console.Write(s);
        Console.WriteLine();
    }

    static void SwapStrings(ref string a, ref string b)
    {
        var tmp=a;
        a = b;
        b = tmp;
    }
}


Measured memory_bytes: 7764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToList();  //aのList
            var result = 0L; //踏み台の高さが足される

            var nowHeight = a[0];


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

                if (nowHeight <= a[i])
                {
                    //後ろのほうが高い時
                    nowHeight = a[i];
                    continue;
                }
                //前のほうが高い時、身長の差分、踏み台足す
                result += nowHeight - a[i];
            }


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 47752
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

int main()
{
	int n;
	int odd = 0;

	for (cin >> n; n--;)
	{
		int a;
		cin >> a;

		if (a % 2 == 1)
		{
			odd++;
		}
	}

	cout << (odd % 2 == 1 ? "NO" : "YES") << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  for (int i=0; i<N; i++) {
    cin >> num[i];
  }
  if (N % 2 == 0) {
    for (int i=0; i<N/2; i++) {
      cout << num[N-1-i*2] << ' ';
    }
    for (int i=0; i<N/2; i++) {
      cout << num[i*2] << ' ';
    }
  }
  if (N % 2 == 1) {
    for (int i=0; i<N/2+1; i++) {
      cout << num[N-1-i*2] << ' ';
    }
    for (int i=0; i<N/2; i++) {
      cout << num[i*2+1] << ' ';
    }
  }
  cout << endl;
}

Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Hashtable;
import java.math.*;
//https://vjudge.net/contest/159423#problem/B
public class Main {
	public static void main(String [] argv) throws Exception{
		// lucky: only contain digits 4, 7.
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		//0 to infinity
		//between time i-1 and time i, can stay, or jump i spots left or right
		int i, total = 0;
		for(i = 1; total < a; i++) {
			total += i;
		}
		System.out.println(i-1);
	} 
	
//	static int jump(int position, int goal, int time) {
//		
//
//	}

}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	string ans;
	rep(i, 0, ty - sy)ans += 'U';
	rep(i, 0, tx - sx)ans += 'R';
	rep(i, 0, ty - sy)ans += 'D';
	rep(i, 0, tx - sx + 1)ans += 'L';
	rep(i, 0, ty - sy + 1)ans += 'U';
	rep(i, 0, tx - sx + 1)ans += 'R';
	ans += 'D';
	ans += 'R';
	rep(i, 0, ty - sy + 1)ans += 'D';
	rep(i, 0, tx - sx + 1)ans += 'L';
	ans += 'U';

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
    int s[100],p,n,t;
    int i,j,sum;
 
    while(1){
        scanf("%d %d",&n,&p);
        if(n==0&&p==0){
            break;
        }
        t=p;
 
        for (i = 0; i < 100; i++)
            s[i] = 0;
        for(i=0;;i++){
            if(p==0){
                p=s[i%n];
                s[i%n]=0;
            }else{
                s[i%n]++;
                p--;
                if(p==0&&s[i%n]==t){
                    break;
                }
            }
        }
        printf("%d\n",i%n);
        s[i%n]=0;
    }
    return 0;
}

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

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (auto &v : vec)
    is >> v;
  return is;
}
#define all(x) (x).begin(), (x).end()
#define rep(i, N) for (int i = 0; i < (int)(N); i++)

void solve()
{
  int N;
  vector<int> D(3);
  cin >> N >> D;
  vector<string> s(N);
  cin >> s;

  vector<char> ans(N);
  rep(i, N)
  {
    int first = s[i][0] - 'A';
    int second = s[i][1] - 'A';
    if (D[first] == 0 and D[second] == 0)
    {
      cout << "No" << endl;
      return;
    }

    int rest = 0 + 1 + 2 - first - second;
    int greater, less;
    if (D[first] == 1 and D[second] == 1 and i + 1 < N)
      if (count(all(s[i + 1]), 'A' + first) == 1)
      {
        greater = second;
        less = first;
      }
      else
      {
        greater = first;
        less = second;
      }
    else if (D[first] >= D[second])
    {
      greater = first;
      less = second;
    }
    else
    {
      greater = second;
      less = first;
    }

    D[greater]--;
    D[less]++;
    ans[i] = 'A' + less;
  }
  cout << "Yes" << endl;
  rep(i, N) cout << ans[i] << endl;
}

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


Measured memory_bytes: 6424
#include <iostream>
#include <cstring>

using namespace std;

const long long int mod = (int)1e9 + 7;
string S;
long long int dp[(int)1e5 + 10][4];

void add(long long int &a, long long int b) {
    a += b;
    if (a >= mod) a -= mod;
}

int main() {
    cin >> S;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 0; i < S.size(); ++i) {
        for (int j = 0; j <= 3; ++j) {
            if (S[i] == '?') add(dp[i + 1][j], (dp[i][j] * 3) % mod);
            else add(dp[i + 1][j], dp[i][j]);
        }
        if (S[i] == 'A' || S[i] == '?') add(dp[i + 1][1], dp[i][0]);
        if (S[i] == 'B' || S[i] == '?') add(dp[i + 1][2], dp[i][1]);
        if (S[i] == 'C' || S[i] == '?') add(dp[i + 1][3], dp[i][2]);
    }

    cout << dp[S.size()][3] << endl;

    return 0;
}




Measured memory_bytes: 3584
from itertools import product

a,b,c,d = [int(i) for i in list(input())]

formula = ''
for x,y,z in product(('+','-'), repeat=3):
    formula = '{}{}{}{}{}{}{}'.format(a,x,b,y,c,z,d)
    if eval(formula) == 7:
        break

print('{}=7'.format(formula))


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


int main(){//main_program
  int a,b,c,N;
  string S;
  cin >> N >> S;
  
  if( S.size() <= N ){
    cout << S << endl;
  }else{
    for(int i = 0; i < N ; i++){
      cout << S.at(i); 
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <stack>

int main(int argc,char* argv[]){
  std::stack<int> vec;
  int temp;
  
  while(std::cin >> temp){
    if(temp == 0){
      int a = vec.top();
      std::cout << a << std::endl;
      vec.pop();
      continue;
    }else{
      vec.push(temp);
      continue;
    }
  }

  return 0;
  
}

Measured memory_bytes: 0
import numpy
H,W = map(int, input().split())
S = [list('#'+input()+"#") for i in range(H)]
S.insert(0, list('#'*(W+2)))
S.append(list('#'*(W+2)))
vector = [(1,0), (-1,0), (0,1), (0,-1)]
ans = 0
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=='.':
            Q = [(i,j)]
            distance = [[0]*(W+2) for i in range(H+2)]
            distance[i][j] = 1
            while Q!=[]:
                x,y = Q.pop(0)
                for k in vector:
                    x1,y1 = x+k[0],y+k[1]
                    if S[x1][y1]=='.' and distance[x1][y1]==0:
                        Q.append((x1,y1))
                        distance[x1][y1] = distance[x][y] + 1
            ans = max(ans, numpy.max(distance))
print(ans-1)

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

using namespace std;

using ll = long long;

// Graph template
template <class... Args> struct Edge {
  int from, to;
  tuple<Args...> values;
  Edge(int from, int to, Args... values)
      : from(from), to(to), values(values...) {}
};
template <class E> auto operator<(const E &e, const E &f) {
  return e.values > f.values;
}

template <class... Args> class Graph {
  using Edges = vector<Edge<Args...>>;
  vector<Edges> graph_;

public:
  Graph(int n) : graph_(n) {}
  size_t size() { return graph_.size(); };
  size_t size() const { return graph_.size(); };
  auto &operator[](unsigned int x) { return graph_[x]; }
  const auto &operator[](unsigned int x) const { return graph_[x]; }
  void AddEdge(int s, int t, Args... v) { graph_[s].emplace_back(s, t, v...); }
};

bool visited[6000];
vector<int> ans;

template <class G> void sweep(int v, const G &g) {
  visited[v] = true;
  for (auto e : g[v]) {
    if (!visited[e.to]) {
      sweep(e.to, g);
    }
  }
  ans.push_back(v);
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> mt(n, vector<bool>(n, false));
  Graph<> g(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    g.AddEdge(u - 1, v - 1);
    mt[u - 1][v - 1] = true;
  }
  for (int i = 0; i < n; ++i) {
    if (!visited[i]) {
      sweep(i, g);
    }
  }
  int pre = 0;
  bool flag = false;
  reverse(ans.begin(), ans.end());
  for (const auto &x : ans) {
    cout << x + 1 << endl;
    if (pre) {
      if (!mt[pre - 1][x]) {
        flag = true;
      }
    }
    pre = x + 1;
  }
  if (flag)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}



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

#define A first
#define B second

int n, m, s[2005], t[2005], ans[2005];
bool ok[2005][2005][2];
vector<int> g[2005];
vector<int> p[2005];
int cur;
int ct[2005][2005];
vector<pii> e;
set<pii> r[2005][2005];
queue<pii> q;

bool dfs(int v, int w, int f = -1) {
	if (v == w) {
		p[cur].push_back(w);
		return 1;
	}

	for (int u : g[v]) {
		if (u == f)
			continue;
		bool b = dfs(u, w, v);
		if (b) {
			p[cur].push_back(v);
			return 1;
		}
	}

	return 0;
}

void ins(int a, int b, int i) {
	if (a > b) {
		r[b][a].insert(pii(i, -1));
	} else {
		r[a][b].insert(pii(i, 1));
	}
}

void deledge(int a, int b, int i, int d) {
	if (a > b) {
		if (ok[b][a][0] && ok[b][a][1])
			return;
		r[b][a].erase(pii(i, -d));
		ok[b][a][1] = 1;
		if (r[b][a].size() == 1) {
			pii t = (*r[b][a].begin());
			// cout << t.A << ' ' << t.B << endl;
			q.push(t);
		}
	} else {
		if (ok[a][b][0] && ok[a][b][1])
			return;
		r[a][b].erase(pii(i, d));
		ok[a][b][0] = 1;
		if (r[a][b].size() == 1) {
			pii t = (*r[a][b].begin());
			t.B = -t.B;
			q.push(t);
		}
	}
}

void del(int i, int d) {
	// cout << "del" << ' ' << i << ' ' << d << endl;
	if (ans[i] != 0)
		return;
	ans[i] = d;
	for (int j = 0; j < p[i].size()-1; ++j) {
		int u = p[i][j], v = p[i][j+1];
		if (d == -1)
			swap(u, v);
		//deleting u -> v
		deledge(u, v, i, d);
	}
}

int main() {
	int sum = 0;
	cin >> n >> m;
	for (int i = 0; i < n-1; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (a > b)
			swap(a, b);
		e.push_back(pii(a, b));
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for (int i = 0; i < m; ++i) {
		cin >> s[i] >> t[i];
		s[i]--; t[i]--;
		cur = i;
		dfs(s[i], t[i]);
		reverse(p[i].begin(), p[i].end());
		for (int k = 0; k < p[i].size()-1; ++k) {
			ins(p[i][k], p[i][k+1], i);
		}
	}

	for (int i = 0; i < n-1; ++i) {
		sum += min(2, (int)r[e[i].A][e[i].B].size());
		/* for (pii u : r[e[i].A][e[i].B])
			cout << u.A << ' ' << u.B << ' ';
		cout << endl; */
	}

	cout << sum << endl;

	while (true) {
		bool z = 1;
		for (int i = 0; i < m; ++i)
			if (ans[i] == 0)
				z = 0;
		if (z)
			break;

		while (!q.empty()) {
			pii k = q.front();
			q.pop();
			del(k.A, k.B);
		}

		for (int i = 0; i < m; ++i) {
			if (ans[i] == 0) {
				del(i, 1);
				break;
			}
		}
	}

	for (int i = 0; i < m; ++i) {
		if (ans[i] == 1)
			cout << s[i]+1 << ' ' << t[i]+1 << endl;
		else
			cout << t[i]+1 << ' ' << s[i]+1 << endl;
	}
}

Measured memory_bytes: 261760
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define INF 3e15
#define mod 1000000007
#define eps 1e-6
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void read(ll &x, ll &y)
{
	scanf("%lld%lld",&x,&y);
}
void read(ll &x, ll &y, ll &z)
{
	scanf("%lld%lld%lld",&x,&y,&z);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
const ll N=100000;
ll n,m,x,y,l,r,mid,ans,sum,a[N+10],b[N+10],li[N+10],w[N+10],p[N+10],ra[N+10],su[N+10];
vector<ll>v[N+10];
set<pair<ll,ll> >s[N+10];
/*ll fin(ll a)
{
	if(a==p[a])
		return a;
	return p[a]=fin(p[a]);
}
void uni(ll a, ll b)
{
	a=fin(a),b=fin(b);
	if(a==b)
		return;
	if(r[a]>r[b])
		r[a]+=r[b],su[a]+=su[b],p[b]=a;
	else
		r[b]+=r[a],su[b]+=su[a],p[a]=b;
}
void dfs(ll x)
{
	w[x]=1;
	ll rt=fin(x);
	su[rt]+=b[x];
	for(ll to:v[x])
		if(fin(x)!=fin(to))
			s[rt].insert({a[to]-b[to],to});
	while(!s[rt].empty())
	{
		ll need=s[rt].begin()->fi,to=s[rt].begin()->se;
		if(fin(x)==fin(to))
			s[rt].erase(s[rt].begin());
		else if(fin(x)!=fin(to)&&su[rt]>=need)
		{
			uni(rt,s[rt].begin()->se);
			dfs(s[rt].begin()->se);
			rt=fin(x);
			s[rt].erase(s[rt].begin());
		}
		else
			return;
	}
}*/
bool cmp(ll x, ll y)
{
	return a[x]-b[x]<a[y]-b[y];
}
int main()
{
	//freopen("c.cpp","r",stdin);
 
	cin>>n>>m;
	for(ll i=1;i<=n;i++)
		read(a[i],b[i]),sum+=b[i],li[i]=i,p[i]=i,ra[i]=1,su[i]=b[i];
	for(ll i=1;i<=m;i++)
		read(x,y),v[x].pb(y),v[y].pb(x);
	sort(li+1,li+n+1,&cmp);
	ll res=INF;
	ll t=ll(1e6)/(n+m);
	t*=5;
	for(ll i=1;i<=min(t,n);i++)
	{
		priority_queue<pair<ll,ll> >q;
		ll bal=0;
		ans=0;
		q.push({-a[li[i]]+b[li[i]],li[i]});
		for(ll j=1;j<=n;j++)
			w[j]=0;
		for(;!q.empty();)
		{
			x=q.top().se,y=-q.top().fi;
			q.pop();
			if(w[x])
				continue;
			w[x]=1;
			if(bal<y)
				ans+=y-bal,bal=y;
			bal+=b[x];
			for(ll to:v[x])
			{
				ll need=a[to]-b[to];
				if(!w[to])
					q.push({-need,to});
			}
		}
		res=min(res,ans);
	}
	for(ll i=1;i<=min(t,n);i++)
	{
		priority_queue<pair<ll,ll> >q;
		ll bal=0,cur=rand()%n+1;
		ans=0;
		q.push({-a[li[cur]]+b[li[cur]],li[cur]});
		for(ll j=1;j<=n;j++)
			w[j]=0;
		for(;!q.empty();)
		{
			x=q.top().se,y=-q.top().fi;
			q.pop();
			if(w[x])
				continue;
			w[x]=1;
			if(bal<y)
				ans+=y-bal,bal=y;
			bal+=b[x];
			for(ll to:v[x])
			{
				ll need=a[to]-b[to];
				if(!w[to])
					q.push({-need,to});
			}
		}
		res=min(res,ans);
	}
	/*for(ll i=1;i<=n;i++)
		if(!w[li[i]])
			ans=a[li[i]]-b[li[i]],dfs(li[i]);*/
	cout<<res+sum;
}

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

int main(){
	int n=0;
	int k=0;
	int l[50];
	int i=0;
	int j=0;
	int t=0;
	int a=0;
	for(i=0;i<50;i++){
		l[i]=0;
	}
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>l[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(l[i]>l[j]){
				 t=l[i];
				 l[i]=l[j];
				 l[j]=t;
				 t=0;
			}
		}
	}
	for(i=0;i<k;i++){
		a=a+l[i];
	}
	cout<<a<<endl;
}
	
	
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  int n = N ;
  int c = 0;
  for ( int i=0 ; n > 0 ; i++ ) {
    int l ; 
    l = n%10 ;
    c += l ;
    n = (n-l)/10;
  }
  cout << (N % c ==0 ? "Yes" : "No" ) << endl;
}



Measured memory_bytes: 3592
#include <iostream>

int main() {
  int R, G, B, N;
  std::cin >> R;
  std::cin >> G;
  std::cin >> B;
  std::cin >> N;

  int result = 0;

  for (int r = 0, r_limit = N / R; r <= r_limit; ++r) {
    int r_buy = r * R;
    for (int g = 0, g_limit = (N - r_buy) / G; g <= g_limit; ++g) {
      int g_buy = g * G;
      if (((N - r_buy - g_buy) % B) == 0) {
        ++result;
      }
    }
  }
  std::cout << result;
  return 0;
}

Measured memory_bytes: 256
import os
import math
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

def get_int():
    return int(input())

def get_int_list():
    return list(map(int, input().split()))

while(True):
    try:
        a, b, x, y = get_int_list()
        print('R' * (x - a) + 'U' * (y - b) + 'L' * (x - a) + 'D' * (y - b) + 'D' + 'R' * (x - a + 1) + 'U' * (y - b + 1) + "LU" + 'L' * (x - a + 1) + 'D' * (y - b + 1) + 'R')
    except EOFError:
        exit()


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int A, B; cin >> A >> B;
	int ans;
	if (A <= 5) {
		ans = 0;
	}
	else if (A <= 12) {
		ans = B / 2;
	}
	else {
		ans = B;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
var n = Number(input[0]);
var max = 0;
var x = 0;
var st = input[1].split("");
for(var i in st){
    if(st[i] == 'I'){
        x++;
      	max = Math.max(max,x);
    }else{
        x--;
    }
    max = Math.max(max,x);
}
console.log(max);

Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Linq;
class P
{
    static int n;
    static void Main()
    {
        string s = Console.ReadLine();
        string t = Console.ReadLine();
        n = s.Length;
        bool f = false;
        for (int i = 0; i < n; i++)
        {
            bool f2 = true;
            for (int j = 0; j < n; j++)
                f2 = f2 && s[mod(i + j)] == t[j];
            f = f || f2;
        }
        Console.WriteLine(f ? "Yes" : "No");
    }
    static int mod(int m)
    {
        return m % n;
    }
}

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

int main(){
	int n, h;
	
	while(1){
		string cards, subcards;
		cin >> cards;

		if (cards == "-") break;
		cin >> n;

		for (int i = 0; i < n; i++){
			cin >> h;
			subcards = cards.substr(0, h);
			cards = cards.erase(0, h);
			cards = cards + subcards;
		}
		cout << cards << "\n";
	}

	return 0;
}


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

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define F first
#define S second

using namespace std;
typedef long long  ll;

int main() {
  int n , m;
  cin >> n >> m;
  vector<int> d;
  for(int i = 1 ; 1ll * i * i <= m ; ++i){
    if(m % i == 0){
      d.pb(i);
      if(i != m / i)d.pb(m / i);
    }
  }
  sort(all(d));
  int ans = 1;
  for(int x : d){
    if(m - 1ll * x * n >= 0 && (m - 1ll * x * n) % x == 0)ans = x;
  }
  cout << ans << '\n';
}


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


int main()
{
	stringstream ss;
    // 入力
    int N;
    cin>>N;
    int C[N],S[N],F[N];
    int ans[N];
    for(int i=0;i<N-1;i++){
        cin>>C[i]>>S[i]>>F[i];
        ans[i]=0;
        // cout<<S[i]<<endl;
    }

    ans[N-1]=0;
    ans[N-2]=S[N-2]+C[N-2];
    // cout<<ans[N-2]<<endl;
    for(int i=0;i<N-2;i++){
        ans[i]=S[i];
        for(int j=i;j<N-2;j++){
            ans[i]+=C[j];
            if(ans[i]<=S[j+1]) ans[i]=S[j+1];
            else {  //最初の電車は出てるので乗れるものを探す
                if(ans[i]%F[j+1]!=0) ans[i]=ans[i]+(F[j+1]-ans[i]%F[j+1]);
                // cout<<"あまり"<<ans[i]%F[j+1]<<endl;
            }
        }
        ans[i]+=C[N-2];
    }

    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

long long int comb[51][51] = {};

long long int getcomb(int n, int r)
{
	if(n == 0) return 0;
	else if(comb[n][r] > 0) return comb[n][r];
	else if(r == 0 || n == r) return 1;
	else return comb[n][r] = getcomb(n - 1, r) + getcomb(n - 1, r - 1);
}

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	long long int v[51];
	map<long long int, int> cnt;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		if(cnt.find(v[i]) == cnt.end()) cnt[v[i]] = 1;
		else cnt[v[i]]++;
	}
	sort(v, v + n);
	reverse(v, v + n);
	long long int sum[51] = {};
	long long int select[51] = {};
	int tmp = 0;
	for(int i = 1; i <= b; i++){
		sum[i] = sum[i - 1] + v[i - 1];
		if(i - 1 >= 0 && v[i - 2] == v[i - 1]) tmp++;
		else tmp = 1;
		select[i] = getcomb(cnt[v[i - 1]], tmp);
	}
	// for(int i = 1; i <= 50; i++){
	// 	for(int j = 1; j <= i; j++){
	// 		cout << i << " " << j << " " << getcomb(i, j) << endl;
	// 	}
	// }
	double ave = (double)sum[a] / a;
	long long int selectnum = select[a];
	for(int i = a + 1; i <= b; i++){
		if(sum[a] * i == sum[i] * a){
			selectnum += select[i];
		}
	}
	printf("%.10f\n", ave);
	cout << selectnum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

 int main(){

 ll n; cin>>n;
   int v[n];

  ll sum=0;

  for(int i=0;i<n;i++) cin>>v[i];

      ll maxi = v[0];
  for(int i=1;i<n;i++){
       if(v[i] <  maxi){
         //  cout<<v[i]<<"  "<<maxi<<endl;
            sum += abs(v[i] - maxi);
       }
       else maxi = v[i];
  }

  cout<<sum<<endl;


 return 0;
 }

Measured memory_bytes: 4348
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <utility>
#include <set>

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

int main(int argc, char const* argv[])
{
	int n, m;
	cin >> n >> m;
	set<P> st;
	for(int i = 0; i < m; i++){
			int a, b;
			cin >> a >> b;
			st.insert(make_pair(a, b));
	}
	vector<int> vec(n);
	iota(vec.begin(), vec.end(), 1);
	int res = 0;
	do{
			if(vec[0] != 1)continue;
			for(int i = 1; i < vec.size(); i++){
					if(st.find(make_pair(vec[i - 1], vec[i])) == st.end() && st.find(make_pair(vec[i], vec[i - 1])) == st.end())break;
					if(i == vec.size() - 1)res++;
			}
	}while(next_permutation(vec.begin(), vec.end()));
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;


int main()
{
    ll X,K,D;
    cin >> X >> K >> D;
    if(X<0) X=-X;
    ll tmp=X/D;
    if(tmp>=K) cout << X-K*D << endl;
    else{
        if((K-tmp)%2==0) cout << X%D <<endl;
        else cout << -(X%D-D) << endl;
    }
    


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
int  main(){
string s,ans;
cin >> s;
for(int i=0;i<s.size();i++){
  if(s.at(i)=='B'){
    if(ans.size()==0)continue;
      string che;
      for(int j=0;j<ans.size()-1;j++){
        che+=ans.at(j);
      }
      ans=che;
  }
  else{
    ans+=s.at(i);
  }
}
cout<<ans<<endl;
}







Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    L,R=map(int,input().split())
    L=bin(L)[2:].zfill(60)
    R=bin(R)[2:].zfill(60)
    dp=[[[0]*2 for _ in range(2)] for _ in range(2)]
    dp[0][0][0]=1 # dp[mt][lt][msb]

    for l,r in zip(L,R):
        l=int(l); r=int(r)
        ndp=[[[0]*2 for _ in range(2)] for _ in range(2)]
        for x,y,mt,lt,msb in product(range(2),repeat=5):
            if((not mt) and l>x): continue
            if((not lt) and y>r): continue
            if((not msb) and x!=y): continue
            if(x>y): continue
            ndp[max(mt,l<x)][max(lt,y<r)][max(msb,x*y)]+=dp[mt][lt][msb]
            ndp[max(mt,l<x)][max(lt,y<r)][max(msb,x*y)]%=MOD
        dp=ndp

    print(sum(dp[mt][lt][msb] for mt,lt,msb in product(range(2),repeat=3))%MOD)
resolve()

Measured memory_bytes: 39664
import copy
s = input()
x,y = map(int,input().split())

ver = []
hor = []
ini = 0
flag = 'h1'
tmp = 0

for i in range(len(s)):
    if s[i] == 'T':
        if flag == 'h':
            if tmp > 0:
                hor.append(tmp)
            tmp = 0
            flag = 'v'
        elif flag == 'v':
            if tmp > 0:
                ver.append(tmp)
            flag = 'h'
            tmp = 0
        elif flag == 'h1':
            if tmp > 0:
                ini = tmp
            flag = 'v'
            tmp = 0
    else:
        tmp += 1

if tmp > 0:
    if flag == 'h1':
        ini = tmp
    elif flag == 'h':
        hor.append(tmp)
    elif flag == 'v':
        ver.append(tmp)

num = 8000
        
ver_li = [[0 for i in range(2)] for j in range(num*2+1)]
hor_li = [[0 for i in range(2)] for j in range(num*2+1)]

hor_li[num+ini][0] = 1
#print(sum(hor))
#exit()

for i in range(len(hor)):
    #c_hor = copy.deepcopy(hor_li)
    for j in range(num*2+1):
        if hor_li[j][0] == 1:
            #print(j,hor[i],i)
            hor_li[j][1] = 0
            hor_li[j+hor[i]][1] = 1
            hor_li[j-hor[i]][1] = 1
    for j in range(num*2+1):
        hor_li[j][0] = hor_li[j][1]

ver_li[num][0] = 1
for i in range(len(ver)):
    #c_ver = copy.deepcopy(ver_li)
    for j in range(num*2+1):
        if ver_li[j][0] == 1:
            ver_li[j][1] = 0
            #print(hor[i])
            ver_li[j+ver[i]][1] = 1
            ver_li[j-ver[i]][1] = 1
    for j in range(num*2+1):
        ver_li[j][0] = ver_li[j][1]
    
if hor_li[num+x][0] == 1 and ver_li[num+y][0] == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 49684
#-*-coding:utf-8-*-

def main():
    n, a, b = map(int, input().split())
    ans = a + b * (n - 1) - (b + a * (n - 1)) + 1
    if ans <= 0:
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940