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

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

        int cnt=0;
        int[] m, f, r, sum;
        m = new int[50];
        f = new int[50];
        r = new int[50];
        sum = new int[50];

        while(true){
            m[cnt] = sc.nextInt();
            f[cnt] = sc.nextInt();
            r[cnt] = sc.nextInt();
            if(m[cnt] == -1 && f[cnt] == -1 && r[cnt] == -1)
                break;
            sum[cnt] = m[cnt] + f[cnt];
            cnt++;
        }
        for(int i=0; i<cnt; i++){
            if(m[i] == -1 || f[i] == -1){
                System.out.println("F");
            }else if(sum[i] >= 80){
                System.out.println("A");
            }else if(sum[i] >= 65 && sum[i] < 80){
                System.out.println("B");
            }else if(sum[i] >= 50 && sum[i] < 65){
                System.out.println("C");
            }else if(sum[i] >= 30 && sum[i] < 50){
                if(r[i] >= 50){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }else{
                System.out.println("F");
            }
        }
        sc.close();
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    int max_num = 0;
    rep(i, N) {
        int h = H[i];
        if (i != 0) {
            if (max_num > h) {
                cout << "No" << '\n';
                return;
            }
            h--;
        }
        max_num = max(max_num, h);
    }
    cout << "Yes" << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc151/tasks/abc151_d
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    using grid = pair<int, int>;
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char>(W));
    REP(i, H) REP(j, W) cin >> S[i][j];
    
    int ans = -1;
    REP(sx, H) REP(sy, W) REP(ex, H) REP(ey, W)
    {
        if ((sx == ex && sy == ey) || '#' == S[sx][sy] | '#' == S[ex][ey])
            continue;

        vector<vector<int>> cnts(H, vector<int>(W, -1));
        cnts[sx][sy] = 0;
        queue<grid> q;
        q.push(grid(sx, sy));
        int cnt = -1;
        while (!q.empty())
        {
            grid cur = q.front();
            q.pop();

            bool arrived = false;
            for (int i = 0; i < 4; ++i)
            {
                int nx = cur.first + dx[i];
                int ny = cur.second + dy[i];

                if (nx >= 0 && nx < H && ny >= 0 && ny < W && S[nx][ny] == '.' && cnts[nx][ny] == -1)
                {
                    cnts[nx][ny] = cnts[cur.first][cur.second] + 1;
                    if (nx == ex && ny == ey)
                    {
                        arrived = true;
                        break;
                    }
                    q.push(grid(nx, ny));
                }
            }
            if (arrived)
            {
                cnt = cnts[ex][ey];
                break;
            }
        }
        if (0 < cnt)
        {
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
/*input
314159265 358979323846264338
*/
#include <iostream>
using namespace std;
typedef long long lol;

int main() {
	lol x, y, ans = 0;
	cin >> x >> y;
	lol now = x;
	while (now <= y && now > 0) {
		ans += 1;
		now *= 2;
	}
	cout << ans << '\n';
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> W(N);
  int sum = 0, ans = (int)1e9;
  for(int i = 0; i < N; ++i) {
    cin >> W[i];
    sum += W[i];
  }
  int left = 0, right = sum;
  for(int i = 0; i < N; ++i) {
    left += W[i];
    right -= W[i];
    ans = min(ans, abs(left-right));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;
 
public class Main{
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		HashMap<Integer,Integer>suu=new HashMap<>();
		Scanner sc=new Scanner(System.in);
		
		int N=sc.nextInt();
		int M=sc.nextInt();
		int errorCount=0;
		int count=0;
		
		if(N==1&&M==0) {
			count++;
		}
		
		for(int i=0;i<M;i++) {
			int key=sc.nextInt();
			int value=sc.nextInt();
			if(suu.containsKey(key)&&!(suu.get(key)==value)) {
				errorCount++;
			}else {
				suu.put(key,value);
			}
		}
		
		for(int i=1;i<=N;i++) {
			if(i==1) {
				if(suu.containsKey(1)){
					if(suu.get(1)==0&&N!=1) {
						errorCount++;
					}
				}else if(!suu.containsKey(1)) {
					suu.put(1, 1);
				}
			}
			
			if(!suu.containsKey(i)) {
				suu.put(i, 0);
			}
		
			
			if(errorCount==0&&count==0) {
				System.out.print(suu.get(i));
				}
		}	
	
		if(errorCount!=0) {
			System.out.println(-1);
		}else if(suu.size()==0) {
			System.out.println(1);
		}else if(count!=0) {
			System.out.println(M);
		}
	}
 
}

Measured memory_bytes: 22100
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

int main() {
    int N;
    cin >> N;
    vector<char> v(N);
    vector<vector<int>> dp(N + 1, vector<int>(N + 1, 0));
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    int res = 0;
    for (int i = N - 1; i >= 0; i--) {
        for (int j = N - 1; j >= i; j--) {
            if (v[i] == v[j]) {
                dp[i][j] = dp[i + 1][j + 1] + 1;
            } else {
                dp[i][j] = 0;
            }
            int len = min(dp[i][j], j - i);
            res = max(res, len);
        }
    }
   
    cout<< res <<endl;
    return 0;
}



Measured memory_bytes: 98176
package main

import (
  "fmt"
)

func abs(a int) int {
	if (a < 0) {
		return -a
	}
	return a
}

func min(a, b int) int {
	if (a < b) {
		return a
	}
	return b
}

func main() {
	var n int
	fmt.Scan(&n)
	var a, dp [100001]int
	dp[0] = 0
	for i := 0; i < n; i++ {
		fmt.Scan(&(a[i]))
		if i > 0 {
			dp[i] = dp[i - 1] + abs(a[i] - a[i - 1])
		}
		if i > 1 {
			dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]))
		}
	}
	fmt.Println(dp[n-1])
}

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

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define li long long
#define ld long double
#define x first
#define y second
#define pt pair<int, int>
#define pll pair<ll, ll>
#define forn(i, t) for(int i = 0; i < (t); i++)
#define fore(i, f, t) for(int i = (f); i < (t); i++)
#define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
#define all(x) (x).begin(), (x).end()
#define ins insert

using namespace std;


const int INF = 1e9;
const int MOD = 1e9 + 7;
const li INF64 = 1e18;
const ld EPS = 1e-7;

mt19937 myrand(time(NULL));

const int N = 100 * 1000 + 13;

int n;
int a[N], ans;
vector<int> g[N];


bool read(){
	if(scanf("%d", &n) != 1)
		return 0;
	forn(i, n)
		g[i] = vector<int>();
	ans = 1;
	forn(i, n - 1){
		scanf("%d", &a[i]);
		g[--a[i]].pb(i + 1);
	}
	return 1;
}

int dfs(int v){
	vector<int> ch;
	for (auto u : g[v])
		ch.pb(dfs(u));
	sort(all(ch), greater<int>());
	int mx = 0;
	forn(i, sz(ch))
		mx = max(mx, ch[i] + i + 1);
	return mx;
}


void solve(){
	printf("%d\n", dfs(0));
}


int main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
	#endif
	while(read())
		solve();
	return 0;
}

Measured memory_bytes: 17376
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;

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

const int kMaxN = 100000;

int n;
int lr[kMaxN][2];
int ans;

int is_prime[kMaxN+1];
int prime2_count[kMaxN+1];

int main() {
  cin >> n;
  REP(i, n) { cin >> lr[i][0] >> lr[i][1]; }

  fill(is_prime+2, is_prime+kMaxN+1, 1);
  FOR(i, 2, 317) {
    if (is_prime[i]) {
      int j = 2*i;
      while (j <= kMaxN) {
        is_prime[j] = 0;
        j += i;
      }
    }
  }

  prime2_count[1] = 0;
  for (int i = 3; i <= kMaxN; i += 2) {
    if (is_prime[i] && is_prime[(i+1)/2]) {
      prime2_count[i] = prime2_count[i-2] + 1;
    } else {
      prime2_count[i] = prime2_count[i-2];
    }
  }

  REP(i, n) {
    if (lr[i][0] == 1) {
      if (lr[i][1] == 1) {
        ans = 0;
      } else {
        ans = prime2_count[lr[i][1]];
      }
    } else {
      ans = prime2_count[lr[i][1]] - prime2_count[lr[i][0] - 2];
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2176
#!/usr/bin/python

import sys
def readints():
    return map(int, sys.stdin.readline().split())

n, k = readints()

while n and k:
    xs = [False for i in range(n+2)]
    for i in range(k):
        x, = readints()
        xs[x] = True

    last = 0
    before = 1
    longest = 0
    #print 'i, longest, last, before'
    for i in range(1, n+2):
        x = xs[i]
        if x:
            pass
        elif xs[0]:
            """
            0123456789
            0-x--x--x-
            i = 8

            """
            #print i, longest, last, before
            longest = max(longest, i - last -1, i - before -1)
            before = last
            last = i
        else:
            longest = max(longest, i - last-1)
            last = i
    print longest
    n, k = readints()

Measured memory_bytes: 8316
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,m,ans;

const int mod = 1e9 + 7;

int f(int x)
{
	int pr = 1;
	for(int i = 1;i <= x;i++) pr *= i,pr %= mod;
	return pr;
}

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n >> m;
    if(abs(n - m) > 1) rc(0);
    if(n == m) rc((1LL * ((f(n) * f(m)) % mod) * 2) % mod);
	rc(1LL * (((1LL * f(min(n,m)) * f(min(n,m))) % mod) * max(n,m)) % mod);
}


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

int main() {
    int N, M, C; cin >> N >> M >> C;
    vector<int> A, B;
    int a_tmp, b_tmp;
    for (int i = 0; i < M; i++) {
        cin >> b_tmp;
        B.push_back(b_tmp);
    }
    for (int i = 0; i < N * M; i++) {
        cin >> a_tmp;
        A.push_back(a_tmp);
    }
    int count = 0, s, sum = 0;
    for (int i = 0; i < N; i++) {
        s = i * M;
        sum = 0;
        for (int j = 0; j < M; j++) {
            sum += A[s+j] * B[j];
        }
        sum += C;
        if (sum > 0) count++;
    }
    cout << count << endl;
    return 0;
}


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

#define lli long long int
#define mpr make_pair
#define par pair<lli,lli>
#define pb push_back
#define vl vector<lli>
#define mp map<lli,lli>
#define all(x) x.begin(),x.end()
#define FOR(i,n) for(lli i=0;i<(lli)n;i++)
#define FOR1(i,j,n) for(lli i=j;i<(lli)n;i++)
#define mod 1000000007

lli power(lli x,lli n,lli m)
{
	lli res=1;
	while(n>0)
	{
		if(n&1) res=(res*x)%m;
		x=(x*x)%m;
		n=n>>1;
	}
	return res%m;
}

lli modInverse(lli n,lli  p)
{
	return power(n,p-2,p);
}

lli nCr(lli n,lli r,lli p,lli fac[])
{
	if(r==0)
	return 1;
	return ((fac[n]* modInverse(fac[r], p) % p )%p* 
            modInverse(fac[n-r], p) % p) % p; 
		}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli k;
    cin>>k;
    string s;
    cin>>s;
    lli l=s.length();
    lli n=k+l;
    lli fac[n+1];
    vl pr(n+1);
    pr[0]=1;
    for(lli i=1;i<=n;i++)
    pr[i]=(pr[i-1]*25)%mod; 
    fac[0] = (lli)1; 
    for (lli i=1;i<=n;i++) 
       fac[i] = fac[i-1]*i%mod; 
    lli r1=power(26,n,mod),r2=0;
    for(lli m=0;m<l;m++)
    r2=(r2+nCr(n,m,mod,fac)*pr[n-m])%mod;
    r2%=mod;
	r1=(r1-r2+mod)%mod;
	cout<<r1<<endl;
	
	
	
return 0;
}


Measured memory_bytes: 35620
import numpy as np
from sys import stdin,stdout
n=int(stdin.readline())
inf=1000000007
# arr = [int(x) for x in stdin.readline().split()] 
a = np.asarray((stdin.readline()+" 0 0").split(), dtype=np.int64)
dp=np.full((n+2),inf,dtype=np.int64)
dp[0]=0
for i in range(n):
    dp[i+1]=min(dp[i+1],dp[i]+abs(a[i+1]-a[i]))
    dp[i+2]=min(dp[i+2],dp[i]+abs(a[i+2]-a[i]))
# print(dp)
print(dp[n-1])


Measured memory_bytes: 37904
#include <cstdio>
#include <climits>

using std::scanf;
using std::printf;

int main() {
    int n, v;
    scanf("%d", &n);
    unsigned long min = ULONG_MAX, max = 1;
    for (int i = 0; i < n; i++) {
        scanf("%d", &v);
        if (v < min) min = v;
        if (v > max) max = v;
    }

    printf("%lu\n", max - min);
    return 0;
}


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

A = list(map(int,input().split()))

even = 0
bai = 0
for i in range(N):
    if A[i] % 2 == 0:
        even = even + 1
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            bai = bai + 1
    i = i + 1
    
if even == bai:
    print("APPROVED")
else:
    print("DENIED")
            
            

Measured memory_bytes: 3060
let n = Scanf.scanf " %d" (+) 0
let vs = Array.init n @@ fun _ -> Scanf.scanf " %f" (+.) 0.
let ans, p = Array.sort compare vs; ref vs.(0), ref vs.(0)
let _ = Printf.printf "%.9f\n" @@ Array.fold_left (fun a v -> (a +. v) /. 2.) vs.(0) vs

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcountll
#define setbitcnt __builtin_ctz
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define roundup(a,b)  std::cout << std::fixed;std::cout << std::setprecision(b); std::cout << a
const int siz = (1e5 + 10);
const int logi = 21;
const double epsilon = 1e-6;
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

vector<int> vt[siz];
int arr[siz];
int s[siz];
int level[siz];
int visited[siz];

int root(int x)
{
	while(x != arr[x])
	{
		arr[x] = arr[arr[x]];
		x = arr[x];
	}

	return x;
}

void uni(int a,int b)
{
	int root_a = root(a);
	int root_b = root(b);

	if(root_a == root_b)
	{
		return ;
	}

	if(s[root_a] > s[root_b])
	{
		s[root_a] += s[root_b];
		arr[root_b]  = root_a;
	}
	else
	{
		s[root_b] += s[root_a];
		arr[root_a] = root_b;
	}


}

void bfs()
{
	visited[1] = 1;
	level[1] = 1;
	queue<int> q;
	q.push(1);

	while(!q.empty())
	{
		int parent = q.front();
		q.pop();

		for(int i = 0 ; i < vt[parent].size() ; i++)
		{
			if(visited[vt[parent][i]] == 0)
			{
				q.push(vt[parent][i]);
				level[vt[parent][i]] = level[parent] + 1;
				visited[vt[parent][i]] = 1;
			}
		}
	}
}


signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		
		int n,m;
		cin>>n>>m;

		for(int i = 0 ; i < m ; i++)
		{
			int u,v;
			cin>>u>>v;

			vt[u].push_back(v);
			vt[v].push_back(u);

			uni(u,v);
		}

		bfs();
		int flag = 0;
		vector<int> ans;
		for(int i = 2 ; i <= n ; i++)
		{
			if(root(i) != root(1))
			{
				flag = 1;
				break;
			}

			int maxi = INT_MAX;
			int par = -1;
			for(int j = 0 ; j < vt[i].size() ; j++)
			{
				if(maxi > level[vt[i][j]])
				{
					maxi = level[vt[i][j]];
					par = vt[i][j];
				}
			}

			ans.push_back(par);
		}

		if(flag == 1)
		{
			cout<<"No";
		}
		else
		{
			cout<<"Yes\n";
			for(int i = 0 ; i < ans.size() ; i++)
			{
				cout<<ans[i]<<"\n";
			}
		}
	}
}

Measured memory_bytes: 15308
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int main(){
    char s[20];
    RS(s);
    int n=LEN(s);
    for(int i=1;i<n;i++){
        if(s[i]=='C'&&s[i-1]=='A')return 0*puts("Yes");
    }
    return 0*puts("No");
}


Measured memory_bytes: 256
/**Test**/
import java.util.*;
public class Main {
	static Scanner s = new Scanner(System.in);
	public static void main(String __[]){
		int in[]= {s.nextInt(),s.nextInt(),s.nextInt()};
		Arrays.sort(in);
		System.out.println(in[0]==5&&in[1]==5&&in[2]==7?"YES":"NO");
	}
}

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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}


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

    int a, b;
    cin >> a >> b;
    if(a <= 0 && b >= 0) cout << "Zero" << endl;
    else {
        int l = max(a, (int)-1e9);
        int r = min(-1, b);
        if(r >= l && (r-l+1)%2 == 1) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }
}





Measured memory_bytes: 3604
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, a, b = LI()
H = IR(n)
ok = 10 ** 9
ng = 0
while ok > ng + 1:
    mid = (ok + ng) // 2
    ret = 0
    for h in H:
        remain = h - b * mid
        if remain > 0:
            ret += remain // (a - b) + bool(remain % (a - b))
    if ret <= mid:
        ok = mid
    else:
        ng = mid


print(ok)

Measured memory_bytes: 45404
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let (mut a, mut b) = {
        let line = get_input();
        let mut split = line.split_whitespace();
        let a:u64 = split.next().unwrap().parse().unwrap();
        let b:u64 = split.next().unwrap().parse().unwrap();
        (a, b)
    };

    let mut ans = 0;

    for _ in 0..2 {
        if a > b {
            ans += a;
            a -= 1;
        } else {
            ans += b;
            b -= 1;
        }
    }

    println!("{}", ans);
}

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

int H,W;

int main(){
  cin >> H >> W;
  string board[H*W];
  for(int i=0; i<H; i++) cin >> board[i];
  const int dx[4] = {1,0,-1,0};
  const int dy[4] = {0,1,0,-1};
  
  for(int y=0; y<H; y++){
    for(int x=0; x<W; x++){
      if(board[y][x]=='.') continue;
      bool flg = false;
      for(int k=0; k<4; k++){
        if(y+dy[k]<0 || y+dy[k]>=H || x+dx[k]<0 || x+dx[k]>=W) continue;
        if(board[y+dy[k]][x+dx[k]] == '#') flg = true;
      }
      if(!flg){
        cout << "No" << endl;
        return 0;
      }      
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3680
#include<iostream>
using namespace std;
int dp[100005][3],a[3][100005];
int n;
int rec(int i,int ch){
	if(i>=n)return 0;
	if(dp[i][ch])return dp[i][ch];
	dp[i][ch]=a[ch][i];
	return dp[i][ch]=dp[i][ch]+max(rec(i+1,(ch+1)%3),rec(i+1,(ch+2)%3));
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[0][i]>>a[1][i]>>a[2][i];
	}
	int ans=rec(0,0);
	ans=max(ans,rec(0,1));
	ans=max(ans,rec(0,2));
	cout<<ans;
}

Measured memory_bytes: 8832
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if (p[i] < p[i + 1] && p[i + 1] < p[i + 2]) {
			ans++;
		}
		else if (p[i] > p[i + 1] && p[i + 1] > p[i + 2]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

int main() {
  long N, M, C;
  cin >> N >> M >> C;
  vector<long> B(M);
  long a;
  long cnt = 0;
  long accum;
  REP(i, M) { cin >> B[i]; }
  REP(i, N) {
    accum = C;
    REP(j, M) {
      cin >> a;
      accum += a * B[j];
    }
    if (accum > 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
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;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////
int a[200010];
int cnt[200010];
int main() {
	int n; cin >> n;
	REP(i, n-1) {
		cin >> a[i];
		a[i]--;
		cnt[i] = 0;
	}
	REP(i, n) {
		cnt[a[i]]++;
	}
	REP(i, n) {
		if (i == 0)cout << cnt[i]-1 << endl;
		else cout << cnt[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main(){
 	int a, b, c, tmp;
  cin >> a >> b >> c;
  tmp = a;
  a = b;
  b = tmp;
  tmp = a;
  a = c;
  c = tmp;
  cout << a << " " << b << " " << c << endl;  
}

Measured memory_bytes: 256
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=x && x<w && 0<=y && y<h)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;
typedef pair<int, int> P;
const int MAX = 2*123500;

/** Problem2253 : Brave Force Story **/
int T;
const int dx0[6]={0, 1, 1, 0, -1, -1};
const int dy0[6]={1, 1, 0, -1, -1, 0};
int ans;
set<P> vis;
typedef struct {
	P pos; int cost;
} S;

int main()
{
	int n, sx, sy;
	while (cin>>T>>n, T||n) {
		vis.clear();
		ans=0;
		
		rep(k, n) {
			int x, y;
			cin>>x>>y;
			vis.insert(P(x, y));
		}
		cin >> sx >> sy;
		
		S s = {P(sx, sy), 0};
		queue<S> Q;
		Q.push(s);
		vis.insert(s.pos);
		
		while (Q.size()) {
			S t = Q.front(); Q.pop();
			//cout << t.pos.first << " " << t.pos.second << endl;
			rep(i, 6) {
				int nx=t.pos.first+dx0[i], ny=t.pos.second+dy0[i];
				if (vis.find(P(nx, ny)) == vis.end() && t.cost+1<=T) {
					S ns = {P(nx, ny), t.cost+1};
					Q.push(ns);
					vis.insert(ns.pos);
				}
			}
		}
		cout << vis.size()-n << endl;
	}
	return 0;
}

Measured memory_bytes: 1360
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,m;cin>>n>>m;
  map<ll,map<ll,ll>> mp;
  rep(i,n){
    ll x;cin>>x;
    mp[x%m];
    mp[x%m][x]++;
    mp[x%m][-1]++;
  }
  ll ans = 0;

  rep(x, m){
    if(x*2 > m){
      break;
    }
    if(x == 0 || x*2 == m){
      ans += mp[x][-1]/2;
      continue;
    }

    ll l = x;
    ll r = m - x;
    if(mp[l][-1] < mp[r][-1]){
      swap(l,r);
    }
    //l >= r

    for(auto itr2 = mp[l].begin(); itr2 != mp[l].end(); itr2++){
      if(itr2->first == -1) continue;
      if(mp[l][-1] <= mp[r][-1]){
        break;
      }
      while(mp[l][-1] > mp[r][-1] && itr2->second >= 2){
        itr2->second -= 2;
        mp[l][-1] -= 2;
        ans++;
      }
    }
    ans += min(mp[l][-1], mp[r][-1]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 22144
//夏合宿の朝は早い
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
#define MAX_V 500
int V;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
vector<int> vG[MAX_V];
bool used[MAX_V];
int cmp[MAX_V];

void add_edge(int from, int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v){
    used[v] = true;
    for(int i = 0; i < (int)G[v].size(); i++){
        if(!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.push_back(v);
}

void rdfs(int v, int k){
    used[v] = true;
    cmp[v] = k;
    vG[k].push_back(v);
    for(int i = 0; i < (int)rG[v].size(); i++){
        if(!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
}

int scc(){
    memset(used, false, sizeof(used));
    vs.clear();
    for(int v = 0; v < V; v++){
        if(!used[v]) dfs(v);
    }
    memset(used, false, sizeof(used));
    int k = 0;
    for(int i = V - 1; i >= 0; i--){
        if(!used[vs[i]]) rdfs(vs[i], k++);
    }
    return k;
}

int main(){

    while(cin >> V, V){

        //初期化
        for(int i = 0; i < MAX_V; i++){
            G[i].clear();
            rG[i].clear();
            vG[i].clear();            
        }

        //入力受け取り
        vector<double> p(V);
        for(int i = 0; i < V; i++){
            int m;
            cin >> p[i] >> m;
            for(int j = 0; j < m; j++){
                int to; cin >> to; to--;
                add_edge(i, to);
            }
        }

        int k = scc();

        /*cout << k << endl;
        for(int i = 0; i < k; i++){
            cout << i << endl;
            for(int j = 0; j < vG[i].size(); j++){
                cout << vG[i][j] << " ";
            }
            cout << endl;
        }*/

        double ans = 1.0;
        for(int i = 0; i < k; i++){
            bool flag = true;              //入次数が0であるか
            double res = 1.0;

            //強連結成分をすべてなめる
            for(int j = 0; j < (int)vG[i].size(); j++){
                res *= p[vG[i][j]];

                //その頂点は入り次数0ですか？(逆辺をすべてなめる)
                for(int l = 0; l < (int)rG[vG[i][j]].size(); l++){
                    flag &= (cmp[vG[i][j]] == cmp[rG[vG[i][j]][l]]);
                }
            }

            if(flag){
                //cout << ans << endl;
                //cout << res << endl;
                //cout << 1.0 - res << endl;
                //cout << ans * (1.0 - res) << endl;                
                ans *= (1.0 - res);
                //cout << ans << endl;
            }
        }

        printf("%.10lf\n", ans);
    }

    return 0;
}


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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long max = a * c;
  if (max < a * d) max = a * d;
  if (max < b * c) max = b * c;
  if (max < b * d) max = b * d;
  cout << max;
}


Measured memory_bytes: 3632
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
#include <cstdlib>

int chh(int Cx, int Cy,int H, int x, int y, int h ){

  int h_est = H - abs(Cx - x) - abs(Cy - y);
  if (h_est < 0) {
    h_est = 0;
  }

  return h_est == h;
}

int main(int argc, char const *argv[]) {

  int NN;
  std::cin >> NN;
  int x[NN],y[NN],h[NN];

  // std::cout << "chhhheck" << '\n';



  for (size_t i = 0; i < NN; i++) {
    std::cin >> x[i]>>y[i]>>h[i];
  }

  int h_min = 1e9;
  for (size_t i = 0; i < NN; i++) {
    if (h[i] < h_min) {
      h_min = h[i];
    }
  }

  if (h_min != 0) {
    h_min += -1;
  }

  for (size_t i = 0; i < NN; i++) {
    h[i] = h[i] - h_min;
  }

  int ans_H, ans_x, ans_y;

  for (size_t i_x = 0; i_x < 101; i_x++) {
    for (size_t i_y = 0; i_y < 101; i_y++) {
      for (size_t i_h = 1; i_h < 401; i_h++) {
        int csum_eq_NN = 0;
        for (size_t i_n = 0; i_n < NN; i_n++) {
          csum_eq_NN += chh(i_x, i_y, i_h, x[i_n], y[i_n], h[i_n]);
        }
        if (csum_eq_NN == NN) {
          ans_x = i_x;
          ans_y = i_y;
          ans_H = i_h + h_min;
          break;
        }
      }
    }
  }

  std::cout <<ans_x << " "<<ans_y << " " <<ans_H << '\n';


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


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


ll lcm(ll number1,ll number2){
	return number1 * number2 / gcd(number1,number2);	
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll l = b - a + 1;
    ll res = 0;
    ll lc = lcm(c, d);
    res += (b / c - (a - 1) / c);
    res += (b / d - (a - 1) / d);
    res -= (b / lc - (a - 1) / lc);
    res = l - res;
    cout << res;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>
#include <time.h>


int main(void){
    long N;
    std::cin >> N;
    bool flag=0;
    clock_t start = clock();    // スタート時間
    for(long i=1; i<=N; i++){
        long lim=std::sqrt(i);
        if(lim*lim!=i){
            lim++;
        }
        long count=0;
        for(long j=1;j<=lim;j++){
            for(long k=1; k<=lim;k++){
                long num=i-j*k-j*j-k*k;
                if(num>0){
                    double t=(-(j+k)+std::sqrt((j+k)*(j+k)+4*num))/2;
                    long r=t;
                    if(r*r+j*j+k*k+j*k+k*r+r*j==i){
                        count++;
                    }else if(j*j+k*k+(r+1)*(r+1)+(r+1)*j+(r+1)*k+j*k==i){
                        count++;
                    }else if(j*j+k*k+(r-1)*(r-1)+(r-1)*j+(r-1)*k+j*k==i){
                        count++;
                    }
                }
            }
        }
        std::cout << count << std::endl;
    }
    //std::cout << "duration = " << (double)(clock() - start) / CLOCKS_PER_SEC << "sec.\n";
    return 0;
}

Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

/////////////         modの計算

int mod = 1000000007;

long long mod_adjust(long long a) {//	余りをとる(0～mod-1に調整する)
	if (a > mod) {
		return a % mod;
	}
	if (a < 0) {
		a *= -1;
		a %= mod;
		return mod - a;
	}
	return a;
}
int mod_adjust(int a) {//	余りをとる(0～mod-1に調整する)
	return (int)mod_adjust((long long)a);
}
int mod_add(int a, int b) {//	足し算
	a = mod_adjust(a), b = mod_adjust(b);
	long long k = a % mod; k += b % mod; k %= mod;
	return (int)k;
}
int mod_sub(int a, int b) {//	引き算
	long long k = mod_adjust((long long)a); k += mod_adjust((long long)b); k %= mod;
	return (int)k;
}
int mod_multi(int a, int b) {//	掛け算
	long long k = mod_adjust((long long)a); k *= mod_adjust((long long)b); k %= mod;
	return (int)k;
}
int mod_inv(int a) {//	逆元
	a = mod_adjust(a);
	if (a == 1) { return 1; }
	long long p = mod, q = a, m = 0, n = 1, r, c;

	while (q > 1) {
		r = p % q;
		c = p / q;
		c = mod_adjust(m - n * c);
		p = q, m = n, q = r, n = c;
	}
	return n;
}
int mod_div(int a, int b) {//	割り算
	return mod_multi(a, mod_inv(b));
}
int mod_pow(int x, int n) {//	累乗(logNオーダーなので速い)
	if (n < 0) {
		return mod_pow(mod_div(1, x), -n);
	}
	if (n == 0) {
		return 1;
	}
	if (n == 1) {
		return x;
	}
	if (n % 2 == 0) {
		int k = mod_pow(x, n / 2);
		return mod_multi(k, k);
	}
	else {
		int k = mod_pow(x, n / 2);
		return mod_multi(mod_multi(k, k), x);
	}
}

int* factorial = NULL;			//	階乗
int* factorial_inv = NULL;		//	階乗の逆元

//	階乗を事前に計算しておく関数。
//	Nはmod_combination(n, r)で呼び出されうる最大の数。
void calc_factorial(int N) {////////////////////////// 初めに必ず呼び出すこと！！！
	factorial = new int[N + 1];
	factorial_inv = new int[N + 1];

	factorial[0] = 1;
	factorial_inv[0] = 1;
	for (int i = 1; i <= N; i++) {
		factorial[i] = mod_multi(factorial[i - 1], i);
		factorial_inv[i] = mod_inv(factorial[i]);
	}
}
int mod_combination(int n, int r) {//	nCr	を計算する
	if (n < 0 || r < 0 || r > n) { return 0; }
	return mod_multi(factorial[n], mod_multi(factorial_inv[n - r], factorial_inv[r]));
}

int main() {
	/*
	
	NM_C_K 通りの配置に対して

	K_C_2 通りのマンハッタン距離を計算して

	足し合わせる

	マンハッタン距離の期待値 = (マンハッタン距離の総和の NM_C_2 分 の 1 倍)をK_C_2倍してNM_C_K倍すればいい

	*/
	int N, M, K;
	cin >> N >> M >> K;

	calc_factorial(210000);

	long* a = new long[210000];// 三角数
	a[0] = 0;
	for (long i = 1; i < 210000; i++) {
		a[i] = mod_add(a[i - 1], i);
	}

	long distSum = 0;
	{
		// 横がNマスの場合、i = 0 to N-1
		// i の左側はa[i] * M^2
		for (int i = 0; i < N; i++) {
			distSum = mod_add(distSum, mod_multi(M, mod_multi(a[i], M)));
		}
		for (int i = 0; i < M; i++) {
			distSum = mod_add(distSum, mod_multi(N, mod_multi(a[i], N)));
		}

		distSum = mod_div(distSum, mod_combination(N * M, 2));
	}

	distSum = mod_multi(mod_combination(K, 2), distSum);
	distSum = mod_multi(distSum, mod_combination(N * M, K));

	cout << distSum << endl;

	return 0;
}

Measured memory_bytes: 3584
// by DenyTianly
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>

using namespace std;

#define iScf(n) scanf("%d", &n)
#define dug() printf("ok!\n")
#define iNxtL() puts("")
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define nrep(i, val, n) for(int i = val; i < n; i++)
#define ipq priority_queue
typedef long long LL;
typedef unsigned long long ULL;

const int inf = 1 << 26;
const LL INF = 1LL << 60;

inline void quick_IO() { ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); }
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar())
		if(ch == '-') f = -f;

	for(; ch >= '0' && ch <= '9'; ch = getchar())
		x = x*10+ch-'0';

	return x*f;
}

// Don't hack me, please ~
// #define _Isopen_File_
// #define _Is_Close_STD_

char a[55][55], b[55][55];
int n, m;

bool cont(int x1, int y1, int x2, int y2) {
	int ci = 0, cj = 0;
	for ( int i = x1; i <= x2; i ++, ci ++) {
		for( int j = y1; j <= y2; j ++, cj++ ) {
			if(a[i][j] != b[ci][cj]) return false;
		}
		cj = 0;
	}
	return true;
}

int main(){

#ifdef _Isopen_File_
	freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
#endif

#ifdef _Is_Close_STD_
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif

	// freopen("B.in", "r", stdin);
	scanf("%d %d", &n, &m);
	for ( int i = 0; i < n; i ++ ) scanf("%s", a[i]);
	for ( int j = 0; j < m; j ++ ) scanf("%s", b[j]);

	for ( int i = 0; i <= n-m; i ++ ) {
		for ( int j = 0; j <= n-m; j ++ ) {
			if(cont(i, j, i+m-1, j+m-1)){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");

	return 0;
}

Measured memory_bytes: 256
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define sz(a)  int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1};
const int dw[8] = {0, 0, 1, -1,1,-1,1,-1};
typedef long long ll;
typedef pair<int, int> p;
typedef vector <int> VI;
typedef vector <string> VS;

vector <int> his;

int main(){

	string s;
	cin >> s;

	int n = s.size();
	VI table(26, -1);	
	
	for(int i = 0; i < n; i++){
		if(table[s[i] - 'a'] == -1){
			table[s[i] - 'a'] = i;
		}else if(table[s[i] - 'a'] < i - 2){
			table[s[i] - 'a'] = i;
		}else{
			cout << table[s[i] - 'a']+1 << " " << i+1 << endl;
			return 0;
		}
	}	

	cout << -1 << " " << -1 << endl;
	return 0;	
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int a,b,c;
	int ans=0;
	cin >>a>>b>>c;
	ans=a+b+c;
	cout<<solve(ans==a*2 or ans==b*2 or ans==c*2)<<endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i

kyori = {}
hen = Array.new(n+1){Array.new()}
lines = readlines
lines.each do |line|
  u,v,w = line.chomp.split().map(&:to_i)
  kyori[[u,v]] = w
  kyori[[v,u]] = w
  hen[u].push v
  hen[v].push u
end

ans = Array.new(n+1, nil)
ans[1] = 1
q = [1]
while !q.empty?
  ten = q.shift
  hen[ten].each do |i|
    next unless ans[i].nil?
    q.push i if
      if ans[ten] == 1 && kyori[[ten,i]].even?
        ans[i] = 1
      elsif ans[ten] == 1 && kyori[[ten,i]].odd?
        ans[i] = 0
      elsif ans[ten] == 0 && kyori[[ten,i]].even?
        ans[i] = 0
      elsif ans[ten] == 0 && kyori[[ten,i]].odd?
        ans[i] = 1
      end
  end
end

ans.each do |an|
  puts an
end


Measured memory_bytes: 50172
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<vector<int> > c(3, vector<int>(3, 0));
  REP(i, 3){
    REP(j, 3){
      cin >> c[i][j];
    }
  }
  
  bool flag = false;
  REP(i, 101){
    int b0 = c[0][0] - i, b1 = c[0][1] - i, b2 = c[0][2] - i;
    if(b0 < 0 || b1 < 0 || b2 < 0) continue;
    REP(j, 101){
      if(c[1][0] != b0 + j || c[1][1] != b1 + j || c[1][2] != b2 + j) continue;
      REP(k, 101){
        if(c[2][0] != b0 + k || c[2][1] != b1 + k || c[2][2] != b2 + k) continue;
        flag = true;
      }
    }
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>

int main(void) {
  int n, i, j, max = 0;
  scanf("%d", &n);
  int ar[n][6];
  std::vector<int> va, vh, vb;
  for(i = 0; i < n; ++i) {
    for(j = 0; j < 6; ++j) {
      int h, m;
      scanf("%d%d", &h, &m);
      ar[i][j] = h * 60 + m;
      if(j < 2) va.push_back(ar[i][j]);
      else if(j > 3) vb.push_back(ar[i][j]);
      else vh.push_back(ar[i][j]);
    }
  }
  /*for(i = 0; i < n; ++i) {
    for(j = 0; j < 6; ++j) printf("%3d ", ar[i][j]);
    printf("\n");
  }*/
  std::sort(va.begin(), va.end());
  std::sort(vb.begin(), vb.end());
  std::sort(vh.begin(), vh.end());
  va.erase(std::unique(va.begin(), va.end()), va.end());
  vb.erase(std::unique(vb.begin(), vb.end()), vb.end());
  vh.erase(std::unique(vh.begin(), vh.end()), vh.end());
  /*for(auto it = va.begin(); it != va.end(); ++it) printf("%3d ", *it);
  printf("\n");
  for(auto it = vh.begin(); it != vh.end(); ++it) printf("%3d ", *it);
  printf("\n");
  for(auto it = vb.begin(); it != vb.end(); ++it) printf("%3d ", *it);
  printf("\n");*/
  auto ita = va.begin();
  for(; ita != va.end(); ++ita) {
    auto ith = vh.begin();
    for(; ith != vh.end(); ++ith) {
      auto itb = vb.begin();
      for(; itb != vb.end(); ++itb) {
        int t = 0;
        for(i = 0; i < n; ++i) {
          if(ar[i][0] <= *ita && *ita <= ar[i][1] && ar[i][2] <= *ith && *ith <= ar[i][3] && ar[i][4] <= *itb && *itb <= ar[i][5])++t;
        }
        if(t > max) max = t;
      }
    }
  }
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 2828