akhauriyash/Code-Regression huggingface dataset:
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    Cins(S);
    map<char,int> m;
    rep(i,N)m[S[i]]++;
    int ans = 1;
    for(auto count:m){
        (ans*=count.second+1)%=MOD;
    }
    cout << ans -1 << nn;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x[2];
	while (cin >> x[0], cin >> x[1], !(x[0] == 0 && x[1] == 0))
	{
		sort(x, x + 2);
		cout << x[0] << " " << x[1] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX],n;

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

    int maxv = -2000000000;
    int minv = R[0];

    for(int i = 1; i < n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> vec(M*2);
  for (int i=0; i<2*M; i++){
  	cin >> vec.at(i);
  }
  
  for (int j=0; j < N; j++) {
  	int n = 0;
    for(int k=0; k < 2*M; k++){
    	if (vec.at(k) == j+1){
        	n++;
        }
    }
    cout << n <<endl;
  }

  
}

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

def digit(a):
  a = list(str(a))
  a = [int(i) for i in a]
  return(sum(a))

ans = 9*8
for i in range(1, N//2+1):
  tmp = digit(i) + digit(N-i)
  ans = min(ans,tmp)

print(ans)

Measured memory_bytes: 3060
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        char c;
        cin >> c;
        if (c >= 'a' && c <= 'z')
            cout << 'a' << endl;
        else
            cout << "A" << endl;
    }
    return 0;
}


Measured memory_bytes: 3644
def resolve():
    # 整数 1 つ
    n = input()
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]
    m = n[:3] + "8" + n[4:]

    print(m)


resolve()

Measured memory_bytes: 38384
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def readln(ch):
    _res = list(map(int,str(input()).split(ch)))
    return _res

n = int(input())
a = readln(' ')
e = [set([]) for i in range(0,n+1)]
for i in range(1,n):
    s = readln(' ')
    e[s[0]].add(s[1])
    e[s[1]].add(s[0])
rt = 1
now = n
v = [0 for i in range(0,n+1)]
q = v[:]
q[now] = rt
v[rt] = 1
for i in range(1,n):
    s = q[n-i+1]
    for p in e[s]:
        if v[p] == 0:
            v[p] = 1
            now = now - 1
            q[now] = p

res = 'YES'
up = [0 for i in range(0,n+1)]
for i in range(1,n+1):
    k = q[i]
    if len(e[k]) == 1:
        sum = a[k-1]
    else:
        sum = a[k-1] * 2
    up[k] = sum
    for son in e[k]:
        up[k] = up[k] - up[son]
        if up[son] > a[k-1] and len(e[k]) > 1: res = 'NO'
    if up[k] < 0:
        res = 'NO'
    if len(e[k]) > 1 and up[k] > a[k-1]:
        res = 'NO'

if up[rt] != 0 : res = 'NO'
print(res)


Measured memory_bytes: 44404
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	ll res = 0;
	int tmpC = C * 2;
	if(A + B <= tmpC) {
		res = A * X + B * Y;
		cout << res << endl;
	} else {
		if(X < Y) {
			res += (tmpC * X);
			Y -= X;
			if(tmpC < B) res += tmpC * Y;
			else res += B * Y;
			cout << res << endl;
		} else {
			res += (tmpC * Y);
			X -= Y;
			if(tmpC < A) res += tmpC * X;
			else res += A * X;
			cout << res << endl;
		}
	}

}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	long long int A, B, C;
	cin >> A >> B >> C;
	long long int sum = A + B + C;
	long long int count = 0;
	while (1) {
		if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
			break;
		}
		A = (sum - A)/2;
		B = (sum - B)/2;
		C = (sum - C)/2;
		count++;
		if (A == B && B == C) {
			count = -1;
			break;
		}
		if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
			break;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(){

  int i=0, x[2], y[2], r[2], rplus, rminus,rdistance;

  while(i<2){
    scanf("%d%d%d", &x[i],&y[i],&r[i]);
    i++;
  }

  rdistance = (x[0]-x[1])*(x[0]-x[1]) +	(y[0]-y[1])*(y[0]-y[1]); //２乗すればsqrtが不要               
  rplus = (r[0]+r[1])*(r[0]+r[1]);
  rminus = (r[0]-r[1])*(r[0]-r[1]); //２乗して、|r1-r2|の絶対値を必要なくしている.他も２乗する.       

  if(rdistance > rplus)	printf("4\n");
  else if(rdistance == rplus) printf("3\n");
  else if(rminus < rdistance &&	rdistance < rplus) printf("2\n");
  else if(rdistance == rminus) printf("1\n");
  else if(rdistance < rminus) printf("0\n");



  return 0;
}




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

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;

int tc, q;
map<int, int> factorize(long long n)
{
    map<int, int> factors;
    int count = 0;

    while (!(n % 2)) {
        n >>= 1;
        count++;
    }

    if(count)factors[2] = count;

    for (long long i = 3; i <= sqrt(n); i += 2) {
        count = 0;
        while (n % i == 0) {
            count++;
            n = n / i;
        }
        if (count)
            factors[i] = count;
    }

    if (n > 2)
        factors[n] = 1;
    return factors;
}



void _() {
    ll tc, a, b, c, d;
    cin >> tc;
    while(tc --){
        cin >> a >> b >> c >>d;
        if(b>d || a<b){
            cout << "No\n";
            continue;
        }
        else{
            ll g = __gcd(b,d);
            ll s = a - (a-c-1)/g*g;
            if(s < b){
                cout << "No\n";
                continue;
            }
            cout << "Yes\n";
        }
    }

};


int main() {
#if __MINGW32__
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Input.txt", "r", stdin);
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Output.txt", "w", stdout);

#endif

    _();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    return 0;

}

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

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << double(abs(W*H)/2) << " ";
    if(x == W/2 && y == H/2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


LL calcsum(int N){
    return (N+1)*(N)/2;
}

LL between(int l, int r){
    return calcsum(r) - calcsum(l);
}
LL sumtoidx(int S){
    return (-1+sqrt(1+2*S))/(2);
}
void solve(long long N, long long K, long long S){
    REP(i, K){
        cout<<S<<" ";
    }
    REP(i, N-K){
        if(S !=999999733){
            cout<<999999733<<" "<<endl;
        }else{
            cout<<999999734<<" "<<endl;
        }
    }
    cout<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long S;
    scanf("%lld",&S);
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 1280
<?php
fscanf(STDIN, "%d %d %d", $p, $q, $r);

$root1 = $p + $q;
$root2 = $r + $q;
$root3 = $p + $r;
$root4 = $q + $r;
$root5 = $r + $p;
$root6 = $q + $p;

$array = array($root1,$root2,$root3,$root4,$root5,$root6);

$r = min($array);

echo $r;

Measured memory_bytes: 4728
from copy import deepcopy
from collections import deque
import sys

M = []
H = 0
W = 0
qx = deque()
qy = deque()
qc = deque()

def main():
    global M,H,W
    H,W = map(int, input().split())  
    for i in range(H):
        M.append(list(input()))

    startX = 0
    startY = 0
    dot = 0
    for i in range(H):
        for j in range(W):
            if M[i][j]=='.':
                dot += 1
    
    cnt = bfs(0,0)
    if(cnt>=0):
        print(dot-cnt)
    else:
        print(-1)

def bfs(y,x):
    global M,H,W
    Mtemp = deepcopy(M)
    Mtemp[y][x] = '#'
    qx.append(x)
    qy.append(y)
    qc.append(1)

    while len(qx) !=0:
        x =  qx.popleft()
        y =  qy.popleft()
        cnt = qc.popleft()
        if(x==W-1 and y==H-1):
            return cnt

        if x-1>=0:
            if Mtemp[y][x-1] == '.':
                Mtemp[y][x-1] = '#'
                qx.append(x-1)
                qy.append(y)
                qc.append(cnt+1)
        if x+1<W:
            if Mtemp[y][x+1] == '.':
                Mtemp[y][x+1] = '#'
                qx.append(x+1)
                qy.append(y)
                qc.append(cnt+1)
        if y-1>=0:
            if Mtemp[y-1][x] == '.':
                Mtemp[y-1][x] = '#'
                qx.append(x)
                qy.append(y-1)
                qc.append(cnt+1)
        if y+1<H:
            if Mtemp[y+1][x] == '.':
                Mtemp[y+1][x] = '#'
                qx.append(x)
                qy.append(y+1)
                qc.append(cnt+1)

    return -1




if __name__ == '__main__':
    main()



Measured memory_bytes: 3572
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		int N = keyboard.nextInt();
		int K = keyboard.nextInt();
		int[] H = new int[N];
		for(int n=0; n<N; n++) {
			H[n] = keyboard.nextInt();
		}
		Arrays.parallelSort(H);
		
		int ans = Integer.MAX_VALUE / 2;
		for(int k=0; k+K-1<N;k++) {
			if(H[k+K-1]-H[k]<ans) {
				ans = H[k+K-1]-H[k];
			}
		}
		
		System.out.println(ans);
		keyboard.close();
	}
}

Measured memory_bytes: 59808
#include<iostream>
#include<algorithm>
#define chkmin(x,y) x=min(x,y)
#define ll long long
using namespace std;
const int Md = 1000000007;
int n, m, k, tim, top = 0, low[55], dfn[55];
bool vis[55];
ll mi[210], ans = 1, fac[210], ifac[210], inv[210];
struct edge
{
	int t; bool vis;
	edge* nx, * rev;
}*con[55], * st[110];

void ins(int x, int y)
{
	edge* p = new edge;
	p->t = y; p->vis = 0; p->nx = con[x]; con[x] = p;
}

ll ksm(ll a, int b)
{
	ll r = 1;
	for (; b; b >>= 1)
	{
		if (b & 1)r = r * a % Md;
		a = a * a % Md;
	}
	return r;
}

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

void tarjan(int v, edge* fro)
{
	dfn[v] = low[v] = ++tim;
	for (edge* p = con[v]; p; p = p->nx)
		if (!p->vis && !p->rev->vis)
		{
			st[++top] = p; p->vis = p->rev->vis = 1;
			if (!dfn[p->t])
			{
				tarjan(p->t, p);
				chkmin(low[v], low[p->t]);
				if (low[p->t] >= dfn[v])
				{
					bool cir = 1; int cnt = 0; ll cal = 0;
					for (int i = top; st[i + 1] != p; cnt++, i--)
						if (vis[st[i]->t]) cir = 0;
						else vis[st[i]->t] = 1;
					if (cir)
					{
						for (int i = 0; i < cnt; i++)
							cal = (cal + mi[gcd(cnt, i)]) % Md;
						cal = cal * inv[cnt] % Md;
					}
					else cal = fac[cnt + k - 1] * ifac[cnt] % Md * ifac[k - 1] % Md;
					ans = ans * cal % Md;
					for (; st[top + 1] != p; top--) vis[st[top]->t] = 0;
				}
			}
			else chkmin(low[v], dfn[p->t]);
		}
}

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	mi[0] = 1;
	for (int i = 1; i <= m; i++) mi[i] = mi[i - 1] * k % Md;
	fac[0] = 1;
	for (int i = 1; i <= m + k; i++) fac[i] = fac[i - 1] * i % Md;
	ifac[m + k] = ksm(fac[m + k], Md - 2);
	for (int i = m + k - 1; i >= 0; i--) ifac[i] = ifac[i + 1] * (i + 1) % Md;
	for (int i = 1; i <= m + k; i++) inv[i] = ifac[i] * fac[i - 1] % Md;
	for (int i = 1; i <= m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		ins(x, y); ins(y, x);
		con[x]->rev = con[y]; con[y]->rev = con[x];
	}
	for (int i = 1; i <= n; i++)
		if (!dfn[i]) tarjan(i, NULL);
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
# 整数 a と、英小文字からなる文字列 s が入力
# a が 3200以上なら s と出力し、 a が 3200 未満なら red と出力
# 2800≤a<5000
# sは長さ 1 以上 10 以下の文字列である。
# s の各文字は英小文字である。

# 入力された値を数値と文字列として扱う
a = int(input())
s = input()
# print(a)
# print(s)

# 条件分岐
if a >= 3200:
    print(s)
else:
    print('red')

Measured memory_bytes: 9128
object Main extends App {
	val Array(l, r) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	if(r - l >= 2019){
		println(0)
	}else{
		val a = l % 2019
		val b = r % 2019

		if(a == 0 || b == 0){
			println(0)
		}else if(a < b){
			var ans = Int.MaxValue
			for(i<-a until b){
				for(j<-i+1 to b){
					ans = math.min(ans, (i*j)%2019)
				}
			}

			println(ans)

		}else{
			println(0)
		}
	}
}

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

/*
A, Bがたかだか100なので、1から10000まで全探索かな
*/

int main() {
    int A, B;
    cin >> A >> B;

    int ans = -1;
    for (int i = 1; i <= 1250; i++)
    {
        /* code */
        if (floor(i*0.08) == A && floor(i*0.1) == B) {
            ans = i;
            break;
        }
    }
    
    cout << ans << endl;

}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string ans = "No";
    for(int i=1; i<=9; i++) {
        for(int j=1; j<=9; j++) {
            if(i*j==n){
                ans ="Yes";
                break;
            }
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;

 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

int n , g = 0 , mx = -1 , k ;  

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k ;
	while ( n -- ) {
		int x ;
		cin >> x ;
		g = __gcd ( x , g ) ;
		smax ( mx , x ) ; 
	}
	if ( mx < k || k % g )
		cout << "IMPOSSIBLE" ;
	else
		cout << "POSSIBLE" ;
	cout << '\n' ;
}


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

int main() {
    int n,cnt;
    bool terusan=false;
    cin >> n;
    for (int i=0; i < n; i++) {
        int a,b;
        cin >> a >> b;
        if (cnt==3) {
            break;
        }
        if (a==b) {
            terusan=true;
            cnt+=1;
        } else {
            terusan=false;
            cnt=0;
        }
    }

    if (cnt==3 && terusan==true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int N;
int A[210];

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }

  int ans = 0;

  while (true){
    bool odd = false;
    for (int i = 0; i < N; i++){
      if (A[i] % 2 != 0) {
        odd = true;
      }
    }

    if (odd == true) break;

    for (int i = 0; i < N; i++){
      A[i] /= 2;
    }
    
    ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
var lines =[];
var readline = require("readline");
var rl = readline.createInterface({
  input:  process.stdin,
  output: process.stdout
});

rl.on('line',function(x){
  lines.push(x);
});

rl.on('close',function(){
  var n = Number(lines[0]);
  var h = lines[1].split(" ");
  var ite = 0;
  var flag = false;

  var zero= Array(h.length);
  zero.fill(0);

  while(h.toString() !== zero.toString()){
    for(var i=0;i<h.length;i++){
      if(Number(h[i])>0){
        flag = true;
        h[i] = Number(h[i]) -1;
      }
      else{
        if(flag === true){ite++;}
        flag = false;
      }
    }
    if(flag === true){ite++;}
    flag = false;
  }
  console.log(ite);
});


Measured memory_bytes: 21448
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var a = Number(lines[0].split(' ')[0]);
 var b = Number(lines[0].split(' ')[1]);
 var x, y;
 var ans = '';
 // x = x - 2;
 // y = y - 6;

 if(b % 2 !== 0){
   ans = 'No';
 }else{
		x = (4 * a - b) / 2;
		y = (- 2 * a + b) / 2;
		if(x < 0 || y < 0){
			ans = 'No';
		}
		else{
			// outputobj.innerHTML = "鶴は " + x + " 羽、";
			// outputobj.innerHTML += "亀は " + y + " 匹です。";
			ans = 'Yes';
		}
	}

  console.log(ans);
});

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

using namespace std;

typedef unsigned long long ll;
ll dp[100001];

const ll num = 1000000007;

ll solve(int a){
    dp[0] = 1;
    for(int i = 0 ; i < a ; i++){
        dp[i + 1] = (i + 1) * dp[i] % num;
    }
    return dp[a];
}
int main(){
    int n; scanf("%d" , &n);
    cout << solve(n) << endl;
}


Measured memory_bytes: 1024
(let* ((n (read))
       (a (make-array (list (1+ n))))
       (ans (make-array (list (1+ n))))
       (m 0))
  (loop :for i :from 1 :to n
        :do (setf (aref a i) (read)))
  ;
  (loop :for i :downfrom n :to 1
        :for z := (loop :for j :from (* 2 i) :to n :by i
                        :sum (aref ans j))
        :do (setf (aref ans i) (if (= (mod z 2) (aref a i)) 0 1))
        :do (incf m (aref ans i)))
  ;
  (format t "~A~%" m)
  (loop :for i :from 1 :to n
        :if (= (aref ans i) 1)
        :do (format t "~A " i))
  (format t "~%"))


Measured memory_bytes: 80412
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using i64=int_fast64_t;
    i64 a;
    const i64 MOD=1000000007;
    modint(i64 a_=0){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a,MOD=_.MOD;
    while(b){
        if(b&1) (n*=A)%=MOD;
        (A*=A)%=MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

class FUnhappyHacking {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,m;
        string s;
        in>>n>>s;
        m=s.length();
        vector<modint> dp(n+1),ndp(n+1);
        dp[0]=1;
        fr(i,n){
            fr(j,n){
                ndp[j+1]+=dp[j]*2;
                if(j) ndp[j-1]+=dp[j];
                else ndp[0]+=dp[0];
            }
            dp.swap(ndp);
            ndp.assign(n+1,0);
        }
        out<<dp[m]*pwr(2,m).inv()<<endl;
    }
};

int main() {
    FUnhappyHacking solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int n, a[100004], b[100004], c[100004], dp[100004][3];

int main() {
	cin>>n;
	for(int i = 1; i<= n ; i++)	cin>>a[i]>>b[i]>>c[i];
	dp[1][0] = a[1], dp[1][1] = b[1], dp[1][2] = c[1];
	for(int i = 2;i<=n;i++){
		dp[i][0] = max(dp[i-1][2],dp[i-1][1])+a[i];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c[i];
	}
	cout<<*max_element(dp[n],dp[n]+3);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    
    ll p = (a1 - b1) * t1, q = (a2 - b2) * t2;

    if (p == -q) {
        cout << "infinity" << endl;
        return 0;
    }
    
    if (p > 0) {
        p = -p;
        q = -q;
    }

    if (p > 0 && q > 0 || p < 0 && q < 0 || p + q < 0) {
        cout << 0 << endl;
        return 0;
    }

    ll t = (-p) / (q + p), m = (-p) % (q + p);

    ll ans;
    if (m) {
        ans = 2 * t + 1;
    } else {
        ans = 2 * t;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    ll ans = 0;

    ll n, r;
    cin >> n >> r;

    if (n < 10) r += 100 * (10 - n);

    

    cout << r << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<tuple>
#include<set>
#include<string.h>
char str[8010];
const int offset = 8000;
bool dyX[offset * 2 + 1][2];
bool dyY[offset * 2 + 1][2];
int main() {
	int x, y;
	scanf("%s%d%d", str, &x, &y);
	std::vector<int> X, Y;
	int sum = 0;
	bool flag = false;
	for (int i = 0; str[i]; i++) {
		if (str[i] == 'F') {
			sum++;
		}
		else {
			if (!flag) {
				X.push_back(sum);
			}
			else {
				Y.push_back(sum);
			}
			flag = !flag;
			sum = 0;
		}
	}
	if (!flag) {
		X.push_back(sum);
	}
	else {
		Y.push_back(sum);
	}

	int mx = offset;
	int Mx = offset+X[0];
	int my = offset;
	int My = offset;
	bool xflag = false;
	bool yflag = false;
	dyX[X[0]+offset][0] = true;
	dyY[0+offset][0] = true;
	for (int i = 1; i < X.size(); i++) {
		for (int p = mx; p <= Mx; p++)dyX[p][!xflag] = false;
		for (int p = mx; p <= Mx; p++) {
			if (dyX[p][xflag]) {
				dyX[p + X[i]][!xflag] |= dyX[p][xflag];
				dyX[p - X[i]][!xflag] |= dyX[p][xflag];
				mx = std::min(mx, p - X[i]);
				Mx = std::max(Mx, p + X[i]);
			}
		}
		xflag = !xflag;
	}
	for (int i = 0; i < Y.size(); i++) {
		for (int p = my; p <= My; p++)dyY[p][!yflag] = false;
		for (int p = my; p <= My; p++) {
			if (dyY[p][yflag]) {
				dyY[p + Y[i]][!yflag] |= dyY[p][yflag];
				dyY[p - Y[i]][!yflag] |= dyY[p][yflag];
				my = std::min(my, p - Y[i]);
				My = std::max(My, p + Y[i]);
			}
		}
		yflag = !yflag;
	}
	if (dyX[x + offset][xflag] && dyY[y + offset][yflag]) {
		printf("Yes");
	}
	else {
		printf("No");
	}

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
uint32_t euclidean_gcd(uint32_t a, uint32_t b){
        return b != 0 ? euclidean_gcd(b, a % b) : a;
}    

int main(){
    int n,max;
    cin >> n;
    VI a(n);
    REP(i,n){
        cin >> a[i];
    }
    max = a[0];
    REP(i,n){
        max = euclidean_gcd(max,a[i]);
    }
    cout << max <<endl;
    return 0;
}
   


Measured memory_bytes: 640
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, m, d ] :: [ Double ] <- map read . words <$> getLine
	let
		k = if d == 0 then 1 else 2
	printf "%0.12f\n" $ ( m - 1 ) * k * ( n - d ) / ( n ^ 2 )

Measured memory_bytes: 508
S=input()

ans=False

if len(S)%2==0:
    if S=='hi':
        ans=True
    elif S=='hihi':
        ans=True
    elif S=='hihihi':
        ans=True
    elif S=='hihihihi':
        ans=True
    elif S=='hihihihihi':
        ans=True
    else:
        pass
else:
    pass

if ans==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
a, b, c = gets.split.map(&:to_i)

i = 0
loop do
    unless [a, b, c].all?{|d|d%2==0}
        puts i
        exit
    end
    if a == b && b == c
        puts -1
        exit
    end
    a, b, c = (b+c)/2, (c+a)/2, (a+b)/2
    i += 1
end

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    // ostr << p.first << ", " << p.second;
    ostr << "(" << p.first << ", " << p.second << ")";
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll v(n); v[i]=x;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll v(m,vll(n)); v[i][j]=x;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll v(n); v[i]=make_pair(x,y); v[i].first/second;
// v.front() : v[0]
// v.back()  : v[v.size()-1]

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF ((ll)1e+12)
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    fix(10);
    ll r;
    cin >> r;
    cout << 2*r*PI << endl;
    return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main(){
    string S;
    long long K;
    cin >> S >> K;
    
    for(int i = 0; i < K; i++){
        if(S[i] != '1'){
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << "1" << endl;


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

int main() {
    int n, k; cin >> n >> k;
    vector<ll> num(k, 0);
    for(int i = 1; i <= n; i++) num[i%k]++;
    ll res = 0;
    rep(a, k){
        int b = (k-a) % k;
        int c = (k-a) % k;
        if((b+c) % k != 0) continue;
        res += num[a] * num[b] * num[c];
    }
    cout << res << ln;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 200005
#define M 200005
#define seed 23333
#define Mo 998244353

using namespace std;
int i,j,m,n,p,k,l[N],r[N],a[N];
long long ans;
int main()
{
		scanf("%d",&n);
		for (i=1;i<=n;++i)  scanf("%d",&a[i]);
		for (i=1;i<=n;++i)
		{
				l[i]=i-1;
				while (a[l[i]]>=a[i]) l[i]=l[l[i]];
		}
		for (i=n;i;--i) 
		{
				r[i]=i+1;
				while (a[r[i]]>a[i]) r[i]=r[r[i]];
		}
		for (i=1;i<=n;++i) ans+=1ll*a[i]*(r[i]-i)*(i-l[i]);
		cout<<ans<<endl;
}


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

//H行W列のどこかの行、列(複数でも良い)を赤で塗りつぶす
//黒いマスがK個残る塗り方は何通り
int main(){
    int H,K,W;
    cin >> H >> W >> K;
    string c[H];
    int count=0;

    for(int i=0;i<H;i++){
        cin >> c[i];
    }
   
    for(int bit_l=0; bit_l < (1<<H); ++bit_l){
        for(int bit_c=0; bit_c < (1<<W); ++bit_c){
            int black=0;
            for(int i=0;i<H;++i){
                for(int j=0;j<W;++j){
                    if(!((bit_l & (1<<i)) || (bit_c & (1<<j)) || c[i][j]=='.')){
                        ++black;
                    }
                }
            }
            if(black==K){
                ++count;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include<string.h>
using namespace std;

int main()
{
    char S[100];
    cin>>S;
    int N=strlen(S);
    for(int i=0;i<N;i++)
    {
        S[i]='x';
        cout<<S[i];
    }


    return 0;
}


Measured memory_bytes: 256
import qualified Data.IntMap as M
import Data.Array.IO
import Data.Maybe (fromJust)
import Data.List
import Control.Monad
import Control.Applicative

type Arr = IOUArray Int Bool
type Edge = (Int, Int)
type Weight = Int
type Vertex = (Int, Weight)
--key:頂点番号, value:隣接点集合
type GraphW = M.IntMap Neighbor
--key:ある点の隣接点の頂点番号, value:辺の重さ
type Neighbor = M.IntMap Weight

main = do
  n <- readLn :: IO Int
  red <- map ((\[x, y] -> (read x, read y)) . words) <$> replicateM n getLine :: IO [(Int, Int)]
  blue <- map ((\[x, y] -> (read x, read y)) . words) <$> replicateM n getLine :: IO [(Int, Int)]
  let rr = zip red [1..n]
      bb = zip blue [n+i | i <- [1..n]]
      edge = concat $ map (check rr) bb
      graph = foldl' makeGraphW M.empty edge
      graph' = foldl' makeGraphW graph [(0, i) | i <- [1..n]]
      graph'' = foldl' makeGraphW graph' [(n+i, 2*n+1) | i <- [1..n]]
  (ans, g) <- fordFulkerson (2*n+1) (0, graph'') 0
  print ans

check :: [((Int, Int), Int)] -> ((Int, Int), Int) -> [(Int, Int)]
check [] _ = []
check (((a, b), i):xx) ((c, d), j) =
  if a < c && b < d
    then (i, j) : check xx ((c, d), j)
    else check xx ((c, d), j)


--Ford-Fulkerson
inf = 10^8

fordFulkerson :: Int -> (Int, GraphW) -> Int -> IO (Int, GraphW)
fordFulkerson dst (flow, graph) v = do
  used <- newArray (0, dst) False :: IO Arr
  (f, g) <- dfsFF used v dst (inf, graph)
  if f == 0
    then return (flow, g)
    else fordFulkerson dst (flow + f, g) v

dfsFF :: Arr -> Int -> Int -> (Int, GraphW) -> IO (Int, GraphW)
dfsFF used v dst (flow, graph)
  | v == dst = return (flow, graph)
  | otherwise = do
    writeArray used v True
    let ne = M.lookup v graph
    if ne /= Nothing
      then do
        dfsFF' used v dst (flow, graph) $ fst . unzip . M.toList $ fromJust ne
      else return (0, graph)

dfsFF' :: Arr -> Int -> Int -> (Int, GraphW) -> [Int] -> IO (Int, GraphW)
dfsFF' _    _ _   (flow, graph) []      = return (0, graph)
dfsFF' used v dst (flow, graph) (to:ts) = do
  isMark <- readArray used to
  let cap = fromJust $ M.lookup to $ fromJust $ M.lookup v graph
  if not isMark && cap > 0
    then do
      (f, g) <- dfsFF used to dst (min flow cap, graph)
      if f > 0
        then do
          let neV = M.adjust (subtract f) to $ fromJust $ M.lookup v g
              g' = M.insert v neV g
              neTo = M.adjust (+f) v $ fromJust $ M.lookup to g'
              g'' = M.insert to neTo g'
          return (f, g'')
        else dfsFF' used v dst (flow, graph) ts
    else dfsFF' used v dst (flow, graph) ts


--重み付き隣接リスト
makeGraphW :: GraphW -> Edge -> GraphW
makeGraphW graph (x, y) =
  let nX = M.lookup x graph
      nY = M.lookup y graph
      vX = if nX == Nothing
             then M.insert x (addNeighbor (y, 1) M.empty) graph
             else M.insert x (addNeighbor (y, 1) $ fromJust nX) graph
  in if nY == Nothing
       then M.insert y (addNeighbor (x, 0) M.empty) vX
       else M.insert y (addNeighbor (x, 0) $ fromJust nY) vX

addNeighbor :: Vertex -> Neighbor -> Neighbor
addNeighbor (i, weight) ne = M.insert i weight ne


Measured memory_bytes: 3836
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
int main(){
	int N,M;
	ll A[100000];
	ll Asum[100000];
	ll sousuu=0;
	std::map <ll,ll> Asumkosu;
	scan(N);scan(M);
	rep(i,N){
		ll kazu;
		scan(kazu);
		A[i]=kazu%M;
		if(i!=0) Asum[i]=(Asum[i-1]+A[i])%M;
		else Asum[i]=A[i];
		if(Asumkosu.find(Asum[i])==Asumkosu.end()){
			Asumkosu[Asum[i]]=1;
		}
		else Asumkosu[Asum[i]]++;
	}
	if(Asumkosu.find(0)==Asumkosu.end()){
		Asumkosu[0]=1;
	}
	else Asumkosu[0]++;
	for(auto i=Asumkosu.begin();i!=Asumkosu.end();i++){
		sousuu+=(i->second)*((i->second)-1)/2;
	}
	prin(sousuu);
	return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[7];
int d[7];
int dp[8][1001];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%d%d",c+i,d+i);
		}
		for(int i=0;i<8;i++)
			for(int j=0;j<1001;j++)
				dp[i][j]=0;
		dp[0][0]=1;
		for(int i=0;i<a;i++){
			for(int j=0;j<1001;j++){
				if(dp[i][j]){
					for(int k=0;k<=d[i];k++){
						if(j+k*c[i]>1000)break;
						dp[i+1][j+k*c[i]]+=dp[i][j];
					}
				}
			}
		}
		int b;
		scanf("%d",&b);
		for(int i=0;i<b;i++){
			int e;
			scanf("%d",&e);
			printf("%d\n",dp[a][e]);
		}
	}
}

Measured memory_bytes: 1052
#!/usr/bin/env python
#-*- coding:utf-8 -*-
 
import sys
import math
 
n = int(input())
 
for data in sys.stdin:
    x1, y1, x2, y2, x3, y3 = map(float, data.split())
    a1 = x2 - x1
    b1 = y2 - y1
    a2 = x3 - x1
    b2 = y3 - y1
    px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))
    py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))
    r = math.sqrt(px * px + py * py)
    px += x1
    py += y1
    print("{0:.3f} {1:.3f} {2:.3f}".format(px, py, r))

Measured memory_bytes: 7672
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

int n, a[N], k;
string s, t;

int32_t main(){_

   cin >> n >> k;

   vector<int> v[150];
   for (int i = 0; i < k; ++i)
   {
      int x;
      cin >> x;

      for (int j = 0; j < x; ++j)
      {
         int y;
         cin >> y;
         v[y].push_back(j);
      }
   }

   int ans = 0;

   for (int i = 1; i <= n; ++i)
   {
      ans += v[i].empty();
   }
   
   cout<<ans;

   return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

const int mod = 1000000007;

struct Mod {
  int n;
  Mod () : n(0) {;}
  Mod (int m) : n(m) {
    if (n >= mod) n %= mod;
    else if (n < 0) n = (n % mod + mod) % mod;
  }
  operator int() { return n; }
};

bool operator==(Mod a, Mod b) { return a.n == b.n; }
Mod operator+=(Mod &a, Mod b) { a.n += b.n; if (a.n >= mod) a.n -= mod; return a; }
Mod operator-=(Mod &a, Mod b) { a.n -= b.n; if (a.n < 0) a.n += mod; return a; }
Mod operator*=(Mod &a, Mod b) { a.n = ((long long)a.n * b.n) % mod; return a; }
Mod operator+(Mod a, Mod b) { return a += b; }
Mod operator-(Mod a, Mod b) { return a -= b; }
Mod operator*(Mod a, Mod b) { return a *= b; }
Mod operator^(Mod a, int n) {
  if (n == 0) return Mod(1);
  Mod res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}

ll inv(ll a, ll p) {
  return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
Mod operator/(Mod a, Mod b) { return a * Mod(inv(b, mod)); }

#define MAX_N 1001

Mod fact[MAX_N], factinv[MAX_N];
void init() {
  fact[0] = Mod(1); factinv[0] = 1;
  REP(i,MAX_N-1) {
    fact[i+1] = fact[i] * Mod(i+1);
    factinv[i+1] = factinv[i] / Mod(i+1);
  }
}
Mod comb(int a, int b) {
  return fact[a] * factinv[b] * factinv[a-b];
}

Mod memo[MAX_N][MAX_N];
int N, A, B, C, D;

Mod dp(int i, int j) {
  if(i < 0 || j < 0) return Mod(0);
  if(memo[i][j].n != 0) return memo[i][j];
  if(i < A) {
    if(j > 0) return memo[i][j] = Mod(0);
    else return memo[i][j] = Mod(1);
  }
  if(j == 0) return memo[i][j] = Mod(1);

  Mod res = dp(i - 1, j);
  for(int k = C; k <= D; ++k) {
    if(j - i * k < 0) break;
    Mod tmp = dp(i - 1, j - i * k) * fact[N - j + i * k] * factinv[N - j] * factinv[k];
    REP(l,k) tmp *= factinv[i];
    res += tmp;
  }

  return memo[i][j] = res;
}

int main(){
  cin >> N >> A >> B >> C >> D;

  init();
  REP(i,MAX_N)REP(j,MAX_N) memo[i][j] = Mod(0);

  cout << dp(B, N).n << endl;
  return 0;
}



Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string b = Console.ReadLine();
            int A = int.Parse(b);
            int an;
            an = A / 2 * (A - A / 2);
            Console.Write(an);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    double a,b,c,d,e,f;
    while(cin >> a >> b >> c >> d >> e >> f)
        printf("%.3f %.3f\n",((e*c-b*f)/(a*e-b*d)==-0.0? 0.0:(e*c-b*f)/(a*e-b*d)),((a*f-c*d)/(a*e-b*d)==-0.0? 0.0:(a*f-c*d)/(a*e-b*d)));
    return 0;
}

Measured memory_bytes: 1236