akhauriyash/Code-Regression huggingface dataset:
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

vector<vector<int> > graph(100000);
long long int result[100000][2] = {};

// flag = 1 -> 黒と白どちらでも塗れる
// flag = 0 -> 白でしか塗れない
long long int solve(int now, int flag, int parent) {
	if (result[now][flag] > 0) return result[now][flag];
	// nowを白く塗る場合
	long long int tmp1 = 1;
	for (int i = 0; i < graph[now].size(); i++) {
		int next = graph[now][i];
		if (next == parent) continue;
		tmp1 = (tmp1 * solve(next, 1, now)) % MOD;
	}

	// nowを黒く塗る場合
	long long int tmp2;
	if (flag == 1) {
		tmp2 = 1;
		for (int i = 0; i < graph[now].size(); i++) {
			int next = graph[now][i];
			if (next == parent) continue;
			tmp2 = (tmp2 * solve(next, 0, now)) % MOD;
		}
	} else {
		tmp2 = 0;
	}
	// cout << now << " " << flag << " " << (tmp1 + tmp2) % MOD << endl;
	return result[now][flag] = (tmp1 + tmp2) % MOD;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	cout << solve(0, 1, -1) << endl;
}

Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
int n,a[100000],b[100000];
int main()
{
	cin>>n;
	for (int i=0,k=1;i<n;i++,k*=-1)
	    cin>>b[i+1],a[1]+=k*b[i+1];
	for (int i=2;i<=n;i++)
		a[i]=2*b[i-1]-a[i-1];
	for (int i=1;i<=n;i++)
	    cout<<a[i]<<" \n"[i==n];
	return 0;
}


Measured memory_bytes: 2048
using System;

class Program
{
    static void Main(string[] args)
    {
        string s = Input.next();
        Console.WriteLine(s.Length - s.Replace("1", "").Length);
    }

}


class Input
{
    static string[] line = { };
    static int index = 0;
    static void readLine()
    {
        line = Console.ReadLine().Split(' ');
        index = 0;
    }
    public static int nextInt()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return int.Parse(line[index - 1]);
    }
    public static long nextLong()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return long.Parse(line[index - 1]);
    }
    public static string next()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return line[index - 1];
    }
}




Measured memory_bytes: 11092
#include <iostream>
#include <string>
int main() {
	int N, M;
	std::cin >> N >> M;
	std::string S;
	for (int i = 0; i < M + 2; i++)
		std::cout << "#";
	std::cout << std::endl;

	for (int i = 0; i < N; i++) {
		std::cout << "#" ;
			std::cin >> S;
			std::cout << S;
               std::cout << "#" << std::endl;
        }
	for (int i = 0; i < M + 2; i++) {
		std::cout << "#";
	}
	std::cout << std::endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

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

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	
	int br = 0;
	int res = 0;
	vector<string> ans;
	each(c, s) {
		bool ok = false;
		if (c == 'a') {
			if (a + b > res) {
				ok = true;
			}
		}
		if (c == 'b') {
			if (a + b > res && br + 1 <= b) {
				ok = true;
			}
			if (ok)br++;
		}
		if (c == 'c') {
			
		}
		if (ok) {
			ans.push_back("Yes");
			res++;
		}
		else {
			ans.push_back("No");
		}
	}
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 6212
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n; cin >> n; ll num = 0; ll cnt = 0; ll ans = 0;
  
  rep(i,n){
    ll x; cin >> x;
    if(x == num + 1){
      cnt++;
      num = x;
    }
  }
  
  ans = n - cnt;
  
  if(ans == n) cout << -1 << endl;
  else cout << n - cnt << endl;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
main()
{
    int n,m,x,sum=0,r;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        sum+=x;
    }
    r=n-sum;
    if(r>0)
    {
        cout<<r<<endl;
    }
    else if(r<0)
    {
        cout<<"-1\n";
    }
    else
    {
        cout<<"0\n";
    }

}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    priority_queue<int> que;
    for(int i=0; i<n; i++){
        cin >> a[i];
        que.push(a[i]);
    }
    for(int i=0; i<n; i++){
        int tmp=que.top();
        que.pop();
        if(tmp==a[i]){
            int re=tmp;
            tmp=que.top();
            que.push(re);
        }
        else que.push(tmp);
        cout << tmp << endl;
    }
}

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();

		int h = 0;
		int m = 0;
		int s = 0;

		while(num >= 3600) {
			num -= 3600;
			h++;
		}
		while(num >= 60) {
			num -= 60;
			m++;
		}

		s = num;

		System.out.println(h + ":" + m +  ":" + s);
	}
}

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

int main() {
    //
    int a;

    cin >> a;

    if (a >= 400 && a <= 599) cout << 8;
    else if(a >= 600 && a <= 799) cout << 7;
    else if(a >= 800 && a <= 999) cout << 6;
    else if(a >= 1000 && a <= 1199) cout << 5;
    else if(a >= 1200 && a <= 1399) cout << 4;
    else if(a >= 1400 && a <= 1599) cout << 3;
    else if(a >= 1600 && a <= 1799) cout << 2;
    else cout << 1;
    //
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long n,k;

int main(void)
{
	long long ans,t;
	scanf("%lld%lld",&n,&k);
	if(n%k==0)
	{
		cout<<"0";
		return 0;
	}
	if(n>k)
		n%=k;
	n=min(n,abs(n-k));
	cout<<n;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
ll n,s;

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

bool chk(ll b)
{
	if (b<=1) return 0; 
	ll now=0,tmp=n;
	while (tmp)
	{
		ll a=tmp%b;tmp/=b;
		now+=a;
	}
	return now==s;
}

int main()
{
	cin >> n >> s;
	if (n==s) {printf("%lld",n+1);return 0;}
	for (int i=2;1ll*i*i<=n;i++)
	{
		if (chk(i)) {printf("%d",i);return 0;}
	}
	ll ans=1e18;
	for (int i=1;1ll*i*i<=n-s;i++)
	{
		if ((n-s)%i) continue;
		if (chk(i+1)) ans=min(ans,(ll)i+1);
		if (chk((n-s)/i+1)) ans=min(ans,(n-s)/i+1);
	}
	if (ans==1e18) ans=-1;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
#import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

#from collections import deque, defaultdict, Counter


def divisor(n):
    """ nの約数列挙 """
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass  # sortされていない


def main():
    N = int(input())
    div_1 = divisor(N)
    div_2 = divisor(N-1)
    cnt = 0

    for i in div_1:
        if i == 1:
            continue
        tmp = N
        while tmp % i == 0:
            tmp = tmp / i
        tmp = tmp % i
        if tmp == 1:
            cnt += 1

    cnt += len(div_2) - 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
#include<bits/stdc++.h>
using namespace std;
double a[2000];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lf",&a[i]);
	sort(a+1,a+n+1);
	double ans=a[1];
	for(int i=2;i<=n;i++){
		ans=(ans+a[i])/2.0;
	}
	printf("%lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


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

	map<char, ll> dic;
	for (auto c : S) {
		dic[c]++;
	}

	ll max_val = 0, min_val = ll_max;
	for (auto x : dic) {
		max_val = max(max_val, x.second);
		min_val = min(min_val, x.second);
	}

	if (max_val == 1 || (dic.size() == 3 && max_val - min_val < 2)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

#define int long long
#define pb push_back
const int mod = 1e9 + 7;
const int N = 100005;
vector<int>g[N];
pair<int,int> dfs(int x,int p){
    int a = 1;
    int b = 0;
    for(int i : g[x]){
        if(i == p){
            continue;
        }
        pair<int,int> pr = dfs(i,x);
        int temp = a;
        a = (a * pr.second) % mod;
        b = (((temp*pr.first)%mod) + ((b*(pr.first+pr.second))%mod)) % mod;
        a %= mod;
        b %= mod;
    }
    return {a,(a+b)%mod};
}
int32_t main(){
    int n;
    cin >> n;
    for(int i=1;i<n;i++){
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    pair<int,int> ans = dfs(1,0);
    cout<<(ans.first+ans.second)%mod<<endl;
}

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

#define ll long long
#define sz 1000

void solve()
{
    string s, t;
    cin >> s >> t;
    int len = s.size();

    bool flag = 1;

    for(int i=0; i<len; i++)
    {
        if(s[i] != t[i])
            flag = 0;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main()
{
    int tc = 1;
    //cin >> tc;
    while(tc--)
    {
        solve();
    }

    return 0;
}




Measured memory_bytes: 3632
N = int(input())
A = list(map(int,input().split()))
ans = 0
mod = 10**9+7
c = [0]*62

for i in range(N):
    a = format(A[i],'b')
    a = a[::-1]
    for j in range(len(a)):
        if a[j] == '1':
            c[j] += 1

k = 1
for i in range(len(c)):
    p = c[i]*(N-c[i])
    ans += k*(p % mod) % mod
    k = k*2 % mod

print(ans%mod)

Measured memory_bytes: 122808
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        for (int i = 1; i < 10; i++)
        {
            for (int j = 1; j < 10; j++)
            {
                if (i * j == n)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }

        Console.WriteLine("No");
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    ll h;
    cin >> h;
    ll now = 1;
    ll ans = 0;
    while(h > 0){
        h /= 2;
        ans += now;
        now *= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// URL: https://atcoder.jp/contests/abc133/tasks/abc133_c

import std.algorithm, std.container, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int l, r; io.getV(l, r);

  auto m = 2019;
  foreach (i; l..min(l+2019, r+1))
    foreach (j; i+1..min(i+2020, r+1))
      m = min(m, ((i%2019)*(j%2019))%2019);

  io.put(m);
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.meta, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  if (hasAssignableElements!T)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  if (allSatisfy!(hasAssignableElements, T))
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, ref T v)
  if (hasAssignableElements!T && hasAssignableElements!(ElementType!T))
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N - 1), B(N - 1);
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
    G[A[i]].emplace_back(B[i]);
    G[B[i]].emplace_back(A[i]);
  }
  int mx = 0;
  map<pair<int, int>, int> res;
  vector<int> color(N, -1);
  color[0] = 0;
  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    auto u = que.front();
    que.pop();
    int c = 1;
    for (auto v : G[u]) {
      if (color[v] != -1) continue;
      if (color[u] == c) c++;
      mx = max(mx, c);
      color[v] = c;
      res[make_pair(u, v)] = res[make_pair(v, u)] = c++;
      que.push(v);
    }
  }
  cout << mx << '\n';
  for (int i = 0; i < N - 1; i++) {
    cout << res[make_pair(A[i], B[i])] << '\n';
  }
  return 0;
}


Measured memory_bytes: 19712
local function gcd(a,b)
    if b>0 then
        return gcd(b,a%b)
    else
        return a
    end
end

local mod=1000000007
local p={1}
for i=1,200010 do
    p[i+1]=p[i]*2%mod
end


local n=io.read("n")
local iwashi={}
local zero=0
for i=1,n do
    local a,b=io.read("n","n")
    if a==0 and b==0 then
        zero=zero+1
    elseif a==0 then
        iwashi[0]=(iwashi[0] or {})
        iwashi[0][0]=(iwashi[0][0] or {})
        iwashi[0][0][1]=(iwashi[0][0][1] or 0)+1
    elseif b==0 then
        iwashi[0]=(iwashi[0] or {})
        iwashi[0][0]=(iwashi[0][0] or {})
        iwashi[0][0][2]=(iwashi[0][0][2] or 0)+1
    else
        if b<0 then
            a,b=-a,-b
        end
        local gcdab=gcd(math.abs(a),math.abs(b))
        a=a//gcdab
        b=b//gcdab
        if a<0 then
            iwashi[b]=(iwashi[b] or {})
            iwashi[b][-a]=(iwashi[b][-a] or {})
            iwashi[b][-a][1]=(iwashi[b][-a][1] or 0)+1
        else
            iwashi[a]=(iwashi[a] or {})
            iwashi[a][b]=(iwashi[a][b] or {})
            iwashi[a][b][2]=(iwashi[a][b][2] or 0)+1
        end
    end
end

local combination=1
for a,_ in pairs(iwashi) do
    for b,_ in pairs(iwashi[a]) do
        local ba=iwashi[a][b][1] or 0
        local ab=iwashi[a][b][2] or 0
        local select=p[ba+1]+p[ab+1]-1
        combination=(combination*select)%mod
    end
end
combination=(combination+zero-1)%mod
print(combination)

Measured memory_bytes: 56640
h,w,d=map(int,input().split())

lis=[[] for i in range(h*w)]
for i in range(h):
  ai=list(map(int,input().split()))
  for j in range(w):
    lis[ai[j]-1].append(i)
    lis[ai[j]-1].append(j)

U=[]

for i in range(d):
  Ui=[0]
  j=1
  while i+j*d<h*w:
    Ui.append(Ui[j-1]+abs(lis[i+j*d][0]-lis[i+(j-1)*d][0])
              +abs(lis[i+j*d][1]-lis[i+(j-1)*d][1]))
    j+=1
  U.append(Ui)

q=int(input())


for i in range(q):
  li,ri=map(lambda x:int(x)-1,input().split())
  modi=li%d
  print(U[modi][(ri-modi)//d]-U[modi][(li-modi)//d])


Measured memory_bytes: 26656
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val a = sc.nextInt //最初の整数が読み込まれる
    val c = sc.nextInt //2番目に出てきた整数が読み込まれる
    var a1 = 0
    var c1 = 0
    // val c = sc.nextInt //3番目に出てきた整数が読み込まれる
    /*
    if ((a + c) < 1 || (a + c) >= 100000) {
      println("out")
    }
    */
    if ((a + c) > 0 && (a + c) <= 100000){
      a1 = a%2
      c1 = c%2
      if (a1 == 0) {
        println("Even")
      }
        if (a1 != 0 && c1 == 0) {
          println("Even")
        }
      if (a1 == 1 &&  c1 == 1){
        println("Odd")
      }
    }
  }
}


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

#define rep(i, N) for(int i = 0;i < N;i++)

using namespace std;

int main(void){
	int N;
	cin >> N;
	vector<int> h(N);
	rep(i, N) {
		cin >> h[i];
	}

	vector<int> dp(N);//足場iまで行くときの最小コスト
	dp[0] = 0;//動かないならコスト0
	dp[1] = abs(h[0] - h[1]);//足場1に行くのは1通りしかないので決定できる

	for (int i = 2; i < N; i++) {
		dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}

	cout << dp[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#define int long long
const int inf=1145141919810893;
const int mod=1000000007;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
int p[500];
signed main(){
	int i,j;
	string s;
	cin>>s;
	std::vector<string> akiba;
	for(i=0;i<16;i++){
		string t;
		if(i&(1<<3))
			t.push_back('A');
		t+="KIH";
		if(i&(1<<2))
			t.push_back('A');
		t+="B";
		if(i&(1<<1))
			t.push_back('A');
		t+="R";
		if(i&1)
			t.push_back('A');
		akiba.push_back(t);
	}
	for(auto t:akiba)
		if(s==t){
			cout<<"YES"<<endl;
			return 0;
		}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    while(t)
    {
        int a,b;
        cin>>a>>b;
        int temp=(b*10);
        int ans=temp;
        temp*=8;
        temp/=100;
        if(temp==a)
        {
            cout<<ans;
        }
        else
        {
            temp=(a*100);
            bool q=false;
            if(temp%8!=0)
            {
                q=true;
            }
            temp/=8;
            if(q)
            {
                temp++;
            }
            ans=temp;
            temp/=10;
            if(temp==b)
            {
                cout<<ans;
            }
            else
            {
                cout<<-1;
            }
        }
        t--;
    }
    return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVVld = vector<VVld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


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

  Vll dp(1<<N);

  rep(S, 1<<N) {
    rep(i, N) rep2(j, i+1, N) if ((S>>i&1) & (S>>j&1)) dp[S] += a[i][j];
    for (int T = S; T > 0; T = (T-1)&S) chmax(dp[S], dp[T] + dp[S-T]);
  }

  ll ans = dp[(1<<N)-1];
  cout << ans << endl;
  return 0;
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L.at(i);
  sort(L.begin(), L.end());
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      auto it = lower_bound(L.begin(), L.end(), L.at(i) + L.at(j));
      int k = distance(L.begin(), it);
      ans += k - j - 1;
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
 
// 数値のハッシュ関数
#define HASHSIZ 250007
int hash[HASHSIZ+3], *hashend = hash+HASHSIZ;
 
int lookup(int n)
{
    int *p;
     
    n++; p = hash + n % HASHSIZ;
    while (*p) {
        if (*p == n) return 1;
        if (++p == hashend) p = hash;
    }
    return 0;
}
 
void insert(int n)
{
    int *p;
     
    n++; p = hash + n % HASHSIZ;
    while (*p) {
        if (*p == n) return;
        if (++p == hashend) p = hash;
    }
    *p = n;
}
 
// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
    int n = 0, c = getchar_unlocked();
    do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
    return n;
}
 
int main()
{
    int n, q, C;
 
    n = in();
    while (n--) insert(in());
 
    C = 0;
    q = in();
    while (q--) if (lookup(in())) C++;
     
    printf("%d\n", C);
    return 0;
}


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

char num[200005];
int sum;

int main(){
	cin>>num;
	
	for(int i=0; num[i]; i++){
		sum += num[i] - '0';
	}
	if(sum%9==0) cout<<"Yes";
	else cout<<"No";

	return 0;
}

Measured memory_bytes: 3228
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a[100004]= {0},ans[100002]= {0};
    cin>>n;
    int sum=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        sum+=abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n]-0);
    for(int i=1; i<=n; i++)
    {
        int tp=sum;
        if(a[i]>a[i-1]&&a[i]>a[i+1])
        {
            tp=sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
        }
        if(a[i]<a[i-1]&&a[i]<a[i+1])
        {
            tp=sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
        }
        cout<<tp<<endl;
    }
}


Measured memory_bytes: 1664
# editorial
N = int(input())

from functools import lru_cache
@lru_cache(maxsize=10**6)
def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if  all(s.count(c) for c in "753") else 0
    for c in "753":
        ret += dfs(s+c)
    return ret

print(dfs("0"))


Measured memory_bytes: 27924
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;

int main() {
    ll N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    ll ans = 0;
    for(int i = 0; i < N; i++){
        if(T[i] == 's'){
            ans += R;
        }
        else if(T[i] == 'r'){
            ans += P;
        }
        else{
            ans += S;
        }
    }

    for(int i = 0; i < N - K; i++){
        if(T[i] == T[i + K]){
            if(T[i] == 's'){
                ans -= R;
                T[i + K] = '*';
            }
            else if(T[i] == 'r'){
                ans -= P;
                T[i + K] = '*';
            }
            else{
                ans -= S;
                T[i + K] = '*';
            }            
        }
    }

    cout << ans << endl;
}


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

int main() {
    ll h, n;
    cin >> h >> n;
    vector<pair<ll, ll>> ab(n);
    rep(i, n) cin >> ab[i].first >> ab[i].second;

    vector<ll> dp(1e8, 0);
    for (ll i = 0; i <= 1e8; i++) {
        rep(j, n) {
            if (i - ab[j].second >= 0) {
                dp[i] = max(dp[i], dp[i - ab[j].second] + ab[j].first);
            }
        }
        if (dp[i] >= h) {
            cout << i << endl;
            return 0;
        }
    }

    // for (ll i = 0; i <= h; i++) {
    //     if (dp[i] >= h) {
    //         cout << i << endl;
    //         return 0;
    //     }
    // }
}

Measured memory_bytes: 781568
using System;
using System.Collections;

public class p0018{
	p0018 ()
	{
		string str;
		string[] ary;
		int [] a;
		
		while ((str=Console.ReadLine()) != null) {
			ary = str.Split (' ');
			a = new int[ary.Length];
			for (int i = 0; i < 5; ++i)
				a [i] = int.Parse (ary [i]);
			Array.Sort (a);
			
			for (int i = 4; i >= 1; --i)
				Console.Write ("{0} ", a[i]);
			Console.WriteLine ("{0}", a[0]);
		}
	}
	
	public static int Main (string[] args)
	{
		new p0018 ();
		return 0;
	}
}

Measured memory_bytes: 5776
#include <bits/stdc++.h>
#define reps(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
#define aa cout<<"aa"<<endl;
typedef long long int ll;
using namespace std;


struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

struct UnionFind {
    //par[N-1]までしかない（Nがない）ことに注意
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
int N,M;
cin>>N>>M;
int p[N];
rep(i,N){
    cin>>p[i];
}


UnionFind ki(N);
int x[M];
int y[M];

rep(i,M){
    cin>>x[i]>>y[i];
    
    ki.unite(x[i]-1,y[i]-1);
}
int ans=0;
rep(i,N){
    
    if(ki.same(p[i]-1,i)){
    ans++;
    }
    
}

cout<<ans<<endl;







    return 0;
}

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

#define vl vector<ll>
#define vi vector<int>

#define ff first
#define ss second

#define pb push_back
#define MOD 1e9+7 
const int nax = 1e6+5;
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "

inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;  cin>>n>>k;
    vl v(n+1);
    for(int i =1 ;i<=n;++i){
        cin>>v[i];
    }
    vector<int> done(n+1,-1);
    vi pos;
    pos.pb(1);
    int id = 1;
    done[1] = 0;
    int at = -1;
    while(1){
        int val = v[id];
        if(done[val]!=-1){
            at = done[val];
            break;
        }
        done[val] = pos.size();
        pos.pb(val);
        id = val;
    }
    if(k <= at){
        cout << pos[k];
    }
    else{
        int cir = pos.size() - at;
        k -= at;
        k %= cir;
        cout << pos[at + k];
    }
     return 0;
 }

Measured memory_bytes: 6628
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var chair = ToInt32(input[0]);
        var human = ToInt32(input[1]);
        var between = ToInt32(input[2]);
        var result = 0;
        while (true)
        {
            chair -= between;
            chair -= human;
            if (chair < between) break;
            result++;
        }
        WriteLine(result);
    }
}



Measured memory_bytes: 11220
#include <stdio.h>
#include <stdlib.h>

int main(){
  int flag=1, i=0, j, tmp, N, A[100],count=0;

  scanf("%d",&N);
  if(N<1 || N>100) exit(1);
  for(i=0; i<N; i++) {
    scanf("%d",&A[i]);
    if(A[i] > 100 || A[i] < 0) exit(2);
  }

  i=0;
  while(flag){
    flag = 0;
    for(j=N-1; j>=i+1; j--){
      if(A[j] < A[j-1]){
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	flag = 1;
	count++;
      }
    }
    i++;
  }

  for(j=0; j<N-1; j++) printf("%d ",A[j]);
  printf("%d\n",A[N-1]);
  printf("%d\n",count);

  return 0;
}



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

#define amen exit(0)

#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll D = 100007;
const ll Inf = 1000000007;

ll sum_dig(ll x)
{
    ll res = 0;
    while (x > 0)
    {
        res += x % 10;
        x /= 10;
    }
    return res;
}

int main() 
{
    ll n;
    cin >> n;
    if (n % sum_dig(n) == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    amen;
}

Measured memory_bytes: 256
# https://abc054.contest.atcoder.jp/tasks/abc054_d

N, Ma, Mb = map(int, input().split())
la, lb, lc = [], [], []
for _ in range(N):
    ai, bi, ci = map(int, input().split())
    la.append(ai)
    lb.append(bi)
    lc.append(ci)
sumA = sum(la)
sumB = sum(lb)

Inf = int(1e10)
dp = [[[Inf for _ in range(sumB + 1)] for _ in range(sumA + 1)] for _ in range(N + 1)]
dp[0][0][0] = 0

for i in range(N):
    ai, bi, ci = la[i], lb[i], lc[i]

    for j in range(sumA + 1):
        for k in range(sumB + 1):
            if dp[i][j][k] == Inf:
                continue
            dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
            dp[i+1][j+ai][k+bi] = min(dp[i+1][j+ai][k+bi], dp[i][j][k]+ci)


ans = Inf
for j in range(1, sumA + 1):
    for k in range(1, sumB + 1):
        if j * Mb == k * Ma:
            ans = min(ans, dp[N][j][k])

if ans == Inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 63196
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int n;
    long m;
    cin >> n >> m;
    map<long, long> mods;
    long rui = 0, sum = 0;
    mods[0] = 1;
    for (int i=0; i<n; i++) {
        long a;
        cin >> a;
        rui = (rui+a) % m;
        sum += mods[rui];
        mods[rui]++;
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    vector<long long>b(100001,0);
    long long sum=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        b[a[i]]++;
        sum+=a[i];
    }
    int q;
    cin>>q;
    int x,y;
    for(int i=0; i<q; i++)
    {

        cin>>x>>y;
        sum=sum-(b[x]*x)+(b[x]*y);
        b[y]+=b[x];
        b[x]=0;
        cout<<sum<<endl;
    }

}


Measured memory_bytes: 4260
#include <cstdio>

int main()
{
  long long n, l, a;
  scanf("%lld%lld%lld", &n, &l, &a);
  long long last = 0;
  for (long long i = 1; i < n; ++i)
  {
    long long b = a;
    scanf("%lld", &a);
    if (a + b >= l)
    {
      last = i;
      break;
    }
  }
  if (last == 0)
  {
    puts("Impossible");
    return 0;
  }
  puts("Possible");
  for (long long i = 1; i < n; ++i)
  {
    if (i == last) break;
    printf("%lld\n", i);
  }
  for (long long i = n - 1; i >= 0; --i)
  {
    if (i == last) break;
    printf("%lld\n", i);
  }
  printf("%lld\n", last);
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
// cf IO: I64d
// atcoder IO: ｌｌｄ
const int Maxn=100005;
int a[Maxn];
int dp[Maxn];
vector<int> G[Maxn]; 
void dfs(int x){
	vector<int> dep;
	for (int i=0;i<G[x].size();i++){
		dfs(G[x][i]);
		dep.push_back(dp[G[x][i]]);
	}
	sort(dep.begin(),dep.end());
	reverse(dep.begin(),dep.end());
	dp[x]=0;
	for (int i=0;i<dep.size();i++){
		dp[x]=max(dp[x],dep[i]+i+1);
	}
}
int main(){
	int n;
	scanf("%d",&n);
	for (int i=2;i<=n;i++){
		scanf("%d",&a[i]);
		G[a[i]].push_back(i);
	}
	dfs(1);
	printf("%d\n",dp[1]);
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define M_PI 3.141592653589793
using namespace std;
typedef long long ll;

double a, b, x;

int main() {

	cin >> a >> b >> x;
	double ans;
	if (2 * x > a * a * b)
	{
		ans = 180 * atan(2 * b / a - 2 * x / (a * a * a)) / M_PI;
	}
	else
	{
		ans = 180 * atan(a * b * b / (2 * x)) / M_PI;
	}


	cout << setprecision(12) << ans;
	return 0;
}


Measured memory_bytes: 256
from heapq import heapify, heappush as hpush, heappop as hpop
def dijkstra(n, E, i0=0):
    h = [[0, i0]]
    D = [-1] * n
    done = [0] * n
    D[i0] = 0
    
    while h:
        d, i = hpop(h)
        done[i] = 1
        for j, w in E[i]:
            nd = d + w
            if D[j] < 0 or D[j] >= nd:
                if done[j] == 0:
                    hpush(h, [nd, j])
                    D[j] = nd
    return D

N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]

M = 51
X = [[] for _ in range(M)]
for i in range(1, M):
    for j in range(1, i+1):
        X[i].append([i%j, 2**j])

def chk(S):
    M = 51
    X = [[] for _ in range(M)]
    for j in S:
        for i in range(j, M):
            X[i].append([i%j, 2**j])
    DI = []
    for i in range(M):
        DI.append(dijkstra(M, X, i))
    for i in range(N):
        if DI[A[i]][B[i]] < 0:
            return 0
    return 1

L1 = [i for i in range(1, 51)]
L2 = []
if chk(L1) == 0:
    print(-1)
else:
    while L1:
        while True:
            if chk(L1 + L2):
                if len(L1) == 0:
                    break
                L1.pop()
            else:
                L2.append(L1[-1]+1 if L1 else 1)
                L1 = [i for i in range(1, L2[-1])]
                break
        if len(L1) == 0:
            break

    print(sum([1<<l for l in L2]))


Measured memory_bytes: 66524
#include <stdio.h>
int main()
{
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		int p = (a+b)/2;
		if((a+b)%2==0)
		{
			printf("%d\n",p);
		}
		else 
		{
			printf("%d\n",p+1);
		}
	}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<int>v;

int main(){
	REP(i,0,10){
		int tmp;
		cin>>tmp;
		v.push_back(tmp);
	}
	sort(all(v));
	printf("%d\n%d\n%d\n",v[9],v[8],v[7]);
	return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

vector<ll> a;
int n, k; 
int mod = 1e9 + 7;

void solution(){
	cin >> n >> k;
	a = vector<ll>(n); for(auto& x : a) cin >> x;
	// dp[i][k] -- number of ways to distribute k candies among children upto i'th index
	// so , dp[i][k] = dp[i-1][k] + dp[i-1][k-1] + ... + dp[i-1][k-a[i]]
	// number of states - O(nk)
	// complexity for calculating each state - O(k)
	// total time - O(nkk)
	// using prefixes, calculate for each state in constant time
	// so, dp[i][k] = pre[k] - pre[k-a[i]-1], where pre is prefixes for dp[i-1]
	ll dp[n+1][k+1];
	memset(dp,0,sizeof(dp));
	vector<ll> pre(k+1,1LL);
	dp[0][0] = 1LL;
	for(int i = 1; i <= n; i++){
		vector<ll> new_pre(k+1,1LL);
		dp[i][0] = 1LL;
		for(int j = 1; j <= k; j++){
			int l = max(0LL, j-a[i-1]);
			int r = j;
			dp[i][j] = (pre[r] - (l == 0? 0 : pre[l-1]) + mod) % mod;
			new_pre[j] = (new_pre[j-1] + dp[i][j]) % mod;
		}
		swap(pre, new_pre);
	}
	cout << dp[n][k] % mod << endl;
}	


int main(){ 

	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}


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

public class Main {
  Scanner sc = new Scanner(System.in);

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

  void run() {
    int[] cnt = new int[256];
    char[] str = sc.next().toCharArray();
    for (char c : str) {
      ++cnt[(int) c];
    }
    boolean flag = true;
    for (int i = 'a'; i <= 'z'; ++i) {
      flag &= cnt[i] % 2 == 0;
    }
    System.out.println(flag ? "Yes" : "No");
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

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

int main(){
    string s; cin >> s;
    if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a,b; cin>>a>>b;
    if (a=='H' && b=='H') cout<<"H\n";
    if (a=='D' && b=='H') cout<<"D\n";
    if (a=='H' && b=='D') cout<<"D\n";
    if (a=='D' && b=='D') cout<<"H\n";
    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_V = 1000, MAX_E = 2000, MOD = 1e9+7;

static const int MAX_UF = MAX_V;

template <class T> class UnionFind {
private:
  T par[MAX_UF];
  T rank[MAX_UF];
  
public:
  T find(T x);
  void init(T n);
  void unite(T x, T y);
  bool same (T x, T y);
};

template <class T> void UnionFind<T>::init(T n) {
  for (T i = 0; i < n; ++i) {
    par[i] = i;
    rank[i] = 0;
  }
}

template <class T> T UnionFind<T>::find(T x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

template <class T> void UnionFind<T>::unite(T x, T y) {
  x = find(x); y = find(y);
  if (x == y) {
    return;
  } else {
    if (rank[x] > rank[y]) {
      par[y] = x;
    } else {
      par[x] = y;
      if (rank[x] == rank[y]) ++rank[y];
    }
  }
}

template <class T> bool UnionFind<T>::same(T x, T y) {
  return find(x) == find(y);
}

struct edge { int cost, u, v; };

edge es[MAX_E];
int E, V;

bool comp(const edge& e1, const edge& e2) {
  return e1.cost < e2.cost;
}

ll kruskal(UnionFind<int> uf) {
  ll res = 0;

  for (int i = 0; i < E; ++i) {
    edge e = es[i];
    if (!uf.same(e.v, e.u)) {
      uf.unite(e.v, e.u);
      res += e.cost;
    }
  }

  return res;
}

int N, M;
ll X;
ll mst_cost[MAX_E]; //その辺が使われている最小全域木のコスト

//x^nをmodのもとで計算する
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow((x*x) % mod, n/2, mod);
  if (n & 1) res = (res*x) % mod;
  return res;
}

ll f(ll x) {
  int c = 0;
  for (int i = 0; i < E; ++i) {
    if (mst_cost[i] <= x) ++c;
  }
  if (c == 0) return mod_pow(2, M, MOD);
  else return mod_pow(2,M-c+1, MOD);
}

int main() {
  cin >> N >> M >> X;
  E = M; V = N;
  for (int i = 0; i < M; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    es[i].cost = w; es[i].u = --u; es[i].v = --v;
  }
  sort(es, es+E, comp);

  if (N == 1) { 
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < E; ++i) {
    UnionFind<int> uf;
    uf.init(V);
    uf.unite(es[i].u, es[i].v);
    mst_cost[i] = kruskal(uf) + es[i].cost;
  }

  ll ans = (f(X-1) - f(X) + MOD) % MOD;

  cout << ans << endl;
}


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

#define ll long long int

int dp[100100];

int main()
{
    int n,m,p,q,i,j,k,l;
    cin>>n>>m;

    dp[0]=0;

    int ara[n+1];
    for(i=1;i<=n;i++) cin>>ara[i];
    for(i=1;i<=m;i++){
        for(j=1;j<=n;j++){
            if(i-ara[j]>=0) dp[i]=1-dp[i-ara[j]];
            if(dp[i]==1)break;
        }
    }

    if(dp[m]==1) cout<<"First\n";
    else cout<<"Second\n";
}


Measured memory_bytes: 3984