akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());


int main()
{
  FAST/**/
   
   ll h,w;
   cin>>h>>w;
   
  
   
   pair<ll,ll> hold[h+1];
   for(ll i=0;i<h;i++)
        cin>>hold[i].ff>>hold[i].ss, hold[i].ff--, hold[i].ss--;
   hold[h] = mp(w,w);        
   
   ll n = h, m = w;
   
   set<pair<ll,ll>> st;
   rep(w)
        st.insert(mp(i,0ll));
   multiset<ll> dis;
   rep(w)
        dis.insert(0);
   ll fin[n+1];
   rep(n)
        fin[i+1] = -1;
   fin[0] = 0;
   for(ll i=1;i<=h;i++)
   {
       ll l = hold[i-1].ff;
       ll r = hold[i-1].ss;
       auto it = st.lower_bound(mp(l-1,inf));
       vector<pair<ll,ll>> er;
       ll diste = inf;
       while(it!=st.end())
       {
           if(it->ff>r)
                break;
           er.pb(*it);
           diste = min(diste, r+1-it->ff + it->ss);
           dis.erase(dis.find(it->ss));
           it++;
       }
       
       rep(er.size())
            st.erase(er[i]);
       
       er.clear();
       
       it = st.find(mp(r,inf));
       
       if(diste != inf && r+1<w && (it == st.end()|| (it->ff>r+1) || (it->ff == r+1 && it->ss>diste)))
       {
           st.insert(mp(r+1,diste));
           it = st.find(mp(r+1,diste));
           dis.insert(diste);
           it++;
           while(it!=st.end())
           {
               if(diste + it->ff - (r+1) <= it->ss)
                    er.pb(*it), dis.erase(dis.find(it->ss));
               else break;        
               it++;        
           }
           
           autoit(er,it)
                st.erase(*it);
       }
       
       /*autoit(st,it)
       {
           cout<<it->ff+1<<" "<<it->ss<<"\n";
       }
       cout<<"\n";*/
       
       if(dis.size()>0)
            fin[i] = *dis.begin()+i;
       
       
   }
   
   rep(n)
        cout<<fin[i+1]<<"\n";
   
   return 0;        
}  

  
          
   

Measured memory_bytes: 30192
import math

n = 10**5+1

prime = [1]*(n+1)
prime[0] = 0
prime[1] = 0
for i in range(2,int(math.sqrt(n))+1):
    if not prime[i]:
        continue
    for j in range(i*2,n+1,i):
        prime[j] = 0

A = [0]*(n+1)
for i in range(1,n,2):
	j = (i+1)//2
	if prime[i] and prime[j]:
		A[i] = 1
for i in range(1,n+1):
	A[i] += A[i-1]

Q = int(input())
for i in range(Q):
    l,r = map(int,input().split())
    print(A[r]-A[l-1])



Measured memory_bytes: 8948
N = int((input()))
ab = [list(map(int,input().split())) for _ in range(N-1)]
c = list(map(int,input().split()))
c.sort(reverse = True)

al = [[] for _ in range(N+1)]
for a,b in ab:
    al[a].append(b)
    al[b].append(a)

d = [0] * (N)
d[ab[0][0]-1] = c[0]
cnt = 1
child = al[ab[0][0]]
ans = 0
Check = [True] * (N+1)
Check[ab[0][0]] = False

while child and cnt < N:
    pi = int(child.pop())
    Check[pi] = False
    d[pi-1] = (c[cnt])
    ans += c[cnt]
    for i in al[pi]:
        if Check[i]:child.append(i)
    cnt += 1
    
print(ans)
print(' '.join(map(str,d)))


Measured memory_bytes: 7464
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
 char str1[201]={'\0'};
 char str2[201]={'\0'};
 char p[101];
 int i,j,k;


 scanf("%s",str1);

 strcpy(str2,str1);

 strcat(str1,str2);

 scanf("%s",p);

 if(strstr(str1,p) != NULL){
  printf("Yes\n");
 }else{
  printf("No\n");
 }



return 0;
}

Measured memory_bytes: 540
#include<stdio.h>
#include<string.h>
int main()
{
	char input[100];
	int total = 0;
	scanf("%s",input);
	int len= strlen(input);
	for(int x=0;x<len;x++)
	{
		if(input[x] == '+')
		{
			total+=1;
		}
		else total-=1;
	}
	printf("%d",total);
}

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

int main(){
  long int N,A,B; cin >> N >>A >> B;
  long int diff = B-A;
  long int r;
  if(diff<0){
    r = 0;
  }else if(diff==0){
    r = 1;
  }else{
    if(N==1){
      r = 0;
    }else{
      long int l = A*(N-1)+B;
      long int h = A + (N-1)*B;
      r = h-l+1;
    }
  }
  
  cout << r << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=Integer.parseInt(scan.next());
		int b=Integer.parseInt(scan.next());
		int temp=0;
		while(a!=0 || b!=0){
			if(a>b){
				temp = a;
				a = b;
				b = temp;
			}
			System.out.println(a+" "+b);
			a=Integer.parseInt(scan.next());
			b=Integer.parseInt(scan.next());
		}	
		scan.close();
	}
}

Measured memory_bytes: 25288
#include <iostream>
#include <sstream>
#include <cstring>

using namespace std;

const int N = 50000;
bool prime[N+1];

void make_prime (void)
{
	int i,j;
	memset (prime, true , sizeof(prime) );

	prime[0] = false;
	prime[1] = false;

	for (j = 0; j <= N; ++j){
		if (prime[j]){
			int p = j;
			for (i = 2*p; i <= N; i += p ){
				if (prime[i] ){
					prime[i] = false;
				} // end if
			} // end for
		} // end if	
	} // end for
}

int main()
{
	string str = "";
	make_prime();

	while (getline (cin, str ) ){
		int n;
		stringstream ss(str);
		ss >> n;
		if (n == 0 ){
			break;
		} // end if
		int res = 0;
		int i;

		for (i = 2; i <= n/2; ++i){
			if (prime[i] && prime[n-i] ){
				++res;
			} // end for
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 984
n,m=map(int,input().split())
a=[]
for i in range(m):
    x,y=input().split()
    a.append([int(x),y])
check=[False]*n
ans=[0]*n
for i in a:
    if check[i[0]-1]==True:
        continue
    else:
        if i[1]=="AC":
            check[i[0]-1]=True
        else:
            if check[i[0]-1]!=True:
                ans[i[0]-1]+=1
total=0
for i in range(n):
    if check[i]==True:
        total+=ans[i]
print(check.count(True),total)

Measured memory_bytes: 23464
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var n=GetInput_string()[0];
            var last = n[n.Length - 1];

            if (last == '3')
            {
                Console.WriteLine("bon");
            }else if (last == '0' || last == '1' || last == '6' || last == '8' )
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }
        }
        
        #region input
        

        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion

        static long mod = 1000000000 + 7;
    }

}

Measured memory_bytes: 25904
fun main(args: Array<String>) {
    val (k, a, b) = readLine()!!.split(" ").map{it.toLong()}

    // 単純にｋ回操作を行ったら時間切れ

    // 交換しないほうが良いケース
    if(b-a <=2) {
        print(k+1)
        return
    }

    // 交換できないケース
    if (a >= k ) {
        print(k+1)
        return
    }


    // 以下の手順を単純に行うのは x 場合分けして計算する

    // その他の場合は溜まり次第交換していったほうが良い，
    // A -> B 交換するたびに，新たに A -> B 交換するための枚数は貯まるので一度条件を満たせば交換し続けるのが最善


    // 交換できる & 交換したほうが良いので，まず第一回まで貯める
    var cnt = a
    var res = k - (a-1)

    // 以降は残り回数の

    cnt += if (res % 2 == 0L) {
        (b-a) * (res/2)
    } else {
        (b-a) * (res/2) + 1
    }

    print(cnt)
}


Measured memory_bytes: 37716
#include <stdio.h>
#include <math.h>

int main(void)
{
	int i, x;
	int a,b;

	while(scanf("%d %d", &a, &b) != EOF){
		for(i = 0, x = a+b; x >= 1; x /= 10, i++);
		printf("%d\n", i);
	}


	return 0;
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.function.BiFunction;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        static long MOD = (long) (1e9 + 7);

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long n = in.nextInt();
            long a = in.nextInt();
            long b = in.nextInt();

            long x = modpow(2, n) - 1;
            BiFunction<Long, Long, Long> func = (Long q, Long w) -> {
                long e = 1;
                long r = 1;
                for (long i = 0; i < w; i++) {
                    e = (e * (q - i)) % MOD;
                    r = (r * (i + 1)) % MOD;
                }
                return (long) ((e * modpow(r)) % MOD);
            };
            long y = func.apply(n, a);
            long z = func.apply(n, b);
            x = (x - y - z + MOD * 2) % MOD;
            out.println(x);
        }

        private long modpow(long a) {
            return modpow(a, MOD - 2);
        }

        private long modpow(long a, long n) {
            long r = 1;
            while (n > 0) {
                r = r * ((n % 2) != 0 ? a : 1) % MOD;
                a = a * a % MOD;
                n >>= 1;
            }
            return r;
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 27476
#include<bits//stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
typedef long long ll;
const ll MOD =  1000000007;
struct edge {
    int to, cap, rev;// 行先　容量　逆辺
};
vector<edge> g[1010]; bool used[1010];
void add(int u, int v, int f) {
    g[u].push_back(edge{ v,f,(int)g[v].size() });
    g[v].push_back(edge{ u,0,(int)g[u].size() - 1 });
}
int dfs(int pos, int to, int f) {
    if (pos == to) return f;
    used[pos] = 1;
    rep(i, g[pos].size()) {
        if (g[pos][i].cap == 0 || used[g[pos][i].to]) continue;
        int D = dfs(g[pos][i].to, to, min(g[pos][i].cap, f));
        if (D >= 1) {
            g[pos][i].cap -= D;
            g[g[pos][i].to][g[pos][i].rev].cap += D;
            return D;
        }
    }return 0;
}
int max_flow(int s, int t) {
    int F = 0; for (;;) {
        fill(used, used + 1001, 0);
        int F2 = dfs(s, t, (1e9));
        F += F2;
        if (F2 == 0) return F;
    }return MOD;
}
int n, m, a[1000], b[1000], c[1000];
int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        add(a[i], b[i], c[i]);
    }cout << max_flow(0, n - 1) << endl;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
#define EPS 1e-9

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 250, M = 1e6 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

void go(int tc = 0){
    string s;   cin >> s;
    int cnt1 = (s[0] == 'R') || (s[1] == 'R') || (s[2] == 'R');
    int cnt2 = 2 * ((s[0] == 'R') && (s[1] == 'R'));
    int cnt3 = 2 * ((s[1] == 'R') && (s[2] == 'R'));
    int cnt4 = 3 * ((s[0] == 'R') && (s[1] == 'R') && (s[2] == 'R'));
    cout << max({cnt1, cnt2, cnt3, cnt4});
}

int main(){
    init();

//    freopen("in.in", "r", stdin);
//    freopen("out.out", "w", stdout);

   int t = 1, tc = 1;
//   cin >> t;
    while(t--)
        go(tc++);
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
typedef long long lint;
using namespace std;

/* gcd */
template<typename T>
T gcd(T a,T b)
{
	if(a==0 || b==0)return 0;
	T r;
	while(1)
	{
		r=a%b;
		if(r==0)break;
		a=b;
		b=r;
	}
	return b;
}

template<typename T>
T gcd(T *x,size_t size)
{
	T ret=x[0];
	for(size_t i=0;i<size;i++)
	{
		ret=gcd(ret,x[i]);
	}
	return ret;
}

/* lcm */
template<typename T>
T lcm(T a,T b)
{
	if(a==0 || b==0)return 0;
	return a*(b/gcd(a,b));
}

template<typename T>
T lcm(T *x,size_t size)
{
	T ret=x[0];
	for(size_t i=0;i<size;i++)
	{
		ret=lcm(ret,x[i]);
	}
	return ret;
}

int main()
{
	int N;
	lint T[110]={};
	
	cin >> N;
	for(int i=0;i<N;i++)
		cin >> T[i];
	
	cout << lcm(T,N) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		double[] v = new double[N];
		double ans = 0;
		double a = 0;
		double b = 0;

		for (int i = 0; i < N; i++) {
			v[i] = sc.nextInt();
		}
		
		Arrays.sort(v);
		
		a = ( v[0] + v[1] ) / 2;
		b = a;
		if(N > 2) {
			for(int j = 2; j < N; j++) {
				b = (b + v[j]) / 2;
			}
		}
		
		
		System.out.println(b);

	}

}

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    // test
    {
        bool f;
        cin>>f;
        cout<<(!f);
    }
}

Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=10010;
int ans[maxn];

int main()
{
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1; i<=n-1; i++)
	  {
	  	for(int j=i+1; j<=n; j++)
	  	{
	  		int d=j-i;
	  		d=min(d,abs(i-x)+abs(j-y)+1);
	  		d=min(d,abs(j-x)+abs(i-y)+1);
	  		ans[d]++;
		  }
	  }
	  for(int i=1; i<=n-1; i++)
	   printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 760
#include<stdio.h>
    int main(void){
    int aih,aim,ais,aoh,aom,aos,bih,bim,bis,boh,bom,bos,cih,cim,cis,coh,com,cos,ah,am,as,bh,bm,bs,ch,cm,cs;
    scanf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d",&aih,&aim,&ais,&aoh,&aom,&aos,&bih,&bim,&bis,&boh,&bom,&bos,&cih,&cim,&cis,&coh,&com,&cos);
    ais=aih*3600+aim*60+ais;
    bis=bih*3600+bim*60+bis;
    cis=cih*3600+cim*60+cis;
    aos=aoh*3600+aom*60+aos;
    bos=boh*3600+bom*60+bos;
    cos=coh*3600+com*60+cos;
    as=aos-ais;
    bs=bos-bis;
    cs=cos-cis;
    /*
    ah=as/3600,as=as%3600;
    am=as/60,as=as%60;
    bh=bs/3600,bs=bs%3600;
    bm=bs/60,bs=bs%60;
    ch=cs/3600,cs=cs%3600;
    cm=as/60,cs=cs%60;
    */
    am=as/60,as=as%60;
    ah=am/60,am=am%60;
    bm=bs/60,bs=bs%60;
    bh=bm/60,bm=bm%60;
    cm=cs/60,cs=cs%60;
    ch=cm/60,cm=cm%60;
    printf("%d %d %d\n%d %d %d\n%d %d %d\n",ah,am,as,bh,bm,bs,ch,cm,cs);
    return 0;
    }

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int cnt=0;
  int maxim=0;
  string str;
  cin>>str;
  for(int i=0;i<3;i++){
    if(str[i]=='R'){
      cnt++;
      maxim=max(maxim,cnt);
    }else{
      cnt=0;
    }
  }
  cout<<maxim<<endl;
  return(0);
}

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

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0);
  int x;
  cin >> x;
  if (x >= 30) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

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

const int INF = 1000000000;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<int> cost(n, INF);
  cost[0] = 0;
  for (int i = 1; i <= n - 1; i++) {
    int it = min(i, k);
    for (int j = 1; j <= it; j++) {
      chmin(cost[i], cost[i - j] + abs(h[i] - h[i - j]));
    }
  }
  cout << cost[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const ll inf=1ll<<60;

vector<int> to[2510];
vector<int> rto[2510];
bool reachablefrom1[2510];
bool reachabletoN[2510];
bool ok[2510];

void dfs(int v){
  if(reachablefrom1[v]) return;
  reachablefrom1[v]=1;
  for(int nv:to[v]){
    dfs(nv);
  }
}
void rdfs(int v){
  if(reachabletoN[v]) return;
  reachabletoN[v]=1;
  for(int nv:rto[v]){
    rdfs(nv);
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<tiii> edges;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--; b--;
    edges.emplace_back(a,b,-c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i]=reachablefrom1[i]&&reachabletoN[i];
  // bellman-ford
  vector<ll> dist(n,inf);
  dist[0]=0;
  bool update=true;
  int step=0;
  while(update){
    update=false;
    rep(i,m){
      int a,b,c;
      tie(a,b,c)=edges[i];
      if(!ok[a]||!ok[b]) continue;
      if(dist[a]+c<dist[b]){
        update=true;
        dist[b]=dist[a]+c;
      }
    }
    step++;
    if(step>n){
      cout << "inf" << endl;
      return 0;
    }
  }
  ll ans=-dist[n-1];
  cout << ans << endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define fd(i,x,y) for(int i=x;i>=y;i--)
using namespace std;

const int maxn=600007,mo=924844033,G=5;

int n,fi[maxn],ne[maxn],la[maxn],tot;
void add(int a,int b){
	tot++;
	ne[tot]=fi[a];
	la[tot]=b;
	fi[a]=tot;
}

int f[maxn];
int b[maxn],si[maxn],fa[maxn];
void bfs(){
	b[b[0]=1]=1;
	fo(i,1,b[0]){
		int v=b[i];
		for(int k=fi[v];k;k=ne[k])
			if (la[k]!=fa[v]){
				b[++b[0]]=la[k];
				fa[la[k]]=v;
			}
		si[v]=1;
	}
	fd(i,b[0],2){
		int v=b[i];
		for(int k=fi[v];k;k=ne[k])
			if (la[k]!=fa[v])
				si[v]+=si[la[k]];
		f[si[v]]++;
		f[n-si[v]]++;
	}
}
int qp(int a,int b){
	int c=1;
	while (b){
		if (b&1) c=1ll*a*c%mo;
		a=1ll*a*a%mo;
		b>>=1;
	}
	return c;
}
int N=1,w[maxn],_w[maxn],Fact[maxn],invFact[maxn];
void pre(){
	while (N<n*2) N<<=1;
	int t=qp(G,(mo-1)/N);
	w[0]=1;
	fo(i,1,N) w[i]=1ll*w[i-1]*t%mo;
	fo(i,0,N) _w[i]=w[N-i];
	Fact[0]=1;
	fo(i,1,N) Fact[i]=Fact[i-1]*1ll*i%mo;
	invFact[N-1]=qp(Fact[N-1],mo-2);
	fd(i,N-2,0) invFact[i]=invFact[i+1]*(i+1ll)%mo;
}
void Init(){
	scanf("%d",&n);
	fo(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	bfs();
	pre();
}

int g[maxn];
void DFT(int *x,int *w){
	for(int i=0,j=0;i<N;i++){
		if (i<j) swap(x[i],x[j]);
		for(int l=N>>1;(j^=l)<l;l>>=1);
	}
	for(int i=2,m=1;i<=N;i<<=1,m<<=1)
		for(int j=0;j<N;j+=i)
			fo(k,0,m-1){
				int tmp=1ll*x[j+k+m]*w[N/i*k]%mo;
				x[j+k+m]=(x[j+k]-tmp+mo)%mo;
				x[j+k]=(x[j+k]+tmp)%mo;
			}
}
void NTT(int *a,int *b){
	DFT(a,w);
	DFT(b,w);
	fo(i,0,N-1) a[i]=1ll*a[i]*b[i]%mo;
	DFT(a,_w);
	int inv=qp(N,mo-2);
	fo(i,0,N-1) a[i]=1ll*a[i]*inv%mo;
}
void Solve(){
	fo(i,0,N-1) f[i]=1ll*f[i]*Fact[i]%mo;
	reverse(f,f+n+1);
	fo(i,0,n) g[i]=invFact[i];
	NTT(f,g);
}

int C(int x,int y){
	return 1ll*Fact[x]*invFact[y]%mo*invFact[x-y]%mo;
}
void Print(){
	fo(i,1,n) printf("%d\n",((1ll*n*C(n,i)-f[n-i]*1ll*invFact[i])%mo+mo)%mo);
}

int main(){
	Init();
	Solve();
	Print();
	return 0;
}

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

int n, f[100][10], p[100][11], ans = -(1 << 30);
bool isOpened[10];
int Count[100];

void dfs(int cnt) {
    if (cnt == 10) {
        // check and init
        bool isZero = true;
        for (int i = 0; i < 10; i++) {
            if(isOpened[i]) isZero = false;
        }
        if (isZero) return;
        for (int i = 0; i < n; i++) {
            Count[i] = 0;
        }
        // count
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 10; j++) {
                if (!isOpened[j]) continue;
                if (f[i][j]) Count[i]++;
            }
        }
        // calc 
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += p[i][Count[i]];
        }
        ans = max(ans, sum);
    } else {
        isOpened[cnt] = false;
        dfs(cnt+1);
        isOpened[cnt] = true;
        dfs(cnt+1);
    }
}

int  main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            scanf("%d", &f[i][j]);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 11; j++) {
            scanf("%d", &p[i][j]);
        }
    }
    dfs(0);
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
A, B, C, D = list(map(int, list(input().strip())))

for op1 in [-1, 1]:
    for op2 in [-1, 1]:
        for op3 in [-1, 1]:
            if A + (op1 * B) + (op2 * C) + (op3 * D) == 7:
                print('{}{}{}{}{}{}{}=7'.format(A, "+" if op1 == 1 else "-", B, "+" if op2 == 1 else "-", C, "+" if op3 == 1 else "-", D))
                exit()

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    if(a + b == c + d) cout << "Balanced" << endl;
    else if(a + b < c + d) cout << "Right" << endl;
    else cout << "Left" << endl;
}


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

using i64 = long long;
using u64 = unsigned long long;

const int mod = (int)1e9+7;

void __print() {cerr << "]\n";}

template<typename T, typename... V>
void __print(T t, V... v)
{ cerr << t; if(sizeof...(v)) printf(" "); __print(v...);}

#define dbg(x...) cerr << "[" << #x << "] = ["; __print(x);



int main()
{
    int n;
    scanf("%d", &n);
    vector<vector<pair<int, int>>> adj(n+1);
    set<int> s[n+1];
    for(int i = 0; i < n - 1; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        adj[x].push_back({y, i});
        adj[y].push_back({x, i});
    }
    vector<int> colors(n);
    vector<bool> visited(n+1, false);
    queue<int> q;
    q.push(1);
    int mx = 0;
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        if(visited[u]) continue;
        visited[u] = true;
        vector<int> v;
        int sz = adj[u].size();
        mx = max(mx, sz);
        for(int i = 1; i <= sz; i++) {
            if(s[u].find(i) == s[u].end()) {
                v.push_back(i);
            }
        }
        for(auto edge : adj[u]) {
            int to, id;
            tie(to, id) = edge;
            if(!visited[to]) {
                colors[id] = v.back();
                v.pop_back();
                q.push(to);
                s[to].insert(colors[id]);
            }
        }
    }
    printf("%d\n", mx);
    for(int i = 0; i < n-1; i++) printf("%d\n", colors[i]);
}


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

int main()
{
    string N;
    cin >> N;
    for (char n : N)
    {
        if (n == '7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;

const int N=1e5+10;

char ch[N];
int a[N],b[N];

int main()
{
	scanf("%s",ch+1);
	int n=strlen(ch+1);
	for(int i=1;i<=n;i++) if(ch[i]=='A') a[i]=1;
	for(int i=2;i<=n;i++) a[i]+=a[i-1];
	scanf("%s",ch+1);
	n=strlen(ch+1);
	for(int i=1;i<=n;i++) if(ch[i]=='A') b[i]=1;
	for(int i=2;i<=n;i++) b[i]+=b[i-1];
	int q;
	scanf("%d",&q);
	while(q--)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		int x1=a[r]-a[l-1];
		int y1=r-l+1-x1;
		scanf("%d%d",&l,&r);
		int x2=b[r]-b[l-1];
		int y2=r-l+1-x2;
	//	cout<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<endl;
		int x,y;
		if(x1<x2)
		{
			x=x2-x1;
			x=3-(x%3);
			x%=3;
		}
		else x=x1-x2;
		//else x=0,y1+=(x1-x2)*2;
		x%=3;
		if(y1<y2)
		{
			y=y2-y1;
			y=3-(y%3);
			y%=3;
		}
		else y=y1-y2;
		y%=3;
		if(!x&&!y) puts("YES");
		else if(x==1&&y==1) puts("YES");
		else if(x==2&&y==2) puts("YES");
		else puts("NO");
	}
}
		
		
		

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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

vector<int> factor(int n){
    vector<int> res;

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

    return res;
}

int main(void){

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

    int not_coprime = a[0];
    for(int i = 1; i < n; ++i){
        not_coprime = gcd(not_coprime, a[i]);
    }
    if(not_coprime != 1){
        cout << "not coprime" << "\n";
        return 0;
    }

    set<int> pr;
    for(int i = 0; i < n; ++i){
        vector<int> x = factor(a[i]);
        set<int> ps(all(x));

        for(auto v : ps){
            if(pr.find(v) != pr.end()){
                cout << "setwise coprime" << "\n";
                return 0;
            }
            pr.insert(v);
        }
    }
    cout << "pairwise coprime" << "\n";

    return 0;
}


Measured memory_bytes: 7288
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

    int a[2][n];
    for(int i=0; i<2; i++){
        for(int j=0; j<n; j++){
            cin >> a[i][j];
        }
    }

    int sum1[n], sum2[n];
    sum1[0]   = a[0][0];
    sum2[n-1] = a[1][n-1];

    for(int j=1; j<n; j++){
        sum1[j] = sum1[j-1] + a[0][j];
    }
    for(int j=n-2; j>=0; j--){
        sum2[j] = sum2[j+1] + a[1][j];
    }

    // cout << sum1[n-1] << " " << sum2[0];

    int ans = 0;
    for(int i=0; i<n; i++){
        ans = max(ans, sum1[i] + sum2[i]);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
// パスカルの三角形
/*
AtCoder abc 132 解説より
https://www.youtube.com/watch?v=mso8tE1yMl8
*/
/*
    1
   1 1
  1 2 1
 1 3 3 1

aCb はa段目のb番目
*/

static MOD: usize = 1_000_000_000 + 7;
use std::ops::{AddAssign, SubAssign, MulAssign};
use std::ops::{Add, Sub, Mul};
#[derive(Copy, Clone, Debug)]
struct MUsize {x: usize}
impl MUsize {
    fn new(x: usize) -> MUsize {
        MUsize{x: x%MOD}
    }
}
impl AddAssign for MUsize {
    fn add_assign(&mut self, other: MUsize) {
        let tmp = self.x + other.x;
        *self = MUsize {
            x: if tmp >= MOD {tmp - MOD} else {tmp}
        };
    }
}
impl<'a> AddAssign<&'a MUsize> for MUsize {
    fn add_assign(&mut self, other: &MUsize) {
        let tmp = self.x + other.x;
        *self = MUsize {
            x: if tmp >= MOD {tmp - MOD} else {tmp}
        };
    }
}
impl SubAssign for MUsize {
    fn sub_assign(&mut self, other: MUsize) {
        let tmp = self.x + MOD - other.x;
        *self = MUsize {
            x: if tmp >= MOD {tmp - MOD} else {tmp}
        };
    }
}
impl MulAssign for MUsize {
    fn mul_assign(&mut self, other: MUsize) {
        *self = MUsize {
            x: self.x * other.x % MOD
        };
    }
}
impl Add for MUsize {
    type Output = MUsize;
    fn add(self, other: MUsize) -> MUsize {
        let mut res = MUsize::new(self.x);
        res += other.clone();
        res
    }
}
impl Sub for MUsize {
    type Output = MUsize;
    fn sub(self, other: MUsize) -> MUsize {
        let mut res = MUsize::new(self.x);
        res -= other;
        res
    }
}
impl Mul for MUsize {
    type Output = MUsize;
    fn mul(self, other: MUsize) -> MUsize {
        let mut res = MUsize::new(self.x);
        res *= other;
        res
    }
}

struct C {
    c: Vec<Vec<MUsize>>
}
impl C {
    fn new(max: usize) -> C {
        let mut c = vec![vec![MUsize::new(0); max+2]; max+2];
        c[0][0] = MUsize::new(1);
        for i in 0..max+1 {
            for j in 0..i+1 {
                let tmp = c[i][j];
                c[i+1][j] += tmp;
                c[i+1][j+1] += tmp;
            }
        }
        C {c:c}
    }
}

use std::io::prelude::*;

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: usize = input();
    let c = C::new(4005);
    for i in 1..k+1 {
        println!("{}", (c.c[n-k+1][i] * c.c[k-1][i-1]).x);
    }
}

Measured memory_bytes: 151804
#include<stdio.h>

int maxHeapify(int);

int array[500001];
int i,num,num2,l,r,kind=0;
  
int main(void){

  scanf("%d",&num);

  for(i = 1;i <= num;i++){
    scanf("%d",&array[i]);
  }
  for(i = num/2;i > 0;i--){
    maxHeapify(i);
  }
  for(i = 1;i <= num;i++){
    printf(" %d",array[i]);
  }
  printf("\n");
  return 0;
}

  
int maxHeapify(i){
 r = 1 +  2 * i;
  l = 2 * i;

  if(l <= num && array[l]>array[i])num2=l;

  else num2 = i;

  if(r <= num && array[r]>array[num2])num2=r;

  if(num2 != i){
    kind = array[i];
    array[i] = array[num2];
    array[num2] = kind;
    return maxHeapify(num2);
  }

  return 0;
}

Measured memory_bytes: 2552
def main():
    N, K, Q, *A = map(int, open(0).read().split())

    ans = float("inf")
    for Y in set(A):
        C = []
        tmp = []
        for a in A:
            if a >= Y:
                tmp.append(a)
            else:
                if len(tmp) >= K:
                    C += sorted(tmp)[:len(tmp) - K + 1]
                tmp = []
        if len(tmp) >= K:
            C += sorted(tmp)[:len(tmp) - K + 1]

        if len(C) >= Q:
            C.sort()
            X = C[Q - 1]
            ans = min(ans, X - Y)

    print(ans)

main()

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc097/tasks/abc097_b

int main() {
    int X; cin >> X;
    vector<bool> expo(X+5);

    expo[1] = true;
    for (int b = 2; b <= X ; b++) {
        int v = b * b;
        while(v <= X) {
            expo[v] = true;
            v *= b;
        }
    }

    for (int i = X; i > 0; i--) if (expo[i]) {
            cout << i << "\n";
            return 0;
    }

    return 0;
}


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

int main(){
    int h,a;
    int count = 0;
    cin >> h >>a;
    while(h > 0){
        h = h - a;
        count ++;
    }
    cout << count << endl;
    return 0;

}

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

int n;
int p[100005] = {0};
int memo[100005][7] = {0};
int minnum[100005] = {0};
vector<int> ls[100005];
queue<pair<int, int>> qu;

int setmemo(int now);

int main() {
  int i, j, ntime, nextn;
  pair<int, int> nowp = make_pair(0, 0);
  cin >> n;
  for(i = 0; i < n; ++i) cin >> p[i];
  for(i = 0; i < n; ++i) {
    if(p[i] != 0)
      memo[i][6] = -1;
    else
      memo[i][6] = i;
  }
  for(i = 0; i < n; ++i)
    for(j = 0; j < 6; ++j) {
      memo[i][j] = setmemo(min(i + j + 1, n - 1));
      if(memo[i][j] < 0) continue;
      ls[memo[i][j]].push_back(i);
    }
  for(i = 0; i < n - 1; ++i) minnum[i] = inf;
  nowp.second = n - 1;
  qu.push(nowp);
  while(qu.size() > 0) {
    nowp = qu.front();
    qu.pop();
    if(nowp.second == 0) {
      cout << nowp.first << endl;
      break;
    }
    for(i = 0; i < ls[nowp.second].size(); ++i) {
      nextn = ls[nowp.second][i];
      ntime = nowp.first + 1;
      if(minnum[nextn] > ntime) {
        minnum[nextn] = ntime;
        qu.push(make_pair(ntime, nextn));
      }
    }
  }
  return 0;
}

int setmemo(int now) {
  if(memo[now][6] != -1) return memo[now][6];
  map<int, int> mp;
  while(1) {
    if(memo[now][6] != -1) {
      now = memo[now][6];
      break;
    }
    if(mp.find(min(n - 1, now + p[now])) != mp.end()) {
      now = -2;
      break;
    }
    mp[now] = min(n - 1, now + p[now]);
    now += p[now];
  }
  for(auto it = mp.begin(); it != mp.end(); ++it) {
    memo[it->first][6] = now;
  }
  return now;
}



Measured memory_bytes: 12908
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> a(N);
for (int i = 0; i < N; ++i) cin >> a[i];
sort(a.begin(), a.end(), greater<int>());
int alice = 0;
for (int i = 0; i < N; i +=2) alice += a[i];
for (int i = 1; i < N; i +=2) alice -= a[i];
cout << alice << endl;
}

Measured memory_bytes: 888
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var w = +lines.shift();
var n = +lines.shift();

var list = [];
var line = null;
while (line = lines.shift()) {
    var args = line.split(',');
    list.push(args);
}

var answers = [];
for (var i = 1; i <= w; i++) {
    var k = i;
    list.forEach(function(args) {
        if (args[0] == k) {
            k = args[1];
        } else if (args[1] == k) {
            k = args[0];
        }
    });
    answers[k] = i;
}
answers.shift();
console.log(answers.join('\n'));

Measured memory_bytes: 15800
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
    int i,j;
    int h,w;
    
    while(1){
        scanf("%d %d",&h,&w);
        if (h==0 && w ==0) break;
        for(i=0; i < h; i++){
            for(j=0; j < w; j++){
                if (i == 0 || i == h-1 || j == 0 || j == w-1)
                {putchar('#');}
                else {putchar('.');}
            }
            putchar('\n');
        }
        putchar('\n');
        }
    return 0; 
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll sum[300001];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
   ll n,k,ans=0,a;
   cin>>n>>k;
   for(int i=1;i<=n;i++)
   {
       cin>>A[i];
       sum[i]=(A[i]+sum[i-1])%k;
   }
   for(int i=1;i<=n;i++)
   {
       sum[i]=(sum[i]-i)%k;
       sum[i]+=k;
       sum[i]%=k;
       //cout<<sum[i]<<" ";
   }
   //myMap[0]=1;
   for(int i=0;i<=n;i++)
   {
       ans+=myMap[sum[i]];
       //cout<<ans<<" "<<myMap[sum[i]]<<" "<<sum[i]<<endl;
       myMap[sum[i]]++;
       if(i>=k-1)
       {
           myMap[sum[i-k+1]]--;
       }

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



Measured memory_bytes: 15360
#include <cstdio>
#include <cstring>
#include <cstdlib>
int main(){
    char s[12];
    int a,b;
    scanf("%d%d\n",&a,&b);
    int len=a+b;
    fgets(s,12,stdin);
    if (s[a]!='-'){
        printf("No\n");
        return 0;
    }
    for (int i=0;i<a;i++){
        if (!(s[i]>='0'&&s[i]<='9')){
            printf("No\n");
            return 0;
        }
    }
    for (int i=a+1;i<len;i++){
        if (!(s[i]>='0'&&s[i]<='9')){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
n,m = map(int, input().split())
a = list(map(int, input().split()))
acc = [0] + list(accumulate(a))
mod = {}
for i in acc:
    d = i%m
    if d not in mod:
        mod[d] = 0
    mod[d] += 1
cnt = 0
for v in mod.values():
    if v:
        cnt += v * (v-1) // 2
print(cnt)


Measured memory_bytes: 63768
#include<bits/stdc++.h>
#include<unistd.h>
#include<iostream>
#include<utility>

using namespace std;

#define REP(i,m) for(int i=0;i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> pp;
ll mod =1000000007;

int c[10000000];
int d[10000000];
int main()
{
    int x,n;
    cin>>x>>n;
    for(int i =0;i<n;i++){
        int a;
        cin>>a;
        c[a] = 1;
    }

    for(int i =0;i<100;i++){
        //check -1 then +1
        if(!c[x-i]){
            cout<<x-i<<endl;
            return 0;
        }
        else if(!c[x+i]){
            cout<<x+i<<endl;
            return 0;
        }
    }


}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int h,a;
    int ans;
    cin >> h >> a;
    ans = h / a;
    if( h % a ){
        ans++;
    }
    cout << ans << "\n";
    return 0;
}


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

int main()
{
    int a, b, MAX = -1003;
    cin >> a >> b;
    MAX = max(MAX, a + b);
    MAX = max(MAX, a - b);
    MAX = max(MAX, a*b);

    cout << MAX << endl;
    return 0;
}


Measured memory_bytes: 256
//
//  sum_gcd.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main(int argc, const char* argv[]) {
  int n;
  std::cin >> n;

  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        cnt += gcd(gcd(i+1, j+1), k+1);
      }
    }
  }
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 3632
import numpy

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

List=list(map(int,input().split()))
EList = []

for i in range(len(List)):
  a = List[i]
  b = (a+1)/2
  EList.append(b)
  

res = numpy.cumsum(EList)
res = numpy.insert(res,0,0)
ans = 0
for i in range(len(List)+1):
  if i < K-1:
    ans = 0
  else:
    ans = float(max(res[i] - res[i-K],ans))

print(float(ans))

Measured memory_bytes: 34004
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
using System.Numerics;

class MainClass
{
    static void Main()
    {
        var r = ReadLine().Split();
        BigInteger a = BigInteger.Parse(r[0]);
        BigInteger b = BigInteger.Parse(r[1].Remove(r[1].Length-3,1));
        WriteLine(a*b/100);
    }
}


Measured memory_bytes: 27808
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n, m, ans = 0;
    int all[10001];
    cin >> n;
    rep(i, n){
        cin >> all[i];
    }
    cin >> m;
    rep(i, m){
        int j = 0, inp;
        cin >> inp;
        all[n] = inp;
        while(all[j] != inp){
            j++;
        }
        if(j != n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int x,y,W;

void move_grid(){
    if(y%2==0){
        if(x+1<W){
            // 右に進む
            x++;
        }else{
            // 下に進む
            y++;
        }
    }else{
        if(x-1>=0){
            // 左に進む
            x--;
        }else{
            // 下に進む
            y++;
        }
    }
}

int main(){
    int H;
    cin >> H >> W;
    vector<vector<int>> G(H,vector<int>(W));
    rep(i,H)rep(j,W){
        cin >> G[i][j];
    }
    ll cnt = 0;
    x=0;
    y=0;
    ll ans = 0;
    vector<pair<int,int>> mv[2];
    while(true){
        cnt++;
        if(cnt==H*W) break;
        if(G[y][x]%2==1){
            ans++;
            mv[0].push_back(make_pair(y+1,x+1));
            move_grid();
            mv[1].push_back(make_pair(y+1,x+1));
            G[y][x]++;
        }else{
            move_grid();
        }
    }
    cout << ans << endl;
    rep(i,ans){
        cout << mv[0][i].first << " " << mv[0][i].second << " ";
        cout << mv[1][i].first << " " << mv[1][i].second << endl;;
    }
    return 0;
}

Measured memory_bytes: 6424