akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
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>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a, b, fact[N];

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   if (a < 0) a += mod;
   return a;
}

inline int mult (int a, int b) {
   return 1ll * a * b % mod;
}

inline int binpow (int a, int b) {
   int res = 1;
   while (b) {
      if (b & 1) res = mult (res, a);
      a = mult (a, a);
      b >>= 1;
   }
   return res;
}

inline int C (int n, int k) {
   int res = 1;
   for (int i = n; i >= n - k + 1; i --)
      res = mult (res, i);
   return mult (res, binpow (fact[k], mod - 2));               
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> a >> b;
   fact[0] = 1;
   for (int i = 1; i <= max (a, b); i ++) fact[i] = mult (fact[i - 1], i);
   int ans = binpow (2, n) - 1;
   ans = add (ans, -(add (C (n, a), C (n, b))));
   cout << ans;
}

int main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


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

pair<int, int> R[100];
long dp[200010];
int DIV = 998244353;

int main() {
  int N, K; cin >> N >> K;
  for (int i = 0; i < K; i++) {
    int l, r; cin >> l >> r; R[i] = make_pair(l, r);
  }
  for (int i = 0; i <= N; i++) dp[i] = 0;
  dp[1] = 1;
  for (int i = 1; i < N; i++) {
    dp[i+1] = dp[i];
    for (int k = 0; k < K; k++) {
      dp[i+1] += dp[max(0, i-R[k].first+1)] - dp[max(0, i-R[k].second)] + DIV;
      dp[i+1] %= DIV;
    }
  }
  cout<<(dp[N]-dp[N-1]+DIV)%DIV << endl;
}

Measured memory_bytes: 5180
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;



int main(){
    int n;
    cin>>n;
    vll v(n,0LL),ma(n,0LL);
    rep(i,n)cin>>v[i];
    for(int i=0;i<n;i++){
        ma[i]=v[i];
    }
    for(int i=n-2;i>=0;i--){
        chmax(ma[i],ma[i+1]);
    }
    ll ans=-LLINF;
    rep(i,n-1){
        chmax(ans,ma[i+1]-v[i]);
    }
    fin(ans);
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int N, K; cin >> N >> K;
    int cnt=0;
    for(int i=0; i<N; i++){
        int h; cin >> h;
        if(h >= K) cnt++;
    }
    cout << cnt << endl;
    return 0;   
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int s, b, nS, nB;
int a[101], r[101];
int main(){
    cin >> nS >> nB;
    for(s=1; s<=nS; s++){cin>>a[s];}
    for(b=1; b<=nB; b++){
        for(s=1; s<=nS; s++){
            r[s] = a[s]%b;
        }
        for(s=1; s<=nS-1; s++){
            if(r[s] > r[s+1]){
                swap(a[s], a[s+1]);
                swap(r[s], r[s+1]);
            }
        }
    }
    for(s=1; s<=nS; s++){
        cout << a[s] << endl;
    }
}
void swap(int x, int y){
     int w;
     w = x;
     x = y;
     y = w;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[500001];
ll sum[500001];
map<ll,int> mp;

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

Measured memory_bytes: 18432
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,m;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)for(char c='A';c<'A'+m;c++){
		string s;cin>>s;if(s=="snuke"){
			cout<<c<<i<<endl;return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    from collections import defaultdict
    import sys
    # functions used
    r = lambda: sys.stdin.readline().strip()
    R = lambda: list(map(int, r().split()))

    N = int(r())
    Dic = defaultdict(list)
    V = 10**5 + 5
    Arrived = [False] * (2 * V)
    for _ in range(N):
        x, y = R()
        y += V
        Dic[x].append(y)
        Dic[y].append(x)

    ans = 0
    task = []
    for k, v in Dic.items():
        if Arrived[k]:
            continue
        Arrived[k] = True
        if k < V:
            cntx = 1
            cnty = 0
        else:
            cntx = 0
            cnty = 1
        cntdot = 0
        task.extend(v)
        cntdot += len(v)
        while task:
            s = task.pop()
            if Arrived[s]:
                continue
            if s < V:
                cntx += 1
            else:
                cnty += 1
            Arrived[s] = True
            task.extend(Dic[s])
            cntdot += len(Dic[s])
        ans += cntx * cnty - cntdot // 2
    print(ans)

if __name__ == '__main__':
    main()


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

int n, a[101010];
int l[101010], r[101010];

int main()
{
    cin >> n;
    rep(i, n) cin >> a[i];

    l[0] = a[0];
    for (int i = 1; i < n; i++)
    {
        l[i] = __gcd(l[i - 1], a[i]);
    }
    r[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--)
    {
        r[i] = __gcd(r[i + 1], a[i]);
    }
    
    int res = 0;
    res = max(l[n - 2], r[1]);
    for (int i = 1; i < n - 1; i++)
    {
        res = max(res, __gcd(l[i - 1], r[i + 1]));
    }
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 1408
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

ans = "NO"
if a < b:
    if a + v * t >= b + w * t:
        ans = "YES"
else:
    if b - w * t >= a - v * t:
        ans = "YES"
print(ans)


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

int C,N,M,S,D;

class Node
{
	public:
		
		vector<int> to,c;
};

class State
{
	public:

		int p,c,k;
		State(int P, int C, int K)
		{
			p=P; c=C; k=K;
		}

		bool operator<(const State &s) const
		{
			if(c!=s.c) return c>s.c;
			return k>s.k;
		}
};



int main()
{
	while(cin>>C>>N>>M>>S>>D, C||N||M||S||D)
	{
		int v[100][10] = {0};
		Node node[100];

		S--; D--;
		for(int i=0; i<M; i++)
		{
			int x,y,z;
			cin>>x>>y>>z;
			x--; y--;
			node[x].to.push_back(y);
			node[y].to.push_back(x);
			node[x].c.push_back(z);
			node[y].c.push_back(z);
		}

		priority_queue<State>	 q;
		q.push(State(S,0,0));
		while(!q.empty())
		{
			State t=q.top(); q.pop();
			if(t.p==D)
			{
				cout << t.c << endl;
				break;
			}

			if(v[t.p][t.k]) continue;
			v[t.p][t.k] = 1;

			for(int i=0; i<node[t.p].to.size(); i++)
			{
				q.push(State(node[t.p].to[i], t.c+node[t.p].c[i], t.k));
				if(t.k<C)
				{
					q.push(State(node[t.p].to[i], t.c+node[t.p].c[i]/2, t.k+1));
				}
			}
		}


	}
}

Measured memory_bytes: 0
CAKE = 4
DONUTS = 7
n = int(input())
max_cake = n//CAKE
max_donuts = n//DONUTS
flag = 0
for i in range(max_cake+1):
    for j in range(max_donuts+1):
        if i*CAKE+j*DONUTS == n:
            flag = 1
if flag == 1 :
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import bisect
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

n = getint()
points = [getint() for _ in range(n)]

cache = {}

def solve(pos, modulo):

    key = (pos, modulo)
    if key in cache:
        return cache[key]

    if pos == n:
        return -100000000 if modulo == 0 else 0

    res1 = solve(pos + 1, modulo)
    res2 = solve(pos + 1, (modulo + points[pos]) % 10) + points[pos]

    res = max(res1, res2)
    cache[key] = res

    return res

res = max(solve(0, 0), 0)

print(res)

Measured memory_bytes: 38640
#include <iostream>
#include <string>

int main() {
  std::string S;
  std::cin >> S;

  std::string ret = "yes";
  int size = S.length();
  for (int i = 0; i < size; ++i) {
    for (int j = i + 1; j < size; ++j) {
      if ( S[i] != S[j] ) continue;
      ret = "no";
    }
  }
  std::cout << ret << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define forn(x) for(int i=1;i<=x;i++) 
#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)
#define pii pair<int, int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK
 
    PIHALITI
 
 */

int main(){ speed;
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(s.substr(0, n/2) == s.substr(n/2, n-n/2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem073c(n, a))
}

fun problem073c(n: Int, a: List<Long>): Int {
    val a = a.toLongArray()
    val set = hashSetOf<Long>()
    for (i in 0 until n) {
        val ai = a[i]
        if (set.contains(ai)) {
            set.remove(ai)
        } else {
            set.add(ai)
        }
    }
    return set.count()
}

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

typedef enum {false, true} bool;

int main(void)
{
    int H, W;
    int HxW;
    bool *A;
    int *Q;
    char c;
    int i, j;
    int front, rear;
    int ctr, temp;
    
    
    scanf("%d%c%d%c", &H, &c, &W, &c);
    
    HxW = H*W;
    
    
    A = (bool*)malloc(sizeof(bool)*HxW);
    Q = (int*)malloc(sizeof(int)*HxW);
    
    
    front = rear = 0;
    
    
    for(i=0; i<H; i++)
    {
        for(j=0; j<W; j++)
        {
            scanf("%c", &c);
            
            if(c == '.')
                A[i*W+j] = false;
            else
            {
                A[i*W+j] = true;
                Q[rear++] = i*W+j;
            }
        }
        scanf("%c", &c);
    }
    
    
    ctr = 0;
    
    
    while(front != rear)
    {
        temp = rear;
        
        i = rear-front;
        
        while(i-- > 0)
        {
            if(Q[front]%W != 0 && !A[Q[front]-1])
            {
                A[Q[front]-1] = true;
                Q[rear++] = Q[front]-1;
            }
            
            if((Q[front]+1)%W != 0 && !A[Q[front]+1])
            {
                A[Q[front]+1] = true;
                Q[rear++] = Q[front]+1;
            }
            
            if(Q[front] >= W && !A[Q[front]-W])
            {
                A[Q[front]-W] = true;
                Q[rear++] = Q[front]-W;
            }
            
            if(Q[front]+W < HxW && !A[Q[front]+W])
            {
                A[Q[front]+W] = true;
                Q[rear++] = Q[front]+W;
            }
            
            front++;
        }
        
        if(rear != temp)
            ctr++;
    }
    
    
    printf("%d\n", ctr);
    
    
    free(A);
    free(Q);
    
    
    //system("pause");
    
    return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    ll n,l;cin>>n>>l;
    ll a[n];
    rep(i,n) cin>>a[i];
    ll m=0,x;
    rep(i,n-1){
        m=max(a[i]+a[i+1],m);
        if(a[i]+a[i+1]>=l){
            x=i+1;
            break;
        }
    }
    if(m<l) {
        cout<<"Impossible"<<"\n";
    }
    else{
        cout<<"Possible"<<"\n";
        for(int i=1;i<x;i++) cout<<i<<"\n";
        for(int i=n-1;i>=x;i--) cout<<i<<"\n";
    }
}

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

using namespace std;

typedef long long ll;

struct Edge {
  int to, cost;
};

int N, Q, K;
vector<Edge> d[100000];
ll v[100000];

void dfs(int idx, int par = -1) {
  for (auto &e : d[idx]) {
    if (e.to == par) continue;
    v[e.to] = v[idx] + e.cost;
    dfs(e.to, idx);
  }
}

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

  cin >> N;
  for (int i = 1; i < N; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    d[a].emplace_back((Edge) {b, c});
    d[b].emplace_back((Edge) {a, c});
  }
  cin >> Q >> K;
  dfs(--K);
  while (Q--) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    cout << v[x] + v[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
ll mod=1000000007;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	rep(i,n){
		cin >> a.at(i);
		b.at(a.at(i))++;
	}
	ll ans=1;
	bool flg=true;
	if(n%2==0){
		rep(i,n){
 			if(a.at(i)%2==0) flg=false;
		}
		if(b[0]!=0) flg=false;
		for(int i=1;i<n;i+=2){
			if(b[i]!=2) flg=false;
		}
	}
	else{
		rep(i,n){
 			if(a.at(i)%2==1) flg=false;
		}
		if(b[0]!=1) flg=false;
		for(int i=2;i<n;i+=2){
			if(b[i]!=2) flg=false;
		}
	}
	rep(i,n/2){
		ans*=2;
		ans%=mod;
	}
	if(flg) cout << ans << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 1024
<?php
# 入力部
fscanf(STDIN, "%s %s", $s, $t);
fscanf(STDIN, "%d %d", $a, $b);
fscanf(STDIN, "%s", $u);
// fscanf(STDIN, "%d %d", $n, $r);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $n);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%s", $s2);
// fscanf(STDIN, "%d %d %d", $a, $b, $c);


# 処理部
// $arr = str_split($s);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// for ($i = $a; $i <= $b; $i++) {
//   if ($i % $k == 0) {
//     $r = "OK";
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
// $r = "No";
// if (strpos($n, "7") !== false) {
//   $r = "Yes";
// }
// $r = "No";
// if ($arr[2] == $arr[3] && $arr[4] == $arr[5]) {
//   $r = "Yes";
// }
// $r = "Yes";
// if ($s == "AAA" || $s == "BBB") {
//   $r = "No";
// }
// if ($n % 2 == 0) {
//   $r = $n / 2;
// } else {
//   $r = ($n + 1) / 2;
// }
// if ($n < 10) {
//   $r += (10 - $n) * 100;
// }
// $arr = array($a, $b, $c);
// $arr = array_unique($arr);
// if (count($arr) == 2) {
//   $r = "Yes";
// } else {
//   $r = "No";
// }
if ($s == $u) {
  $a--;
} else {
  $b--;
}

# 出力部
// echo ($n * ($n - 1) / 2) + ($m * ($m - 1) / 2) . "\n";
// echo $z . " " . $x . " " . $y . "\n";
// echo ($i * 1000) - $n . "\n";
// echo json_encode($arr) . "\n";
// echo $r . "\n";
echo $a . " " . $b . "\n";


Measured memory_bytes: 15972
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, K, s = 0, c = 0;

  std::string S;

  std::cin >> N >> K >> S;

  for (int i = 0; i < N - 1; i ++)
    if (S[i] == S[i + 1]) {
      s ++;
    }
    else {
      c ++;
    }

  std::cout << s + std::min(c, K * 2) << std::endl;

  return 0;
}


Measured memory_bytes: 512
#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;
    // P(X+L, X-L)
    vector< P > robots(N);
    rep(i, N) {
        int x, l;
        cin >> x >> l;
        robots[i] = P(x + l, x - l);
    }
    sort(robots.begin(), robots.end());

    int ans = 1;
    int curr = robots[0].first;
    for (int i = 1; i < N; ++i) {
        if (robots[i].second < curr) {
            continue;
        }
        ++ans;
        curr = robots[i].first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               int n;
               cin>>n;
               int a[n],sum=0,mid=0;
               for(int i=0;i<n;++i)
               {
                    cin>>a[i];
                    sum += a[i];
               }
               mid = sum/n;
               ll ans1=0;
               for(int i=0;i<n;++i)
               {
                    ans1 += (a[i]-mid)*(a[i]-mid);
               }
               mid++;
               ll ans2=0;
               for(int i=0;i<n;++i)
               {
                    ans2 += (a[i]-mid)*(a[i]-mid);
               }
               cout<<min(ans1,ans2);
       }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int dsum(int A){
  int tans = 0;
  while (A!=0){
    tans += A%10;
    A /= 10;
  }
  return tans; 
}

int main() {
  int N;
  cin >> N;
  int ans = N;
  for (int i=1; i < N ; i++){
    if (dsum(i) + dsum(N-i) < ans){
      ans = dsum(i) + dsum(N-i);
//      cout << i << "_"<< dsum(i) << " "<< N-i << "_" << dsum(N-i) << endl;
    }
  }
  
  cout << ans << endl;
  
} 


Measured memory_bytes: 3600
using System;

namespace GraphTheory
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            if (N % 2 != 0) { Console.WriteLine(0); return; }

            long m = 10;
            long sum = 0;
            while (m <= N)
            {
                sum += N / m;
                m *= 5;
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

int dp[111][2][4];
void solve()
{
    string s;
    int k;
    cin>>s>>k;
    int n = sz(s);
    dp[0][0][0] = 1;

    forn(i, n)
    {
        int D = s[i] - '0';
        forn(j, 2)
        {
            forn(x, k + 1)
            {
                for(int d = 0; d <= (j?9:D); ++d)
                {
                    if (x+(d != 0) <= k)
                        dp[i+1][j||(d<D)][x+(d!=0)] += dp[i][j][x];
                }
            }
        }
    }
    cout << dp[n][0][k] + dp[n][1][k] << '\n';
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,_,w) = get!(usize, usize, isize);
    let a = get!([isize]);

    let mut mx = (a[n-1]-w).abs();
    let mut mn = std::isize::MAX;
    for i in 1..n {
        mn = min!(mn, (a[n-i-1]-a[n-1]).abs());
        mx = max!(mx, mn);
    }
    println!("{}", mx);
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n;
struct pos{
	int x,y;
}pointset[1007];
int edgenum=0,f[1007],sizex[1007];
int gf(int x) {
	while(x!=f[x])
		x=f[x]=x[f][f];
	return x;
}
struct edge{
	int a,b,v;
	bool operator<(const edge&e)const {
		return v<e.v;
	}
	void unite() {
		int x=gf(a),y=gf(b);
		if(x!=y) {
			f[x]=y;
			sizex[y]+=sizex[x];
		}
	}
}edgeset[207*207];
int gcd(int a,int b) {
	return b?gcd(b,a%b):a;
}
int pow2[1007],ans;
int main(){
	scanf("%d",&n);
	pow2[0]=1;
	for(int i=1;i<=n;++i)
		pow2[i]=pow2[i-1]*2%mod;
	ans=(pow2[n]-n-1)%mod;
	for(int i=0;i<n;++i)
		scanf("%d%d",&pointset[i].x,&pointset[i].y);
	for(int i=0;i<n;++i) {
		for(int j=0;j<i;++j) {
			int x=pointset[i].x-pointset[j].x,y=pointset[i].y-pointset[j].y;
			int g=gcd(x,y);
			x/=g,y/=g;
			if(!x)
				y=1;
			if(!y)
				x=1;
			if(x<0)
				x=-x,y=-y;
			edgeset[edgenum++]=(edge){i,j,x*30000+y};
		}
	}
	sort(edgeset,edgeset+edgenum);
	for(int i=0,j=0;i<edgenum;i=j) {
		for(int a=0;a<n;++a)
			sizex[f[a]=a]=1;
		for(;j<edgenum&&edgeset[i].v==edgeset[j].v;edgeset[j++].unite());
		for(int a=0;a<n;++a)
			if(f[a]==a&&sizex[a]>1)
				ans=(ans-pow2[sizex[a]]+sizex[a]+1)%mod;
	}
	printf("%d\n",(ans%mod+mod)%mod);
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  switch(a + b) {
    case 3:
      cout << 3 << endl;
      break;
    case 4:
        cout << 2 << endl;
      break;
    case 5:
      cout << 1 << endl;
      break;
  }
}

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

#define YukimiDaifuku
#define Tabetainaaaaa

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

    std::vector<int> a(n + 2);
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        std::cin >> a[i];
        sum += std::abs(a[i] - a[i - 1]);
    }
    sum += std::abs(a[n + 1] - a[n]);

    for (int i = 1; i <= n; i++)
    {
        int x = std::abs(a[i - 1] - a[i]);
        int y = std::abs(a[i] - a[i + 1]);
        int z = std::abs(a[i - 1] - a[i + 1]);
        std::cout << sum - x - y + z << std::endl;
    }

    YukimiDaifuku Tabetainaaaaa return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int n;
int cnt = 62;
vector<ll> vec;
ll mod = 1e9+7;

ll solve() {
  vector<vector<int>> sum_zero(n+1, vector<int>(cnt, 0));
  vector<vector<int>> sum_one(n+1, vector<int>(cnt, 0));

  ll ans = 0;
  reps(i, 1, n+1) {
    rep(j,cnt) {
      if (vec.at(i-1) >> j & 1ll) {
        sum_one.at(i).at(j) = sum_one.at(i-1).at(j) + 1;
        sum_zero.at(i).at(j) = sum_zero.at(i-1).at(j);
      } else {
        sum_one.at(i).at(j) = sum_one.at(i-1).at(j);
        sum_zero.at(i).at(j) = sum_zero.at(i-1).at(j) + 1;
      }
    }
  }
  rep(i, n-1) {
    ll t = 1;
    rep(j, cnt) {
      ll v;
      if (vec.at(i) >> j & 1ll) {
        v = (sum_zero.at(n).at(j) - sum_zero.at(i+1).at(j));
      } else {
        v = (sum_one.at(n).at(j) - sum_one.at(i+1).at(j));
      }
      ans += v * t;
      ans %= mod;
      t *= 2;
      t %= mod;
    }
  }
  return ans;
}

int main()
{ 
  cin >> n;
  vec.resize(n);
  rep(i, n) cin >> vec.at(i);
  cout << solve() << endl;
  
  return 0;
}

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

int main(){

    int a, b;
    cin >> a >> b;

    if(a < b){
        cout << "a < b" << endl;
    }else if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define Forr(i, s, e) for (ll i = s; i > e; i--)
#define pb push_back
#define ll long long
#define mp make_pair
double dp[300 + 1][300 + 1][300 + 1];

double sushi(ll a, ll b, ll c, ll n)
{
    if (a < 0 || b < 0 || c < 0)
        return 0;
    if (a == 0 && b == 0 && c == 0)
        return 0;
    if (dp[a][b][c] >= 0)
        return dp[a][b][c];
    ll sum = a + b + c;
    double xd = n + (a) * (sushi(a - 1, b, c, n)) + (b) * (sushi(a + 1, b - 1, c, n)) + (c) * (sushi(a, b + 1, c - 1, n));
    dp[a][b][c] = xd / sum;
    return dp[a][b][c];
}
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(8);
    ll n, k;
    cin >> n >> k;
    bool a[k + 1] = {0};
    ll arr[n];
    For(i, 0, n) cin >> arr[i];
    For(i, 0, k + 1)
    {
        For(j, 0, n)
        {
            if (i - arr[j] >= 0)
                if (arr[j] <= i && a[i - arr[j]] == 0)
                    a[i] = 1;
        }
    }
    if (a[k])
        cout << "First\n";
    else
        cout << "Second\n";
    return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<deque>
#include<algorithm>
#include<functional>
#define P pair<int,int>//??¶????????????
#define int long long
using namespace std;

P c[30];
P n[14348907], m[14348907];
deque<P>Q;
int x, y;
int d, e;
P S;
void saiki(int a, bool b) {
	if (!b) {
		if (a == d) { n[x] = S; x++; return; }
		saiki(a + 1, b);
		S.first += c[a].first;
		S.second += c[a].second;
		saiki(a + 1, b);
		S.first -= c[a].first*2;
		S.second -= c[a].second*2;
		saiki(a + 1, b);
		S.first += c[a].first;
		S.second += c[a].second;
	}
	else {
		if (a == e) { m[y] = S; y++; return; }
		saiki(a + 1, b);
		S.first += c[a + d].first;
		S.second += c[a + d].second;
		saiki(a + 1, b);
		S.first -= c[a + d].first*2;
		S.second -= c[a + d].second*2;
		saiki(a + 1, b);
		S.first += c[a + d].first;
		S.second += c[a + d].second;
	}
}
void push(P a) {
	while (Q.size()) {
		P b = Q.back();
		if (b.second <= a.second)Q.pop_back();
		else break;
	}
	Q.push_back(a);
}
signed main() {
	int a, b; cin >> a >> b;
	for (int d = 0; d<a; d++) {
		scanf("%lld%lld", &c[d].first, &c[d].second);
	}
	d = a / 2; e = a - d;
	saiki(0, false);
	S = P(0, 0);
	saiki(0, true);
	sort(n, n + (int)pow(3, d));
	sort(m, m + (int)pow(3, e),greater<P>());
	int sum = 0;
	int MAX = 0;
	for (int i = 0; i<pow(3, d); i++) {
		for (0; sum < pow(3, e);sum++) {
			if (n[i].first + m[sum].first > b)continue;
			if (n[i].first + m[sum].first < -b)break;
			push(m[sum]);
		}
		while (Q.size()) {
			P t = Q.front();
			if (abs(n[i].first+t.first)>b)Q.pop_front();
			else break;
		}
		if (Q.size())MAX = max(MAX, Q.front().second + n[i].second);
	}
	cout << MAX << endl;
}

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

int main(void)
{
  while(1)
    {
      int a[60]={};
      int n=0,p=0;
      int i=0,j=0;
      int judge[2]={};
      int m=0,s=0;
      int turn=0;

      scanf("%d %d",&n,&p);
      if(!(n+p))break;

      /* ????????¶??????????????? */
      m=p/n;
      for(i=0;i<n;i++)a[i]+=m;
      m=p%n;
      for(i=0;i<m;i++)a[i]++;
      turn=m;

      while(1) //1?????????
	{
	  /* ???????????¶????¢???? */
	  judge[0]=0;
	  for(i=0;i<n;i++)
	    if(a[i]!=0)judge[0]++,judge[1]=i;
	  if(judge[0]==1)break;

	  /* ????????\??¬????????§??? */
	  s=a[turn];

	  if(s)
	    {
	      a[turn]=0;
	      m=s/n;
	      for(i=0;i<n;i++)a[i]+=m;
	      m=s%n;
	      for(i=1;i<=m;i++)a[(turn+i)%n]++;
	      
	      turn=(turn+i)%n;
	    }
	  else
	    turn=(turn+1)%n;

	}

      printf("%d\n",judge[1]);

    }
  return 0;
}

Measured memory_bytes: 600
import itertools

n=int(input())
a = list(map(int, input().split()))
b = list(itertools.accumulate(a))

sum=0
count=0

sum1=0
count1=0

for i in range(n):
    if i%2==0:
        if b[i]+sum>0:
            continue
        else:
            count+=1-(b[i]+sum)
            sum+=1-(b[i]+sum)

    else:
        if b[i]+sum<0:
            continue
        else:
            count+=b[i]+sum+1
            sum-=b[i]+sum+1

for i in range(n):
    if i%2==0:
        if b[i]+sum1<0:
            continue
        else:
            count1+=b[i]+sum1+1
            sum1-=b[i]+sum1+1


    else:
        if b[i]+sum1>0:
            continue
        else:
            count1+=1-(b[i]+sum1)
            sum1+=1-(b[i]+sum1)

print(min(count,count1))

Measured memory_bytes: 65364
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
#include<map>
#include<queue>
using namespace std;

int main(){

  int r0, w0, c, r;
  while( cin >> r0 >> w0 >> c >> r ){
    if( r0 == 0 && w0 == 0 && c == 0 && r == 0 ) break;
    int cnt = 0;

    while( true ){
      if( r0 < w0 * c ){
        r0 += r;
        cnt++;
      }else break;
    }
    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 3076
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    REP(i, N) cin >> h[i];

    SORT(h);
    int ans = INF32;
    REP(i, N) {
        if (i + K - 1 >= N)
            break;
        ans = min(ans, h[i + K - 1] - h[i]);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int N;
	string s, t;
	cin >> N >> s >> t;
	int ans = 2 * N;
	for (int i = N; i >0; i--) {
		if (s.substr(N - i, i) == t.substr(0, i)) {
			ans = 2 * N - i;
			break;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
    while (true) {
        int n, k, s;
        cin >> n >> k >> s;
        if (n == 0 && k == 0 && s == 0) {
            break;
        }

        int count = 0;
        // k個選ぶ
        std::string bitMask(k, 1);
        // n個の中から
        bitMask.resize(n, 0);
        do {
            int sum = 0;
            for (int i = 0; i < n; ++i) {
                // 組み合わせに選ばれた値
                if (bitMask[i]) {
                    // 0からなので1ずらす
                    sum += i + 1;
                }
            }
            if (sum == s) {
                count += 1;
            }
            // 次のマスクを求める
        } while (std::prev_permutation(bitMask.begin(), bitMask.end()));
        cout << count << endl;
    }
}


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

int eulerPhi(int n) {
  int res = n;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      res = res / i * (i - 1);
      while (n % i == 0) n /= i;
    }
  }
  if (n != 1) res = res / n * (n - 1);
  return res;
}

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



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {

  int a,b;
  cin >> a>>b;
  


  cout << a*b << endl ; 
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  int s=0;
  cin >> N;
  for(int i=0;i<N.length();i++){
    s+=N[i]-'0';
  }
  int ans = stoi(N)%s;
  if(ans==0) cout<<"Yes"<<endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

def bisect(ng, ok, judge, eps=1):
    while abs(ng-ok) > eps:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

N,M = map(int,input().split())
A = sorted(map(int,input().split()))
acc = [0]+list(accumulate(A))

def judge(p):
    j = N
    cnt = 0
    for al in A:
        while j > 0 and al+A[j-1] >= p:
            j -= 1
        cnt += N-j
    return cnt <= M

p = bisect(0, A[-1]*2+1, judge)

j = N
cnt = 0
res = 0
nv = 0
max2 = lambda x,y: x if x > y else y
for al in A:
    while j > 0 and al+A[j-1] >= p:
        j -= 1
    cnt += N-j
    res += (N-j)*al + acc[-1]-acc[j]
    if j > 0:
        nv = max2(nv, al+A[j-1])

res += nv*(M-cnt)
print(res)

Measured memory_bytes: 91144
#include <iostream>
#include <string>


using namespace std;

bool rev(string s) {
   int N = s.length();
   
   for(int i = 0; i < (N + 1) / 2; i++) {
      if(s[i] != s[N - i - 1]) {
         return false;
      }
   }

   return true;
}
   

int main ()  {
   string S; cin >> S;

   bool rev1 = rev(S);

   int N = S.length();
   string s1;
   for(int i = 0; i < (N - 1) / 2; i++) {
      s1 += S[i];
   }

   string s2;
   for(int i = (N + 3) / 2 - 1; i < N; i++) {
      s2 += S[i];
   }

   bool rev2 = rev(s1);
   bool rev3 = rev(s2);

   if(rev1 && rev2 && rev3) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }


}

      
      


Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
s = gets

now = n
route = []
while t = (-[m,now].min..-1).find{|i|s[now+i]==?0}
  now += t
  route << -t
end

if now == 0
  puts route.reverse*" "
else
  p -1
end


Measured memory_bytes: 3960
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli ans=0;
    lli n;
    cin >> n;
    rep(i,n){
        if((i+1)%5!=0&&(i+1)%3!=0){
            ans += i + 1;
        }
    }
    out(ans);
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

/*
map<tuple<int, int, int, bool>, int> memo;

int process(int z, int w, int n, int p, const vector<int> cards, bool turn_x)
{
	auto past = memo.find(make_tuple(z, w, p, turn_x));
	if (past != memo.end()) {
		return past->second;
	}

	assert(p < n);
	if (turn_x) {
		int result = 0;
		for (int i = p + 1; i < n; i++) {
			int new_z = cards[i - 1];
			int cur = process(new_z, w, n, i, cards, false);
			result = max(result, cur);
		}
		{
			int new_z = cards[n - 1];
			result = max(result, abs(new_z - w));
		}

		memo[make_tuple(z, w, p, turn_x)] = result;
		return result;
	}
	else {
		int result = INT_MAX;
		for (int i = p + 1; i < n; i++) {
			int new_w = cards[i - 1];
			int cur = process(w, new_w, n, i, cards, true);
			result = min(result, cur);
		}
		{
			int new_w = cards[n - 1];
			result = min(result, abs(z - new_w));
		}

		memo[make_tuple(z, w, p, turn_x)] = result;
		return result;
	}
}
*/

map < tuple<int, int, bool>, int> memo;
int process(int s, int n, int p, bool turn_x, const vector<int> cards)
{
	auto elem = memo.find(make_tuple(s, p, turn_x));
	if (elem != memo.end()) {
		return elem->second;
	}

	int result;
	if (turn_x) {
		result = 0;
		for (int i = p + 1; i < n; i++) {
			int cur = process(cards[i - 1], n, i, false, cards);
			result = max(result, cur);
		}
		result = max(result, abs(s - *cards.rbegin()));
	}
	else {
		result = INT_MAX;
		for (int i = p + 1; i < n; i++) {
			int cur = process(cards[i - 1], n, i, true, cards);
			result = min(result, cur);
		}
		result = min(result, abs(s - *cards.rbegin()));
	}

	memo[make_tuple(s, p, turn_x)] = result;
	return result;
}

int main()
{
	int n, z, w;
	cin >> n >> z >> w;

	vector<int> cards(n);
	for (int& card : cards) {
		cin >> card;
	}

	int result = process(w, n, 0, true, cards);

	cout << result << endl;

	return 0;
}

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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

const int MAXN = 1e5+10;
vector<pair<int, int> > g[MAXN];
int edges[MAXN];
int ans = 0;

void dfs(int v, int p, int prev, int next){
    for(pair<int, int> e: g[v]){
        if(e.fst == p) continue;
        if(next == prev) next++;
        edges[e.snd] = next;
        ans = max(next, ans);
        int aux = next+1;
        if(next != 1) aux = 1;
        dfs(e.fst, v, next, aux);
        next++;
    }
}

int main() {FIN;
    int n;
    cin>>n;
    int deg[n];
    fill(deg, 0);

    int c = 0;
    fore(i,0,n-1){
        int a,b;
        cin>>a>>b; a--; b--;
        deg[a]++; deg[b]++;
        g[a].pb(make_pair(b,c));
        g[b].pb(make_pair(a,c));
        c++;
    }
    vector<pair<int, int> > ord;
    fore(i,0,n){
        ord.pb(make_pair(deg[i], i));
    }
    sort(ord.begin(), ord.end());
    dfs(ord[0].snd, -1, -1, 1);
    cout<<ans<<"\n";
    fore(i, 0, n-1) cout<<edges[i]<<"\n";
    return 0;
}



Measured memory_bytes: 10104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000007
typedef long long int lint;

int main (){
  int K;
  string S;
  cin >> K >> S;
  if(S.size() > K){
    rep(i,0,K){cout << S[i];}
    co("...");
  }
  else{co(S);}
}

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

using namespace std;

int A, B, C;
int X;

int main (){
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;

    int cnt = 0;

    for (int i = 0; i <= A; i++){
        for (int j = 0; j <= B; j++){
            for (int k = 0; k <= C; k++){
                if ((500 * i + 100 * j + 50 * k) == X){
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256