akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    v = [[] for i in range(n)]
    v_ = [[] for i in range(n)]
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v_[b].append(a)
    p = [0]*n
    p[0] = 1
    for x in range(n):
        for y in v[x]:
            p[y] += p[x]/len(v[x])
    e = [0]*n
    e_ = [0]*n
    for x in range(n)[::-1]:
        s = 0
        for y in v[x]:
            s += e[y]
        if v[x]:
            e[x] = e_[x] = 1+s/len(v[x])
        if len(v[x]) > 1:
            e_[x] = 1+(s-max([e[y] for y in v[x]]))/(len(v[x])-1)
    ans = e[0]
    print(ans+min(list(map(lambda x:x[0]*(x[2]-x[1]), zip(p,e,e_)))))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 65372
import bisect

n = int(input())
al, bl, cl = list(sorted(map(int, input().split())) for i in range(3))
ans = 0

for key in bl:
    top = bisect.bisect_left(al, key)
    btm = len(cl) - bisect.bisect_right(cl, key)
    ans += top * btm

print(ans)

Measured memory_bytes: 22720
import copy
H,W,K=map(int,input().split())
S=[]
for _ in range(H):
    S.append([int(x) for x in list(input())])

ans=(H-1)+(W-1)

for i in range(2**(H-1)):
    check=[0]*H
    for j in range(H-1):
        if ((i>>j)&1):
            check[j+1]=check[j]+1
        else:
            check[j+1]=check[j]
    
    g=check[H-1]+1
    A=[0]*g
    c=0
    f=0
    for j in range(W):
        B=[0]*g
        for k in range(H):
            if S[k][j]==1:
                B[check[k]]+=1
            if B[check[k]]>K:
                c=10**4
                f=1
                break
        if f:
            break
        #print("AB",A,B)
        for l in range(g):
            if B[l]==0:
                continue
            elif A[l]+B[l]>K:
                c+=1
                A=copy.copy(B)
                break
            else:
                A[l]+=B[l]
    ans=min(ans,c+g-1)

print(ans)




Measured memory_bytes: 45916
#include<stdio.h>

int grade(int pm, int pe, int pj)
{   
    int t;
    int sum = pm + pe +pj;
    if ((pm == 100) || (pe == 100) || (pj == 100)) {
        t = 0;
    } else if (pm + pe >= 180) {
        t = 0;
    } else if (sum >= 240) {
        t = 0;
    } else if (sum >= 210) {
        t = 1;
    } else if ((sum >= 150) && ((pe >= 80) || (pm >= 80))) {
        t = 1;
    } else {
        t = 2;
    } 
    return t;
}
    
        
int main(void)
{
    int n;
    while(1) {
        scanf("%d", &n);
        if ( n == 0) {
            break;
        } else {    
            for (int i = 0; i < n; i++) {
                int pm, pe, pj;
                scanf("%d %d %d", &pm, &pe, &pj);
                int t = grade(pm, pe, pj);
                if (t == 0) {
                    printf("A\n");
                } else if (t == 1) {
                    printf("B\n");
                } else {
                    printf("C\n");
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1012
/* Ajay Jadhav */
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

const int N=1e5+5;
int g[N][3];
int dp[N][3];
int n;
int f(int i,int p)
{
    if(i>=n) return 0;
    if(dp[i][p]!=-1)
        return dp[i][p];
    int& ans=dp[i][p];
    ans=0;
    rep(j,0,3)
    {
        if(j!=p) 
            ans=max(ans,g[i][j]+f(i+1,j)); 
    }
    return ans;
}
void solve()
{
    cin>>n;
    rep(i,0,n) cin>>g[i][0]>>g[i][1]>>g[i][2];
    int ans=0;
    memset(dp,-1,sizeof dp);
    rep(i,0,3)
    {
        ans=max(ans,g[0][i]+f(1,i));
    }
    cout<<ans;
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 10368
import math

N, H = map(int, input().split())

a_list = []
b_list = []
for i in range(N):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)

max_a = max(a_list)
b_list.sort(reverse=True)

count = 0
for b in b_list:
    if b > max_a and H > 0:
        count += 1
        H -= b
    else:
        break

if H > 0:
    count += math.ceil(H / max_a)
print(count)

Measured memory_bytes: 61528
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
#define yi first
#define er second
typedef pair<ll,ll> pll;
typedef vector<ll> vlt;
const ll inf=1e18;
const int yuzu=1e5;
int n=read(),m=read(),s=read(),t=read();

struct edge{int to;ll cost;};
vector<edge> lj[2][yuzu|10];

vlt pao(int s,int id){
priority_queue<pll,vector<pll>,greater<pll> > q;
vlt d(n+2,inf);
d[s]=0,q.push(pll(0,s));
for (;!q.empty();){
  pll p=q.top();q.pop();
  int v=p.er;
  if (d[v]>=p.yi){
    for (edge e:lj[id][v]){
      if (d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        q.push(pll(d[e.to],e.to));
	    } 
	  }
    }
  }return d;
}

int main(){
int i;
for (i=1;i<=m;++i){
  int u=read(),v=read();ll a=read(),b=read();
  lj[0][u].push_back(edge{v,a});
  lj[0][v].push_back(edge{u,a});
  lj[1][u].push_back(edge{v,b});
  lj[1][v].push_back(edge{u,b});
  }
vlt gmy=pao(s,0),xhk=pao(t,1),ans(n+2,inf);
for (i=n;i;--i) ans[i]=min(gmy[i]+xhk[i],ans[i+1]);
ll llx=1e15;
for (i=1;i<=n;++i) write(llx-ans[i]),pl;
}

Measured memory_bytes: 19140
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

// グラフを隣接行列で管理する
bool G[10][10];

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b; // 0index
    G[a][b] = G[b][a] = true;
  }

  // 順列
  vector<int> ord(N);
  for (int i = 0; i < N; ++i) {
    ord[i] = i;
  }

  // 順列を全部試すa
  int res = 0;
  do {
    if (ord[0] != 0) break;

    bool ok = true;
    for (int i = 0; i < N-1; ++i) {
      int from = ord[i];
      int to = ord[i+1];
      if (!G[from][to]) {
        ok = false;
      }
    }

    if (ok) {
      ++res;
    }
  } while (next_permutation(ord.begin(), ord.end()));

  cout << res << endl;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;


template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T lcm(T a, T b) {return a*b/gcd(a,b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){d = extgcd(b,a%b,y,x); y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,mod);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact;vector<ll> ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {fact[i+1] = fact[i]*(i+1) % M;ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;}
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b]* ifact[b] % M;
        return tmp * fact[a] % M;
    }
};


int f(int x){
    int r = 0;
    while (x%2==0) {
        x/=2;
        r++;
    }
    return r;
}


int main()
{
    int n,m;
    cin >> n >> m;
    vi a(n);
    in(n,a);
    rep(i,n) a[i]/=2;
    
    
    int t = f(a[0]);
    rep(i,n){
        if(f(a[i]) != t){
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= t;
    }
    m >>= t;
    
    
    ll l = 1;
    rep(i,n){
        l = lcm(l,ll(a[i]));
        if(l > m){
            cout << 0 << endl;
            return 0;
        }
    }
    
    m/=l;
    int ans = (m+1)/2;
    cout << ans << endl;
    
    


    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;
#define MOD 1000000007

string S;
int N;

bool judge(string ans){
    REP(i,ans.size()){
        if(S[i]=='o'){
            if(ans[i]=='S'){
                if(ans[(i-1+N)%N]!=ans[(i+1)%N])return false;
            }else{
                if(ans[(i-1+N)%N]==ans[(i+1)%N])return false;
            }
        }else{
            if(ans[i]=='S'){
                if(ans[(i-1+N)%N]==ans[(i+1)%N])return false;
            }else{
                if(ans[(i-1+N)%N]!=ans[(i+1)%N])return false;
            }
        }
    }
    return true;
}

int main(){
    
    cin>>N;
    cin>>S;
    
    vector<string> ans= {"SS","SW","WW","WS"};
    REP(i,ans.size()){
        for(int j=2;j<N;j++){
            if(S[j-1]=='o'){
                if(ans[i][j-1]=='S')ans[i].push_back(ans[i][j-2]);
                else{
                    if(ans[i][j-2]=='S')ans[i].push_back('W');
                    else ans[i].push_back('S');
                }
            }else{
                if(ans[i][j-1]=='S'){
                    if(ans[i][j-2]=='S')ans[i].push_back('W');
                    else ans[i].push_back('S');
                }else ans[i].push_back(ans[i][j-2]);
            }
        }
    }
    
    REP(i,ans.size()){
        if(judge(ans[i])){
            cout<<ans[i]<<endl;
            return 0;
        }
    }
    
    cout<<-1<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
n,m=map(int,input().split())
a=[]
for _ in range(n):
    a.append([int(i) for i in input().split()])
a.sort()
ans=0 ; ind=-1 ; p=0
while ans<m:
    ind+=1
    ans+=a[ind][1]
for i in range(ind):
     p+=a[i][1]*a[i][0]
p+=a[ind][0]*(a[ind][1]-(ans-m))
print(p)
    
    

Measured memory_bytes: 61912
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#define mp(i, j) make_pair(i, j)
#define pii pair<int, int>
#define fir first
#define sec second
const int N = 1e6 + 5;
const int INF = 0x3f3f3f3f; 
using namespace std;

int n, m, cnt, cnte, head[N], vis[N], pa[N], dis[N], mx, ans; 
struct edge { int to, nxt, cost; } e[N << 2];
priority_queue<pii, vector<pii >, greater<pii > > q; 
vector<pii > vec[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

inline void adde(int u, int v, int w) { e[++cnte] = (edge) { v, head[u], w }, head[u] = cnte; }

int dijkstra()
{
	for(int i = 1; i <= cnt; i++) dis[i] = INF, vis[i] = 0;
	dis[1] = 0, q.push(mp(dis[1], 1));
	while(!q.empty())
	{
		int u = q.top().sec; q.pop();
		if(vis[u]) continue; vis[u] = 1;
		for(int v, i = head[u]; i; i = e[i].nxt)
		{ 
			v = e[i].to;
			if(dis[v] > dis[u] + e[i].cost) dis[v] = dis[u] + e[i].cost, q.push(mp(dis[v], v)); 
		}
	}
	return dis[n]; 
}

int getf(int x) { return pa[x] ^ x ? pa[x] = getf(pa[x]) : x; }

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif 
	n = read <int> (), m = read <int> (), cnt = 2 * n;
	for(int i = 1; i <= n; i++) adde(i, i + n, 1);
	for(int u, v, c, i = 1; i <= m; i++)
	{
		u = read <int> (), v = read <int> (), c = read <int> ();
		vec[c].push_back(mp(u, v)), mx = max(mx, c); 
	}
	for(int i = 1; i <= mx; i++)
		if(vec[i].size())
		{
			for(int j = 0; j < vec[i].size(); j++)
				pa[vec[i][j].fir] = vec[i][j].fir, pa[vec[i][j].sec] = vec[i][j].sec;
			for(int u, v, j = 0; j < vec[i].size(); j++)
				if(getf(u = vec[i][j].fir) != getf(v = vec[i][j].sec)) pa[getf(u)] = getf(v);
			for(int j = 0; j < vec[i].size(); j++)
				vis[getf(vec[i][j].fir)] = vis[getf(vec[i][j].sec)] = 0; 
			for(int u, j = 0; j < vec[i].size(); j++)
			{
				u = vec[i][j].fir; if(!vis[getf(u)]) vis[getf(u)] = ++cnt;
				adde(vis[getf(u)], u, 0), adde(u + n, vis[getf(u)], 0); 
				u = vec[i][j].sec; if(!vis[getf(u)]) vis[getf(u)] = ++cnt;
				adde(vis[getf(u)], u, 0), adde(u + n, vis[getf(u)], 0); 
			}
		}
	printf("%d\n", (ans = dijkstra()) == INF ? -1 : ans); 
	return 0; 
}


Measured memory_bytes: 48324
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define PB push_back
#define MOD 10000007
#define PI 3.14159265359

using namespace std;

int main(){

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int Right = c+d;
    int Left = a+b;

    if(Right > Left)puts("Right");
    else if(Right < Left)puts("Left");
    else puts("Balanced");

}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
float a,b;
int EOA=-1;
	while(EOA!=scanf("%f%f",&a,&b))
	{
	if(a<35.50&&b<71.00)
	{
		printf("AAA\n");
	}
	else if(a<37.50&&b<77.00)
	{
		printf("AA\n");
	}
	else if(a<40.00&&b<83.00)
	{
		printf("A\n");
	}
	else if(a<43.00&&b<89.00)
	{
		printf("B\n");
	}
	else if(a<50.00&&b<105.00)
	{
		printf("C\n");
	}
	else if(a<55.00&&b<116.00)
	{
		printf("D\n");
	}
	else if(a<70.00&&b<148.00)
	{
		printf("E\n");
	}
	else
	{
		printf("NA\n");
	}
}
return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;

// 座標で表す
//x[i]、y[i]：i番目の正方形のx座標とy座標

public class Main {

	int[] x;
	int[] y;

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

	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int N = sc.nextInt();

			if (N == 0) {
				break;
			}

			int max_x = 0, min_x = 0;
			int max_y = 0, min_y = 0;

			x = new int[N];
			y = new int[N];

			x[0] = y[0] = 0;
			for (int i = 1; i < N; i++) {
				int n = sc.nextInt();
				int d = sc.nextInt();

				x[i] = x[n] + dx[d];
				y[i] = y[n] + dy[d];

				if (max_x < x[i]) {
					max_x = x[i];
				}
				if (min_x > x[i]) {
					min_x = x[i];
				}
				if (max_y < y[i]) {
					max_y = y[i];
				}
				if (min_y > y[i]) {
					min_y = y[i];
				}
			}

			int w = max_x - min_x + 1;
			int h = max_y - min_y + 1;

			System.out.println(w + " " + h);

		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

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

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

using lint = long long;
constexpr lint INF = 1LL << 60;

void solve() {
    int h, w, k;
    std::cin >> h >> w >> k;

    auto css = vec(h, vec(w, -INF));
    while (k--) {
        int x, y;
        lint c;
        std::cin >> x >> y >> c;
        css[--x][--y] = c;
    }

    auto dp = vec(2, vec(w, 0LL));
    for (const auto& cs : css) {
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < w; ++j) {
                dp[1][j] = std::max(dp[1][j], dp[0][j] + cs[j]);
            }
            for (int j = 0; j + 1 < w; ++j) {
                dp[0][j + 1] = std::max({dp[0][j + 1], dp[0][j], dp[1][j]});
            }
        }
        for (int j = 0; j < w; ++j) {
            dp[0][j] = std::max(dp[0][j], dp[1][j]);
        }
    }

    std::cout << std::max(dp[0].back(), dp[1].back()) << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 74064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int H,W;
  cin>>H>>W;
  
  vector<string> a(H);
  rep(i,H){
    cin>>a[i];
  }
  
  vector<bool> tate(H,false);
  vector<bool> yoko(W,false);
   
  rep(i,H){
    rep(j,W){
      if(a[i][j]=='#')
        tate[i]=true;
    }
  }
  
  rep(j,W){
    rep(i,H){
      if(a[i][j]=='#')
        yoko[j]=true;
    }
  }
  
  rep(i,H){
    if(tate[i]){
      rep(j,W){
        if(yoko[j])
          cout<<a[i][j];
      }
      cout<<endl;
    }
  }
  
}


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

int main(){
    int n;
    cin >> n;
   string s,t;
    cin >> s >> t;
    for(int i = 0; i < n; ++i){
        cout << s[i] << t[i];
    }

    cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b;
  string s;
  cin >> a >> b >> s;
  rep(i, s.size()){
    if(i != a){
      if(s[i] == '-'){
	cout << "No\n";
	return 0;
      }
    }
  }
  if(s[a] != '-'){
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
  return 0;
}


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

int main(){
  int N , A , B ;
  cin >> N >> A >> B ;
  int S = 0 ;
  for (int i= 1 ; i < N + 1 ; i++){
    int c = 0;
    int m = i;
    while (m !=0){
      int d = 0 ;
        d= m %10 ; 
        c += d ;
        m /= 10  ;
    }
    if ( c >= A && c <= B ){
      S += i ;
    }
  }
cout << S << endl ;
  return 0 ;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(string, s);
  in(int, k);
  rep(i, s.size()) {
    if (k == 1 || s[i] != '1') {
      out(s[i]);
      return 0;
    }
    --k;
  }
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,a,b;
ll x[N],y[N],X[N],Y[N],ax[N],ay[N],dis;
set<pair<ll,int> > Sx[N],Sy[N];
set<pair<ll,ll> > S;
vector<ll> vx[N],vy[N];
queue<int> Q;
int q[N],size;
void push(int i){
	static bool inq[N];
	if (inq[i]) return;
	inq[i]=1;
	Q.push(i);
	q[++size]=i;
}
ll ans=0;
void calc(vector<ll> &v,ll l,ll r){
	/*for (int i=0;i<v.size();i++) printf("%lld ",v[i]);puts("");
	printf("query(%lld,%lld)\n",l,r);*/
	int cnt=upper_bound(v.begin(),v.end(),r)-lower_bound(v.begin(),v.end(),l);
	//printf("ans=%d\n",cnt);
	ans+=cnt;
}
void work(set<pair<ll,int> > &S,ll l,ll r){
	S.insert(make_pair(l,0));
	S.insert(make_pair(r+1,0));
	set<pair<ll,int> >::iterator i=S.find(make_pair(l,0));
	set<pair<ll,int> >::iterator R=S.find(make_pair(r+1,0));
	for (++i;i!=R;++i) push(i->second);
	S.erase(make_pair(l,0));
	S.erase(make_pair(r+1,0));
}
void release(int i){
	//printf("release %d\n",i);
	ll lx=x[i]+y[i]-dis,rx=x[i]+y[i]+dis;
	ll ly=x[i]-y[i]-dis,ry=x[i]-y[i]+dis;
	size=0;
	int id=lower_bound(ax+1,ax+n+1,lx)-ax;
	if (ax[id]==lx) calc(vx[id],ly,ry),work(Sx[id],ly,ry);
		id=lower_bound(ax+1,ax+n+1,rx)-ax;
	if (ax[id]==rx) calc(vx[id],ly,ry),work(Sx[id],ly,ry);
		id=lower_bound(ay+1,ay+n+1,ly)-ay;
	if (ay[id]==ly) calc(vy[id],lx,rx),work(Sy[id],lx,rx);
		id=lower_bound(ay+1,ay+n+1,ry)-ay;
	if (ay[id]==ry) calc(vy[id],lx,rx),work(Sy[id],lx,rx);
	if (S.count(make_pair(lx,ly))) ans--;
	if (S.count(make_pair(lx,ry))) ans--;
	if (S.count(make_pair(rx,ly))) ans--;
	if (S.count(make_pair(rx,ry))) ans--;
	for (int i=1;i<=size;i++){
		int v=q[i];
		Sx[X[v]].erase(make_pair(x[v]-y[v],v));
		Sy[Y[v]].erase(make_pair(x[v]+y[v],v));
		//printf("find %d\n",v);
	}
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<=n;i++){
		scanf("%lld%lld",&x[i],&y[i]);
		ax[i]=X[i]=x[i]+y[i];
		ay[i]=Y[i]=x[i]-y[i];
		S.insert(make_pair(X[i],Y[i]));
	}
	sort(ax+1,ax+n+1);
	sort(ay+1,ay+n+1);
	for (int i=1;i<=n;i++){
		X[i]=lower_bound(ax+1,ax+n+1,X[i])-ax;
		Y[i]=lower_bound(ay+1,ay+n+1,Y[i])-ay;
		Sx[X[i]].insert(make_pair(x[i]-y[i],i));
		Sy[Y[i]].insert(make_pair(x[i]+y[i],i));
		vx[X[i]].push_back(x[i]-y[i]);
		vy[Y[i]].push_back(x[i]+y[i]);
	}
	for (int i=1;i<=n;i++){
		vx[i].push_back(-1e16);
		vx[i].push_back(1e16);
		vy[i].push_back(-1e16);
		vy[i].push_back(1e16);
	}
	for (int i=1;i<=n;i++){
		sort(vx[i].begin(),vx[i].end());
		sort(vy[i].begin(),vy[i].end());
	}
	push(a);push(b);
	dis=abs(x[a]-x[b])+abs(y[a]-y[b]);
	while (!Q.empty()) release(Q.front()),Q.pop();
	printf("%lld\n",ans/2);
	return 0;
}

Measured memory_bytes: 49024
#!/usr/bin/env python3
import sys


def solve(S: int):
    a = S//100
    b = S%100
    if a < 1 or a >12:
        if b < 1 or b > 12:
            print('NA')
        else:
            print('YYMM')
    else:
        if b < 1 or b > 12:
            print('MMYY')
        else:
            print('AMBIGUOUS')
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


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

int main(int argc, char *argv[], char *envp[]){
	int N;
	string s;
	cin >> N >> s;
	for(int i=0; i<s.size(); ++i){
		//s[i] = (s[i] + (N % ('Z' - 'A')) );
		s[i] = s[i] + N ;
		if(s[i] > 'Z') {
			s[i] = s[i] - ('Z' - 'A' + 1);
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	for(;;){
		vector<int>a(2);
		std::cin >> a[0]>>a[1];
		if(a[0]==0&&a[1]==0)exit(0);
		sort(all(a));
		std::cout << a[0]<<" "<<a[1] << std::endl;
	}
	
}


Measured memory_bytes: 3056
#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 FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    
    int N;
    cin >> N;
    if(N%2==0) {cout << 0.5 << endl; return 0;}
    double a=(N-1)/2;
    cout << (N-a)/N << endl;
    return 0;


}


Measured memory_bytes: 256
use std::io::{stdin, Read};

fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    let mut iterator = buf.split_whitespace();

    let n: isize = iterator.next().unwrap().parse().unwrap();

    let mut s = iterator
        .map(|s| s.parse::<isize>().unwrap())
        .collect::<Vec<_>>();

    let count = merge_sort(&mut s, 0, n);
    println!(
        "{}",
        s.into_iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" ")
    );
    println!("{}", count);
}

fn merge_sort(a: &mut Vec<isize>, left: isize, right: isize) -> usize {
    let mut count = 0;
    if left + 1 < right {
        let mid = (left + right) / 2;
        count += merge_sort(a, left, mid);
        count += merge_sort(a, mid, right);
        count += merge(a, left, mid, right);
    }
    count
}

fn merge(a: &mut Vec<isize>, left: isize, mid: isize, right: isize) -> usize {
    let n1 = mid - left;
    let n2 = right - mid;

    let mut l: Vec<isize> = Vec::new();
    for i in 0..n1 {
        l.push(a[(left + i) as usize]);
    }
    l.push(std::isize::MAX);

    let mut r: Vec<isize> = Vec::new();
    for i in 0..n2 {
        r.push(a[(mid + i) as usize]);
    }
    r.push(std::isize::MAX);

    let mut i = 0;
    let mut j = 0;
    for k in left..right {
        if l[i] <= r[j] {
            a[k as usize] = l[i];
            i += 1;
        } else {
            a[k as usize] = r[j];
            j += 1;
        }
    }
    i + j
}



Measured memory_bytes: 35592
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
using namespace std;
int max(int a,int b){
  if(a>= b) return a;
  else return b;
}
int main(){
  string s;
  cin >>s;
  int y=(s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
  int m=(s[5]-'0')*10+(s[6]-'0');
  int d=(s[8]-'0')*10+(s[9]-'0');
  if(y>2019) {cout<<"TBD"<<endl; return 0;}
  else if(y==2019 && m>4) {cout<<"TBD"<<endl; return 0;}
  else if(y== 2019 && m<=4 && d>30){cout<<"TBD"<<endl; return 0;}
  else {cout <<"Heisei"<<endl; return 0;}
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100;
static const int MAX_V = 1000;
static const ll INF = 1LL << 60;

int N, W;
int w[MAX_N], v[MAX_N];
int sum[MAX_N + 1];
ll memo[MAX_N + 1][MAX_N * MAX_V + 1];

int main(){
	scanf("%d %d", &N, &W);
	for(int i = 0; i < N; i++){
		scanf("%d %d", &w[i], &v[i]);
		sum[i + 1] = sum[i] + v[i];
	}
	fill(memo[0], memo[N + 1], INF);
	memo[0][0] = 0LL;
	int res = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= sum[i + 1]; j++){
			if(j == 0) memo[i][j] = 0;
			else if(j < v[i]) memo[i + 1][j] = memo[i][j];
			else memo[i + 1][j] = min(memo[i][j], memo[i][j - v[i]] + (ll)w[i]);
			if(memo[i + 1][j] <= W) res = max(res, j);
		}
	}
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= sum[i + 1]; j++){
			if(memo[i][j] <= W) res = max(res, j);
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
int l[maxn],w[maxn],q;
long long ans;
int main() {
	cin>>q;
	for(int i=0;i<=q;i++) scanf("%d",&l[i]);
	for(int i=1;i<=q;i++) scanf("%d",&w[i]);
	for(int i=1;i<=q;i++) {
		if(w[i]<=l[i-1]) ans+=w[i];
		else if(w[i]<=l[i-1]+l[i]){
			ans+=w[i];
			l[i]-=w[i]-l[i-1];
		}
		else {
			ans+=l[i-1]+l[i];
			l[i]=0;
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){

  int N = 0;
  cin >> N;

  int min = 0;
  cin >> min;

  int ans = 1;
  int num = 0;

  for (int i = 1; i < N; i++) {
    cin >> num;
    if (num <= min) {
      ans++;
      min = num;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 888
import math
N = int(input())
figure = []
for i in range(1, int(math.sqrt(N))+1):
  if N % i == 0:
    figure.append([i, N/i])
  else:
    continue
cnt_list = []
for l in range(len(figure)):
  cnt = 1
  Max = max(figure[l])
  while Max // 10 >= 1:
    cnt += 1
    Max /= 10
  cnt_list.append(cnt)
print(min(cnt_list))   

Measured memory_bytes: 9268
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}



int32_t main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();
    int n,d;
    cin>>n>>d;
    int count = 0;
    while(n--){
        int x,y;
        cin>>x>>y;
        long double val = sqrt(x*x + y*y);
        if(val<=d){
            count++;
        }
    }
    cout<<count<<"\n";
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
	int i,p[10000],d1,d2,d[10000],xp,max,n;
	while(1){
		max=-1;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&p[i],&d1,&d2);
			d[i]=d1+d2;
		}
		for(i=0;i<n;i++){
			if(max<d[i]){
				max=d[i];
				xp=p[i];
			}
		}
		printf("%d %d\n",xp,max);
	}
	return 0;
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int sum=0;
  for(int i=0;i<N;i++)sum+=v[i];
  std::vector<int> d;
  for(int i=1;i*i<=sum;i++){
    if(sum%i==0){
      d.push_back(i);
      d.push_back(sum/i);
    }
  }
  int ans=0;
  for(auto p:d){
    std::vector<int> w(N);
    for(int i=0;i<N;i++)w[i]=v[i]%p;
    sort(w.begin(),w.end());
    std::vector<int> ma(N);
    for(int i=0;i<N;i++)ma[i]=(p-w[i])%p;
    for(int i=N-1;i>0;i--)ma[i-1]+=ma[i];
    for(int i=1;i<N;i++)w[i]+=w[i-1];
    for(int i=0;i<N-1;i++)if(ma[i+1]<=K&&w[i]<=K)ans=max(ans,p);
  }
  cout<<ans<<endl;
}


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

int main()
{
	int n,result;
	string s;
	cin>>n>>s;
	for (int i=0;i<s.size();i++)
    {
    	result=(s[i]-'A'+n)%26 +'A';
		cout<<char(result);
    }
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

ids=[]

import bisect

arr=[[] for _ in range(n)]

for _ in range(m):
    p,y=map(int,input().split())
    ids.append([p,y])
    arr[p-1].append(y)

for i in range(n):
    arr[i]=sorted(arr[i])

for info in ids:
    p=info[0]
    y=info[1]
    index = bisect.bisect_left(arr[p-1],y)

    print(str(info[0]).zfill(6)+str(index+1).zfill(6))


Measured memory_bytes: 34344
#include <bits/stdc++.h>
using namespace std;
int main(){
  int sx,sy,tx,ty,i,xsa,ysa;
  cin>>sx>>sy>>tx>>ty;
  xsa=tx-sx;
  ysa=ty-sy;
  for(i=0; i<ysa; i++){
    cout<<'U';
  }
  for(i=0;i<xsa; i++){
    cout<<'R';
  }
  for(i=0; i<ysa; i++){
    cout<<'D';
  }
  for(i=0; i<=xsa; i++){
    cout<<'L';
  }
  for(i=0; i<=ysa; i++){
    cout<<'U';
  }
  for(i=0; i<=xsa; i++){
    cout<<'R';
  }
  cout<<"DR";
  for(i=0; i<=ysa; i++){
    cout<<'D';
  }
  for(i=0; i<=xsa; i++){
    cout<<'L';
  }
  cout<<'U';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

template <class T>
inline void read(T &x)
{
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int p[10], q[10], a[10];
int n, ap, aq, k;
bool flag1, flag2;

int main()
{
    read(n);
    for (int i = 1; i <= n; ++i)
        read(p[i]);
    for (int i = 1; i <= n; ++i)
        read(q[i]);
    for (int i = 1; i <= n; ++i)
        a[i] = i;
    do
    {
        ++k;
        flag1 = true, flag2 = true;
        for (int i = 1; i <= n; ++i)
        {
            if (a[i] != p[i])   flag1 = false;
            if (a[i] != q[i])   flag2 = false;
        }
        if (flag1) ap = k;
        if (flag2)  aq = k; 
    } while (std::next_permutation(a + 1, a + n + 1));
    std::cout << abs(ap - aq) << std::endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int t=N, c=0;
  for (int i=0; i<N; i++) {
    c=c+(t%10);
    t=t/10;
    if (t==0) 
      break;
  }
  if (N%c==0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define met(a,x) memset(a,x,sizeof(a))
#define inf 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
const int N=200010;
int a[N],b[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int i,j,k,m,n;
    int ans=0,cnt=0,num=0;
    cin>>n>>k;
    for(i=1; i<=n; i++)
    {
        cin>>m;
        a[m]++;
    }
    for(i=1; i<=n; i++)
        if(a[i])
            cnt++;
    sort(a+1,a+1+n);
    if(cnt<k)
    {
        cout<<0<<endl;
        return 0;
    }
    for(i=1; i<=n; i++)
    {
        if(cnt==k+num)
            break;
        if(a[i])
        {
            num++;
            ans+=a[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

long gcd(long a, long  b) {
    if(b==0) return a;
    return gcd(b,a%b);
}

int main() {
    int n;
    cin >> n;
    vector<long> a(n), l(n+1), r(n+1);
    for(int i=0; i<n; i++) cin >> a[i];

    l[0] = 0;
    r[n] = 0;
    for(int i=0;i<n;i++) {
        l[i+1] = gcd(l[i], a[i]);
        int j = n - 1 - i;
        r[j] = gcd(r[j+1], a[j]);
    }

    long res = 1;
    for(int i= 0;i<n;i++) {
        res = max(res, gcd(l[i], r[i+1]));
    }

    cout << res << endl;
}

Measured memory_bytes: 2560
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector <ll> v(n);
    ll tot = 0;
    for (ll &x : v) {
        cin >> x;
        tot ^= x;
    }
    for (int i=  0; i < n; i++) {
        ll ans = tot^v[i];
        cout << ans << ' ';
    }
    return 0;
}




Measured memory_bytes: 4776
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        h: [usize; n]
    }
    println!("{}", h.iter().filter(|&hi| hi >= &k).count());
}


Measured memory_bytes: 4352
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp

#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
using namespace std;

//O(|E||V|^2)
class Dinic{
public:
	class edge{
	public:
		int to, cap, rev;
		edge(){};
		edge(int _to, int _cap, int _rev){
			to = _to;
			cap = _cap;
			rev = _rev;
		}
	};
	vector<vector<edge> >G;
	vector<int>level;
	vector<int>iter;
	Dinic(int n){
		G.resize(n);
	}
	void addEdge(int from, int to, int cap){
		G[from].push_back(edge(to, cap, G[to].size()));
		G[to].push_back(edge(from, 0, G[from].size() - 1));
	}
	void bfs(int s){
		level.clear();
		level.resize(G.size(), -1);
		queue<int>que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()){
			int v = que.front();
			que.pop();
			for (int i = 0; i < G[v].size(); i++){
				edge &e = G[v][i];
				if (e.cap>0 && level[e.to] < 0){
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}
	int dfs(int v, int t, int f){
		if (v == t)return f;
		for (int &i = iter[v]; i < G[v].size(); i++){
			edge &e = G[v][i];
			if (e.cap > 0 && level[v]<level[e.to]){
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	int maxFlow(int s, int t){
		int flow = 0;
		for (;;){
			bfs(s);
			if (level[t] < 0)return flow;
			iter.clear();
			iter.resize(G.size(), 0);
			for (;;){
				int f = dfs(s, t, 1145141919);
				if (f>0)flow += f;
				else break;
			}
		}
	}
};

int main(){

	int V, E;
	cin >> V >> E;
	Dinic din(V);
	for (int i = 0; i < E; i++){
		int from, to, cap;
		cin >> from >> to >> cap;
		din.addEdge(from, to, cap);
	}
	cout << din.maxFlow(0, V - 1) << endl;

	return 0;
}


Measured memory_bytes: 3168
import math
n = sorted(list(map(int,input().split())))
n[1] %= (10**9 + 7)
n[0] %= (10**9 + 7)
if n[1] - n[0] >= 2:
    ans = 0
elif n[1] - n[0] == 0:
    ans = (math.factorial(n[1])%(10**9 + 7)) **2 * 2
else:
    ans = n[1] * (math.factorial(n[0]) % (10**9 + 7))**2
print(ans % (10**9 + 7) )

Measured memory_bytes: 4092
#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>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define sz(x) (int)(x.size())
#define pb push_back
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int long long

const int N = (int)(1e6) + 322;
const int inf = (long long)(1e9) + 123;
const int mod = 1000000007;
const double eps = 1e-9;

int fact[N], inv[N];

int binpow (int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1) {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
        n >>= 1;
    }
    return res;
}

int calc(int n, int k) {
    return fact[n] * inv[n - k] % mod * inv[k] % mod;
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1;
    inv[0] = 1;
    for(int i = 1; i < N; ++i) {
        fact[i] = (fact[i - 1] * i) % mod;
        inv[i] = binpow(fact[i], mod - 2);
    }
    int x, y; cin >> x >> y;

    for(int i = 0; i <= x; ++i) {
        if ((x - i) % 2 != 0) continue;
        int j = (x - i) / 2;
        int X = i + j * 2;
        int Y = i * 2 + j;
        //cout << X << ' ' << Y << endl;
        if ((X == x && y == Y)) {
            //cout << i << ' ' << j << endl;
            cout << calc(i + j, i);
            return 0;
        }
    }
    cout << 0;
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    
    ll blackCnt = 0;
    string ans;
    ans = "No";
    rep(ni, N + 1){
        rep(mi, M + 1){
            blackCnt = (ll)ni * M + mi * N - 2 * ni * mi;
            if(blackCnt == K){
                ans = "Yes";
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <fstream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <bitset>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <set>
#include <complex>

using namespace std;

const int SIZE = 1 << 10;

int pointer = SIZE;
char buffer[SIZE];

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0;
    char ch = Advance();
    while (!isdigit(ch))
        ch = Advance();
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer;
}

const int INF = (1LL << 31) - 1;

long long s;
long long a, b;

bool Ok(long long st, long long dr, long long l, long long r) {
    if (dr <= l)
        return dr * l <= s;
    if (st >= r)
        return st * r <= s;
    double q = 1.0 * (st + r) / 2;
    long long x = q;
    if (1.0 * x == q) {
        if (x * x > s)
            return false;
    }
    else
        if (x * (x + 1) > s)
            return false;
    return true;
}

bool Split(int x, int y, int l, int r) {
    if (y < x || r < l)
        return true;
    if (x <= a && a <= y) {
        int len = a - x;
        return Split(x, x + len - 1, r - len + 1, r) && Split(x + len + 1, y + 1, l, r - len);
    }
    if (l <= b && b <= r) {
        int len = b - l;
        return Split(y - len + 1, y, l, l + len - 1) && Split(x, y - len, l + len + 1, r + 1);
    }
    return Ok(x, y, l, r);
}

bool Check(int x) {
    return Split(1, x, 1, x);
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int tests;
    scanf("%d", &tests);
    for (int test = 1; test <= tests; test++) {
        scanf("%lld%lld", &a, &b);
        if (a > b)
            swap(a, b);
        s = a * b - 1;
        long long left = 1, right = INF, answer = 0;
        while (left <= right) {
            long long middle = (left + right) / 2;
            if (Check(middle)) {
                answer = middle;
                left = middle + 1;
            }
            else
                right = middle - 1;
        }
        printf("%lld\n", answer);
    }
    return 0;
}


Measured memory_bytes: 128