akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <chrono>
//#include <random>

#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define long int64_t
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ std::cerr << name << " : " << arg1 << std::endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); std::cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<> dis(0, INF<<1);

const int N = 100001;

struct T
{
	int l, r;

	bool operator< (const T &a) const
	{
		return l < a.l;
	}

} a[N];

int main()
{
	fio;
	int n, ms = 0, maxl = 0, minr = INF;
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		cin >> a[i].l >> a[i].r;
		ms = max(ms, a[i].r - a[i].l + 1);
		minr = min(minr, a[i].r);
		maxl = max(maxl, a[i].l);
	}
	sort(a+1, a+n+1);
	int ans = ms + max(minr - maxl + 1, 0), minR = a[n].r;
	for(int i=n-1; i; i--)
	{
		ans = max(ans, max(minR - maxl + 1, 0) + max(minr - a[i].l + 1, 0));
		minR = min(minR, a[i].r);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  string map[1000];
  map['A']="100101"; map['B']="10011010"; map['C']="0101"; map['D']="0001";
  map['E']="110"; map['F']="01001"; map['G']="10011011"; map['H']="010000";
  map['I']="0111"; map['J']="10011000"; map['K']="0110"; map['L']="00100";
  map['M']="10011001"; map['N']="10011110"; map['O']="00101"; map['P']="111";
  map['Q']="10011111"; map['R']="1000"; map['S']="00110"; map['T']="00111";
  map['U']="10011100"; map['V']="10011101"; map['W']="000010"; map['X']="10010010";
  map['Y']="10010011"; map['Z']="10010000"; map[' ']="101"; map['\'']="000000";
  map[',']="000011"; map['-']="10010001"; map['.']="010001",map['?']="000001";
  string alpha[]={"00000","00001","00010","00011","00100","00101","00110","00111",
		  "01000","01001","01010","01011","01100","01101","01110","01111",
		  "10000","10001","10010","10011","10100","10101","10110","10111",
		  "11000","11001","11010","11011","11100","11101","11110","11111"};
  string altmp="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
  string line,chli,ans;
  while(1){
    getline(cin,line);
    if(cin.eof()) break;
    for(int i=0;i<line.size();i++){
      chli += map[line[i]];
    }
    if(chli.size() % 5 != 0) chli.append(5-chli.size()%5,'0');
    for(int i=0;i<chli.size();i+=5){
      string tmp = chli.substr(i,5);
      for(int j=0;j<32;j++){
	if(tmp == alpha[j]){
	  ans += altmp[j];
	  break;
	}
      }
    }
    cout<< ans << endl;
    ans.erase();
    chli.erase();
  }
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int n;
bitset<50> dp[50];
vector< vector<bool> > d;

int solve() {
    for (int i = 0; i < n; i++) {
        dp[i].reset();
        dp[i].set(i);
    }

    for (int i = 1; i <= 30; i++) {
        bitset<50> bs(0);
        for (int j = 0; j < n; j++) {
            if (d[j][i]) {
                bs |= dp[j];
            }
        }

        if (bs.count() == n) {
            return i;
        }

        for (int j = 0; j < n; j++) {
            if (d[j][i]) {
                dp[j] = bs;
            }
        }
    }

    return -1;
}

int main() {
    while (cin >> n, n) {
        d.resize(50, vector<bool>(31));
        for (int i = 0; i < 50; i++) {
            for (int j = 1; j <= 30; j++) {
                d[i][j] = false;
            }
        }
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            for (int j = 0; j < a; j++) {
                int b;
                cin >> b;
                d[i][b] = true;
            }
        }

        cout << solve() << endl;
    }

    return 0;
}

Measured memory_bytes: 3100
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = (int)1e5 + 3;

int n, m, res;
string s, t;
bool is[2][300];
VI ind[300];

signed main() {
  init_ios();
  cin >> s >> t;
  n = s.size();
  m = t.size();
  s = "!" + s;
  t = "!" + t;
  for (int i = 1; i <= n; ++i) {
    ind[s[i]-'a'].PB(i);
    is[0][s[i]-'a'] = true;
  }
  for (char c: t)
    is[1][c-'a'] = true;
  for (int i = 0; i < 30; ++i)
    if (is[1][i] && !is[0][i]) {
      cout<<"-1\n";
      return 0;
    }
  int poz = 1;
  for (int i = 1; i <= m; ++i) {
    int co = t[i]-'a';
    int id = lower_bound(ind[co].begin(), ind[co].end(), poz) - ind[co].begin();
    if (id == (int)ind[co].size()) {
      res += n;
      poz = 1;
      --i;
      continue;
    }
    if (i == m)
      res += ind[co][id];
    poz = ind[co][id]+1;
  }
  cout<<res<<"\n";
}

Measured memory_bytes: 1768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<ctime>
#include<cassert>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
int f[1100000],go[1100000][21],g[1100000],nd1[100],nd2[100];
int main()
{	int n,m,k,x,y,z; cin>>n>>m>>k; n--;
	for(rint i=1;i<=k;i++) cin>>x>>y>>z,nd1[x]|=(1<<y-1),nd2[x]|=z*(1<<y-1);
	memset(go,-1,sizeof(go));
	for(rint i=0;i<(1<<n);i++)
	{	int num=0;
		for(rint j=1;j<=n;j++)
		if(i&(1<<j-1))
		{	num++;
			if(j!=1&&!(i&(1<<j-2))) go[i][num]=i^(1<<j-1)^(1<<j-2);
		}
	}
	for(rint i=0;i<(1<<n);i++)
	for(rint j=n;j>=1;j--)
	if(!(i&(1<<j-1))){g[i]=i^(1<<j-1);break;}
	f[0]=1;//debug(g[0]);debug(go[2][1]);
	for(rint i=0;i<m;i++)
	{	for(rint j=0;j<(1<<n)-1;j++) f[g[j]]=(f[g[j]]+f[j])%mod;
	//	debug(f[1][0]);debug(f[1][1]);debug(f[1][2]);debug(f[1][3]);fgx;
	//debug(f[0]);debug(f[1]);debug(f[2]);debug(f[3]);fgx;
		for(rint k=1;k<=n;k++)
		for(rint j=(1<<n)-1;j>=0;j--)
		if(go[j][k]!=-1) f[go[j][k]]=(f[go[j][k]]+f[j])%mod;
	//debug(f[2][0]);debug(f[2][1]);debug(f[2][2]);debug(f[2][3]);
		for(rint j=0;j<(1<<n);j++) if((j&nd1[i+1])!=nd2[i+1]) f[j]=0;
		//debug(f[1][0]);debug(f[1][1]);debug(f[1][2]);
	}
	int ans=0;
	for(rint i=0;i<(1<<n);i++) ans=(ans+f[i])%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 98560
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<long long> a(n);
  for(int i=0;i<n;i++)cin>>a.at(i);
  vector<bool> ans(n-k);
  for(int i=0;i+k<n;i++){
    if(a.at(i)<a.at(i+k)){
      ans.at(i)=true;
    }else{
      ans.at(i)=false;
    }
  }
  for(auto x:ans){
    if(x){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll m;
  cin >> m;
  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == 0) {
      ll min = INF;
      for (ll j = b; j < c; j++) {
        if (v.at(j) < min) min = v.at(j);
      }
      cout << min << endl;
    } else {
      ll max = -INF;
      for (ll j = b; j < c; j++) {
        if (v.at(j) > max) max = v.at(j);
      }
      cout << max << endl;
    }
  }
}


Measured memory_bytes: 3104
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] u = new int[M];
        int[] v = new int[M];
        for (int i=0; i<M; i++) {
            u[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        int S = sc.nextInt();
        int T = sc.nextInt();

        System.out.println(solve(N, M, u, v, S, T));
    }

    /**
     * そのまま解く．
     * https://atcoder.jp/contests/abc132/submissions/6178008
     * @param N
     * @param M
     * @param u
     * @param v
     * @param S
     * @param T
     * @return
     */
    private static int solve(int N, int M, int[] u, int[] v, int S, int T) {
        List<List<Integer>> graph = new ArrayList();
        for (int i=0; i<N; i++) {
            graph.add(new ArrayList());
        }
        for (int i=0; i<M; i++) {
            graph.get(u[i]-1).add(v[i]-1);
        }
        // graph.forEach(System.err::println);


        List<Integer> next = new ArrayList();
        next.add(S-1);
        List<Integer> next2 = new ArrayList();

        boolean[][] reached = new boolean[3][N];

        // i 回目のけんけんぱで移動できる範囲を列挙する
        for (int i=1; !next.isEmpty(); i++) {
            for (int k=0; k<3; k++) {
                for (int s: next) {
                    if(!reached[k][s]) {
                        next2.addAll(graph.get(s));
                        reached[k][s] = true;
                    }
                }

                next.clear();
                next.addAll(next2);
                next2.clear();
            }

            for (Integer n: next) {
                if (n == T-1) return i;

                next2.add(n);
            }

            next.clear();
            next.addAll(next2);
            next2.clear();
        }

        return -1;
    }
}


Measured memory_bytes: 95624
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    N, M = map(int, input().split())
    A = [0] * (N + 1)
    for i in range(M):
        bre = int(input())
        A[bre] = -1
    A[0] = 1
    A[1] = 1 if A[1] != -1 else -1
    # print(A)
    for i in range(N):
        if (A[i] == -1) & (A[i + 1] == -1):
            print(0)
            sys.exit()

    for i in range(2, N + 1):
        if A[i] == -1:
            continue
        elif A[i - 1] == -1:
            A[i] = A[i - 2]
        elif A[i - 2] == -1:
            A[i] = A[i - 1]
        else:
            A[i] = A[i - 1] + A[i - 2]
    print(A[N] % 1000000007)

if __name__ == '__main__':
    main()

Measured memory_bytes: 469020
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
int n,T;
cin>>n>>T;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
int mina=MOD,sa=0;
for(int i=0;i<n;i++){
    if(mina>a[i])mina=a[i];
    else{
        if(sa<a[i]-mina)sa=a[i]-mina;
    }
}
mina=MOD;
int ans=0,count=0,t=0,maxt=0;
for(int i=0;i<n;i++){
    if(mina>a[i]){
        mina=a[i];
        ans+=count-maxt;
        count=0;t=-1;maxt=0;
        continue;
    }
    if(mina==a[i]){
        t--;
    }
    if(mina+sa==a[i]){
        count++;
        t++;
        maxt=max(maxt,t);
    }
}
ans+=count-maxt;
cout<<ans;






return 0;
}


Measured memory_bytes: 1024
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
// #define ONLINE_JUDGE
#define inf 0x3f3f3f3f
#define mod 
#define maxm 
#define maxn 

int main()
{/*
	#ifdef ONLINE_JUDGE
    	freopen("aplusb.in", "r", stdin);
    	freopen("aplusb.out", "w", stdout);
	#endif*/
	// ios::sync_with_stdio(false);
	ll n, a, b, c, d;
	
	scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
	ll x = b - a;
	int fg = 0;
	for (int i = 0; i < n; i++) {
		if (x >= i * c - (n - i - 1) * d && x <= i * d - (n - i - 1) * c) {
			fg = 1;
			break;
		}
	}
	puts(fg ? "YES" : "NO");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

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

  string s, ans;
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      if (ans.size()) {
        ans = ans.substr(0,ans.size()-1);  
      }
    } else {
      ans = ans + s[i];
    }
  }

  cout << ans << eol;
  
  return 0;
}


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, ans=0, tmp=0;
vector<ll> A;
vector<pair<ll,ll>> P;
vector<vector<ll>> G;
string S;
map<ll,ll> MP, MPS;

signed main(){
    cin >> N;
    A.resize(N*N, -1);
    for(int i=1;i<=N;i++) {
        ll a;
        cin >> a;
        P.push_back(make_pair(a, i));
        A[a-1] = i;
        MPS[i] = a;
        MP[i]++;
    }
    sort(P.begin(), P.end());
    ll itr=0;
    for(int i=0;i<N*N;i++) {
        //cout << "OK" << endl;
        if(A[i]!=-1) {
            if(MP[A[i]]!=A[i]) {
                //cout << MP[A[i]]+1 << " " << A[i] << endl;
                cout << "No" << endl;
                return 0;
            }
            continue;
        }
        if(itr<N) {
            while(MP[P[itr].second]==P[itr].second) {
                itr++;
            }
            if(itr<N) {
                A[i] = P[itr].second;
                MP[P[itr].second]++;
            }
            else {
                while(1) {
                    if(MP[P[tmp].second]<N) {
                        A[i] = P[tmp].second;
                        MP[P[tmp].second]++;
                        break;
                    }
                    else tmp++;
                }
            }
        }
        else {
            while(1) {
                if(MP[P[tmp].second]<N) {
                    A[i] = P[tmp].second;
                    MP[P[tmp].second]++;
                    break;
                }
                else tmp++;
            }
        }
    }
    cout << "Yes" << endl;
    for(int i=0;i<N*N;i++) {
        cout << A[i] << endl;
    }
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	vector<int>ss(26),tt(26);
	for(auto&&i:s)++ss.at(i-'a'); for(auto&&i:t)++tt.at(i-'a');
	sort(ss.begin(),ss.end()); sort(tt.begin(),tt.end());
	cout<<(ss==tt?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 916
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

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

#define MAX_N 8
int perm[MAX_N];
int perm_P[MAX_N];
int perm_Q[MAX_N];
int N;


void permutation(int n){
    for(int i=0; i<n; i++){
        perm[i]=i+1;
    }
    int count=0;
    int p_index=0;
    int q_index=0;
    do{
        bool is_perm_P=true;
        bool is_perm_Q=true;
        /* ここにpermの処理を書く */
        for(int i=0; i<n; i++){
            if(perm[i]!=perm_P[i]) is_perm_P=false;
            if(perm[i]!=perm_Q[i]) is_perm_Q=false;
        }
        
        count++;
        if(is_perm_P) p_index=count;
        if(is_perm_Q) q_index=count;
        
    }while(next_permutation(perm, perm+n));
    
    cout << abs(p_index-q_index) << endl;
}

int main(int argc, const char * argv[]) {
    
    cin >> N;
    rep(i, N){
        cin >> perm_P[i];
    }
    rep(i, N){
        cin >> perm_Q[i];
    }
    
    permutation(N);

    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  vector<int> B(A);
  sort(B.begin(), B.end());
  for (int i = 0; i < N; ++i) {
    if (A[i] == B.back()) cout << B[N - 2] << endl;
    else cout << B.back() << endl;
  }
}

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

int main(){
  int H,W;
  cin>>H>>W;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++){
      string S;
      cin>>S;
      if(S=="snuke"){
        cout<<(char)('A'+j)<<i+1<<endl;
        return 0;
      }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int n, cnt = 0, A[1000000 + 5];
vector<int> G;

void insertion_sort(int A[], int n, int g) {
  for (int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shell_sort(int A[], int n) {
  for (int h = 1; h <= n;) {
    G.push_back(h);
    h = 3 * h + 1;
  }
  for (int i = G.size() - 1; i >= 0; i--) {
    insertion_sort(A, n, G[i]);
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  shell_sort(A, n);
  cout << G.size() << endl;
  for (int i = G.size() - 1; i >= 0; i--) {
    cout << G[i];
    if (i) cout << " ";
  }
  cout << endl << cnt << endl;
  for (int i = 0; i < n; i++) {
    cout << A[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 7040
#include<iostream>
#include<stack>
using namespace std;
int main()
{
	int num;
	cin >> num;
	stack<int>p[num];
	int opr;
	cin >> opr;
	while (opr--)
	{
		int oper;
		cin >> oper;
		switch(oper)
		{
			int num;
			case 0:
				
				cin >> num;
				int inte;
				cin >> inte;
				p[num].push(inte);
				break;
			case 1:
				cin >> num;

				if (p[num].empty() == false)
					cout << p[num].top() << endl;
				break;
			case 2:
				cin >> num;
				if (p[num].empty() == false)
					p[num].pop();
				break;
		}
	}
}


Measured memory_bytes: 4340
n = int(input())
for i in range(3, n + 1):
    x = i
    if x % 3 == 0:
        print(" " + str(i), end="")
        continue
    while x > 0:
        if x % 10 == 3:
            print(" " + str(i), end="")
            break
        x //= 10
print("")


Measured memory_bytes: 5868
#include <bits/stdc++.h>
#define mst(a,b) memset(a,b,sizeof(a));
const int N = 1e9;
const int mod=(int)1e9+7;
const int INF=0x3f3f3f3f;
typedef long long LL;
//#define LOCAL
const double PI = acos(-1.0);
const int maxn=1e5+5;

using namespace std;


bool cmp(int a, int b)
{
    return a>b;
}

int gcd(int a, int b)
{
    return (b==0)?a:gcd(b,a%b);
}


#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())

int main()
{
#ifdef LOCAL
    freopen("test.txt", "r", stdin);
#endif // LOCAL
    int a;
    scanf("%d", &a);
    printf("%d", 48-a);
    return 0;
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())
absX = abs(X)
k = absX//D
if k < K:
    abs_pos = absX-k*D
    K -= k
    if K % 2 == 0:
        print(int(abs_pos))
    else:
        print(int(abs(abs_pos - D)))
else:
    print(int(abs(absX-D*K)))

Measured memory_bytes: 9200
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a;
    cin >> a;
    cout << "ABC" << a << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n;cin>>n;
  vl t(n);
  rep(i,n)cin>>t[i];
  ll ans=1;
  rep(i,n)ans=ans/__gcd(ans,t[i])*t[i];
  cout<<ans<<endl;
}

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

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;

template <typename T>
void show_all(T t) {
  rep (i, t.size()) {
    rep (j, t[0].size()) {
      cout << t[i][j];
    }
    cout << endl;
  }
}

int main() {

  int m;
  cin >> m;
  string ld, rd;
  string nor_d, rev_d;

  rep (i, m) {
    cin >> nor_d;
    map<string, int> res;

    rep (j, nor_d.size()-1) {
      ld = nor_d.substr(0, j+1);
      rd = nor_d.substr(j+1, nor_d.size()-j-1);

      string tmp_ld = ld;
      string tmp_rd = rd;
      reverse(tmp_ld.begin(), tmp_ld.end());
      reverse(tmp_rd.begin(), tmp_rd.end());

      res[ld+rd] = 1;
      res[ld+tmp_rd] = 1;
      res[tmp_ld+rd] = 1;
      res[tmp_ld+tmp_rd] = 1;

      res[rd+ld] = 1;
      res[rd+tmp_ld] = 1;
      res[tmp_rd+ld] = 1;
      res[tmp_rd+tmp_ld] = 1;
    }

    cout << res.size() << endl;
  }
}

Measured memory_bytes: 3140
#n 経路の数
#t 時間
# cost 時間
n,t = map(int,input().split())
#cost_time = [input().split() for i in range(n)]
cost_time = [list(map(int,input().split())) for i in range(n)]
result =float('inf')
inf =  float("inf")
for i in range(n):
    time = cost_time[i][1]
    if t >= time and result >= cost_time[i][0]:
       result = cost_time[i][0]
if result == inf:
    print("TLE")
else:
    print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
ll A,B,C,D,pre=-1;
ll ans=0;

ll gcd(ll a, ll b)
{
  if(b==0) return a;
  return gcd(b,a%b);
}
int main(void)
{
  cin >> A >> B >> C >> D;
  if(A!=1) pre=A-1;
  ll GCD=gcd(C,D);
  ll LCM=C*D/GCD;
  ans+=(B-((B/C)+(B/D)-B/LCM));
  if(pre>0)
  {
    ans-=(pre-((pre/C)+(pre/D)-pre/LCM));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9) cout << "hon";
  else if (n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) cout << "pon";
  else cout << "bon";
  return 0;
}

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

int main(void){
  int data[200],cnt=0,i;
  char input[100];

  while(scanf("%s",input)!=EOF){
    //演算子の処理
    if(input[0]=='+' || input[0]=='-' || input[0]=='*'){
      switch(input[0]){
      case '+':
	data[cnt-2]=data[cnt-2]+data[cnt-1];
	break;
      case '-':
	data[cnt-2]=data[cnt-2]-data[cnt-1];
	break;
      case '*':
	data[cnt-2]=data[cnt-2]*data[cnt-1];
	break;
      default:
	printf("Error!\n");
	exit(1);
      }
      cnt--;
    }

    //オペランドの処理
    else{
      data[cnt]=atoi(input);
      cnt++;
    }

  }

  //出力
  printf("%d\n",data[0]);
  
  return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<ll,ll>
const ll N = 1e5+4 , M=N,inf=(ll)1e9;
const ll mod=1e9+7;
ll fastAbs(ll n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
//map< pair<ll,ll> , ll > mp;
const ll dx[4] = {1,0,0,-1};
const ll dy[4] = {0,-1,1,0};
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
void solve( int y ){
    int n ;
    cin >> n ;
    vector < ld > a(n);
    for( int i = 0 ; i < n;  i++) cin >> a[i] ;
    priority_queue < ld > q ;
    for( int i = 0 ; i < n ; i++ ) q.push(-a[i]);
    for( int i = 0 ; i < n-1 ; i++){
        ld x = -q.top();
        q.pop();
        ld y = -q.top();
        q.pop();
        ld z = (x+y)/2;
        q.push(-z);
    }
    cout << fixed << setprecision(6) << -q.top();
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q=1;
    //cin >> q;
//    while(q--)
//        solve();
    for( int i = 1 ; i <= q ; i++) solve(i);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/


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

	ll n;
	cin >> n;
	vector<ll> a(n);
	ll num = 0;
	rep(i, n) {
		cin >> a[i];
		num = max(num, a[i]);
	}


	// 中間くらいの値が大きい

	sort(allof(a));

	if (num % 2 == 0) {
		ll tn = lower_bound(allof(a), num / 2) - a.begin();
		if ((num / 2) - a[tn - 1] <= a[tn] - (num / 2)) {
			cout << num << " " << a[tn - 1] << endl;
		}
		else
			cout << num << " " << a[tn] << endl;
		return 0;
	}
	else {
		double tnum = (double)num / (double) 2;
		ll tn = lower_bound(allof(a), tnum) - a.begin();
		if (tnum - a[tn - 1] <= a[tn] - tnum) {
			cout << num << " " << a[tn - 1] << endl;
		}
		else
			cout << num << " " << a[tn] << endl;
		return 0;
	}


	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int i=1;
	for(;i<=5;i++)
	 {   int x;
	     cin>>x;
	     if(x==0)
	      break;
	 }
	cout<<i;
	return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
#define MV 100000
#define INF 1e9

struct edge{int to,cost; };
vector <edge> G[MV];

int V,E;
int d[MV+1];//???????????????????´?

bool bellmanford(int s){
  fill(d,d+MV,INF);
  d[s] = 0;
  int c = 0;
  bool upd = false;
  while(true){
    upd = false;
    for(int i = 0;i < V;i++){
      for(int j = 0;j < G[i].size();j++){
	edge e = G[i][j];
	if(d[i] != INF && d[e.to] > d[i] + e.cost){
	  d[e.to] = d[i] + e.cost;
	  upd = true;
	}
      }
    }
    if(!upd)
      break;
    if(c == V-1)
      return true;//?????????????????????
    c++;
  }
  return false;
}

int main(){
  d[MV] = INF+10;
  int first;
  bool flag;
  cin >> V >> E >> first;
  for(int i = 0;i < E;i++){
    int f,t;
    edge e;
    cin >> f >> e.to >> e.cost;
    G[f].push_back(e);
    /*
      G[f]??????f????????§????????????????´???????????????????
     */
    t = e.to;
    
    //e.to = f;
    //G[t].push_back(e);
  }

  
  flag = bellmanford(first);
  if(flag == true)
    cout << "NEGATIVE CYCLE" << endl;
  else{
    for(int i = 0;i < V;i++){
      if(d[i] == INF){
	cout << "INF" << endl;
      }
      else{
	cout << d[i] << endl;
      }
    }
  }
  
}

Measured memory_bytes: 5880
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  string s, t;
  cin >> s >> t;
  vector<vector<int>> v(26);
  for (int i = 0; i < sz(s); i++) {
    v[s[i] - 'a'].push_back(i + 1);
  }
  for (int i = 0; i < sz(t); i++) {
    if (sz(v[t[i] - 'a']) == 0) {
      cout << "-1\n";
      return 0;
    }
  }
  int kamel = 0;
  int idx = -1;
  for (int i = 0; i < sz(t); i++) {
    int ch = t[i] - 'a';
    idx = upper_bound(v[ch].begin(), v[ch].end(), idx) - v[ch].begin();
    if (idx == sz(v[ch])) {
      kamel++;
      idx = v[ch][0];
    } else {
      idx = v[ch][idx];
    }
  }
  cout << kamel * sz(s) + idx << "\n";
}



Measured memory_bytes: 1736
def solve():
    N, M = map(int, input().split())
    edges = [[] for _ in [0] * N]
    for _ in [0] * M:
        a, b = map(int, input().split())
        edges[a].append(b)
        edges[b].append(a)
    for v in sorted(get_lowlink(edges, M)[1]):
        print(v)


def get_lowlink(edges, edge_num):
    import sys
    sys.setrecursionlimit(10**7)

    n = len(edges)
    order = [-1] * n
    low = [float("inf")] * n
    bridges = []
    articulations = [0] if edge_num == n-1 and len(edges[0]) > 1 else []
    append_bridge, append_articulation = bridges.append, articulations.append

    def dfs(v, prev, k):
        order[v] = low[v] = k

        is_articulation = False
        for dest in edges[v]:
            if order[dest] == -1:
                dfs(dest, v, k + 1)
                if low[v] > low[dest]:
                    low[v] = low[dest]
                if order[v] < low[dest]:
                    append_bridge((v, dest))
                is_articulation |= order[v] <= low[dest]

            elif dest != prev and low[v] > order[dest]:
                low[v] = order[dest]

        if v > 0 and is_articulation:
            append_articulation(v)

    dfs(0, 0, 0)
    return bridges, articulations


if __name__ == "__main__":
    solve()

Measured memory_bytes: 22172
S = input()

kisu = True
gusu = True
count = 1

for s in S:
  if count % 2 == 1:
    if s == 'L':
      kisu = False
  else:
    if s == 'R':
      gusu = False
  
  count += 1

print('Yes' if kisu and gusu else 'No')


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var A = ReadSplitInt().OrderBy(x => x).ToList();

            var ans = (A[0] + A[1]) / 2.0;
            for (int i = 2; i < N; i++)
            {
                ans = (A[i] + ans) / 2.0;
            }

            Println(ans);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13396
def bfs(field,H,W,start_x,start_y,tmp_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    que = []
    que.append([start_x,start_y])
    INF = 1000000
    min_path = [[INF] * W for i in range(H)]
    min_path[start_y][start_x] = 0
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < W and 0 <= ny < H and field[ny][nx] != "X" and min_path[ny][nx] == INF:
                min_path[ny][nx] = min_path[current[1]][current[0]] + 1
                if field[ny][nx] == tmp_N:
                    return nx,ny,min_path[ny][nx]
                else:
                    que.append([nx,ny])

def getField():
    matrix = []
    first = input().strip()
    H,W,N = map(int,first.split())
    for i in range(H):
        row = list(input().strip())
        for j in range(W):
            if row[j].isdigit():
                row[j] = int(row[j])
        matrix.append(row)
    return matrix,H,W,N

def getStart(field):
    for y in range(len(field)):
        for x in range(len(field[0])):
            if field[y][x] == "S":
                return x,y

def main():
    matrix,H,W,N = getField()
    sx,sy = getStart(matrix)
    distance = 0
    for k in range(N):
        if k != 0:
            tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,tmps[0],tmps[1],k+1)
            distance += tmp_dist
            tmps = [tmp_x,tmp_y]
        else:
            tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,sx,sy,k+1)
            distance += tmp_dist
            tmps = [tmp_x,tmp_y]
    print(distance)

if __name__=='__main__':
    main()

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

int main() {
    int n;
    cin>>n;
    int w[n];
    int sum=0;
    for (int i=0;i<n;i++) {
        cin>>w[i];
        sum+=w[i];
    }
    int mn=1e9,sm=0;
    for (int i=0;i<n-1;i++) {
        sm+=w[i];
        sum-=w[i];
        mn=min(mn,abs(sm-sum));
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

vector<LL> A,B;

int main(){
    int N;
    cin >> N;
    LL a;
    LL maxi=0;
    for(int i=0;i<N;i++){
        cin >> a;
        A.pb(a);
        B.pb(-a);
        maxi=max(maxi,a);
    }
    LL ans,ans1,ans2=LINF;
    sort(ALL(A));
    sort(ALL(B));
    auto t=lower_bound(ALL(A),maxi/2);
    auto k=lower_bound(ALL(B),-maxi/2);
    if(abs(*t-maxi/2)>=abs(*k+maxi/2)) ans1=-*k;
    else ans1=*t;
    if(N&1){
        auto t=lower_bound(ALL(A),maxi/2+1);
        auto k=lower_bound(ALL(B),-(maxi/2+1));
        if(abs(*t-maxi/2)>=abs(*k+maxi/2)) ans2=-*k;
        else ans2=*t;
    }
    if(abs(ans1-maxi/2)>=abs(ans2-maxi/2)) ans=ans2;
    else ans=ans1;
    cout << maxi <<" "<< ans << endl;
    return 0;
}

Measured memory_bytes: 2036
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;



int main() {
	int a, b;
	cin >> a >> b;
	if (a > b * 2)cout << a - 2 * b << endl;
	else cout << 0 << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin>>n;
    vector<ll>ans(n+1,0);
    for(ll i=1;i<=n;i++)
    for(ll j=i;j<=n;j+=i)
	ans[j]++;
	ll ret=0;
    for(ll i=1;i<=n;i++)
    ret+=(i*ans[i]);
	cout<<ret;
}

Measured memory_bytes: 81404
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
using System.Text;
class Simple
{
    long N, M;
    const int mod = (int)1e9 + 7;
    void Solve() {
        //input
        N = io.Int;
        //cal
        var snuke = 1L;
        for(int i = 1; i <= N; ++i) {
            snuke = (snuke * i) % mod;
        }
        //ret
        Console.WriteLine(snuke);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //System.Console.SetIn(exStdIn);
        Solve();
        io.writeFlush();
    }

}
class SimpleIO
{
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 11092
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                if (n ==(i * j)) {
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
        System.out.println("No");
        System.exit(0);
    }
}

Measured memory_bytes: 22868
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(){
	int dp[100000];
	int N, K; cin >> N >> K;
	vector<int> h;
	h.resize(N);

	for(int i = 0; i < N; ++i) cin >> h[i];

	dp[0] = 0;
	for(int i = 1; i < N; ++i){
		int mindp = 1000000000; // INF
		for(int j = i-K; j < i; ++j){
			if(j < 0) continue;
			int dur = dp[j] + abs(h[i]-h[j]);
			if(dur < mindp) mindp = dur;
		}
		dp[i] = mindp;
		// cout << "i:" << i << ", dp:" << dp[i] << endl;
	}

	cout << dp[N-1] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

struct UnionFind {
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
};

int main() {
  ll n, m;
  cin >> n >> m;
  vl a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  reverse(all(a));
  reverse(all(b));
  UnionFind uf(n);
  vl d(m, 0);
  d[0] = n * (n - 1) / 2;
  rep(i, m - 1) {
    d[i + 1] = d[i];
    if(uf.root(a[i]) == uf.root(b[i])) continue;
    ll sa = uf.size(a[i]);
    ll sb = uf.size(b[i]);
    d[i + 1] -= sa * sb;
    uf.unite(a[i], b[i]);
  }
  reverse(all(d));
  rep(i, m) cout << d[i] << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#define mod 998244353
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
using namespace std;
typedef long long ll;
const double PI=3.14159265358979;
const double eps=1e-15;
const ll INF=2000000000000000000;
const int maxn=10000010;
const int maxm=20;

int n,a;

int main(){  
    while(~scanf("%d%d", &n, &a)){
        printf("%d\n",n*n-a);
    }
    return 0;  
}  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);
const ll M = (ll)(1e10);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<int> g[100100];

int solve(int v, int p = -1){
	int i,u,ret=0;
	for(i=(g[v].l_ength()-1); i>=0; --i){
		u = g[v][i];
		if(u==p){
			continue;
		}
		ret ^= (solve(u,v)+1);
	}
	return ret;
}

int main(void){
	int n,i,x,y;
	cin >> n;
	for(i=1; i<n; ++i){
		cin >> x >> y;
		--x; --y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	cout << (solve(0)?"Alice":"Bob") << endl;
	return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define fv            first
#define sv            second
#define ll            long long
#define pb            push_back
#define mp            make_pair
#define pll           pair<ll,ll>
#define pii           pair<int,int>
#define READ(x)       freopen(x,"r",stdin)
#define WRITE(x)      freopen(x,"w",stdout)
#define all(x)        (x).begin(),(x).end()
#define isWorking()   cout<<"Wroking"<<endl
#define FOR(i,x,y)    for(int i=x; i<y; i++)
#define SORT(x)       sort(x.begin(),x.end())
#define PRINT(ok)     cout<<(ok? "Yes":"No")<<endl
#define SetPrint(a,x) cout<<fixed<<setprecision(x)<<a<<endl
#define Fast_Input    ios_base :: sync_with_stdio(0),cin.tie(0);
typedef vector<int> VI;
const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int main() {

    Fast_Input

    //cin>>testCase;
    while(testCase--) {
        int n; cin>>n;
        int ok=0;
        for(int i=1; !ok && i<10; i++){
            for(int j=1; j<10; j++){
                if(i*j==n){
                    ok=1; break;
                }
            }
        }
        PRINT(ok);
    }
    return 0;
}

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

const vector<char> ss = {'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',
                         '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'};

int main  ()
{
    int n;
    while (cin >> n, n) {
        vector<int> v(n);
        for (auto &i : v) cin >> i;
        string str;
        cin >> str;
        for (int i = 0; i < str.size(); i++) {
            int t = (str[i] - (('a' <= str[i] && str[i] <= 'z') ? 'a' : ('A' - 26)) - v[i % n] + 52) % 52;
            cout << ss[t];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();

        for (int i = 0; i < 10; i++) {
            x = r * x - d;
            System.out.println(x);
        }
    }
}

Measured memory_bytes: 21972
import bisect
import sys
input = sys.stdin.readline
N = int(input())
A = [int(input()) for _ in range(N)]

dp = [float('inf')]*(N+1)
for a in A[::-1]:
  idx = bisect.bisect_right(dp, a)
  dp[idx] = a

ans = 0
for n in dp:
  if n != float('inf'):
    ans += 1
print(ans)

Measured memory_bytes: 49884
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		A = (A+11)%13;
		B = (B+11)%13;
		System.out.println(A>B?"Alice":(A<B?"Bob":"Draw"));
		sc.close();
	}

}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define dg(x) cerr << #x << " = " << x <<endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define fore(i,a,b) for(int i=(int)a;i<=(int)b;++i)
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main(){
#ifdef LOCAL
    //freopen("h.txt", "r", stdin);
    // freopen("main.out", "w", stdout);
#else
    ios::sync_with_stdio(0), cin.tie(0);
    #define endl '\n'
#endif
    string s;
    cin>>s;
    bool ok=1;
    fore(i,1,sz(s)){
        if(i%2&&s[i-1]=='L'){
            ok=0;
            break;
        }
        if(i%2==0&s[i-1]=='R'){
            ok=0;
            break;
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	string in, name;
	int n, ans=0;
	cin >> n;
	cin >> name;

	rep(i,n){
		bool found = false;
		cin >> in;
		for(int j=1; j<in.length(); j++ ){	// 文字間隔
			for( int k=0; k<in.length(); k++ ){	// 開始位置
				string part = "";
				for( int l=0; k+l<in.length()&&l<name.length()*j; l+=j ){
					part += in[k+l];
				}
				if(name==part){
					ans++;
					found = true;
					break;
				}
			}
			if(found) break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1220