akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)1e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
                                
int n, W, w[N], c[N];
ll dp[2][N];

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

inline void Solve () {
   cin >> n >> W;
   for (int i = 1; i <= n; i ++) cin >> w[i] >> c[i];
   for (int i = 0; i <= 1; i ++)
      for (int j = 0; j < N; j ++)
         dp[i][j] = inf;
   dp[0][0] = 0;
   for (int i = 1; i <= n; i ++) {
      bool ch = (i & 1);
      for (int j = 0; j < N; j ++) {
         dp[ch][j] = dp[(ch ^ 1)][j];
         if (j >= c[i]) 
            dp[ch][j] = min (dp[ch][j], dp[(ch ^ 1)][j - c[i]] + w[i]);
      }
   }
   int ans = 0;
   for (int i = 0; i < N; i ++)
      if (dp[(n & 1)][i] <= W)
         ans = i;
   cout << ans;
}

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

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

vector<int> Zalgorithm( string S, int N ){
    vector<int> Z(N);
    Z[0] = N;
    int i = 1, j = 0;
    while(i < N){
        while(i + j < N && S[j] == S[i + j]) j++;
        Z[i] = j;

        if(j == 0){
            i++;
            continue;
        }
        int k = 1;
        while(k < j && k + Z[k] < j){
            Z[i + k] = Z[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return Z;
}


int main (){
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int len = 0;
    int n = N;
    for ( int i = 0; i < N-1; ++i){
        //cout << S << endl;
        vector<int> Z;
        Z = Zalgorithm(S,n);
        
        for ( int i = 0; i < n; ++i){
            Z[i] = min(i,Z[i]);
        }
        int m = *max_element(Z.begin(),Z.end());
        len = max(len,m);
        //cout << max << endl;
        
        S.erase(0,1);
        --n;
    }
    
    cout << len << endl;
    return 0;
}



Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    final Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    LinkedHashMap<String, Integer> map = new LinkedHashMap<String, Integer>();
    for (int i = 0; i < N; ++i) {
      String S = sc.next();
      int T = sc.nextInt();
      map.put(S, T);
    }
    String X = sc.next();
    sc.close();

    String title = "";
    int loaded = 0;
    int sum = 0;
    for (Map.Entry<String, Integer> entry : map.entrySet()) {
      title = entry.getKey();
      sum += entry.getValue();
      if (title.equals(X)) {
        loaded = sum;
      }
    }

    System.out.println(sum - loaded);
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <unordered_map>
#include <list>
using namespace std;
#define pb push_back
#define fi first
#define se second
// using pii = pair<int, pair<int,int>>;
// using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x7fffffff;
const int N = 1e5 + 10;
int n;
int x;
map<int, int> mp;
int main()
{
    while (cin >> n) {
        mp.clear();
        for (int i = 0; i < n; i++) {
            cin >> x;
            mp[x]++;
        }
        int res = 0;
        for (auto p : mp) {
            int tim = p.second;
            int v = p.first;
            if (tim < v) res += tim;
            else res += tim - v;
        }
        cout << res << endl;
    }
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int H, W, K;
    cin >> H >> W >> K;

    int mp[500][500];
    for(int i = 1; i <= H; ++i) {
        for(int j = 1; j <= W; ++j) {
            char c;
            cin >> c;
            if(c == '.') mp[i][j] = 0;
            else mp[i][j] = 1;
        }
    }

    int res = 0;
    for(int i = 0; i < (1 << H); ++i) {
        for(int j = 0; j < (1 << W); ++j) {
            int tmp[500][500];
            for(int k = 1; k <= H; ++k) {
                for(int l = 1; l <= W; ++l) {
                    tmp[k][l] = mp[k][l];
                }
            }

            for(int k = 0; k <= H; ++k) {
                if((i >> k) & 1) {
                    for(int l = 1; l <= W; ++l) {
                        tmp[k + 1][l] = 3;
                    }
                }
            }
            for(int k = 0; k <= W; ++k) {
                if((j >> k) & 1) {
                    for(int l = 1; l <= H; ++l) {
                        tmp[l][k + 1] = 3;
                    }
                }
            }
            int cnt = 0;
            for(int k = 1; k <= H; ++k) {
                for(int l = 1; l <= W; ++l) {
                    if(tmp[k][l] == 1) ++cnt;
                }
            }
            if(cnt == K) ++res;
        }
    }
    cout << res << endl;
    return 0;
}



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

int main() {
	int i, l;
	int x, y;
	while (1) {
		cin >> x >> y;
		if (x == 0)break;
		for (i = 0; i < x; i++) {
			for (l = 0; l < y; l++) {
				cout << '#';
			}
			cout <<  endl;
		}
		cout  << endl;
	}

}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
 
#define rep(i,N) for(int i=0;i<(int)N;i++)
bool joken(int a,int b,int c);
 
int main()
{
  int N;
  cin>>N;
  vector<int> L(N,0);
  int number=0;	//条件に合致する組み合わせの数
  
  rep(ni,N)
  {
    cin>>L[ni];
  }
  
  if(N<3)
  {
    cout<<0<<endl;
    return 0;
  }
  
  rep(ni,N-2)
  {
    for(int nj=ni+1;nj<N-1;nj++)
    {
      for(int nk=nj+1;nk<N;nk++)
      {
        if(joken(L[ni],L[nj],L[nk]))
             number++;
      }
    }
  }
  cout<<number<<endl;
  return 0;
}
 
bool joken(int a,int b,int c)
{
  if((a==b)||(b==c)||(c==a))
    return false;
  
  if(((a+b)>c)&&((b+c)>a)&&((c+a)>b))
    return true;
  else
    return false;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    Int N, A, B; cin >> N >> A >> B;
    Int ans = 2e18;
    if ((B - A) % 2 == 0) {
        ans = (B - A) / 2;
    } else {
        Int a, b, k;
        // 1
        k = A - 1 + 1;
        a = 1, b = B - k;
        ans = min(ans, k + (b - a) / 2);
        // N
        k = N - B + 1;
        a = A + k, b = N;
        ans = min(ans, k + (b - a) / 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		long sum[] = new long[n+1];
		for(int i=0;i<n;i++)sum[i+1] = sum[i] + a[i];
		HashMap<Long, Integer> hm = new HashMap<>();
		for(int i=0;i<n+1;i++) {
			hm.put(sum[i], hm.getOrDefault(sum[i], 0)+1);
		}
		
		long ans = 0;
		for(long key : hm.keySet()) {
			int num = hm.get(key);
			ans += (long)num * (num - 1) /2;
		}
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

#define BLACK 'b'
#define WHITE 'w'
#define SPACE '+'

using namespace std;


char isWin(string data[3]) {
  char temp;
  temp = data[0][0];
  if(temp != SPACE && data[1][1] == temp && data[2][2] == temp) return temp;
  temp = data[2][0];
  if(temp != SPACE && data[1][1] == temp && data[0][2] == temp) return temp;

  for(int i = 0; i < 3; i++) {
    temp = data[i][0];
    if(temp == SPACE) continue;
    bool flag = true;
    for(int j = 0; j < 3; j++) {
      if(data[i][j] != temp) {
	 flag = false;
	 break;
      }
    }
    if(flag) {
      return temp;
    }
  }

  for(int i = 0; i < 3; i++) {
    temp = data[0][i];
    if(temp == SPACE) continue;
    bool flag = true;
    for(int j = 0; j < 3; j++) {
      if(data[j][i] != temp) {
	 flag = false;
	 break;
      }
    }
    if(flag) {
      return temp;
    }
  }

  return SPACE;
}

int main() {
  while(1) {
    string data[3];
    getline(cin, data[0]);
    if(data[0] == "0") break;
    for(int i = 1; i < 3; i++) {
      getline(cin, data[i]);
    }

    char temp = isWin(data);
    if(temp == SPACE) {
      cout << "NA" << endl;
    } else {
      cout << temp << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int N;
  cin >>N;
  cout << (N+1)/2 << endl;
}


Measured memory_bytes: 256
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += - P[j][1]*P[j+1][0] + P[j+1][1] * P[j][0]
print(s*0.5)

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

long long N, M, a[100009][3], maxn = -(1LL << 60);
 
int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 3; j++) cin >> a[i][j];
	}
	for (int i = 0; i < 8; i++) {
		vector<long long>vec;
		for (int j = 1; j <= N; j++) {
			long long S = 0;
			for (int k = 0; k < 3; k++) { if ((i / (1 << k)) % 2 == 0) S += a[j][k]; else S -= a[j][k]; }
			vec.push_back(S);
		}
		sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end());
		long long ans = 0;
		for (int j = 0; j < M; j++) ans += vec[j];
		maxn = max(maxn, ans);
	}
	cout << maxn << endl;
	return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int x = 0;
    for (int i = a; i <= b; ++i)
    {
        if (c % i == 0)
            ++x;
    }
    cout << x << endl;
    return 0;
}



Measured memory_bytes: 3120
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (n, k) = InputLine.to_ia

  if n <= k then
    puts [n, k - n].min.to_s
  else # n > k
    m = n / k
    puts [n - m * k, (m + 1) * k - n].min.to_s
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int n, z, w;
int a[2000];
int memo[2001][2];

int solve(int c, int f, int x, int y) {
    if(c == n) return abs(x - y);
    if(memo[c][f] >= 0) return memo[c][f];
    int ret;
    if(f) {
        ret = INF;
        FOR(i, c, n) {
            ret = min(ret, solve(i + 1, 0, x, a[i]));
        }
    }
    else {
        ret = 0;
        FOR(i, c, n) {
            ret = max(ret, solve(i + 1, 1, a[i], y));
        }
    }
    return memo[c][f] = ret;
}

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

    cin >> n >> z >> w;
    rep(i, n) cin >> a[i];
    memset(memo, -1, sizeof(memo));
    if(n == 1) cout << abs(a[0] - w) << endl;
    else cout << solve(0, 0, z, w) << endl;
    return 0;
}

Measured memory_bytes: 384
N, Q = map(int, input().split())
char = input()
num_list = [0]
for i in range(1,N):
  if char[i-1:i+1] == 'AC':
    num_list.append(num_list[-1]+1)
  else:
    num_list.append(num_list[-1])

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

Measured memory_bytes: 6180
blue_dict = {}

N = int(input())
for _ in range(N):
    key = input()
    if key in blue_dict.keys():
        blue_dict[key] += 1
    else:
        blue_dict[key] = 1

M = int(input())
for _ in range(M):
    key = input()
    if key in blue_dict.keys():
        blue_dict[key] -= 1

print(max(0, max(blue_dict.values())))


Measured memory_bytes: 3060
import java.util.*;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
        make(scanner);
    }

    

    public static void make(Scanner cs) {
        int[] counting = new int[45];
        int n = cs.nextInt();
        counting[0] = counting[1] = 1;
        for (int i = 2; i <= n; ++i) {
            counting[i] = counting[i - 1] + counting[i - 2];
        }
        System.out.println(counting[n]);
    }

}


Measured memory_bytes: 26180
import random
import time

t1=time.time()
d=int(input())
c=input()
cl=[int(n) for n in c.split()]
sl=list()
for i in range(d):
    s=input()
    sl=sl+[int(n) for n in s.split()]
tl=[1]*d
sat=0
for i in range(d):
    sat+=sl[i*26+tl[i]-1]

def decr(tl,cl):
    dec=0
    for i in range(26):
        last=[a for a, x in enumerate(tl) if x==i+1]
        if last==list():
            dec+=(d*(d+1)/2)*cl[i]
        else:
            for v in range(len(last)):
                if v!=len(last)-1:    
                    dec+=cl[i]*(last[v+1]-last[v]-1)*(last[v+1]-last[v])/2
                else:
                    dec+=cl[i]*(d-last[v]-1)*(d-last[v])/2
            dec+=cl[i]*(last[0])*(last[0]+1)/2
    return(int(dec))

oldscore=sat
oldans=oldscore-decr(tl,cl)
oldtl=[int(x) for x in tl]
t2=time.time()
while t2-t1<1.8:
    da=random.randint(1,d)
    q=random.randint(1,26)
    cha=sl[(da-1)*26+q-1]-sl[(da-1)*26+tl[da-1]-1]
    tl[da-1]=q
    newscore=oldscore+cha
    newans=newscore-decr(tl,cl)
    if newans<oldans:
        tl=[int(x) for x in oldtl]
    else:
        oldans=newans
        oldtl=[int(x) for x in tl]
        oldscore=newscore
    t2=time.time()
for i in range(d):
    print(tl[i])
        


Measured memory_bytes: 86368
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] sides = new int[n];
		int maxp = 0;
		int sum = 0;
		String ans = "Yes";
		for( int i = 0; i < n; i++ ) {
			sides[i] = in.nextInt();
			maxp = Math.max(sides[i], maxp);
			sum += sides[i];
		}
		sum -= maxp;
		if(maxp>=sum) ans = "No";
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
package main

import (
        "fmt"
)

func solution(s string) string {
        var a [26]int
        for _, r := range s {
                if a[r-'a'] != 0 {
                        return "no"
                }
                a[r-'a']++
        }
        return "yes"
}

func main() {
        var s string
        fmt.Scan(&s)
        fmt.Println(solution(s))
}

Measured memory_bytes: 512
io = STDIN
n=io.gets.to_i
h=io.gets.split.map(&:to_i)
def calc(h)
  ix=h.find_index{|a|a>0}||0
  h=h[ix..-1].reverse
  ix=h.find_index{|a|a>0}||0
  h=h[ix..-1].reverse
  size=0
  h.chunk do |i|
    i>0
  end.each do |plus,ar|
    next unless plus
    min=ar.min
    size+=min
    ar.map!{|n|n-min}
    size+=calc(ar)
  end
  size
end
puts calc(h)


Measured memory_bytes: 2428
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
	int ans = 0;
	string s;
	cin >> s;
	for (int i = 0; i <= s.length(); i++) {
		if (s[i] == '+')ans++;
		else if (s[i] == '-')ans--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000

vector<int>prim;

void prim_make(int k){
	if (k >= 2)prim.push_back(2);
	if (k >= 3)prim.push_back(3);
	if (k >= 5)prim.push_back(5);
	int x = 7;
	bool v;
	while (x <= k){
		v = true;
		for (int i = 2; prim[i] * prim[i] <= x; i++){
			if (x%prim[i] == 0){
				v = false;
				break;
			}
		}
		if (v)prim.push_back(x);
		if (x % 6 == 1)x += 4;
		else x += 2;
	}
	return;
}


long long kai[N];
long long rkai[N];
long long xx[30];
int yy[30];

void kaiz(void){
	kai[0] = 1;
	f(i, N - 1){
		kai[i + 1] = kai[i] * (i + 1);
		kai[i + 1] = kai[i + 1] % MOD;
	}
	int x = MOD - 2;
	f(i, 30){
		if (x % 2 == 1)yy[i] = 1;
		else yy[i] = 0;
		x = x / 2;
	}
	f(i, N){
		xx[0] = kai[i];
		f(j, 29){
			xx[j + 1] = xx[j] * xx[j];
			xx[j + 1] = xx[j + 1] % MOD;
		}
		rkai[i] = 1;
		f(j, 30){
			if (yy[j] == 1){
				rkai[i] = rkai[i] * xx[j];
				rkai[i] = rkai[i] % MOD;
			}
		}
	}
}

long long ni(int x, int y){
	if (x < 0 || y<0 || y>x)return 0;
	long long re = kai[x];
	re = re*rkai[x - y];
	re = re%MOD;
	re = re*rkai[y];
	re = re%MOD;
	return re;
}




int main(){
	vector<int>a;
	int n, m, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	prim_make(40000);
	kaiz();
	ans = 1;
	scanf("%d %d", &n, &m);
	f(i, prim.size()){
		if (m%prim[i] == 0){
			x = 0;
			while (m%prim[i] == 0){
				x++;
				m = m / prim[i];
			}
			a.push_back(x);
		}
		if (m == 1)break;
	}
	if (m != 1)a.push_back(1);

	f(i, a.size()){
		s = ni(n + a[i] - 1, a[i]);
		s = s%MOD;
		ans = ans*s;
		ans = ans%MOD;
	}

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 100010
int n;
vector<int> v[N];
int DFS(int x,int from){
  int sum=0,ocnt=0;
  lol(i,v[x].size()){
    int to=v[x][i];
    if(to==from)continue;
    int t=DFS(to,x);
    sum+=t;
    if(t==0)ocnt++;
  }
  //cout<<x<<" "<<sum<<" "<<ocnt<<endl;
  return sum+max(0,ocnt-1);
}
int main(){
  cin>>n;
  lol(i,n-1){
    int a,b;cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  lol(i,n){
    if(v[i].size()>2){
      cout<<DFS(i,-1)<<endl;
      return 0;
    }
  }
  cout<<"1"<<endl;
  return 0;
}


Measured memory_bytes: 9984
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys


n = int(input())
abc = [[0 for j in range(3)] for i in range(n)]
for i in range(n):
  abc[i] = list(map(int, sys.stdin.readline().rstrip().split()))


dp = [[0 for j in range(3)] for i in range(n+1)]
for i in range(1,n+1):
  dp[i][0] = abc[i-1][0] + max(dp[i-1][1],dp[i-1][2])
  dp[i][1] = abc[i-1][1] + max(dp[i-1][0],dp[i-1][2])
  dp[i][2] = abc[i-1][2] + max(dp[i-1][0],dp[i-1][1])
  
print(max(dp[n]))


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

#include <vector>
#include <iostream>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define linf 122337203685477000

using namespace std;

typedef long long ll;

/*
vector.push_back()
vector<int> hoge(3,-1); {-1,-1,-1}
vector<vector<int>> hogehoge(2,vector<int>(2,-1)); {{-1,-1},{-1,-1}} 
cin >>temp;
scanf("%d %d %d",&A,&B,&Q);
sort(a.begin(),a.end());
a.push_back(4000000000000);
a.insert(a.begin(),-1000000000000);
upper_bound(a.begin(),a.end(),x); // list[i] > x のイテレータ取得. *itrで数値化 
    std::priority_queue<
      int,
      std::vector<int>,
      decltype(compare) // 比較関数オブジェクトを指定
    > que(comp);
*/
template <typename T> void debug(T arr);
template <typename T> void debug (T arr, int dim);



int main(void){
    ll n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << " " << max(0LL,a+b-n) << endl;


};


template <typename T> void debug(T arr){
    for (auto col:arr){
        cout << col << " ";
    }
    cout <<endl;
};

template <typename T> void debug (T arr, int dim){
    for (auto raw:arr){
        for(auto col:raw){
            cout << col << " ";
        }
        cout << endl;
    }
};


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


int main() {
    int a,b,c;
    cin>>a>>b>>c;

    if((a+b+c)>=22){
        cout<<"bust";
    }else{
        cout<<"win";
    }

}


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

vector<ll> prime;//素因数分解で出てきた素数を全て挿入するvector
//typedef long long ll;
//O(√n)
//整列済み
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
    for(ll i = 2; i <= l; i++) {
        if(n%i==0){
        prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    prime.push_back(n);return;
}

 
int main() {

    ll n;
    cin >> n;

    int ans = 0;

    prime_factorize(n);
    int count = 1;
    for(int i = 1;i<prime.size();i++) {
        if(prime[i] == prime[i-1]) {
            count++;
            if(i == prime.size()-1) {
                ans += ((-1+sqrt(1+8*count))/2);
            }
        }
        else {
            ans += ((-1+sqrt(1+8*count))/2);
            count = 1;
            if(i == prime.size()-1) {
                ans ++;
            }
        }
    }
    if(prime.size() == 1)  ans++;
    
    cout<<ans<<endl;

 return 0;
}

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

using namespace std;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    
    vector<int> vec(M);
    for(int m=0; m<M; m++) {
        cin >> vec[m];
    }
    
    sort(vec.begin(), vec.end());
    int a=lower_bound(vec.begin(), vec.end(), X)-vec.begin();
    int b=vec.end()-lower_bound(vec.begin(), vec.end(), X);
    cout << min(a, b) << endl;

    return 0;
    
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD ((ll)1e9+7)
ll N,K;
ll C[4040][4040];
ll i,j,ans;
int main(){
    scanf("%lld%lld", &N,&K);

    C[0][0]=1;
    fornum(i,0,N){
        C[i + 1][0] = 1;
        fornum(j,0,N){
            C[i + 1][j + 1] = (C[i][j] + C[i][j + 1]) % MOD;
        }
    }
    ll R = N - K;
    ll B = K;
    j = 0;
    if(R>0){
        j += C[R-1][1];
        j += C[R-1][0] * 2;
        printf("%lld\n", j%MOD);
    }else{
        printf("1\n");
    }
    
    fornum(i,2,B+1){
        j = 0;
        if(R>0){
            j = C[R-1][i] % MOD;
            j = (j + C[R-1][i - 1]*2) % MOD;
            j = (j + C[R-1][i - 2]) % MOD;
            printf("%lld\n", j * C[B-1][i - 1] % MOD);
        }else{
            printf("0\n");
        }
        //printf("%lld %lld\n", j, C[B - 1][i - 1]);
        
        
    }
    
    return 0;
}

Measured memory_bytes: 62976
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 5;
int main()
{
	int n , m ,k , a[maxn ] , dp[maxn];
	for(int i = 1;i <= 1e5 + 5;i++)dp[i] = 1e9;
	scanf("%d %d",&n , &k);
	for(int i = 1;i <= n;i++)scanf("%d",&a[i]);
	dp[1] = 0,dp[2] = abs(a[1] - a[2]);
	for(int j = 3;j <= n;j++){
		for(int i = 1;i <= k;i++){
			if(j == i) break;
		dp[j] = min(dp[j],dp[j - i] + abs(a[j - i] - a[j]));
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

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

int main() {
    ll n,a,b; cin >> n >> a >> b;
    ll ans = (n/(a+b))*a + min(a,n%(a+b));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
a = [int(0) for i in range(n)]
a[0] = b[0]
a[n-1] = b[n-2]
b.append(b[n-2])
for i in range(1,n-1):
    a[i] = min(b[i-1], b[i])
print(sum(a))

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int h, w;
    cin >> h >> w;

    string s;
    REP(i, h) {
        REP(j, w) {
            cin >> s;
            if (s == "snuke") {
                cout << (char)('A' + j) << i + 1 << endl;
            }
        }
    }
}


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

int zm[26];

int main()
{
	ios::sync_with_stdio(false);
	
	string s;
	cin>>s;
	
	for(int i=0;i<s.size();i++)
		zm[s[i]-'a']++;
	for(int i=0;i<26;i++)
	{
		if(zm[i]%2==1)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define TOP 0
#define FRONT 1
#define RIGHT 2
#define LEFT 3
#define BACK 4
#define BOTTOM 5
using namespace std;

int dice[6] = {1,2,3,4,5,6};

void rotN(){
  swap(dice[TOP], dice[BACK]);
  swap(dice[TOP], dice[BOTTOM]);
  swap(dice[TOP], dice[FRONT]);
}

void rotE(){
  swap(dice[TOP], dice[RIGHT]);
  swap(dice[TOP], dice[BOTTOM]);
  swap(dice[TOP], dice[LEFT]);
}

void rotS(){
  rotN(), rotN(), rotN();
}

void rotW(){
  rotE(), rotE(), rotE();
}

void rotH(){
  swap(dice[FRONT], dice[RIGHT]);
  swap(dice[FRONT], dice[BACK]);
  swap(dice[FRONT], dice[LEFT]);
}


int main(){
cin >> dice[TOP]>> dice[FRONT]>> dice[RIGHT]>> dice[LEFT]>> dice[BACK]>> dice[BOTTOM];
int dice2[6];
  int flag = 0;
  cin >> dice2[TOP]>> dice2[FRONT] >> dice2[RIGHT]>> dice2[LEFT]>> dice2[BACK]>> dice2[BOTTOM];
if(dice[TOP]==dice2[TOP]&&dice[FRONT]==dice2[FRONT]&&dice[RIGHT]==dice2[RIGHT]&&dice[LEFT]==dice2[LEFT]&&dice[BACK]==dice2[BACK]&&dice[BOTTOM]==dice2[BOTTOM])flag = 1;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 4; j++){
      if(dice[TOP]!=dice2[TOP])break;
      rotH();
      if(dice[TOP]==dice2[TOP]&&dice[FRONT]==dice2[FRONT]&&dice[RIGHT]==dice2[RIGHT]&&dice[LEFT]==dice2[LEFT]&&dice[BACK]==dice2[BACK]&&dice[BOTTOM]==dice2[BOTTOM]){
        flag = 1;
        break;
      }
    }
    rotW();
    for(int j = 0; j < 4; j++){      
      if(dice[TOP]!=dice2[TOP])break;
      rotH();
      if(dice[TOP]==dice2[TOP]&&dice[FRONT]==dice2[FRONT]&&dice[RIGHT]==dice2[RIGHT]&&dice[LEFT]==dice2[LEFT]&&dice[BACK]==dice2[BACK]&&dice[BOTTOM]==dice2[BOTTOM]){
        flag = 1;
        break;
      }
    }
    rotN();
  }
  
  if(flag == 1) cout << "Yes" << endl;
  if(flag == 0) cout << "No" << endl;
}


Measured memory_bytes: 3108
W,a,b = gets.split.map(&:to_i)
ra = (a..(a+W)).to_a
rb = (b..(b+W)).to_a
# Aの範囲からBの範囲を引いてsizeが変動したら連結している
if ra.size != (ra - rb).size
  p 0
else
  p [(a+W-b).abs,(b+W-a).abs].min
end

Measured memory_bytes: 9852
#include<iostream>
using namespace std;
int main(){
  int N,W;
  cin>>N>>W;
  W+=1;
  int value[N];
  int weight[N];
  int data[W];
  for(int i=0;i<N;i++){
    cin>>value[i]>>weight[i];
  }
  for(int i=0;i<W;i++){
    data[i]=0;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<W;j++){
      if(j-weight[i]>=0){
        if(data[j]<=data[j-weight[i]]+value[i])
          data[j]=data[j-weight[i]]+value[i];
      }
    }
  }
  int max=0;
  for(int i=0;i<W;i++){
    if(max<data[i])
      max=data[i];
  }
  cout<<max<<endl;
  return 0;
}



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

int main() {
  string st;
  cin>>st;
  bool n,w,s,e;
  n=false;
  w=false;
  s=false;
  e=false;
  for(int i=0;i<st.size();i++){
    if(st[i]=='N') n=true;
    else if(st[i]=='W') w=true;
    else if(st[i]=='S') s=true;
    else e=true;
  }
  if((s && n) && (w && e)) cout<<"Yes"<<endl;
  else if((s && n) && (!w && !e)) cout<<"Yes"<<endl;
  else if((!s && !n) && (!w && !e)) cout<<"Yes"<<endl;
  else if((!s && !n) && (w && e)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
/*
O(NM)
n個のもの(区別できない)をm個以下に分割する方法
ei1333さんのブログによるともっと高速化できるらしい(FFT使ってる)
dp[n][m]

ライブラリは囲まれた部分だけ
*/

#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define bit(n,k) ( (n>>k)&1 )

//+++++++++++++++++++++++++++++

template<typename T>
vector<vector<T>> Partition(int n,int m){
    vector<vector<T>> dp(n+1,vector<T>(m+1));
    dp[0][0]=1;
    for(int i=0;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(i-j>=0) dp[i][j]=dp[i-j][j]+dp[i][j-1];
            else dp[i][j]=dp[i][j-1];
        }
    }
    return dp;
};

//+++++++++++++++++++++++++++++++++++

const int MOD = 1000000007;

struct ModInt{
    ll a;
    ModInt() : a(0) {}
    ModInt(ll x) {
        x%=MOD;
        if(x<0) x+=MOD;
        a=x;
    }

    ModInt operator+=(const ModInt p){
        a+=p.a;
        if( a>=MOD ) a-=MOD;
        return *this;
    }
    ModInt operator-=(const ModInt p){
        a-=p.a;
        if(a<0) a+=MOD;
        return *this;
    }
    ModInt operator*=(const ModInt p){
        a=(a*p.a)%MOD;
        return *this;
    }
    ModInt operator/=(const ModInt p){
        *this*=p.inverse();
        return *this;
    }

    ModInt operator+(const ModInt p){
        ModInt x(a);
        return x+=p;
    }
    ModInt operator-(const ModInt p){
        ModInt x(a);
        return x-=p;
    }
    ModInt operator*(const ModInt p){
        ModInt x(a);
        return x*=p;
    }
    ModInt operator/(const ModInt p){
        ModInt x(a);
        return x*=p.inverse();
    }

    ModInt operator=(ll p){
        p%=MOD;
        if(p<0) p+=MOD;
        a=p;
        return *this;
    }

    bool operator==(const ModInt p){
        return a==p.a;
    }

    bool operator!=(const ModInt p){
        return a!=p.a;
    }

    ModInt pow(ll N) const{
        ModInt ans(1),p(a);
        while(N>0){
            if(bit(N,0)){
                ans*=p;
            }
            p*=p;
            N>>=1;
        }
        return ans;
    }
    ModInt inverse() const{
        return pow(MOD-2);
    }

};

ModInt Mr(ll p){
    p%=MOD;
    if(p<0) p+=MOD;
    ModInt x(p);
    return x;
}


signed main(){
    int n,k;
    cin>>n>>k;
    auto v=Partition<ModInt>(n,k);
    cout<<v[n][k].a<<endl;
}


Measured memory_bytes: 10668
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
    int x , y , z ;
    cin  >> x >> y >> z ;
    cout <<z - min ( x-y , z );

return 0 ;
}


Measured memory_bytes: 256
from scipy.misc import comb
n,k=map(int,input().split())
mod=10**9+7
for i in range(1,k+1):
    if i>n-k+1:
        print(0)
    else:
        print( ((comb(k-1, i-1, exact=True) %mod) * (comb(n-k+1,i, exact=True) %mod) ) %mod )

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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	char s[n];
	cin >> s;
	int w[n];
	int e[n];

	if(s[0] == 'W'){
		w[0] = 1;e[0] = 0;
	}else{
		w[0] = 0;e[0] = 1;
	}

	rep(i,1,n){
		if(s[i] == 'W'){
			w[i] = w[i-1]+1;
			e[i] = e[i-1];
		}else{
			w[i] = w[i-1];
			e[i] = e[i-1]+1;
		}
	}
	int mini = e[n-1]-e[0];
	rep(i,1,n){
		mini = min(mini,(e[n-1]-e[i])+w[i-1]);
	}
	cout << mini << endl;


}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int w, s;
    cin >> s >> w;
    if (w >= s) { 
        cout << "unsafe";
    } else {
        cout << "safe";
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <cstring>
#include <cctype>
#include <string>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main(){
	vector<int> prime(1, 2);
	for (int i = 3; i < 10000; i += 2){
		bool b = true;
		for (auto p = prime.begin(); *p <= sqrt(i); ++p){
			if (i%*p == 0)
				b = false;
		}
		if (b){
			prime.push_back(i);
		}
	}
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++){
		cin >> v[i];
	}
	int kosu = 0;
	bool b;
	for (int i = 0; i < N; i++){
		b=true;
		for (auto p = prime.begin(); p != prime.end(); ++p){
			if (v[i]%*p==0&&v[i]!=*p){
				b = false;
				break;
			}
		}
		if (b)
			kosu++;
	}
	cout << kosu<<endl;
	return 0;
}

Measured memory_bytes: 1268
#include <stdio.h>
int main()
{
    int t = 0;
    char str[4];
    scanf("%s", str);
    for (int i = 0; i < 4; i++)
    {
        if (str[i] == '+')
            t++;
        else
            t--;
    }
    printf("%d", t);
    return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = getInt(sc);
		int d = getInt(sc);
		int preWeight = getInt(sc);

		for (int i = 0; i < 10; i++) {
			preWeight = r * preWeight - d;
			System.out.println(preWeight);
		}

	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	int row = 0;
	int col = 0;
	int candies = 0;

	public Status(int row, int col, int candies) {
		this.row = row;
		this.col = col;
		this.candies = candies;
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }



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

  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  ll asum = 0, bsum = 0, dsum = 0;
  rep(i, n) asum += a[i];
  rep(i, n) bsum += b[i];
  rep(i, n) {
    if (a[i] >= b[i]) dsum += a[i] - b[i];
    else {
      if ((b[i] - a[i]) % 2 == 1) dsum++;
    }
  }
  cout << (dsum <= bsum - asum ? "Yes" : "No") << '\n';


  
  return 0;
}

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

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

    for (int i = 0; i < S.size(); i++) {
        bool equals = true;
        for (int j = 0; j < T.size(); j++) {
            equals = equals and (S[j] == T[(i + j) % T.size()]);
        }
        if (equals) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 384
n,a,b,c,d=input().split()
n,a,b,c,d=int(n),int(a),int(b),int(c),int(d)
n-=1
f=False
for i in range(0,n+1):
	l=a+c*i-d*(n-i)
	r=a+d*i-c*(n-i)
	if l<=b<=r:
		f=True
		break
if(f):print("YES")
else:print("NO")

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


using namespace std;

#define ll long int
#define ull unsigned long long int

#define I_read()  freopen("input.tex","r",stdin);

#define O_write() freopen("output.txt","w",stdout);

#define fast() ios_base::sync_with_stdio(false); cin.tie(0);


int main(){

//	fast();	
#ifdef _DEBUG

//	  I_read();
//        O_write();

#endif
	int k;
	string s,s1="...";
	
	cin>>k >>s;

	int len=s.length();

	if( len<= k)
	{
		cout<<s<<endl;
	}	
	else
	{
		s=s.substr(0,k);
		s=s+s1;
		cout<<s<<endl;
	}

 return 0;	
}



Measured memory_bytes: 3596
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
glad=0

for i in range(N-1):
    if A[i]+1==A[i+1]:
        glad+=C[A[i]-1]
    else:
        pass

for i in range(N):
    glad+=B[i]

print(glad)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}






int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<pll> A(N);
  cin>>A;
  if(N==1){cout<<0<<endl; return 0;}
  else if(N==2){cout<<min(abs(A[0].F-A[1].F)*abs(A[0].S-A[1].S),abs(A[0].F-A[1].S)*abs(A[0].S-A[1].F))<<endl; return 0;}
  ll mx=-1,idx1=-1,mi=MOD,idx2=-1;
  for(int i=0;i<N;i++){
    auto &I=A[i];
    if(I.F>I.S){swap(I.F,I.S);}
    if(mx<I.S){mx=I.S; idx1=i;}
    if(mi>I.F){mi=I.F; idx2=i;}
  }
  ll mx2=MOD,mi2=-1;
  for(int i=0;i<N;i++){
    auto &I=A[i];
    if(i==idx1 && i==idx2){continue;}
    if(i==idx1){mi2=max(mi2,I.F);}
    else if(i==idx2){mx2=min(mx2,I.S);}
    else{mi2=max(mi2,I.F); mx2=min(mx2,I.S);}
  }
  ll ans=(mx-mx2)*(mi2-mi);
  if(idx1!=idx2){
    mx2=max(A[idx1].F,A[idx2].S);
    mi2=min(A[idx1].F,A[idx2].S);
    vector<pll> B;
    for(int i=0;i<N;i++){
      if(i!=idx1 && i!=idx2){B.push_back(A[i]);}
    }
    sort(B.begin(),B.end());
    mx2=max(mx2,B.back().F);
    ans=min(ans,(mx2-min(mi2,B[0].F))*(mx-mi));
    for(int i=0;i+3<N;i++){
      mx2=max(mx2,B[i].S);
      mi2=min(mi2,B[i].S);
      ans=min(ans,(mx2-min(mi2,B[i+1].F))*(mx-mi));
    }
    mx2=max(mx2,B.back().S);
    ans=min(ans,(mx2-min(mi2,B[0].S))*(mx-mi));
  }
  cout<<ans<<endl;
  


  return 0;
}


Measured memory_bytes: 9584
#include<stdio.h>
#include<string.h>

#define M 2000000
#define L 14

char H[M][L];

int getChar( char ch )
{
	if( ch == 'A') {
		return 1;
	} else if( ch == 'C') {
		return 2;
	} else if( ch == 'G') {
		return 3;
	} else if( ch == 'T') {
		return 4;
	} else {
		return 0;
	}
}

long long getKey( char str[] )
{
	long long sum = 0, p = 1, i;
	for ( i=0; i<strlen(str); i++ ) {
		sum += p*( getChar( str[i] ) );
		p *= 5;
	}
	return sum;
}

int find( char str[] )
{
	int i;
	long long hashkey;
	for( i=0; i<M; i++ ) {
		hashkey = getKey( str );
		hashkey = ( hashkey+ (2*i-1)*hashkey )%M;
		if( '\0' == H[ hashkey ][0] ) {
			return 0;
		} else {
		    if( 0 == strcmp( H[ hashkey ], str ) ) {
		    	return 1;
		    }
		}
	}
	return 0;
}

void insert( char str[] )
{
	int i;
	long long hashkey;
	for( i=0; i<M; i++ ) {
		hashkey = getKey( str );
		hashkey = ( hashkey+ (2*i-1)*hashkey )%M;
		if( '\0' == H[ hashkey ][0] ) {
			strcpy( H[ hashkey ], str );
			break;
		}
	}
    return;
}

int main() 
{

	int i, n;
	char str[L], com[9];
	
	for ( i=0; i<M; i++ ) {
		H[i][0] = '\0';
	}
	scanf( "%d", &n );
	for ( i=0; i<n; i++ ) {
		scanf( "%s %s", com, str );
		if ( com[0] == 'i' ){
			insert( str );
		} else {
			if( find( str ) ){
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}

    return 0;
}

Measured memory_bytes: 27952
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  string s;
  cin >> n >> s;
  vector<int> e(n+1,0),w(n+1,0);
  REP(i,n) (s[i]=='E') ? ++e[i] : ++w[i+1];
  for(int i=n;i>0;--i) e[i-1]+=e[i];
  REP(i,n) w[i+1]+=w[i];
  int answer = n-1;
  REP(i,n) answer = min(answer, e[i+1]+w[i]);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3076
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
int dp[100005];
int fun(int i,int a[],int n){
    if(i<0)return 1;
    if(i==0)return 0;
    if(dp[i]!=-1)return dp[i];
    int ans=0;
    for(int j=0;j<n;j++){
        if(fun(i-a[j],a,n)==0){
            ans=1;
            break;
        }
    }
    return dp[i]=ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    if(fun(k,a,n))cout<<"First";
    else cout<<"Second";
    return 0;
}

Measured memory_bytes: 5760