akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<utility>
#include<sstream>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
map<string,int>mp;
struct Node
{
    string s;
    int t,pos;
    Node(string s = "",int t = 0,int pos = 0):s(s),t(t),pos(pos){}
};
void init()
{
    queue<Node>p;
    p.push(Node("01234567",0,0));
    string ttt = "01234567";
    mp[ttt] = 0;
    while(p.size())
    {
        Node temp = p.front();
        p.pop();
        string s;
        int pos = temp.pos;
        if(pos != 3&&pos != 7)
        {
            s = temp.s;
            swap(s[pos],s[pos + 1]);
            if(!mp.count(s))
            {
                mp[s] = temp.t + 1;
                p.push(Node(s,mp[s],pos + 1));
            }
        }
        if(pos != 0&&pos != 4)
        {
            s = temp.s;
            swap(s[pos],s[pos - 1]);
            if(!mp.count(s))
            {
                mp[s] = temp.t + 1;
                p.push(Node(s,mp[s],pos - 1));
            }
        }
        if(pos < 4)
        {
            s = temp.s;
            swap(s[pos],s[pos + 4]);
            if(!mp.count(s))
            {
                mp[s] = temp.t + 1;
                p.push(Node(s,mp[s],pos + 4));
            }
        }
        if(pos >= 4)
        {
            s = temp.s;
            swap(s[pos],s[pos - 4]);
            if(!mp.count(s))
            {
                mp[s] = temp.t + 1;
                p.push(Node(s,mp[s],pos - 4));
            }
        }
    }
}
int main()
{
	#ifdef LOCAL
	freopen("C:\\Users\\巍巍\\Desktop\\in.txt","r",stdin);
	//freopen("C:\\Users\\巍巍\\Desktop\\out.txt","w",stdout);
	#endif // LOCAL
	init();
	string in;
	while(getline(cin,in))
    {
        stringstream ss(in);
        string ans = "";
        for(int i = 1;i <= 8;i++)
        {
            int x;
            ss >> x;
            char c = x + 48;
            ans += c;
        }
        printf("%d\n",mp[ans]);
    }
	return 0;
}

Measured memory_bytes: 3496
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] s = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
			long max = 0L;
			for (int c = 1; c < n - 1; c++) {
				// indexを保存する用
				Set<Integer> set = new HashSet<>();
				long sum = 0L;
				for (int k = 1; k * c < n - 1; k++) {
					// n-1-k*c<=c の条件は https://atcoder.jp/contests/abc128/submissions/14461827 に参考
					if ((n - 1 - k * c <= c) || set.contains(n - 1 - k * c) || set.contains(k * c)
							|| n - 1 - k * c == k * c) {
						break;
					}
					sum = sum + s[n - 1 - k * c] + s[k * c];
					max = Math.max(max, sum);
					set.add(n - 1 - k * c);
					set.add(k * c);
				}
			}
			System.out.println(max);
		}
	}
}


Measured memory_bytes: 66176
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int a,b;cin>>a>>b;
    if(a*b%2==1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3624
while True:
    inp = input()
    if inp == '0': break

    num = 1
    for i in range(1, int(inp)+1):
        num = num * i

    cnt = 0
    strnum = str(num)
    while True:
        if strnum[-1] == '0':
            cnt = cnt + 1
            strnum = strnum[:-1]
        else:
            break

    print(cnt)

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

using namespace std;

int n, k;

int h[100005];
int wynik[100005];

int main(void)
{
	
	cin >> n >> k;
	
	for(int i=1;i<=n;i++)
	{
		
		cin >> h[i];
		
	}
	
	wynik[0]=1000000;
	wynik[1]=0;
	
	for(int i=2;i<=n;i++)
	{
		
		int minw=INT_MAX;
		
		for(int a=1;a<=min(k, i-1);a++)
		{
			
			minw=min(minw, wynik[i-a]+abs( h[i]-h[i-a] ));
			
		}
		
		wynik[i]=minw;
		
	}
	
	cout << wynik[n];

	return(0);
	
}

Measured memory_bytes: 1024
let quick_sort (a : (int * char * int) array) =
  let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
  let partition p r =
    let rec exchange = function
      | (i, j) when j = r -> swap i r; i
      | (i, j) when (fun (_, _, x) (_, _, y) -> x - y) a.(j) a.(r) <= 0 -> swap i j; exchange (i + 1, j + 1)
      | (i, j) -> exchange (i, j + 1) in
    exchange (p, p) in
  let rec doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end in
  doit 0 (Array.length a - 1)

let stable_p (a : (int * char * int) array) n =
  let rec doit i =
    if i = n then true
    else if (fun (xi, _, xd) (yi, _, yd) -> xd = yd && xi > yi) a.(i-1) a.(i) then false
    else doit (i + 1) in
  doit 1

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let () =
  let n = read_int () in
  let a = Array.init n (fun i ->
    match split (read_line ()) ' ' with
    | [c; d] -> (i, c.[0], int_of_string d)
    | _ -> exit 1) in
  quick_sort a;
  print_endline (if stable_p a n then "Stable" else "Not stable");
  Array.iter (fun (_, c, d) -> Printf.printf "%c %d\n" c d) a

Measured memory_bytes: 8852
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    vector<vector<int>> level(N, vector<int>(N));
    int l = 1;
    int fill = 0;
    while(fill < N*(N-1)/2) {
        int d = pow(2, l-1);
        while(N-d > 0) {
            FOR(i, 0, N-d) {
                level[i][i+d] = l;
                fill++;
            }
            d += pow(2, l-1)*2;
        }
        l++;
    }
    REP(i, N-1) {
        FOR(j, i+1, N) cout << level[i][j] << (j!=N-1 ? " " : "");
        cout << endl;
    }
}

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

int main()
{
    int m;
    cin >> m;
    cout << 48-m << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int x; cin >> x;
  int y = 0;
  int i;
  for(i = 1; y < x; i++){
    y += i;
  }
  if(y % x == 0) cout << i - 1<< endl;
  else{
    cout << i - 1 << endl;
  }
  return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

string s,t;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> s >> t;
    int x = s.size();
    int y = t.size();
    if(x < y){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    string ans = "";
    REP(i,x-y+1){
        bool isok = true;
        REP(j,t.size()){
            if(s[i+j]!='?' && s[i+j]!=t[j]){
                isok = false;
                break;
            }
        }
        if(isok){
            string tmp = "";
            REP(k,x){
                tmp += (s[k]=='?' ? 'a' : s[k]);
            }
            REP(l,y) tmp[i+l] = t[l];
            ans = tmp;
        }
    }
    if(ans=="") cout << "UNRESTORABLE" << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

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

    for (int i = 0; i <= (N/4); ++i) {
        for (int j = 0; j <= (N/7); ++j) {
            if (4 * i + 7 * j == N) {
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "No" << std::endl;
    return 0;
}

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

void solve()
{
	int n; cin >> n;
	if ( n >= 400 && n <= 599){
		cout << "8" << endl;
	}
	else if (n >= 500 && n <= 799){
		cout << "7" << endl;
	}
	else if (n >= 800 && n <= 999) {
		cout << "6" << endl;
	}
	else if (n >= 1000 && n <= 1199){
		cout << "5" << endl;
	}
	else if (n >= 1200 && n <= 1399){
		cout << "4" << endl;
	}
	else if (n >= 1400 && n <= 1599){
		cout << "3" << endl;
	}
	else if (n >= 1600 && n <= 1799){
		cout << "2" << endl;
	}
	else if (n >= 1800 && n <= 1999){
		cout << "1" << endl;
	}
}


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

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

int main()
{
    int sx, sy, tx, ty;
    int y, x;
    cin >> sx >> sy >> tx >> ty;
    y = (ty - sy), x = (tx - sx);
    for(int i = 0; i < y; i++) cout << "U";
    for(int i = 0; i < x; i++) cout << "R";
    for(int i = 0; i < y; i++) cout << "D";
    for(int i = 0; i < x; i++) cout << "L";
    cout << "L";
    for(int i = 0; i < y + 1; i++) cout << "U";
    for(int i = 0; i < x + 1; i++) cout << "R";
    cout << "DR";
    for(int i = 0; i < y + 1; i++) cout << "D";
    for(int i = 0; i < x + 1; i++) cout << "L";
    cout << "U" << endl;

    return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll n,ans=0;

int main(void){
	cin>>n;
	for(ll i=2; i*i<=n; i++){
		int c=0;
		while(n%i==0){
			n/=i;
			c++;
		}
		// cerr<<i<<","<<c<<endl;
		for(int j=1; j<=c; j++){
			c-=j;
			ans++;
		}
	}
	if(n>1)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

class Main{

  public static void main(String arg[]){
  Scanner sc = new Scanner(System.in);
    
    int sum = 0;
    int n = sc.nextInt();
    for(int i = 1;i<=n;i++){
    sum = sum + i;
    }
    System.out.println(sum);
  }

}

Measured memory_bytes: 35580
#include <iostream>
#define REP(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,a) REP(i,0,a)
using namespace std;

int w,h;
int c[51][51];

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

void dfs(int x,int y) {
    c[y][x] = 0;
    
    rep(i,8) {
        int nx = x+dx[i], ny = y+dy[i];
        if (0 <= nx && nx < w && 0 <= ny && ny < h && c[ny][nx] == 1) dfs(nx,ny);
    }
}
    
int main(void){
    while (1) {
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        rep(y,h) rep(x,w) cin >> c[y][x];
        
        int ans = 0;        
        rep(y,h)
            rep(x,w)
                if (c[y][x] == 1) {
                    dfs(x,y);
                    ans++;
                }

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

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, h, w;
  cin >> n >> h >> w;
  int cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    int a, b;
    cin >> a >> b;
    if (a >= h && b >= w)
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 384
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL n, cap[5];
	cin >> n;
	for (int i = 0; i < 5; ++i) {
		cin >> cap[i];
	}
	LL m = *min_element(cap, cap + 5);
	LL ans = 4 + (n + m - 1) / m;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll memo[51][51][21];
int n,imos[27][51][20];	//??????,?´????,???		a=0
string s[50];
void add(ll &x,ll y){
	x+=y;
	if(x>=mod) x%=mod;
}
ll rec(int a,int b,int c){
	//cout<<a<<" "<<b<<" "<<c<<endl;
	if(memo[a][b][c]!=-1) return memo[a][b][c];
	for(int i=a+1;i<b;i++) if(s[i].size()<=c) return memo[a][b][c]=0;
	if(s[a].size()<=c){
		if(b-a==1) return memo[a][b][c]=1;
		return memo[a][b][c]=rec(a+1,b,c);
	}
	int bb=b;
	b=n;
	ll dp[51][27]={},sum[51][27]={};
	dp[0][0]=1;
	rep1(j,26) sum[0][j]=1;
	rep1(i,b-a){
		rep1(j,26){
			rep(x,i){
				int ii=i+a,xx=x+a;
				if(imos[j-1][ii][c]-imos[j-1][xx][c]+imos[26][ii][c]-imos[26][xx][c]==i-x){
					//cout<<"sumxj"<<sum[x][j]<<endl;
//					if(sum[x][j]==2) //cout<<"is2";
					add(dp[i][j],sum[x][j]*rec(xx,ii,c+1));
				}
			}
		}
		rep(j,26){
			sum[i][j+1]=sum[i][j]+dp[i][j];
			sum[i][j+1]%=mod;
		}
		ll val=0;
		rep1(j,26){
			add(val,dp[i][j]);
		}
		memo[a][i+a][c]=val;
	}
	ll val=0;
	return memo[a][bb][c];
}
int main(){
	rep(i,51) rep(j,51) rep(k,21) memo[i][j][k]=-1;
	cin>>n;
	rep(i,n) cin>>s[i];
	rep(i,n) rep(j,s[i].size()){
		if(s[i][j]=='?') imos[26][i+1][j]++;
		else imos[s[i][j]-'a'][i+1][j]++;
	}
	rep(c,27) rep(i,n) rep(j,20) imos[c][i+1][j]+=imos[c][i][j];
	cout<<rec(0,n,0)<<endl;
}

Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
int main(){
    int a, b;
    cin >> a>>b;
    if(a+b==15){
    cout << "+" << endl;
    }else if(a*b==15){
    cout << "*" << endl;
 
    }else{
        cout << "x" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
SA=list(input())
SB=list(input())
SC=list(input())

T=[]
T.append(SA[0])
del SA[0]

for i in range(300):

    if SA==[] and T[-1]=='a':
        print('A')
        break
        
    elif SB==[] and T[-1]=='b':
        print('B')
        break
        
    elif SC==[] and T[-1]=='c':
        print('C')
        break
        
    elif T[-1]=='a':
        T.append(SA[0])
        del SA[0]
        

    elif T[-1]=='b':
        T.append(SB[0])
        del SB[0]
        

    elif T[-1]=='c':
        T.append(SC[0])
        del SC[0]

Measured memory_bytes: 3064
n, k = map(int, input().split())
dp = {}

dp[(0, 0, 0)] = 1

def perm(i, j, k):
  if (i, j, k) in dp:
    return dp[(i, j, k)]
  
  if i < 0 or j < 0 or k < 0:
    return 0
  
  dp[(i, j, k)] = ((j+j+1)*perm(i-1, j, k-2*j)\
                + (j+1)*(j+1)*perm(i-1, j+1, k-2*j)\
                +  1*perm(i-1, j-1, k-2*j))%(10**9+7)
  return dp[(i, j, k)]

print(perm(n, 0, k))

Measured memory_bytes: 76084
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    let hoge = b"pphbhhphph";
    let ans = hoge[n % 10] as char;
    println!("{}on", ans);
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std ;
const int N = 100 + 5 ;
typedef long long LL ;
typedef pair<int,int> pii;

pii a[N];
LL ans;
int n, w;

bool cmp(pii a , pii b) {
    return 1LL*a.first*b.second > 1LL*a.second*b.first;
}

LL get(LL k, int w, LL res) {
    for(int i = k; ~i; i--) {
        if(a[i].first <= w) {
            w -= a[i].first;
            res += a[i].second;
        }
        else {
            res += 1.0*a[i].second/a[i].first*w;
            break;
        }
    }
    return res;
}

void dfs(int k, int w, LL res) {
    ans = max(ans, res);
    if(k < 0 || get(k,w,res) <= ans) return;
    if(a[k].first <= w) dfs(k-1, w-a[k].first,res+a[k].second);
    dfs(k-1, w, res);
}

int main() {
    scanf("%d%d", &n, &w);
    for(int i = 0; i < n; i++) {
        scanf("%d%d" , &a[i].first, &a[i].second);
        if(a[i].first > w) n--, i--;
    }
    sort(a, a+n, cmp);
    ans = 0;
    dfs(n-1, w, 0);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e2;
bool comp(pii a, pii b) {
    return a.se*b.fi < b.se*a.fi;
}
int n, x[N], y[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n) cin >> x[i] >> y[i];
  ll ans = modPow(2, n, MOD) - (n*n+n+2)/2;
  FOR(i, 0, n){
    V<pii> v;
    FOR(j, 0, n){
      if(i==j) continue;
      int dx = x[j]-x[i], dy = y[j]-y[i];
      if(dx < 0) dx *= -1, dy *= -1;
      if(dx == 0) dy = abs(dy);
      v.pb(mp(dx, dy));
    }
    sort(all(v), comp);
    V<pii>::iterator l = v.begin();
    while(l != v.end()){
      V<pii>::iterator r = upper_bound(all(v), *l, comp);
      int d = r-l+1;
      ans -= (modPow(2, d, MOD)-(d*d+d+2)/2) * modInv(d, MOD) % MOD;
      l = r;
    }
  }
  cout << (ans%MOD+MOD)%MOD << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<vector<i64>> e;

pair<i64, i64> dfs(i64 u, i64 b, i64 d) {
  pair<i64, i64> p(u, d);
  for (i64 v : e[u]) {
    if (v != b) {
      auto q = dfs(v, u, d + 1);
      if (q.second > p.second) {
        p = q;
      }
    }
  }
  return p;
}

int main() {
  cin >> n;
  init_n(e, n + 1);
  for (i64 i = 0; i < n - 1; ++i) {
    i64 a, b; cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  auto p = dfs(1, 0, 0);
  auto q = dfs(p.first, 0, 0);
  i64 d = q.second, md = d % 3;
  if (md == 0 || md == 2) { cout << "First\n"; }
  else cout << "Second\n";
  return 0;
}


Measured memory_bytes: 26752
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	double a, l, x;
	while( scanf("%lf %lf %lf", &a, &l, &x) != EOF ){
		double ABC = 0.5 * a * sqrt( l * l - (a/2.0) * (a/2.0));
		double ADC = 0.5 * l * sqrt( ((l+x)/2.0) * ((l+x)/2.0) - (l/2.0) * (l/2.0) );
		double ans = ABC + 2.0 * ADC;
		printf("%.10f\n", ans);
	}
}

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

long long int gcd(long long int a, long long int b){
  long long int x,y;
  x= a<=b ? b : a;
  y= a<=b ? a : b;
  while (true){
    if (x%y != 0){
      a = y;
      b = x % y;
      x = a;
      y = b;
    }
    else{
      return y;
    }
  }
}
using namespace std;
int main(){
  long long int a,b,c,d;
  cin >> a >> b >> c >> d;
  long long int cd = c*d / gcd(c,d);
  long long int cn = b/c - (a-1)/c;
  long long int dn = b/d - (a-1)/d;
  long long int cdn = b/cd - (a-1)/cd;
  long long int ans = (b-a+1) -cn - dn + cdn;
  cout << ans <<endl ;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a, b, c, n, i;
    c = 0;
    int A[30];
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    for(i = 1; i < n-1; i++){
        if(A[i] < A[i-1] && A[i] > A[i+1])c++;
        if(A[i] > A[i-1] && A[i] < A[i+1])c++;
    }
    printf("%d\n", c);
    
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main() {
    int n, i, min, dmax;
    int r[200000];
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++)
        scanf("%d", &r[i]);
    
    min = r[0];
    dmax = r[1] - r[0];
    
    for (i = 1; i < n; i++){
        if(r[i] - min > dmax)
            dmax = r[i] - min;
        if (r[i] < min)
            min = r[i];
    }
    printf("%d\n", dmax);
    
}

Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
    int N, K;
    cin>>N>>K;
    int a, g, m;
    rep(i, N){
        cin>>a;
        if(i==0) {
            m=a;
            g=a;
            continue;
        }
        else{
            m=max(a, m);
            g=__gcd(a, g);
        }
    }
    if(K<=m&&K%g==0){
        cout<<"POSSIBLE"<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <valarray>
#include <string>

int main(void) {


	std::string str;
	std::cin >> str;


	int min = 1000;
	for (int i = 0; i < str.size() - 2; ++i) {
		
		//std::string t = std::to_string(str[i]) + std::to_string(str[i + 1]) + str[i + 2];
		std::string t = str.substr(i, 3);

		auto sub = abs(753 - std::stoi(t));
		min = std::min(min, sub);
	}

	std::cout << min << "\n";

	
	return 0;
}

Measured memory_bytes: 256
def main():
  n,k = input_list()
  a = input_list()
  ans = 0
  r = 1
  while True:
    r += k-1
    ans += 1
    if r >= n:
      break
  print(ans)
  
def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

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

int HowManyApplePies(int a, int p){
  p=p+3*a;
   int pie=p/2;
   return pie;
}

int main()
{
    int A,P;
  cin>>A>>P;
  cout<<HowManyApplePies(A,P);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/* #define int long long */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll INF = 1LL<<60;
const int MAX_N = 110;
const int MAX_V = 100100;

int N;
ll W, w[MAX_N], v[MAX_V];
ll dp[MAX_N][MAX_V];

signed main(){
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];

    rep(i, MAX_N){
        rep(j, MAX_V){
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    for(int i = 0; i < N; i++){
        for(int sum_v = 0; sum_v <= MAX_V; sum_v++){
            if(sum_v - v[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i]);
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    ll ans = 0;
    rep(sum_v, MAX_V){
        if(dp[N][sum_v] <= W) ans = sum_v;
    }

    cout << ans << endl;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    int minn = INF, cnt = 1;
    cin >> p[0];
    minn = p[0];
    rep(i, 1, n){
        cin >> p[i];
        if(minn > p[i]) {
            cnt++;
            minn = min(minn, p[i]);
        }
    }
    cout << cnt << endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c,k;
  cin >> n >> c >> k;
  int i,t[100010];
  for(i=0;i<n;i++){
    cin >> t[i];
  }
  sort(t,t+n);
  int sum=1,time=t[0],ans=0;
  for(i=1;i<n;i++){
    if(sum==c){
      ans++,sum=1,time=t[i];
    }
    else if(t[i]-time>k){
      if(sum%c==0){
        ans+=sum/c;
      }
      else{
        ans+=sum/c+1;
      }
      sum=1,time=t[i];
    }
    else{
      sum++;
    }
  }
  if(sum%c==0){
    ans+=sum/c;
  }
  else{
    ans+=sum/c+1;
  }
  cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    int L[N];
    int length_num[N], num=0;
    int length_sum[N]={0};
    rep(i, N) cin >> L[i];

    int sum=0;

    sort(L, L+N);
    length_num[0]=L[0];
    length_sum[0]=1;
    rep(i, N){
        if(i!=0){
            if(length_num[num]!=L[i]){
                num++;
                length_num[num]=L[i];
                length_sum[num]++;
            }else if(length_num[num]==L[i]){
                length_sum[num]++;
            }
        }
    }
    num++;
    if(num < 3) sum=0;
    else{//num種類の棒がある
        rep(i, num-2){
            for(int j=i+1; j<num-1; j++){
                for(int k=j+1; k<num; k++){
                    if(length_num[i]+length_num[j] > length_num[k] && length_num[i]+length_num[k] > length_num[j] && length_num[k]+length_num[j] > length_num[i]){
                        sum+=length_sum[i]*length_sum[j]*length_sum[k];
                    }
                }
            }
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3616
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    for a in range(1,3501):
        for b in range(a,3501):
            if 4*a*b-n*(a+b)>0 and n*a*b%(4*a*b-n*(a+b))==0:
                print(a,b,n*a*b//(4*a*b-n*(a+b)))
                sys.exit()

if __name__=='__main__':
    main()

Measured memory_bytes: 39024
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int a[110];
int main(){
	int n,m;
	cin>>n>>m;
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt+=a[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(a[i]>cnt/(4*m))ans++;
		else if(a[i]==cnt/(4*m)&&cnt%(4*m)==0)ans++;
	}
	if(ans>=m)cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int answer = H*W;
		answer = answer - h*W - w*H + h*w;
		System.out.println(answer);
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print1(a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
char c;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> c;
	print1(char(c+1));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int main() {

    int a[3][3];
    rep(i, 3){
        rep(j, 3){
            cin >> a[i][j];
        }
    }

    int n;
    cin >> n;
    int b[12];
    rep(i, n) cin >> b[i];

    bool exist = false;
    int c[3][3] = {0};

    rep(i, 3){
        rep(j, 3){
            rep(k, n) {
                if (a[i][j] == b[k]) c[i][j] = 1;
            }
        }
    }

    rep(i, 3){
        if (c[i][0] == 1 && c[i][1] == 1 && c[i][2] == 1) exist = true;
    }

    rep(i, 3){
        if (c[0][i] == 1 && c[1][i] == 1 && c[2][i] == 1) exist = true;
    }
    
    if (c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1) exist = true;
    
    if (c[2][0] == 1 && c[1][1] == 1 && c[0][2] == 1) exist = true;

    if (exist) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
loop do
  input_a, op, input_b = gets.chomp.split
  a = input_a.to_i
  b = input_b.to_i
  break if op == '?'
  puts a + b if op == '+'
  puts a - b if op == '-'
  puts a * b if op == '*'
  puts a / b if op == '/'
end


Measured memory_bytes: 6868
#define _CRT_NO_SECURE_WARNINGS
#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <string>
#include <iomanip>
#include <set>
#include <random>
#include <queue>
#include <map>
#include <ctime>
#include <sstream>
#include <cstdlib>
using namespace std;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std; int INF = 1e6; typedef long long ll; typedef double d; typedef unsigned long long ull;

void solve() {
	int n;
	cin >> n;
	set<string>test;
	for (int i = 0; i < n; ++i) {
		string element;
		cin >> element;
		test.insert(element);
	}
	cout << test.size() << endl;
} 

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("solver.txt", "r", stdin);
	solve();
	return 0;
}

Measured memory_bytes: 15600
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

int main(void)
{
    //input
    int N;
    vector<int> H;
    cin>>N;
    for(int i=0; i<N; i++)
    {
        int temp;
        cin>>temp;
        H.push_back(temp);
    }

    //calc
    int count=1;
    for(int i=N-1; i>0; i--)
    {
        int j=i-1;
        for(;j>=0; j--)
        {
            if(H[j] > H[i])
            {
                break;
            }
        }
        if(j==-1) 
        {
            count++;
        }
    }

    //output
    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N, M, K; cin >> N >> M >> K;
  vector<int> A = {0}, B = {0};

  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    A.push_back(A.back() + a);
  }

  for (int i = 0; i < M; i++) {
    int a; cin >> a;
    B.push_back(B.back() + a);
  }

  int ans = 0;

  int p = M;
  for (int i = 0; i <= N; i++) {
    if (A[i] > K) {
      break;
    }

    while (B[p] + A[i] > K) {
      p--;
    }

    ans = max(ans, p+i);
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 7472
x,y = map(int, input().split())
if x==2 or y==2:
  print("No")
  exit()

if x==4 or x==6 or x==9 or x==11:
  if y==4 or y==6 or y==9 or y==11:
    print("Yes")
  else:
    print("No")
else:
    print("Yes")
 

Measured memory_bytes: 38256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (max(max(a + b, a - b), a * b)) << endl;
	return 0;
}
 

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int cnt = 0;
  while (A > 0 || C > 0) {
    if (cnt % 2 == 0) {
      C -= B;
    } else {
      A -= D;
    }
    cnt++;
  }
  
  if (cnt % 2 == 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    sort(d.begin(), d.end());
    int ans = d[n/2] - d[n/2-1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    int n; cin >> n;
    vector<vector<pair<int, int>>> edges(n);
    for(int i = 0; i < n - 1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }
    int q, k;
    cin >> q >> k;
    k--;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
    pq.push({0, k});
    vector<char> visited(n);
    vector<ll> lens(n, MLL);
    while(pq.size()){
        auto e = pq.top(); pq.pop();
        if(visited[e.second]){ continue; }
        visited[e.second] = true;
        lens[e.second] = e.first;
        for(auto edge : edges[e.second]){
            pq.push({e.first + edge.second, edge.first});
        }
    }
    for(int i = 0; i < q; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << lens[x] + lens[y] << '\n';
    }
    return 0;
}


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

#define ll long long int
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define nl '\n'
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define all(a) a.begin(),a.end()
#define F first
#define S second
const ll N=1e6+9;
const ll mod=1e9+7;

ll a[105][N];
vector<pair<ll,ll>> v;

void solve()
{
	ll n,w,w1,v1;
	cin>>n>>w;
	v.pb({0,0});
	
	rep(i,1,n)
	{
		cin>>w1>>v1;
		v.pb({v1,w1});
	} 
	//sort(all(v));

	rep(i,0,n)
	{
		rep(j,1,100000)a[i][j]=1e9+7;
	}
	rep(i,1,n)a[i][0]=0;

	rep(i,1,n)
	{
		rep(j,1,100000)
		{
			a[i][j]=a[i-1][j];
			if(j-v[i].F>=0)
			a[i][j]= min(a[i-1][j], a[i-1][j-v[i].F]+v[i].S);
			//cout<<j<<"<<"<<a[i][j]<<" ";}
			
		}
		//cout<<nl;
	}
	repd(i,100000,1)
	{
		if(a[n][i]<=w)
		{
			cout<<i;
			break;
		}
	}

}



int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    //if(t^1)exit(0);
    while(t--)
       solve();
}

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

using namespace std;

int main()	
	{
  		int n;
  		cin >> n;
  		
  		if(n%1000==0) cout<<0<<endl;
  		else {
          int x = ceil((float)n/1000);
          cout<< abs(n- 1000*x);
  		}
      return 0;
     }
 

Measured memory_bytes: 3728
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int main() {
	string s; cin >> s; ll n = s.length();
	ll sum = n * (n - 1)/2;
	ll alf[26] = {};
	rep(i, n) {
		alf[s[i] - 'a']++;
	}
	rep(i, 26) {
		sum -= alf[i] * (alf[i] - 1)/2;
	}
	cout << sum+1 << endl;
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define NumberOfOnes __builtin_popcount
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twoll pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
int n;
ll a[200004];
ll ans,si,Ans;
int main(){FAST;xRand;
cin>>n;
for(int i=1;i<=n;i++){
	cin>>a[i];
	ans+=a[i];
}
Ans=ans;
for(int i=1;i<=n;i++){
	ans-=a[i];
	si+=a[i];
//	cout<<si-ans<<endl;
	Ans=min(Ans,abs(si-ans));
}
cout<<Ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/



Measured memory_bytes: 1792
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
    return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
          x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def num_roots(self):
    return len([i for i, x in enumerate(self.parents) if x < 0])

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def num_members(self,x):
    return abs(self.parents[self.find(x)])

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
from bisect import *
from collections import defaultdict
def solve():
  ans = 0
  N, M = map(int, input().split())
  A = list(map(int, input().split()))
  uf = UnionFind(N)
  for _ in range(M):
    x,y = map(int, input().split())
    uf.union(x,y)
  if N>2*(M+1):
    return 'Impossible'
  if N-M==1:
    return 0
  d = defaultdict(lambda: [])
  for i in range(N):
    r = uf.find(i)
    if r<0:
      d[i].append(A[i])
    else:
      d[r].append(A[i])
  lis1 = []
  for v in d.values():
    mini = min(v)
    ans += mini
    v.remove(mini)
    for l in v:
      insort_right(lis1,l)
  ans += sum(lis1[:(N-M-2)])
  return ans
print(solve())

Measured memory_bytes: 96996
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	char x, y;
	cin >> x >> y;
	if ((int)x < (int)y) {
		cout << "<" << endl;
	}
	else if (x == y) {
		cout << "=" << endl;
	}
	else {
		cout << ">" << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(){
	int N,number,co1,co2,co4;
	co4=co2=co1=0;

	cin>>N;
	REP(i,N){
		cin>>number;
		if(number%4==0) co4++;
		else if(number%2==0) co2++;
		else co1++;
	}
	if(co2!=0) co1++;

	if(abs(co4-co1)<=1||co1==0) puts("Yes");
	else puts("No");

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int main () {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);

	long long n, m;
	cin >> n >> m;

	long long res = (1 << m) * (1900 * m + 100 * (n - m));
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n;
    cin >> n;
    if(n%1000 == 0){
        cout << 0 << endl;
    }else{
        int ans = 1000 - (n %1000);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3640