akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;


ll n, m, s, t;
vector< ll > g[100005];
ll vis[100005][3];
ll inf = 1e16;
void bfs()
{
        queue< ll > q;
        vis[s][0]=0;
        q.push(s); q.push(0);
        while(q.empty() == false) {

                ll u = q.front();
                q.pop();
                ll md = q.front();
                q.pop();
                for(auto &i : g[u]) {
                        ll nn = (md+1)%3;
                        if(vis[i][nn] == inf) {
                                vis[i][nn] = vis[u][md]+1;
                                q.push(i);
                                q.push(nn);
                        }
                }
        }
}
int main()
{
        cin >> n >> m;
        for(ll i=1;i<=n;i++) {
                for(ll j=0;j<3;j++) vis[i][j] = inf;
        }
        for(ll i=1;i<=m;i++){
                ll a,b;
                cin >> a >> b;
                g[a].pb(b);
        }
        cin >> s >> t;
        bfs();
        ll ans = n*n;
        ans = min(ans, vis[t][0] / 3);
        if(ans >= n*n) ans=-1;
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

long n, a, b;
vector<long> h;

bool judge( long mm )
{
    ll sum=0;
    long i;
    for(i=0; i<n; i++) {
        if(h[i] > mm*b) {
            sum += (h[i]-mm*b-1) / (a-b) + 1;
        }
    }
    if(sum > mm) {
        return false;
    }
    else {
        return true;
    }
}

int main(int argc, char* argv[])
{
    scanf("%ld%ld%ld", &n, &a, &b);

    h.resize(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &h[i]);
    }
    sort(h.rbegin(), h.rend());

    long rr = h[0]/b+1;
    long ll = 0;

    while(rr-ll>1) {
        long mm = ll + (rr-ll)/2;

        if( judge(mm) ) {
            rr = mm;
        }
        else {
            ll = mm;
        }
    }

    printf("%ld\n", rr);


    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

#define N 110
#define _for(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;

char s1[N], s2[N], s3[N];

int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        int res = 0;
        scanf("%s%s%s", s1, s2, s3);
        for (int i = 0; i < n; ++i) {
            if (s1[i] == s2[i] && s2[i] == s3[i]) continue;
            else if (s1[i] != s2[i] && s2[i] != s3[i] && s1[i] != s3[i]) res += 2;
            else ++res;
        }
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
    fast;
    int n;
    cin>>n;
    int a[n+7];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    int c=0,mx=0;
    int x=a[0];
    for(int i=0; i<n-1; i++)
    {
        if(a[i+1]<=a[i])c++;
        else
        {
           // x=a[i];
            mx=max(mx,c);
            c=0;
        }
    }
    cout<<max(mx,c);
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
long int Gcd(long int a,long int b){
  long int r;
  if(a<b){
    long int c;
    c=a;
    a=b;
    b=c;//a>b
  }
  while(true){
    r=a%b;
    if(a%b==0){
      break;
    }
    a=b;
    b=r;
  }
  return b;
}
long int PrimeFactorization(long int N){
  int count=0;
  long int i=2;
  while(i<=sqrt(N)+1){
   if(N%i==0){
     while(N%i==0){
      N=N/i;
     }
     count+=1;
     if(N==1){
       break;
     }
   }
   i+=1;
  }
  if(N!=1){
    count+=1;
  }
  return count;
}
int main(){
  long int a,b;
  long int ans;
  std::cin>>a>>b;
  long int S=Gcd(a,b);
  ans=PrimeFactorization(S);
  std::cout<<ans+1<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define N 12
#define P 100001
using namespace std;

int main(){
  int n,d,x,p[N][N],dp[N][P],ans;
  cin>>n>>d>>x;
  for(int i=0;i<d;i++)
    for(int j=0;j<n;j++) cin>>p[i][j];
  for(int i=0;i<N;i++)
    for(int j=0;j<P;j++) dp[i][j]=-1;
  for(int i=0;i<d;i++) dp[i][x]=ans=x;
  for(int i=0;i<d;i++){
    for(int l=i+1;l<d;l++){
      for(int j=P-1;j>=0;j--){
	if(dp[i][j]<0) continue;
	for(int k=0;k<n;k++){
	  if(j<p[i][k]) continue;
	  if(p[i][k]>p[l][k]) continue;
	  int idx=dp[i][j]+(p[l][k]-p[i][k]);
	  dp[i][j-p[i][k]]=max(dp[i][j-p[i][k]],idx);
	  dp[l][idx]=idx;
	}
	
      }
    }
  }
  for(int i=0;i<d;i++)
    for(int j=0;j<P;j++) ans=max(ans,dp[i][j]);
  cout<<ans<<endl;
  return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vl x(n);
  vl y(n);
  REP(i,n) cin >> x[i] >> y[i];
  double ans = 0;
  REP(i,n){
    REP(j,n){
      ll xd = x[i]-x[j];
      ll yd = y[i]-y[j];
      ans += sqrt(xd*xd+yd*yd);
    }
  }
  ans = ans/n;

  cout << fixed;
  cout << setprecision(10);
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a = i()
b = i()
c = i()
x = i()

ans = 0
for i in range(a+1):
	for j in range(b+1):
		for k in range(c+1):
			if x == 500*i + 100*j + 50*k:
				ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     string str;
     ll cnt=0,arr[30];
     cin>>str;
     mem(arr,0);
     for(int i=0;i<str.size();i++)
     {
         arr[str[i]-'a']++;
     }
     char i;
     for(i='a';i<='z';i++)
     {
         if(arr[i-'a']==0)
         {
             cnt=10;
             break;
         }
     }
     if(cnt==10)
        cout<<i<<endl;
     else
        cout<<"None"<<endl;
}



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

int main(){
    long long mod=1000000007;
    long long n,sum=0,ans=0;
    cin>>n;
	long long a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
        sum+=a[i];
    }
    for(int i=0;i<n;i++){
    	sum-=a[i];
        ans=(ans+(sum%mod)*a[i])%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int H, W; cin >> H >> W;
    vector<string> A(H);
    REP(i, 0, H) cin >> A[i];

    vector<bool> whiter(H), whitec(W);
    REP(i, 0, H) {
        bool white = true;
        REP(j, 0, W) {
            if (A[i][j] == '#') white = false;
        }
        whiter[i] = white;
    }
    REP(j, 0, W) {
        bool white = true;
        REP(i, 0, H) {
            if (A[i][j] == '#') white = false;
        }
        whitec[j] = white;
    }

    REP(i, 0, H) {
        if (whiter[i]) continue;
        REP(j, 0, W) {
            if (whitec[j]) continue;
            cout << A[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations
n=int(input())
A,B=[i+1 for i in range(n)],[]
num=n if n%2==1 else n+1
for a,b in combinations(A,2):
    if a+b!=num:B.append([a,b])
print(len(B))
for i in B:print(*i)

Measured memory_bytes: 43376
s,t = input(),input()
def g(s,t):
    for j in range(len(s)):
        if len(s) == len(t):
            S = [i for i in s if i != s[0]]
            T = [i for i in t if i != t[0]]
            s = S
            t = T
        else:
            return 'No'
    return 'Yes'
print(g(s,t))

Measured memory_bytes: 9264
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  string s;
  cin >>s;
  for(int i=0;i<s.size();i++){
    if((i+1)%2==0 && s[i]=='R'){
      cout<< "No" <<endl;
      return 0;
    }
    else if((i+1)%2!=0 && s[i]=='L'){
      cout<< "No" <<endl;
      return 0;
    }
  }
  cout<< "Yes" <<endl;
}


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

#define EPS 0.00000000001L

#define PI 3.141592653589793238462643383279L

int main()
{
    int q, x1, y1, x2, y2, x3, y3, x4, y4;
    
    scanf("%d", &q);
    
    for(int i = 0; i < q; i++)
    {
        scanf("%d", &x1);
        scanf("%d", &y1);
        scanf("%d", &x2);
        scanf("%d", &y2);
        scanf("%d", &x3);
        scanf("%d", &y3);
        scanf("%d", &x4);
        scanf("%d", &y4);
        
        long double angle1 = atan2l(y2 - y1, x2 - x1);
        long double angle2 = atan2l(y4 - y3, x4 - x3);
        
        long double sa = fabsl(angle2 - angle1);
        
        if(sa < -EPS) { sa += PI * 2.0; }

        if((sa - EPS < PI * 0.5 && PI * 0.5 < sa + EPS) || (sa - EPS < PI * 1.5 && PI * 1.5 < sa + EPS))
        {
            printf("1\n");
        }
        else if((sa - EPS < PI && PI < sa + EPS) || (sa - EPS < 0.0 && 0.0 < sa + EPS))
        {
            printf("2\n");
        }
        else
        {
            printf("0\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 2748
N,x,y=map(int,input().split())
dp=[[abs(i-k) for k in range(N)]for i in range(N)]
dp[x-1][y-1]=1
dp[y-1][x-1]=1
for k in [x-1,y-1]:
    for i in range(N):
        for j in range(N):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j],abs(i-j))

cnt={}
for k in range(N):
    for i in range(N):
        if dp[k][i] in cnt:
            cnt[dp[k][i]]+=1
        else:
            cnt[dp[k][i]]=1

for i in range(1,N):
    try :
        print(cnt[i]//2)
    except:
        print(0)

Measured memory_bytes: 83292
#include <bits/stdc++.h>
main(){
    long a,b,ans=0;
    std::cin>>a>>b;
    if(b%2==0)ans=ans^b;
    if(a%2==1)ans=ans^(a-1);
    ans=(((b+1)/2)%2)^ans;
    ans=((a/2)%2)^ans;
    std::cout<<ans;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  ll ans = 0;
  cin >> N;
  rep(i, N){
    ll a = i+1;
    if(a%3!=0 and a%5!=0){
      ans += a;
    }
  }

  cout << ans;
  return 0;

  
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

int64_t solve(int64_t n, std::vector<int64_t> as) {
  std::multiset<int64_t> ss;
  ss.insert(as.back());
  for (int i = n - 2; i >= 0; --i) {
    auto const a = as[i];
    auto const back = *(ss.rbegin());
    if (a >= back) {
      ss.insert(a);
      continue;
    }
    auto const it = ss.lower_bound(a + 1);
    ss.erase(it);
    ss.insert(a);
  }
  return ss.size();
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> as(n);
  for (int i = 0; i < n; i++) {
    std::cin >> as[i];
  }
  auto const res = solve(n, std::move(as));
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 5760
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    boolean flag = false;
    for(int i = 0;i<N/4 + 1;i++) {
      for(int j = 0;j<N/7 + 1;j++) {
        if(4*i+7*j == N) flag = true;
      }
    }
    if(flag) System.out.println("Yes");
    else System.out.println("No");
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
X = int(input())

#A**5,B**5でとり得る可能性のある数をあらかじめリストで用意する

N = [i**5 for i in range(1000)]
 
#A,Bで別々の処理をするため、変数はi,jの２種を用意する


for i in range(1000):
	for j in range(1000):

#リストから２つの数を抽出し、Xになるか計算を繰り返す
#Xは正の整数であるため、Aが負になる可能性は除外

		if N[j] - N[i] == X:
			print(j, i)
			exit()

#Bが負の場合、符号が変わる可能性があるため、もう１パターン計算

		if N[j] + N[i] == X:
			print(j, -i)
			exit()

Measured memory_bytes: 9192
//minamoto
#include<bits/stdc++.h>
#define R register
#define int unsigned int
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int P;
//inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
//inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
//inline int add(R int x,R int y){return }
inline void upd(R int &x,R int y){x+=y,x-=P*((x>>30)&3),x%=P;}
inline int add(R int x,R int y){return (x+=y,x-=P*((x>>30)&3))%P;}
inline int mul(R int x,R int y){return 1ull*x*y-1ull*x*y/P*P;}
int ksm(R int x,R int y){
    R int res=1;
    for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
    return res;
}
const int N=105;
int f[N][N][N][2],coef[N][N][N][2],bn[N][N];
int n,m,L,ret,cp;
signed main(){
    scanf("%u%u%u%u",&n,&m,&L,&P);
    fp(i,0,max(n,m)){
        bn[i][0]=1;
        fp(j,1,i)bn[i][j]=add(bn[i-1][j],bn[i-1][j-1]);
    }
    fp(k,1,L)fp(i,0,m){
        cp=mul(ksm(L-k+1,i),add(ksm(k,m-i),P-ksm(k-1,m-i)));
        ret=1;
        fp(j,0,n)coef[k][i][j][0]=ret,ret=mul(ret,cp);
    }
    fp(k,1,L)fp(i,0,n){
        cp=mul(add(ksm(L-k+1,i),P-ksm(L-k,i)),ksm(k,n-i));
        ret=1;
        fp(j,0,m)coef[k][i][j][1]=ret,ret=mul(ret,cp);
    }
    f[1][0][0][0]=1;
    fp(k,1,L)fp(i,0,n)fp(j,0,m){
        ret=f[k][i][j][0];
        fp(l,0,n-i)upd(f[k][i+l][j][1],1ull*ret*bn[n-i][l]%P*coef[k][j][l][0]%P);
        ret=f[k][i][j][1];
        fp(l,0,m-j)upd(f[k+1][i][j+l][0],1ull*ret*bn[m-j][l]%P*coef[k][i][l][1]%P);
    }
    printf("%u\n",f[L+1][n][m][0]%P);
    return 0;
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}

signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  int index;
  rep(i,n){
    cin>>a[i];
    if(a[i]==1)index=i;
  }
  if(n==k){
    cout<<1<<endl;
    return 0;
  }
  int ans=0;
  int tmp=index;
  while(1){
    if(tmp<=0)break;
    ans+=1;
    tmp-=(k-1);
  }
  tmp=index;
  while(1){
    if(n-1<=tmp)break;
    ans+=1;
    tmp+=(k-1);
  }
  int ans1=0;
  tmp=0;
  while(1){
    if(n-1<=tmp)break;
    ans1++;
    tmp+=(k-1);
  }
  cmin(ans,ans1);
  ans1=0;
  tmp=n-1;
  while(1){
    if(tmp<=0)break;
    ans1++;
    tmp-=(k-1);
  }
  cout<<min(ans,ans1)<<endl;
  return 0;

}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll N;
ll a[200000];

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

    ll sum=0;
    rep(i,N) sum+=a[i];

    ll ans=LINF;
    ll x=0, y=sum;
    rep(i,N-1){
        x+=a[i];
        y-=a[i];
        ans=min(ans,abs(x-y));
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 5124
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def r_sort(a) a.sort{|a,b|b<=>a} end
a,b,c = inp
p [b*a,c].min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define ll128 __uint128_t
#define ld long double
#define pll pair <ll, ll>

#define vll vector <ll>
#define vld vector<ld>
#define vpll vector<pll>

#define vvll vector <vll>

#define rep(i, a, b) for(ll i = a; i < b; i++)
#define per(i, a, b) for(ll i = (ll)a - 1; i >= b; --i)

#define endl "\n"
#define pb push_back
#define pf push_front

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define sorta(v) sort(all(v))
#define sortd(v) sort(rall(v))

#define debug if (1)
#define log(val) debug {cout << "\n" << #val << ": " << val << "\n";}

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(name) freopen(name".in", "r", stdin); freopen(name".out", "w", stdout);
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

#define mod (ll)(1e9 + 7)
#define inf (mod * mod)

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

ostream & operator << (ostream & out, vll & a) {
    for(auto i : a) out << i << " ";
    return out;
}

istream & operator >> (istream & in, vll & a) {
    for(auto &i : a) in >> i;
    return in;
}

const ll N = 52;
map<ll, ll> dp[N];

int main() {
    ll n, av;
    cin >> n >> av;
    vll a(n);
    cin >> a;

    for (auto & i : a) {
        i -= av;
    }
    dp[0][0] = 1;
    rep(i, 1, n + 1) {
        rep(w, -N * N, N * N) dp[i][w] = dp[i - 1][w];
        rep(w, -N * N, N * N) {
            dp[i][w + a[i - 1]] += dp[i - 1][w];
        }
    }
    cout << dp[n][0] - 1 << endl;

    return 0;
}


Measured memory_bytes: 20924
import math

N = int(input())
ans = 0

for i in range(1,N+1):
    for j in range(i,N+1):
        for k in range (j,N+1):
            if i==j==k:
                ans+=math.gcd(math.gcd(i,j),k)
            elif i!=j!=k:
                ans+=math.gcd(math.gcd(i,j),k)*6
            else:                
                ans+=math.gcd(math.gcd(i,j),k)*3

print(int(ans))

Measured memory_bytes: 9208
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int a = Cin.Ni();
        int b = Cin.Ni();
        int c = Cin.Ni();
        if (a == b) {
            Console.WriteLine(c);
        } else if (a == c) {
            Console.WriteLine(b);
        } else {
            Console.WriteLine(a);
        }
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	long long n,k;
	cin>>n>>k;
	n%=k;
	cout<<min(n,abs(n-k));
	return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

// https://stackoverflow.com/questions/1954858/sieve-of-eratosthenes-algorithm
vector<long long> SieveOfEratosthenes(int max) {
  vector<long long> sieve;
  vector<long long> primes;

  for (int i = 1; i < max + 1; ++i) {
    sieve.push_back(i);
  }

  sieve[0] = 0;
  for (int i = 2; i < max + 1; ++i) {
    if (sieve[i - 1] != 0) {
      primes.push_back(sieve[i - 1]);
      for (int j = 2 * sieve[i - 1]; j < max + 1; j += sieve[i - 1]) {
        sieve[j - 1] = 0;
      }
    }
  }

  return primes;
}

void solve(long long N, long long P) {
  if (N == 1) {
    print(P);
    return;
  }

  vl primes = SieveOfEratosthenes(1e6);
  ll ans = 1;
  for (ll p : primes) {
    if (P <= 1) {
      break;
    }

    ll cnt = 0;
    while (P % p == 0) {
      cnt++;
      P /= p;
    }

    if (cnt / N != 0) {
      ans *= pow(p, cnt / N);
    }
  }
  print(ans);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long P;
  scanf("%lld", &P);
  solve(N, P);
  return 0;
}


Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
void solve()
{
		
}
int main()
{
	long long n,m,x;
	cin>>n>>m>>x;
	vector<long long> c(n);
	vector<vector<long long>> a(n,vector<long long>(m));
	for(int i = 0;i<n;i++)
	{
		cin>>c[i];
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	}
	long long M = 1<<n;
	long long price = 1e9;
	for(int k =0;k<M;k++)
	{
		long long cost = 0;
		vector<long long> cur(m);
		for(int i = 0;i<n;i++)
		{
			if(k&(1<<i))
			{
				cost+=c[i];
				for(int j = 0;j<m;j++)
					cur[j]+=a[i][j];
			}
		}
		if(*min_element(cur.begin(),cur.end())>=x)
		{
			price = min(cost,price);
		}
	}
	if(price==1e9)
		cout<<"-1\n";
	else
		cout<<price<<'\n';
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(void){
  int n,y,i,j,k,sum;
  scanf("%d %d",&n,&y);
  y/=1000;
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      for(k=0;i+j+k<=n;k++){
        sum = 10*i+5*j+k;
        if((sum==y) && (i+j+k==n)){
          printf("%d %d %d\n",i,j,k);
          return 0;
        }
      }
    }
  }
  printf("%d %d %d\n",-1,-1,-1);
  return 0;
}

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


const int N = 200020;
int n,m , a[N], s1 = 0, s2 = 0;
int main() {
	scanf("%d",&n);
	for(int i = 1; i <= n; ++ i) scanf("%d" , &a[i]);
	for (int i = 1; i <= n; ++ i) {
		if (a[i] > s1) s2 = s1, s1 = a[i];
		else if (a[i] > s2) s2 = a[i];
	}
	for(int i = 1; i <= n; ++ i)
	 if (a[i] == s1) printf("%d\n", s2);
	 else printf("%d\n", s1);
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 998244353;


void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
// BIT //
const int MAXN=2*1e5+10;
vector<int> bit(MAXN,0);
int sump(int idx) {
    int ret = 0;
    for (++idx; idx > 0; idx -= idx & -idx)
        ret += bit[idx];
    return ret;
}

int sum(int l, int r) {
    return sump(r) - sump(l - 1);
}

void upd(int idx, int delta) {
    for (++idx; idx < MAXN; idx += idx & -idx)
        bit[idx] += delta;
}
/////-----//////
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll genRand(ll B) {
    return (ull)rng() % B;
}
///--//
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * const int N is defined way above in the starting
    */
    int n,k; cin>>n>>k;
    vector<ll> v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ll s=0;
    for(int i=0; i<k; i++){
        s+=v[i];
    }

    cout<<s;
}








Measured memory_bytes: 3848
H, W, N = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]

from itertools import product

S = [set() for _ in range(10)]
# S[i]: set(黒いマスをi個こ含む3*3マスの中心セル)

memo = {}
for a,b in AB:
  for x,y in product([-1,0,1], repeat=2):
    X = a+x-1
    Y = b+y-1
    if X<=0 or H-1<=X or Y<=0 or W-1<=Y:
      continue
    memo[(X,Y)] = memo.get((X,Y),0) + 1

#print(memo)

from collections import Counter
c = Counter(memo.values())
L = [c.get(i,0) for i in range(1,10)]

print((H-2)*(W-2) - sum(L))

for l in L:
  print(l)

Measured memory_bytes: 191248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[200100],b[200100];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    int i,j=0,k=0,m,n;
    int a1,b1;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>a1>>b1;
        if(a1==1)
            a[b1]=1;
        if(b1==n)
            b[a1]=1;
    }
    for(i=1;i<=200010;i++)
    {
        if(a[i]==1&&b[i]==1)
        {
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

void bomb(char field[8][8], int a, int b){
	int i;
	field[a][b] = '0';

	for(i = -3;i <= 3;i++){
		if(a + i >= 0 && a + i < 8){
			if(field[a + i][b] == '1'){
				bomb(field, a + i, b);
			}
		}
		if(b + i >= 0 && b + i < 8){
			if(field[a][b + i] == '1'){
				bomb(field, a, b + i);
			}
		}
	}
}

int main(void){
	int n, i, j, k, x, y;

	char field[8][8];

	scanf("%d", &n);

	for(i = 0;i < n;i++){
		for(j = 0;j < 8;j++){
			for(k = 0;k < 8;k++){
				scanf(" %c", &field[k][j]);
			}
		}
		scanf("%d", &x);
		scanf("%d", &y);

		bomb(field, x - 1, y - 1);

		printf("Data %d:\n", i + 1);
		for(j = 0;j < 8;j++){
			for(k = 0;k < 8;k++){
				printf("%c", field[k][j]);
			}
			printf("\n");
		}
	}


	return 0;
}

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

using namespace std;

typedef long long ll;

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

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

const int MAX_N = 2 * 100000;

int node[MAX_N];
int answer[MAX_N];
bool visited[MAX_N];

void f(const int cur_nd, int acc, const vector<vector<int> > &edge) {
    if (visited[cur_nd]) {
        return;
    }
    visited[cur_nd] = true;
    acc += node[cur_nd];
    answer[cur_nd] = acc;
    for (int i = 0; i < (int) edge[cur_nd].size(); i++) {
        f(edge[cur_nd][i], acc, edge);
    }
}

int main(void) {
    int N, Q;
    cin >> N >> Q;

    vector<vector<int> > edge(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        edge[a - 1].push_back(b - 1);
        edge[b - 1].push_back(a - 1);
    }

    for (int q = 0; q < Q; q++) {
        int p, x;
        cin >> p >> x;
        node[p - 1] += x;
    }

    f(0, 0, edge);

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

    return 0;
}


Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(ll n){
    cout << n << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x, y;
    cin >> x >> y;
    if(x == 0){
        if(y < 0){
            pr(-y+1);
        }else{
            pr(y);
        }
    }
    if(y == 0){
        if(x < 0){
            pr(-x);
        }else{
            pr(x+1);
        }
    }
    if(x < y && y < 0){
        pr(y-x);
    }
    if(x < y && x > 0){
        pr(y-x);
    }
    if(y < x && x < 0){
        pr(-y+x+2);
    }
    if(y < x && y > 0){
        pr(x-y+2);
    }
    if(x*y < 0){
        pr(abs(abs(x)-abs(y))+1);
    }
    return 0;
}

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
  return 0;
}

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

import sys
import os
import math


N, A, B = list(map(int, input().split()))
values = list(map(int, input().split()))
values.sort()

# 上からA個
subset = values[-A:]
mean = sum(subset) / len(subset)
print(mean)

def pascals_triangle(n_rows):
    results = []
    for _ in range(n_rows):
        row = [1]
        if results:
            last_row = results[-1]
            row.extend([sum(pair) for pair in zip(last_row, last_row[1:])])
            row.append(1)
        results.append(row)
    return results[-1] # 最後だけでOK

if subset[0] == subset[-1]:
    # 数を増やしてもmeanが減らない可能性がある
    cnt = values.count(subset[0])
    tri = pascals_triangle(cnt + 1)

    if cnt >= B:
        tri_subset = tri[A:B+1]
        print(sum(tri_subset))

    # B > cntなので、
    else:
        tri_subset = tri[A:cnt + 1]
        print(sum(tri_subset))

else:
    # 数を増やすのはあり得ない
    v = subset[0]
    cnt_in_all = values.count(v)
    cnt_in_subset = subset.count(v)

    #ans = combination(cnt_in_all, cnt_in_subset)
    tri = pascals_triangle(cnt_in_all + 1)
    ans = tri[cnt_in_subset]
    print(ans)


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> abc = new ArrayList<>();
        abc.add(sc.nextInt());
        abc.add(sc.nextInt());
        abc.add(sc.nextInt());
        Collections.sort(abc);
        System.out.println(abc.get(0) * abc.get(1) / 2);
    }
}


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

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

    int count = 0;
    for (size_t i = 0; i < S.size() / 2; i++)
    {
        if (S[i] != S[S.size() - 1 - i])
        {
            count++;
        }
    }

    cout << count << endl;
}

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

int main(){
    int N;
    cin >> N;
    int x[110];
    int i;
    int ave=0;

    for(i=0; i<N; i++){
        cin >> x[i];
        ave+=x[i];
    }
    ave/=N;

    int sum1=0,sum2=0;
    for(i=0;i<N;i++){
        sum1+=pow((x[i]-ave),2);
        sum2+=pow((x[i]-ave-1),2);
    }
    if(sum1>sum2) cout << sum2 << endl;
    else cout << sum1 << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
   int a[1005];
   int n;
   scanf("%d",&n);
   for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
   for(int i=0;i<n;i++)
    if(a[i]%2==0)
   {
       if(a[i]%3==0||a[i]%5==0)continue;
            else {


                printf("DENIED\n");
                return 0;
            }

   }

printf("APPROVED\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
  int A,B;
  cin >> A >> B;
  if(A%B == 0){
    cout << "0" << endl;
  }
  else{
    cout << "1" << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <map>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define DBG1(a) cerr<<#a<<" = "<<(a)<<"\n"
#define DBG2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define y1 frgrwegreg

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;

const double PI = acos(-1.0);
const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 100017;

LL x = 1, y = 1;
LL n, a, b;

int main()
{
	//freopen("C.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios::sync_with_stdio(0); cin.tie(0);

	cin >> n;
	FOR (i,0,n)
	{
		cin >> a >> b;
		LL d1 = (x+a-1)/a;
		LL d2 = (y+b-1)/b;
		LL d = max(d1,d2);
		x = a*d, y = b*d;
	}
	cout << x + y;
	return 0;
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import queue
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")

def cnt(n, k):

    return k

def main():
    K = int(input())

    Q = queue.Queue()
    for i in range(1, 10):
        Q.put(str(i))
    
    cnt = 1
    while cnt < K:
        q = Q.get()
        cnt += 1
        n = int(q[-1])
        if n != 0:
            Q.put(q + str(n-1))
        Q.put(q + str(n))
        if n != 9:
            Q.put(q + str(n+1))
    
    print(Q.get())
            


if __name__ == '__main__':
    main()

Measured memory_bytes: 105812
import bisect
import sys
input = sys.stdin.readline

a, b, q =  [ int(v) for v in input().split() ]

temple_list = [ int(input()) for i in range(a) ]
shrine_list = [ int(input()) for i in range(b) ]


def excursion(x):
	global temple_list, shine_list
	temple_west = bisect.bisect_left(temple_list,x)
	shrine_west = bisect.bisect_left(shrine_list,x)

	tw, te, sw, se = temple_list[(temple_west-1)%a],temple_list[temple_west%a],shrine_list[(shrine_west-1)%b],shrine_list[(shrine_west)%b]
	print(min( abs(x-tw) + min(abs(sw-tw),abs(tw-se)) , abs(te-x) + min(abs(se-te),abs(te-sw)), abs(x-sw) + min(abs(tw-sw),abs(sw-te)) , abs(se-x) + min(abs(te-se),abs(se-tw))))
	return 


for i in range(q):
	excursion(int(input()))

Measured memory_bytes: 12180
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=500005,mod=1e9+7;
int f[N]={1};
int qp(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int c(int n,int m)
{
	return f[n]*qp(f[m],mod-2)%mod*qp(f[n-m],mod-2)%mod;
}
signed main()
{
	for(int i=1;i<=500000;i++)
		f[i]=f[i-1]*i%mod;
	int n,m,ans=0;
	cin>>n>>m;
	for(int i=0;i<=n;i++)
	{
		int zh=1;
		zh=zh*c(m,i)%mod*c(n,i)%mod*f[i]%mod;
		zh=zh*c(m-i,n-i)%mod*c(m-i,n-i)%mod*f[n-i]%mod*f[n-i]%mod;
		if(i%2)
			ans=(ans+mod-zh)%mod;
		else
			ans=(ans+zh)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7488
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> inline void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> inline void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> inline void UNIQUE(vector<T>& vec) { sort(ALL(vec)); vec.erase(unique(ALL(vec)), vec.end()); }

vec<string> S;
int H, W;
int ans = 0;
int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };

inline bool range2d(int x, int y, int W, int H) { return (x >= 0) && (W >= x) && (y >= 0) && (H >= y); }




int main(void) {
	int N, H, W;
	cin >> N >> H >> W;

	int ans = 0;
	REP(i, N) {
		REP(j, N) {
			if (range2d(j + W, i + H, N, N))++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

def cnt(A, x):
    N = len(A)
    i = 0
    ret = 0
    while i<N:
        if A[i]<x:
            i += 1
        else:
            ret += 1
            while i<N and A[i]>=x:
                i += 1
    return ret

def main():
    N = int(input())
    A = list(map(int, input().split()))

    ret = 0
    for i in range(1,101):
        ret += cnt(A,i)

    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll f=1;
  rep(i,3){
    if(s[i]==s[i+1])f=0;
  }
  if(f){
    cout<<"Good"<<endl;

  }
  else {
    cout<<"Bad"<<endl;

  }


  return 0;

}




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

int main() {
	int A, B;
	cin >> A >> B;

	int ans = 0;
	if (B == 1) {
		ans = 0;
	}
	else {
		B -= 1;
		for (;;) {
			B -= (A - 1);
			ans++;
			if (B <= 0) {
				break;
			}
		}
	}

	cout << ans << endl;
}


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

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    vector<int>v;
    for(int i=n-1;i>=0;i-=2)
    {
        v.push_back(arr[i]);
        arr[i]=-2;
    }
    for(int i=0;i<n;i++)
    {
        if(arr[i]!=-2) v.push_back(arr[i]);
    }
    for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int maxi(int a,int b,int c)
{
    return max(a,max(b,c));
}
int main()
{
    int n;
    cin >> n;
    int a[n+1],b[n+1],c[n+1];
    for(int i=1;i<=n;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n+1][4];
    dp[1][1] = a[1];
    dp[1][2] = b[1];
    dp[1][3] = c[1];
    for(int i=2;i<=n;i++)
    {
        dp[i][1] = a[i]+max(dp[i-1][2],dp[i-1][3]);
        dp[i][2] = b[i]+max(dp[i-1][1],dp[i-1][3]);
        dp[i][3] = c[i]+max(dp[i-1][1],dp[i-1][2]);
    }
    cout << maxi(dp[n][1],dp[n][2],dp[n][3]) << "\n";
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}
long comb(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
using namespace std;
/*int main(){
    int n;std::cin >> n;
    int keta=0;
    while(true){
        keta++;
        if(n/10==0)break;
        n=n/10;
    }
    keta=keta-1;
    if(n>=7)n=3;
    else if(n>=5)n=2;
    else if(n>=3)n=1;
    int k=0;
    for(int i=3;i<=keta;i++){
        k+=comb(i-1,2);
        std::cout << k << std::endl;
    }std::cout << k << std::endl;
    k+=n*(keta);
    
    std::cout << k << std::endl;
    
}


*/
int main(){
  int a[3],b[3],c[3],n;
  rep(i,3){
      std::cin >> a[i]>>b[i]>>c[i];
  }
  std::cin>>n;
  int d[n];
  rep(i,n){
      std::cin >> d[i];
      rep(j,3){
          if(d[i]==a[j])a[j]=0;
          if(d[i]==b[j])b[j]=0;
          if(d[i]==c[j])c[j]=0;
      }
  }
  if(a[1]+a[2]+a[0]==0)std::cout << "Yes" << std::endl;
  else if(b[1]+b[2]+b[0]==0)std::cout << "Yes" << std::endl;
  else if(c[1]+c[2]+c[0]==0)std::cout << "Yes" << std::endl;
  else if(a[1]+b[1]+c[1]==0)std::cout << "Yes" << std::endl;
  else if(a[2]+b[2]+c[2]==0)std::cout << "Yes" << std::endl;
  else if(a[0]+b[0]+c[0]==0)std::cout << "Yes" << std::endl;
  else if(a[0]+b[1]+c[2]==0)std::cout << "Yes" << std::endl;
  else if(a[2]+b[1]+c[0]==0)std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //inf=0x3f3f3f3f;//printf("%.10lf\n",x);
#define ROCK ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const int N=1e5+20;
int h[N],n,k,dis[N];

int mincoast(int pos){
if(pos==n-1)return 0;
if(dis[pos]!=-1)return dis[pos];
int ans=INT_MAX;
for(int i=1;i<=k;i++){
    if(pos+i<n)ans=min(ans,abs(h[pos]-h[pos+i])+mincoast(pos+i));
    else break;
}return dis[pos]=ans;
}

int main()
{
    ROCK;
    cin>>n>>k;
    memset(dis,-1,sizeof dis);
    for(int i=0;i<n;i++)cin>>h[i];
    cout<<mincoast(0);
    return 0;
}



Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n == 7 || n == 5 || n == 3)System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 35700
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,k,ans;
signed main(){
	n=read();m=read();k=read();
	ans=n*min(m-1,k)/m;
	printf("%d",ans);
}


Measured memory_bytes: 3724