akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException{
		Traveling solver = new Traveling();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}


	static class Traveling {

		private int n;

		private int t[];
		private int x[];
		private int y[];

		private Scanner scanner;
		private String output;

		public Traveling() {
			scanner = new Scanner(System.in);
		}
		public void readInput() {
			n = Integer.parseInt(scanner.next());

			t = new int[n];
			x = new int[n];
			y = new int[n];

			for(int i=0; i<n; i++) {
				t[i] = Integer.parseInt(scanner.next());
				x[i] = Integer.parseInt(scanner.next());
				y[i] = Integer.parseInt(scanner.next());
			}
			return;
		}

		public void solve() {
			for(int i=0; i<n; i++) {
				if(t[i] < (x[i]+y[i]) || ((t[i]%2) != (x[i]+y[i])%2)) {
					output = "No";
					return ;
				}
			}
			output = "Yes";
			return;
		}

		public void writeOutput() {
			System.out.println(output);
			return;
		}


	}
}


Measured memory_bytes: 62000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)

int main(){
    int n,m;
    cin>>n>>m;

    vector<vector<int>> graph(n,vector<int>(n,0));
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        graph.at(a-1).at(b-1)=1;
        graph.at(b-1).at(a-1)=1;
    }

    vector<int> perm(n-1);
    iota(perm.begin(),perm.end(),1);
    
    int path=0;
    do{
        int index=0,now_node=0;
        while(index<n-1){
            int next_node=perm.at(index);
            if(!graph.at(now_node).at(next_node)) break;
            index++;
            if(index>=n-1) path++;
            now_node=next_node;
        }
    }while(next_permutation(perm.begin(),perm.end()));

    cout<<path<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
    unsigned int N, K;
    cin >> N >> K;
    
    unsigned int ans = K;
    for (int i = 0; i < N-1; i++) {
        ans *= K - 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N , K = map(int, input().split())
S = list(input())
gap=0
for i in range(N-1):
    if(S[i]!=S[i+1]):
        gap+=1

P=len(S)-1-gap
if(gap==0):
    print(P)
    exit()

for i in range(K):
    if(gap>1):
        P+=2
    else:
        P+=1
        break
    gap-=2
    if(gap==0):
        break

print(P)

Measured memory_bytes: 4084
#include<string.h>
#include<iostream>

// std::をしなくてよくなる?
using namespace std;

//question
// A: Kind of Refrigerator (0<= i <= A)
// B: Kind of Microwave    (0<= j <= B)
// M: Kind of Coupon
// Condition:  If you buy Xi + Yi at the same time, You can get cheaper Ci yen.

int main(void)
{
  int A, B, M;
  cin >> A >> B >> M;
  int a[A];
  int b[B];
  int m[M][3];
  int min_a=-1;
  int min_b=-1;
  int ans[M];
  for(int i=0; i<A; i++)
	{
	  cin >> a[i];
	  if(a[i] < min_a || min_a == -1) min_a = a[i];
	  
	}

  for(int i=0; i<B; i++)
	{
	  cin >> b[i];
	  if(b[i] < min_b || min_b == -1) min_b = b[i];
	}
  
  int min = min_a + min_b;
  for(int i=0; i<M; i++)
	{
	cin >> m[i][0] >> m[i][1] >> m[i][2];
	ans[i] = a[m[i][0]-1]+b[m[i][1]-1]-m[i][2];
	}



  for(int i=0; i<M; i++){
	if(ans[i] < min) min = ans[i];
  }
  cout << min << endl;	

  
  return 0;
}


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

int n, l[2020];

int main(){
  cin >> n;
  rep(i, n) cin >> l[i];
  sort(l, l + n);
  int sum = 0;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      int a = min(l[i], l[j]), b = l[i] + l[j] - a;
      auto sentou = l + j + 1;
      auto ub = upper_bound(sentou, l + n, a + b - 1);
      int num = ub - sentou;
      //cerr << a << " " << b << " " << *ub << " " << num << endl;
      sum += num;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
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 long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    ll N,sum=0;
    cin >> N;
    vector<ll> data(N+1);
    rep(i,N+1){
        cin >> data.at(i);
    }
    vector<ll> ushiro(N+1);
    vector<ll> mae(N+1);
    if(N==0 && data.at(0)!=1){
        cout << -1 << endl;
        return 0;
    }
    if(N==0 && data.at(0)==1){
        cout << 1 << endl;
        return 0;
    }
    if(N!=0 && data.at(0)==1){
        cout << -1 << endl;
        return 0;
    }
    for(ll i=N; i>=0; i--){
        if(i==N){
            ushiro.at(i)=data.at(N);
            continue;
        }
        ushiro.at(i)=ushiro.at(i+1)+data.at(i);
    }
    for(ll i=0; i<=N; i++){
        if(i==0){
            mae.at(i)=1;
            sum++;
            continue;
        }
        mae.at(i)=min((mae.at(i-1))*2,ushiro.at(i));
        sum+=mae.at(i);
        mae.at(i)-=data.at(i);
        if(mae.at(i)<0){
            cout << -1 << endl;
            return 0;
        }
    }

    
    cout << sum << endl;
}

Measured memory_bytes: 5640
import copy

s = list(input())

s2 = s.copy()

cnt1 = 0
cnt2 = 0

for i in range(len(s)):
	if i % 2 == 0:
		#print("even, i, s[i]", i, s[i])
		if s[i] != "0":
			s[i] = "0"
			cnt1 += 1
			#print("s[i] != 0")
	else:
		#print("odd, i, s[i]", i, s[i])
		if s[i] != "1":
			s[i] = "1"
			cnt1 += 1
			#print("s[i] != 1")
	#print("cnt1", cnt1)



for i in range(len(s)):
	if i % 2 == 0:
		#print("even, i, s[i]", i, s[i])
		if s2[i] != "1":
			s2[i] = "1"
			cnt2 += 1
	else:
		#print("odd, i, s[i]", i, s[i])
		if s2[i] != "0":
			s2[i] = "0"
			cnt2 += 1
	#print("cnt2", cnt2)


print(min(cnt1, cnt2))

Measured memory_bytes: 5160
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    string S;
    cin >> S;
    ll win = 0;
    for (char c : S) {
        if (c == 'o') {
            win++;
        }
    }
    win += 15 - S.size();

    cout << (win >= 8 ? "YES" : "NO") << endl;
}

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

using namespace std;

int main(){
    char s[100001];
    scanf("%s",s);
    int a,b,c=0,d=0,t;
    t=strlen(s);
    a=s[0]=='B'?0+'B':0+'W';
    b=s[t-1]=='B'?0+'B':0+'W';
    for (int i=0;i<t;i++) {
        if (0+s[i]!=a) {
            c++;
            a=0+s[i];
        }
        if (0+s[-1*i-1]!=b) {
            d++;
            b=0+s[-1*i-1];
        }
    }
    printf("%d\n",c);
    return 0;
}


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

int main() {
  int N,X,D;
  int maxD = 0;
  cin >> N >> X;
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  
  vector<int> dist(N);
  
  int mindt = 1000000000;
  
  for (int i = 0; i < N; i++) {
    dist.at(i) = max(X,x.at(i)) - min(X,x.at(i));
    if (mindt > dist.at(i))
      mindt = dist.at(i);
  }
  D = mindt;
  
  while (maxD == 0) {
    for (int i = 0; i < N; i++) {
      if (dist.at(i) % D != 0) 
        break;
      if (i == N - 1)
        maxD = D;
    }
    D--;
  }
  
  cout << maxD << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int N,M;
	int x,y;
	int i,j;
	int tower;
	bool flag;
	int answer=0;
	int counter=0;
	ll tmp;
	vector<ll> H;
	vector<ll> maxH;

	cin >> N >> M;
	maxH.resize(N);

	for(i=0;i<N;i++){
		cin >> tmp;
		H.emplace_back(tmp);
	}

	for(i=0;i<M;i++){
		cin >> x;
		cin >> y;

		maxH[x-1]=max(maxH[x-1],H[y-1]);
		maxH[y-1]=max(maxH[y-1],H[x-1]);
	}

	for(i=0;i<N;i++)
		if(H[i]>maxH[i]) counter++;

	answer=counter;
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 5048
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
using ld = long double;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
#define pi (long double) 3.141592653589793238462643383279;
#pragma endregion

#define INF (lint)10000000000000000;
#define mod (int)1000000007



int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int h, w; cin >> h >> w;
	vector<vector<char>> d(h + 2, vector<char>(w + 2, '#'));
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			cin >> d[i][j];
	int ans = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			for (int k = 1; k <= h; k++) {
				for (int l = 1; l <= w; l++) {
					vector<vector<int>> a(h + 2, vector<int>(w + 2, -1));
					queue<pair<int, int>> q;
					if (d[i][j] == '#' || d[k][l] == '#') continue;
					q.push({ i,j });
					a[i][j] = 0;
					while (!q.empty()) {
						auto s = q.front();
						q.pop();
						for (int f = 0; f < 4; f++) {
							if (d[s.first + dy[f]][s.second + dx[f]] == '#') continue;
							if (a[s.first + dy[f]][s.second + dx[f]] != -1) continue;
							a[s.first + dy[f]][s.second + dx[f]] = a[s.first][s.second] + 1;
							q.push({ s.first + dy[f],s.second + dx[f] });
						}
					}
					ans = max(ans, a[k][l]);
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first 
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
// ミント
const int mod = 1e9+7 ;
  //998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n,int k){
    return fact[n]*ifact[n-k] ;
  }
  }  c(200000);
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }
 


int main(){
   ll n ; cin>>n ;
   vector<ll> A(n),B(n) ;
   rep(i,n){
     ll a,b ; cin>>a>>b ;
     A[i]=a+b ;
     B[i]=a-b ;
   }
   sort(A.begin(),A.end()) ;
   sort(B.begin(),B.end()) ;
   cout<< max( A[n-1]-A[0],B[n-1]-B[0]) <<endl ;
     return 0;
  }
   



Measured memory_bytes: 9608
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
    cin >> x >> y;
    if(x<y){
        cout << x << endl;
    }else if(x%y==0){
        cout << -1 << endl;
    }else{
        cout << x << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

S = list(input())
min_num = pow(10, 3)
tmp = 0
array = []

for i in range(len(S) - 2):
    array = S[i : i + 3]
    tmp = int(''.join(array))
    if min_num > abs(tmp - 753):
        min_num = abs(tmp - 753)
print(min_num)


Measured memory_bytes: 2940
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			boolean mark[] = new boolean[9];
			
			Map<Integer, Integer> numMap = new HashMap<>();
			
			for(int i = 0 ; i < 9 ; i++ ) {
				numMap.put(sc.nextInt(), i);
			}
			
			int n = sc.nextInt();
			
			for(int i = 0 ; i < n ; i++ ) {
				int b = sc.nextInt();
				if ( numMap.containsKey(b) ) {
					int index = numMap.get(b);
					mark[index] = true;
				}
			}
			
			//check
			// 0 1 2
			// 3 4 5
			// 6 7 8
			boolean bingo = false;
			for(int i = 0 ; i < 3 ; i++ ) {
				if ( mark[i*3] && mark[i*3+1] && mark[i*3+2]) {
					bingo = true;
					break;
				}
				if ( mark[i] && mark[i+3] && mark[i+6]) {
					bingo = true;
					break;
				}
			}
			if ( mark[0] && mark[4] && mark[8] ||
					mark[2] && mark[4] && mark[6] ) {
				bingo = true;
			}
			
			System.out.println(bingo ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 23124
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{

    static int n;
    static int c;
    static int k;
    static int lef;
    static int rig;
    static String s;
    static String anss;
    static int[] times;
    static int m;
    static long ans;
    static int[] w;
    static int[] ww;
    static boolean[] visit;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        n = sc.nextInt();
        s = sc.next();

        anss = makekakko(s);

        System.out.println(anss);
        sc.close();
    }

    public static String makekakko(String s) {
        String ansss = s;
        int minn = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == ')' ){
                c--;
            }else{
                c++;
            }
            minn = Math.min(minn, c);
        }

        minn *= -1;

        for (int i = 0; i < minn; i++) {
            ansss = "("+ansss;
        }
        for (int i = 0; i < c+minn; i++) {
            ansss = ansss+")";
        }

        return ansss;
    }

    public static long gcd(long a, long b) {
        
        if (a < b) {
            long tmpp = a;
            a = b;
            b = tmpp;
        }
        if (b == 0) {
            return a;
        }else{
            return gcd(b, a%b);
        }
    }

    public static long lcm(long a, long b) {
        long gcd = gcd(a,b);
        return a/gcd*b;
    }

    public static void dfs(int placenow) {
        // if went all -> success! 
        // if not went all -> fail...
        
        /*
         dfs
         Go All Place that there is way to and not having been yet. 

         if island 1 is start point, dfs(1);
         if there is way to island 2 and island 3,
         - island 2 changes non-visited -> visited, and dfs(2).
         - island 3 changes non-visited -> visited, and dfs(3).
         

        */

        visit[placenow] = true;
        boolean success = true;
        for (int i = 0; i < n; i++) {
            if (visit[i] == false) { // not go all place
                success = false;
                break;
            }
        }
        if (success) {
            ans++;
            visit[placenow] = false;
            return;
        }

        for (int i = 0; i < m; i++) {
            if (w[i] == placenow && visit[ww[i]] == false ) {
                dfs(ww[i]);
            }else if(ww[i] == placenow && visit[w[i]] == false){
                dfs(w[i]);
            }else{
                continue;
            }
        }
        visit[placenow] = false;
        return;
    }

}



Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>>n;
    vi x(n);
    cin>>x;
    vi y(x);
    sort(all(y));
    cerr<<y<<endl;
    REP(i,n){
        int it=lower_bound(all(y), x[i]) - y.begin();
        if(it<=(n-1)/2)cout<<y[(n-1)/2+1]<<endl;
        else cout<<y[(n-1)/2]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

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

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            // Nは使用しないので読み込むだけ
            br.readLine();

            List<String> housePlaceStringList = Arrays.asList(br.readLine().split(" "));
            List<Integer> housePlaceList = new ArrayList<>();
            for (String str : housePlaceStringList) {
                housePlaceList.add(Integer.parseInt(str));
            }

            sortNatualOrder(housePlaceList);

            int ans = 0;
            ans = housePlaceList.get(housePlaceList.size() - 1) - housePlaceList.get(0);
            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    private static void sortNatualOrder(List<Integer> intList) {
        for (int i = 0; i < intList.size() - 1; i++) {
            for (int j = intList.size() - 1; j > i; j--) {
                if (intList.get(j - 1) > intList.get(j)) {
                    int tmp = intList.get(j - 1);
                    intList.set(j - 1, intList.get(j));
                    intList.set(j, tmp);
                }
            }
        }
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
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 INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N,T;
    cin>>N>>T;
    vector<ll> A(N),B(N,0);
    rep(i,N)cin>>A[i];
    //B[i]: iで売るとき、あげられる利益
    ll minn = INFLL;
    ll maxx = 0;
    for(int i = 0; i < N; i++){
        B[i] = A[i] - minn;
        chmax(maxx, B[i]);
        chmin(minn, A[i]);
    }
    int cnt = 0;
    rep(i,N){
        if(B[i] == maxx)cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

vector<int> P, Q, S;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int p;
        cin >> p;
        P.push_back(p);
    }
    for(int i = 1; i <= N; i++){
        int q;
        cin >> q;
        Q.push_back(q);
        S.push_back(i);
    }
    int a = 0, b = 0;
    int cnt = 0;
    do{
        bool flag = true;
        for(int i = 0; i < N; i++){
            if(S[i] != P[i]) flag = false;
        }
        if(flag) a = cnt;
        
        flag = true;
        for(int i = 0; i < N; i++){
            if(S[i] != Q[i]) flag = false;
        }
        if(flag) b = cnt;
        cnt++;
    }while(next_permutation(S.begin(), S.end()));
    cout << abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;
using P = pair<int, int>;

void chmax(int &a, int b) {
    if(a < b) a = b;
}

int main(){
    int h, w, m; cin >> h >> w >> m;
    map<int, int> bh, bw;
    vector<int> bhmax, bwmax;
    int hmax = 0, wmax = 0;
    set<P> s;
    rep(i, m) {
        int hi, wi; cin >> hi >> wi;
        s.insert({hi, wi});
    }

    for(auto si : s) {
        chmax(hmax, ++bh[si.first]);
        chmax(wmax, ++bw[si.second]);
    }

    for(auto tmp : bh) {
        if(tmp.second == hmax) bhmax.push_back(tmp.first);
    }
    for(auto tmp : bw) {
        if(tmp.second == wmax) bwmax.push_back(tmp.first);
    }

    int ans = hmax + wmax - 1;
    for(int bi : bhmax) {
        for(int bj : bwmax) {
            if(s.find({bi, bj}) == s.end()) {
                ans++;
                goto PRINT;
            }
        }
    }
    PRINT:
    cout << ans << endl;

    return 0;
}

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

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

    int n,k;
    cin >> n >> k ;

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

    vector<int> ans(n);

    while(k--){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(arr[a] > arr[b]){
            ans[b]=-1;
        } else if (arr[a] < arr[b]){
            ans[a]=-1;
        } else {
            ans[a]=-1;
            ans[b]=-1;
        }
    }

    int answer=0;
    for(int i=0; i<n; i++){
        if(ans[i]==1 || ans[i]==0){
            answer++;
        }
    }
    cout << answer << endl;
    return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void){
    int n;
    cin>>n;
    vector<pair<ll,ll>> p(n);
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        p[i]=make_pair(b,a);
    }
    sort(p.begin(),p.end());
    bool ok=true;
    ll time=0;
    rep(i,0,n){
        if(time+p[i].second<=p[i].first){
            time+=p[i].second;
        }else {ok=false; break;}
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;

}

Measured memory_bytes: 3328
#include <stdio.h>

long abs(long a){
  if(a > 0){
    return a;
  }
  return -a;
}

int main(void){
  int N,T,A;
  long H,min;
  int ans;
  scanf("%d%d%d",&N,&T,&A);
  T *= 1000;
  A *= 1000;

  for(int i = 0;i < N;i++){
    scanf("%ld",&H);
    if(i == 0){
      min = abs(A-T+H*6);
      ans = 1;
    }else if(min > abs(A-T+H*6)){
      min = abs(A-T+H*6);
      ans = i+1;
    }
  }

  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc ll t;cin>>t;while(t--)
#define otc ll t=1;while(t--)
#define PI 3.141592653589793238
//ang=(PI*ang)/180.0 in radian
#define ll long long int
#define ld long double
#define pb push_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
ll n, w;
ll dp[105][100005];
ll knapsack(ll pos, ll cap, ll ar[][2])
{
	if (pos >= n || cap <= 0)
		return 0;

	if (dp[pos][cap] != -1)
		return dp[pos][cap];

	if (ar[pos][0] > cap)
		dp[pos][cap] = knapsack(pos + 1, cap, ar);
	else
		dp[pos][cap] = max((ar[pos][1] + knapsack(pos + 1, cap - ar[pos][0], ar)), knapsack(pos + 1, cap, ar));

	return dp[pos][cap];
}
void solve()
{
	cin >> n >> w;
	ll ar[n][2];
	for (ll i = 0; i < n; i++)
		cin >> ar[i][0] >> ar[i][1];

	memset(dp, -1, sizeof(dp));

	cout << knapsack(0, w, ar) << endl;
}
int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fio
	otc
	{*/
		solve();
	//}
	return 0;
}

Measured memory_bytes: 82304
let i=readLine()!.characters.split(" ").map{Int(String($0))!},N=i[0],P=i[1],odd=readLine()!.characters.split(" ").filter{Int(String($0))!%2>0}.count
print(odd>0 ?2<<(N-2):P>0 ?0:2<<(N-1))

Measured memory_bytes: 1024
import heapq

class Pair:
    def __init__(self, num=None, wei=None):
        self.num = num
        self.wei = wei # weight
    def __str__(self):
        return str(self.num) + ' ' + str(self.wei)

def createAdjList():
    adjList = []
    for i in range(n):
        innerList = []
        u, k, *v = map(int, input().split())
        for j in range(0, k*2, 2):
            # [weight, num] (not [num, weigt])
            # Comparison of lists in Python is lexicographical -  the first non-equal pair determines the winner of the ordering
            newPair = [v[j+1],v[j]]
            innerList.append(newPair)
        adjList.append(innerList)
    return adjList

#TODO: write dijkstra
def dijkstra():
    d[0] = 0
    pq = []
    pq.append([0,0])
    heapq.heapify(pq)

    while len(pq) > 0:
        # cost が最小の node を選択
        uWei, uNum  = heapq.heappop(pq)

        status[uNum] = VISITED

        # uWei が最小コストでない場合は無視 (wight 更新前に push された、最短ではないルート)
        if d[uNum] < uWei:
            continue

        # u と v をつなぐ edge のうち最小の経路のコストの合計に更新
        for v in adjList[uNum]:
            vNum = v[1]
            vWei = v[0]
            if status[vNum] != VISITED and d[uNum] + vWei < d[vNum]:
                d[vNum] = d[uNum] + vWei
                status[vNum] = VISITING
                heapq.heappush(pq, [d[vNum], vNum])

import sys
# sys.stdin = open('input.txt')

n = int(input())
NOT_VISITED = 0 # WHITE
VISITING = 1 # GRAY
VISITED = 2 # BLACK
INFTY = 10**21

status = [NOT_VISITED] * n
d = [INFTY] * n
p = [-1] * n

adjList = createAdjList()
dijkstra()
for i in range(n):
    print(i, d[i])


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

int main(){
  int A,B;
  cin >> A >> B;
  if (B>A){
    int r=A;
    A=B;
    B=r;
  }
  if (A>B){
    cout << 2*A-1 << endl;
  } else if(A==B){
    cout << 2*A << endl;
  }
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	int x, t;
	cin >> x >> t;
	cout << (max(0, x - t)) << endl;
}


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

int a, b, acards[5001], bcards[5001], mx = 0, mxcards[5001], dp[5001];

int main()
{
	cin >> a >> b;
	for (int i = 1; i <= a; i++) cin >> acards[i];
	for (int i = 1; i <= b; i++) cin >> bcards[i];

	for (int i = 1; i <= a; i++){
		for (int j = 1; j <= b; j++){
			if (acards[i] == bcards[j]){
				dp[j] = mxcards[j - 1] + 1;
				mx = max(mx, dp[j]);
			}
		}
		for (int j = 1; j <= b; j++){
			mxcards[j] = max(mxcards[j], dp[j]);
		}
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

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

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;

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

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

	if (a <= c && c <= b) Yes;
	else No;

	return 0;
	
}

Measured memory_bytes: 256
n, k = map(int, input().split())
h = list(map(int, input().split()))

INF = float('inf')
dp = [INF] * (n + k + 10)

dp[0] = 0
for i in range(n-1):
    for j in range(1, k+1):
        if i + j >= n:
            break
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[n-1])

Measured memory_bytes: 55008
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	int a,b,t;
	cin >> a >> b >> t;
	cout << t/a*b << endl;
	return 0;
}

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

int N, M, temp;
int i=0,ans=0;
pair<int,int> PD[10010];

int main() {
  while (cin >> N >> M && N) {
    int d, p;
    for (int j=0; j<N; ++j) {
      cin >> d >> p;
      PD[j] = make_pair(p, d);
    }
    sort(PD,PD+N);
    reverse(PD,PD+N);
    while(i<N){
      temp=M;
      M-=PD[i].second;
      if(M<0){
        PD[i].second-=temp;
        break;
      }
      else{
        PD[i].second=0;
        i++;
      }
    }
    for(int k=0;k<N;k++){
      ans+=PD[k].first*PD[k].second;
    }
    cout << ans << endl;
    ans=0;
    i=0;
  }
}



Measured memory_bytes: 3108
#include <iostream>
#define N 100010
using namespace std;

int arr[N];
long long dp_table[N];
int find_min(int idx,int n)
{
    if(idx==n){
        return 0;
    }
    if(dp_table[idx]!=-1){
        return dp_table[idx];
    }
    int s1,s2;
    if(idx+2<=n-1){
        s1=abs(arr[idx+1]-arr[idx])+find_min(idx+1,n);
        s2=abs(arr[idx+2]-arr[idx])+find_min(idx+2,n);
        dp_table[idx]=min(s1,s2);
    }
    else{
        s1=abs(arr[idx+1]-arr[idx])+find_min(idx+1,n);
        dp_table[idx]=s1;
    }
    return dp_table[idx];
}
int main()
{
    int n,i,j,s1,s2;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        dp_table[i]=-1;
    }
    dp_table[n-1]=0;
    if(n>=2){
        dp_table[n-2]=abs(arr[n-1]-arr[n-2]);
        for(j=n-3;j>=0;j--){
            s1=abs(arr[j]-arr[j+1]);
            s2=abs(arr[j]-arr[j+2]);
            dp_table[j]=(long long)(min(dp_table[j+1]+s1,dp_table[j+2]+s2));
        }
        cout<<dp_table[0];
    }
    else{
        cout<<dp_table[0];
    }
}


Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
	ll a = 2LL, b = 1LL;
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++)
	{
		swap(a,b);
		b += a;
	}
	cout << b << endl;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int x,a,b,c,ans=0;
  vector<int> n(3);
  rep(i,3) cin>>n[i];
  if(n[0]==n[1] && n[1]==n[2]){
    if(n[0]%2==0){
      cout<<-1<<endl;
      return 0;
    }else if(n[0]%2!=0){
      cout<<0<<endl;
      return 0;
    }
  }
  sort(n.begin(),n.end());
  
  x=n[2]-n[0];
  
  while(x%2==0){
    x/=2;
    if((n[0]+n[1])%2==0 && (n[0]+n[2])%2==0 && (n[1]+n[2])%2==0){
      a=(n[0]+n[1])/2;
      b=(n[0]+n[2])/2;
      c=(n[1]+n[2])/2;
      n[0]=a;
      n[1]=b;
      n[2]=c;
      ans++;
    }else{
      cout<<ans<<endl;
      return 0;
    }    
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int k = b / a < c ? b/a : c;
    cout << k << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  rep(i,s.size()){
    cout << s[i];
    if(i==t.size()) break;
    cout << t[i];
  }
  cout << endl;
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;
#define MOD 1000000007

bool allPos(ll a[], int n) {
	for (int i = 0; i < n; i++)
		if (a[i] < 0)
			return false;

	return true;
}

bool allNeg(ll a[], int n) {
	for (int i = 0; i < n; i++)
		if (a[i] > 0)
			return false;

	return true;
}

int main() {

	IOS

	int n, k;
	cin >> n >> k;

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

	sort(a, a+n);

	// for (int i = 0; i < n; i++)
	// 	cout << a[i] << endl;
	// cout << endl;

	ll prod = 1;

	if (k == n) {
		for (int i = 0; i < n; i++)
			prod = (prod * a[i]) % MOD;

	} else if (allPos(a, n)) {
		for (int i = 0; i < k; i++)
			prod = (prod * a[n-1-i]) % MOD;

	} else if (allNeg(a, n)) {
		if (k%2 == 1) {
			for (int i = 0; i < k; i++)
				prod = (prod * a[n-1-i]) % MOD;

		} else {
			for (int i = 0; i < k; i++)
				prod = (prod * a[i]) % MOD;
		}

	} else {

		int l = 0, r = n-1;

		if (k%2 == 1) {
			prod = (a[r]) % MOD;
			r--;
			k--;
		}

		while (k > 0) {
			if (a[l]*a[l+1] > a[r]*a[r-1]) {
				prod = (((prod * a[l]) % MOD) * a[l+1]) % MOD;
				l += 2;

			} else {
				prod = (((prod * a[r]) % MOD) * a[r-1]) % MOD;
				r -= 2;
			}

			k -= 2;
		}
	}

	// deb(prod);
	cout << (prod < 0 ? prod + MOD : prod) << endl;

	return 0;
}

Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std; 
#define m 1000000007
int main()
{
    long long int h,w;
    cin>>h>>w;
    long long int dp[h][w];
    char a[h][w];
    for(long long int i=0;i<h;i++)
    {
          for(long long int j=0;j<w;j++)
        {
          cin>>a[i][j];
        }  
    }
    for(long long int i=0;i<h;i++)
    {
          for(long long int j=0;j<w;j++)
        {
          
         if(a[i][j]=='.')
          dp[i][j]=1;
         else
           dp[i][j]=0;
        }  
    }
     for(long long int i=1;i<w;i++)
    {
       if(dp[0][i-1]==0)
       dp[0][i]=0;
    }
    for(long long int i=1;i<h;i++)
    {
       if(dp[i-1][0]==0)
       dp[i][0]=0;
    }
    for(long long int i=1;i<h;i++)
    {
        for(long long int j=1;j<w;j++)
        {
            if(dp[i][j]!=0)
            {
                dp[i][j]=((dp[i][j-1]%m)+(dp[i-1][j]%m))%m;
            }
        }
    }
    cout<<(dp[h-1][w-1])%m;
}

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

unsigned long long ans = 1e18, a, b, n;

int main() {
	cin>>n>>a>>b;
	if((b - a)%2 == 0) ans = (b - a)/2;
	else {
		ans = min(ans, a + (b - a - 1)/2);
		ans = min(ans, n - b + 1 + (b - a - 1)/2);
	}
	cout<<ans<<endl;
} 

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 1e9 + 1
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

#define MAX_N 100
#define MAX_M 100

vector<ll> yakusu_a;
vector<ll> yakusu_b;

int main(){
    ll n;
    cin >> n;

    vector<ll> yakusu_a;
    vector<ll> yakusu_b;
    yakusu_a.push_back(n);
    yakusu_b.push_back(n-1);

    if(n==2) {
        cout << "1" << endl;
        return 0;
    }

    REPN(i, 2, sqrt(n)+1) {
        if(n % i == 0) {
            yakusu_a.push_back(i);
            if(i*i != n) yakusu_a.push_back(n/i);
        }
    }

    REPN(i, 2, sqrt(n-1)+1) {
        if((n-1) % i == 0) {
            yakusu_b.push_back(i);
            if(i*i != n-1) yakusu_b.push_back((n-1)/i);
        }        
    }

    ll ans = yakusu_b.size();
    
    REP(i, yakusu_a.size()) {
        ll tmp = n;
        while(1) {
            if(tmp % yakusu_a[i] == 0) tmp = tmp / yakusu_a[i];
            else break;
        }
        if(tmp % yakusu_a[i] == 1) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

vector<vector<int>> G;
vector<int> val;
vector<bool> seen;

void dfs(int v, ll now){
    seen[v] = true;
    now += val[v];
    val[v] = now;
    
    for(auto next_v : G[v]){
        if(seen[next_v]) continue;
        
        dfs(next_v, now);
    }
}

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

    G.resize(N);
    for(int i = 1; i < N; i++){
        int a,b; cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    val.assign(N, 0);
    seen.assign(N, false);
    
    for(int i = 1; i <= Q; i++){
        int p,x; cin >> p >> x;
        p--;
        val[p] += x;
    }
    
    dfs(0, 0);
    
    for(int i = 0; i < N; i++){
        cout << val[i] << " ";
    }
    cout << "\n";
}


Measured memory_bytes: 23552
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >>e;
    if(a == 0){
        cout << 1 << endl;
    }
    if(b == 0){
        cout << 2 << endl;
    }
    if(c == 0){
        cout << 3 << endl;
    }
    if(d == 0){
        cout << 4 << endl;
    }
    if(e == 0){
        cout << 5 << endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e2 + 5;
const int maxK = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

int a[maxN];
ll dp[maxN][maxK], ps[maxN][maxK];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	memset(dp, 0, sizeof dp);
	memset(ps, 0, sizeof ps);
	for (int i = 0; i <= n; i++){
		dp[i][0] = 1;
		ps[i][0] = 1;
	}
	for (int i = 0; i <= k; i++){
		ps[0][i] = 1;
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= k; j++){
			dp[i][j] = (ps[i - 1][j] - (j >= a[i - 1] + 1 ? ps[i - 1][j - a[i - 1] - 1] : 0ll) + MOD) % MOD;
			ps[i][j] = ps[i][j - 1] + dp[i][j];
		}
	}
	cout << dp[n][k] << endl;
	return 0;
}



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

int main(void) {
	int a, number = 0, i;
	while(cin >> a) {
		if(a == 0) {
			break;
		}
			
		else {
		  number++;
		  cout << "Case " << number << ": " << a << endl;
		}
		
	}
	return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

#define MOD 1000000007LL

int main(){
  string S;
  cin >> S;
  int N = S.size();

  ll dp[4][N];
  if(S[0]=='A'){
    dp[0][0]=1;
    dp[1][0]=1;
  }else if(S[0]=='B'){
    dp[0][0]=1;
    dp[1][0]=0;
  }else if(S[0]=='C'){
    dp[0][0]=1;
    dp[1][0]=0;
  }else if(S[0]=='?'){
    dp[0][0]=3;
    dp[1][0]=1;
  }
  dp[2][0]=0;
  dp[3][0]=0;

  for(int j=1;j<N;j++){
    if(S[j]=='A'){
      dp[0][j] = dp[0][j-1];
      dp[1][j] = dp[1][j-1] + dp[0][j];
      dp[2][j] = dp[2][j-1];
      dp[3][j] = dp[3][j-1];
    }
    else if(S[j]=='B'){
      dp[0][j] = dp[0][j-1];
      dp[1][j] = dp[1][j-1];
      dp[2][j] = dp[1][j-1] + dp[2][j-1];
      dp[3][j] = dp[3][j-1];
    }
    else if(S[j]=='C'){
      dp[0][j] = dp[0][j-1];
      dp[1][j] = dp[1][j-1];
      dp[2][j] = dp[2][j-1];
      dp[3][j] = dp[2][j-1] + dp[3][j-1];
    }
    else if(S[j]=='?'){
      dp[0][j] = dp[0][j-1] * 3LL;
      dp[1][j] = dp[1][j-1] * 3LL + dp[0][j-1];
      dp[2][j] = dp[2][j-1] * 3LL + dp[1][j-1];
      dp[3][j] = dp[3][j-1] * 3LL + dp[2][j-1];
    }

    dp[0][j] %= MOD;
    dp[1][j] %= MOD;
    dp[2][j] %= MOD;
    dp[3][j] %= MOD;
  }

  cout << dp[3][N-1] << endl;
  return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    bool flg = true;
    int mn = INF;
    int mx = 0;
    REP(i,N) {
        mn = min(mn, A[i]);
        mx = max(mx, A[i]);
    }
    if(mx == mn) {
        if(mx == N-1) cout << "Yes" << endl;
        else{
            if(2 * mx > N) cout << "No" << endl;
            else cout << "Yes" << endl;
        }
        return 0;
    }
    if(mx - mn >= 2) flg = false;
    int unq = 0;
    REP(i,N) if(A[i] == mn) unq++;
    if(mx - unq <= 0 || N - unq <= 1 || N + unq < 2 * mx) flg = false;
    cout << (flg ? "Yes" : "No") << '\n';
    return 0;
}

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

bool is_prime(int base)
{
  for (auto n = 2; n < sqrtl(base) + 1; n++)
  {
    if (base % n == 0 && base != n)
    {
      return false;
    }
  }

  return true;
}

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

  auto candidates = vector<int>{};
  for (auto i = 0; i < n; i++)
  {
    int j;
    cin >> j;
    candidates.push_back(j);
  }

  auto prime_count = 0;
  for (auto i = 0; i < candidates.size(); i++)
  {
    auto n = candidates.at(i);

    if (is_prime(n))
    {
      prime_count++;
    }
  }

  cout << prime_count << endl;

  return 0;
}



Measured memory_bytes: 3228