akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>



using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a)

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef  long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const double EPS = 1e-7;
const int MAX = 20 * 1000 + 47;
const int MAS = 1e5 * 6;
const int MOD = 1000 * 1000 * 1000 + 7;

double DIST(double x1, double x2, double y1, double y2)
{
    return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}

int main()
{
    int n;
    cin >> n; 
    VI dp(n);
    rep(day, n)
    {
        VI new_dp(3, 0);
        VI a(3);
        rep(i, 3)
        {
            cin >> a[i];
        }
        rep(i, 3)
        {
            rep(j, 3)
            {
                if (i != j)
                {
                    new_dp[j] = max(new_dp[j], dp[i] + a[j]); 
                }
            }
        }
        dp = new_dp; 
    }
    cout << max({ dp[0],dp[1],dp[2] }); 

   
}










Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func() uint64 {
		sc.Scan()
		i, _ := strconv.ParseUint(sc.Text(), 10, 64)
		return i
	}

	n := in()

	vc := make(map[uint64]uint64)

	var i uint64
	for i = 0; i < n; i++ {
		vc[in()]++
	}

	var val uint64

	for v, c := range vc {
		for v1, c1 := range vc {
			if v1 > v {
				for v2, c2 := range vc {
					if v2 < (v1+v) && v2 > v1 {
						val += c * c1 * c2
					}
				}
			}
		}
	}

	fmt.Println(val)
}


Measured memory_bytes: 1844
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int k, s;
    cin >> k >> s;

    int i, j, z;
    int ans = 0;
    for(i = 0; i <= k; i ++)
    {
    	for(j = 0; j <= k; j ++)
    	{
    		z = s - i - j;
    		if(z >= 0 && z <= k)
    			ans ++;
    	}
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <complex>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;

const int N = 1e5 + 10;
vector<int> bit[N];

void add(int x, int a){
	for (int i = x; i < N; i += i&-i){
		bit[i].push_back(a);
	}
}

int sum(int x, int Min, int Max){
	int cnt = 0;
	for (int i = x; i > 0; i -= i&-i){
		cnt += upper_bound(ALL(bit[i]), Max) - lower_bound(ALL(bit[i]), Min);
	}
	return cnt;
}

int sum(int l, int r, int Min, int Max){
	return sum(r, Min, Max) - sum(l, Min, Max);
}


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

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n){
		cin >> a[i];
		add(i + 1, a[i]);
	}
	rep(i, N) sort(ALL(bit[i]));

	int q;
	cin >> q;
	while (q--){
		int l, r, e;
		cin >> l >> r >> e;
		--l;

		int ans = r - l;
		int Min = min(a[l], a[r-1]) - e;
		int Max = max(a[l], a[r-1]) + e;
		ans -= sum(l, r, Min, Max);
		cout << ans << '\n';
	}
}

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

using namespace std;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int a[100009];
  for(int b: {0, 1}){
    for(int c: {0, 1}){
      a[1] = b;
      a[2] = c;
      a[0] = (s[1]=='o'?1:0)^b^c;
      for(int i=3;i<n;i++){
        a[i] = (s[i-1]=='o'?1:0)^a[i-1]^a[i-2];
      }
      if((s[n-1]=='o'?1:0)^a[n-1]==a[0]^a[n-2] && (s[0]=='o'?1:0)^a[0]==a[n-1]^a[1]){
        for(int i=0;i<n;i++){
          cout << (a[i]==1?'S':'W');
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}



Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main(void){
    int a;
    int num = 1;
    while(1){
        cin >> a;
        if(a == 0){
            break;
        }
        else{
            cout << "Case "<< num << ":"<< " "<< a << endl;
        }
        num++;
    }
}


Measured memory_bytes: 3052
N=int(input())
A=list(map(int,input().split()))
a=[0]*N
for i in range(N-1):
    a[i]=A[i+1]-A[i]
a[N-1]=A[0]-A[N-1]
S=sum(A)
t=[0]*N
for i in range(0,N,2):
    if i+2==N+1:
        t[1]=t[i]+a[i]*2
    else:
        t[i+2]=t[i]+a[i]*2
for i in range(1,N-2,2):
    t[i+2]=t[i]+a[i]*2
s=sum(t)
d=(S-s)//N
ans=[d+i for i in t]
print(' '.join(map(str,ans)))

Measured memory_bytes: 27172
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}
void swap(int& a, int& b){
	int t=a;
	a = b;
	b = t;
}
 
void solveTest(){
	
	int n;
	cin>>n;
	int a[n];
	int mx=-1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mx = max(a[i],mx);
	}
	int dp[mx+1];
	sort(a,a+n);
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++){
		if(dp[a[i]]==0){
			for(int j=a[i];j<=mx;j+=a[i]){
				dp[j]++;
			}
		}
		else if(dp[a[i]]==1){
			dp[a[i]]++;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(dp[a[i]]==1)cnt++;
	}
	cout<<cnt<<endl;
	return ;
}
 
int main(){
	fastio();
	//input();
 
	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	
	return 0;
}

Measured memory_bytes: 8316
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

typedef pair<ll, ll> pii;
int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> dis(n+1, (ll)INT_MAX*(ll)(INT_MAX-2));
    dis[1] = 0;
    ll l, r, c;
    vector<vector<int>> e;
    for(int i = 0; i < m; i++) {
        cin >> l >> r >> c;
        e.push_back({l, r, c});
    }
    sort(e.begin(), e.end());
    // dijkstra
    int idx = 0; ll so_far = 1;
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    for(int i = 0; i < m;i++) {
        if (e[i][0] <= so_far) {
            pq.push({dis[so_far]+e[i][2], e[i][1]});
            idx = i+1;
            // cout << "push " << e[i][1] << ", dis = " << dis[so_far]+e[i][2] << endl;
        } else {
            break;
        }
    }
    while (!pq.empty()) {
        auto p = pq.top(); pq.pop();
        ll cur_dis = p.first;
        ll dst = p.second;
        //cout << "visit " << dst << ", dis = " << cur_dis << endl;
        if (cur_dis >= dis[dst])
            continue;
        dis[dst] = cur_dis;
        if (dst == n) {
            cout << dis[dst] << endl;
            return 0;
        }
        so_far = dst;
        for(int k = idx; k < m; k++) {
            if (e[k][0] <= so_far) {
                if (e[k][1] <= so_far) continue;
                pq.push({dis[so_far]+e[k][2], e[k][1]});
                // cout << "push " << e[k][1] << ", dis = " << dis[so_far]+e[k][2] << endl;
            } else {
                idx = k;
                break;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 10032
using System;
using System.Text.RegularExpressions;
using System.Text;
using System.Linq;


namespace aizu
{
	public class EntryPoint
	{
		public static int[] Split(string line)
		{
			return Regex.Split(line, " ").Select(x => int.Parse(x)).ToArray();
		}
		public static void Main()
		{
			var line = Console.ReadLine();
			
			var v = Split(line);
			
			if (v[0] < v[1])
			{
				Console.WriteLine("a < b");
			}
			else if (v[0] > v[1])
			{
				Console.WriteLine("a > b");
			}
			else
			{
				Console.WriteLine("a == b");
			}
			
			
		}
	}


}

Measured memory_bytes: 7128
#include <bits/stdc++.h>
#define INF 1e9+7
#define LINf 1e18+7
#define fr first 
#define sc second
#define ll long long
#define pb push_back
#define pii pair<int,int>

using namespace std;
int n, h[100005] , dp[100005],k;

int main(){
	cin >> n >> k;
	for(int i = 1;  i<= n ; i++){cin >> h[i];dp[i]=INF;}
	dp[1] = 0;
	for(int i = 1 ; i <= n ; i++){
		for(int j = i-1 ; j >= max(1,i-k); j--){
			dp[i] = min(dp[i],dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n];
}

Measured memory_bytes: 1152
def pri_me(x):
    if x == 2:
        return True
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            return False
    return True
#print(pri_me(n))


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
if n==1 or n == 0:
    print(0)
    exit()
if pri_me(n):
    print(1)
    exit()
N = n
ans = 0
from collections import Counter
d=prime_factorize(n)
d = sorted(d)
for i in set(d):
    cnt = d.count(i)
    now = 1
    k = 1
    while now <=cnt:
        ans += 1
        k+=1
        now += k
print(ans)

Measured memory_bytes: 68316
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
#define mid ((l+r)>>1)
using namespace std;

typedef long long LL;
int n,k,b[100100],m,l[100100],r[100100];
LL f[100100],a[100100];
struct node
{
    int minw;
    node *lc,*rc;
    node();
} *tp,*root;

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

node::node()
{
    lc=tp,tp=this;
}

node *newnode()
{
    if (!tp)
        new node[50000];
    node *t=tp;
    tp=t->lc,t->lc=t->rc=0,t->minw=1<<30;
    return t;
}

void cover(node *&x,int l,int r,int ql,int qr,int w)
{
    if (qr<l || ql>r)
        return;
    if (!x)
        x=newnode();
    if (ql<=l && qr>=r)
    {
        x->minw=min(x->minw,w);
        return;
    }
    cover(x->lc,l,mid,ql,qr,w);
    cover(x->rc,mid+1,r,ql,qr,w);
}

int query(int p)
{
    node *x=root;
    int l=0,r=k-1,ret=1<<30;
    while (x)
    {
        ret=min(ret,x->minw);
        if (p<=mid)
            x=x->lc,r=mid;
        else
            x=x->rc,l=mid+1;
    }
    return ret;
}

LL calc(int x)
{
    int t=query(x);
    if (t==1<<30)
        return 0;
    return f[t]+(l[t]+k-x)%k;
}

int main()
{
    scanf("%d%d",&n,&k);
    repu(i,1,n)
    {
        a[i]=getint(),b[i]=getint();
        if (b[i]==1 && a[i]*2>k)
        {
            puts("-1");
            return 0;
        }
        a[i]+=a[i-1];
        if (b[i]==1)
        {
            l[++m]=(-a[i-1]*2%k+k)%k;
            r[m]=(-a[i]*2%k+k)%k;
        }
    }
    repd(i,m,1)
    {
        int t=query(l[i]);
        if (t<1<<30)
            f[i]=f[t]+(l[t]+k-l[i])%k;
        if (l[i]<=r[i])
        {
            cover(root,0,k-1,0,l[i]-1,i);
            cover(root,0,k-1,r[i]+1,k-1,i);
        }
        else
            cover(root,0,k-1,r[i]+1,l[i]-1,i);
    }
    LL ans=m?1LL<<60:0;
    repu(i,1,m)
        ans=min(ans,min(calc(l[i]),calc(r[i])));
    printf("%lld\n",ans+a[n]*2);
    return 0;
}

Measured memory_bytes: 63872
n = int(input())
a = [list(map(int,input().split())) for _ in range(2)]

ans = 0
for i in range(n):
  candy = 0
  for j in range(n):
    if j <= i:
      candy += a[0][j]
    if j >= i:
      candy += a[1][j]
  ans = max(ans, candy)

print(ans)

Measured memory_bytes: 3064
n = int(input())
(t, a) = list(map(int, input().split()))
h = list(map(int, input().split()))

neari = None
near = 10000
for i in range(n):
    if near > abs(a - (t - h[i] * 0.006)):
        neari = i
        near = abs(a - (t - h[i] * 0.006))
print(neari + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 998244353
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
char fd[1009][1009];
void fill4(int s){
	string str[4];
	str[0] = "abcc";
	str[1] = "abdd";
	str[2] = "ccab";
	str[3] = "ddab";
	for(int i=0;i<=3;i++){
		for(int j=0;j<=3;j++){
			fd[s+i][s+j]=str[i][j];
		}
	}
}
void fill5(int s){
	string str[5];
	str[0]="abbaa";
	str[1]="ac..b";
	str[2]="bc..b";
	str[3]="b.dda";
	str[4]="aabba";
	for(int i=0;i<=4;i++){
		for(int j=0;j<=4;j++){
			fd[s+i][s+j]=str[i][j];
		}
	}
}
void fill6(int s){
	string str[6];
	str[0]="aa..cd";
	str[1]="bb..cd";
	str[2]="aa..dc";
	str[3]="..bbdc";
	str[4]="..aacd";
	str[5]="..bbcd";
	for(int i=0;i<=5;i++){
		for(int j=0;j<=5;j++){
			fd[s+i][s+j]=str[i][j];
		}
	}
}
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<=1000;i++){
		for(int j=0;j<=1000;j++){
			fd[i][j] = '.';
		}
	}
	if( n == 2 ){ 
		cout<< -1 <<endl;
		return 0;
	}
	else if( n == 3 ){
		fd[0][1] = 'a';
		fd[0][2] = 'a';
		fd[1][0] = 'a';
		fd[2][0] = 'a';
	}
	else if( n == 7 ){
		string str[7];
		str[0] = "ad..d..";
		str[1] = "ad..d..";
		str[2] = "b.ee.ee";
		str[3] = "bd..d..";
		str[4] = "cd..d..";
		str[5] = "c.ee.ee";
		str[6] = ".ccbbaa";
		for(int i=0;i<=6;i++){
			for(int j=0;j<=6;j++){
				fd[i][j]=str[i][j];
			}
		}
	}
	else{
		int n4=0,n5=0,n6=0;
		for(int i=0;i<=250;i++){
			for(int j=0;j<=200;j++){
				int rem = n - 4*i - 5*j;
				if( rem >= 0 && rem%6 == 0 ){
					n4 = i;
					n5 = j;
					n6 = rem/6;
				}
			}
		}
		int cur = 0;
		for(int i=0;i<n4;i++){
			fill4(cur);
			cur += 4;
		}
		for(int i=0;i<n5;i++){
			fill5(cur);
			cur += 5;
		}
		for(int i=0;i<n6;i++){
			fill6(cur);
			cur += 6;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cout<<fd[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int ans[1000+10];
int xl[1000+10];
int len;
int anslen=100000;
vector<int>g[1000+10]; 
bool arr[1000+10]; 
int p=1;
void dfs(int now ,int yb)
{
	if(len+1>anslen)
		return ;
	arr[now]=true;
	xl[len++]=now;
	for(int i=0;i<g[now].size();i++)
	{
		int v=g[now][i];
		if(v==yb)
		{
			if(len<anslen)
			{
				anslen=len;
				for(int k=0;k<len;k++)
					ans[k]=xl[k];
			}
		}
		if(!arr[v])
			dfs(v,yb);
	}
	len--;
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		g[a].push_back(b);
	}
	for(int i=1;i<=n;i++)
	{
			memset(arr,false,sizeof(arr)); 
			dfs(i,i);
	}
	if(anslen!=100000)
	{
		printf("%d\n",anslen);
		for(int i=0;i<anslen;i++)
			printf("%d\n",ans[i]);
	}
	else
		printf("-1\n");
	return 0;
 } 

Measured memory_bytes: 384
num = int(input())

if 400 <= num and num <= 599:
    print("8")
elif num <= 799:
    print("7")
elif num <= 999:
    print("6")
elif num <= 1199:
    print("5")
elif num <= 1399:
    print("4")
elif num <= 1599:
    print("3")
elif num <= 1799:
    print("2")
elif num <= 1999:
    print("1")

Measured memory_bytes: 8976
import sys
import numpy as np


def solve(A, B, N):
    res = 0
    n = 0
    for i in range(N):
        x = min(A[i], B[i] + n)
        res += x
        n = min(B[i] + n - x, B[i])
    res += min(A[N], n)
    return res


line = sys.stdin.readline
N = int(line())
A = np.fromstring(line(), dtype=np.int64, sep=' ')
B = np.fromstring(line(), dtype=np.int64, sep=' ')
print(solve(A, B, N))

Measured memory_bytes: 21272
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
using namespace std;
typedef long long ll;
typedef double db;
const int N=2e5+7;
vector<int> tu[N];
int n,m,S,T,son[N],vis[N],clk,ok[N],p[N],stk[N],top=0,now;
void dfs(int x){
	vis[x]=1;
	for(int i=0;i<tu[x].size();i++){
		int v=tu[x][i];
		if(!vis[v]){
			p[v]=x;
			dfs(v);
			son[x]++;
		}
	}
	if(!son[x])T=x;
}
bool dfs2(int x){
	vis[x]=1;
	for(int i=0;i<tu[x].size();i++){
		int v=tu[x][i];
		if(!vis[v]){
			stk[++top]=v;
			if(dfs2(v))return true;
			top--;
			son[x]++;
		}
	}
	if(!son[x]){
		return true;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int x,y;
	rep(i,1,m){
			scanf("%d%d",&x,&y);
			tu[x].pb(y);
			tu[y].pb(x);
	}
	dfs(1);
	memset(vis,0,sizeof(vis));
	now=T;
	while(now!=1){
		vis[now]=1;
		stk[++top]=now;
		now=p[now];
	}
	stk[++top]=1;
	memset(son,0,sizeof(son));
	dfs2(1);
	printf("%d\n",top);
	rep(i,1,top)printf("%d ",stk[i]);
}

Measured memory_bytes: 15616
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n;
ll A[N];
ll minv;
ll ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>A[i];
    for(int i=1;i<=n;i++)
    {
        if(i==1)
            minv=A[i];
        else
            {
                if(minv>=A[i])
                    ans+=minv-A[i];
                else
                    minv=A[i];
            }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5100
#include<bits/stdc++.h>
using namespace std;
#define ll      long long
#define hell    1000000007
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb      push_back


int main()
{
	ios;
	ll s,w;
	cin>>s>>w;
	if(s<=w)cout<<"unsafe";
	else cout<<"safe";
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(){
	long long h, w;
	cin >> h >> w;
	if (h < w) swap(h, w);
	long long ans = 1e9+10;
		for (int i = 1;i < h;++i) {
			long long a = i * w;
			long long b = ((w + 1) / 2) * (h - i);
			long long c = (w / 2) * (h - i);
			ans = min(ans, max(a, b) - min(a, min(b, c)));
		}
		for (int i = 1;i < w;++i) {
			long long a = i * h;
			long long b = ((h + 1) / 2) * (w - i);
			long long c = (h / 2) * (w - i);
			ans = min(ans, max(a, b) - min(a, min(b, c)));
		}
		ans = min(ans, ((h + 2) / 3) * w - (h / 3)*w);
		ans = min(ans, ((w + 2) / 3) * h - (w / 3)*h);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N;
	LL Z,W;
	cin>>N>>Z>>W;
	vector<LL> A(N);
	int i;
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	if (N==1){
		LL x1=A[0]-W;
		if (x1<0){
			x1=-x1;
		}
		cout<<x1<<endl;
		return 0;
	}
	LL x1=A[N-2];
	LL x2=A[N-1];
	int ab1=x1-x2;
	int ab2=x2-W;
	if (ab1<0){
		ab1=-ab1;
	}
	if (ab2<0){
		ab2=-ab2;
	}
	if (ab1>ab2){
		cout<<ab1<<endl;
	}else{
		cout<<ab2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
int main(){
    int n;
    cin>>n;
    int n1=n/1000;
    n1=n1*1000;
    if(n1 == n){
        cout<<0<<'\n';
    }
    else{
        cout<<((n1+1000)-n)<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
using lint = long long;

using namespace std;

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

  string l;
  cin >> l;
  vector<vector<lint>> dp(l.size(), vector<lint>(2));
  dp[0][0] = 1;
  dp[0][1] = 2;
  rep1(i, l.size() - 1) {
    dp[i][0] = dp[i - 1][0] * 3 + (l[i] == '1' ? dp[i - 1][1] : 0);
    dp[i][1] = l[i] == '1' ? dp[i - 1][1] * 2 : dp[i - 1][1];
    dp[i][0] %= MOD;
    dp[i][1] %= MOD;
  }
  cout << (dp.back()[0] + dp.back()[1]) % MOD << endl;
  return 0;
}

Measured memory_bytes: 5840
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    int n,x,y;cin>>n>>x>>y;
    cout<<min(x,y)<<" "<<max(0, x + y -n)<<endl;
    return 0;
}

Measured memory_bytes: 256
score = [[] for i in range(31)]
while True:
    try:
        p, s = map(int, input().split(","))
        if p == 0:
            break
        score[s].append(p)
    except:
        break

rank = {}
j = 1
for i in range(31)[::-1]:
    if len(score[i]) > 0:
        rank[i] = j
        j += 1

while True:
    try:
        p = int(input())
        for i in range(31):
            if p in score[i]:
                print(rank[i])
    except:
        break



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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	string s;
	cin >> s;

	YesNo(    s[0] == s[1] ? 
		   (  s[2] == s[3] && s[0] != s[2] ) : 
		   ( ( s[0] == s[2] && s[1] == s[3] ) || ( s[0] == s[3] && s[1] == s[2] ) )
		 );

	return 0;
}


Measured memory_bytes: 256
require 'pp'

x, k, d = gets.split.map(&:to_i)
tmp_x = x
tmp_k = k

cnt = (x / d).abs 
if cnt <= k
    if x >= 0
        tmp_x -= cnt * d
        tmp_k -= cnt
    else
        tmp_x += cnt * d
        tmp_k += cnt 
    end
else
    if x >= 0
        tmp_x -= k * d
        tmp_k = 0
        puts tmp_x.abs
        exit 0
    else
        tmp_x += k * d
        tmp_k = 0
        puts tmp_x.abs
        exit 0 
    end
end

if tmp_k % 2 == 0
    puts tmp_x.abs
else
    puts [(tmp_x + d).abs, (tmp_x - d).abs].min
end


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

vector<pair<Int, Int>> prime_factory(Int p) {
    vector<pair<Int, Int>> primes;
    Int tmp_p = p;
    for (Int i = 2; (Int)i*i <= p; i++) {
//cout << "i=" << i << endl;
        if (tmp_p % i != 0) continue;

        int sum = 0;
        while (tmp_p % i == 0) {
            sum++;
            tmp_p /= i;
        }
        primes.push_back(make_pair((Int)i, (Int)sum));
    }
    return primes;
}

int main() {
    Int n, p; cin >> n >> p;
    auto primes = prime_factory(p);
#if 0
    for(auto prime : primes) {
        cout << prime.first << " " << prime.second << endl;
    }
#endif
    int ans = 1;
    if (n == 1) {
        cout << p << endl;
        return 0;
    }
    for(auto prime : primes) {
        int tmp = prime.second / n;
        for (int i = 0; i < tmp; i++) {
            ans *= prime.first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#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>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

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

typedef pair<int, int> pii;
typedef long long ll;

int dx[4][4] = { {-1, -1, 0, 0}, {0, 0, 1, 1}, {0, 0, 1, 1}, {-1, -1, 0, 0} };
int dy[4][4] = { {0, 1, 1, 0}, {0, 1, 1, 0}, {-1, 0, 0, -1}, {-1, 0, 0, -1} };
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

struct frac {
    int a, b;
    bool operator<(const frac &x) const {
        return a*x.b < x.a*b;
    }
};

map<int, map<int, int> > mp;

signed main() {
    int N; cin >> N;

    vector< pair<pii, int> > vs;
    rep(i,0,N) {
        int x, y, w; cin >> x >> y >> w;
        mp[x][y] = w;
        vs.push_back(make_pair( make_pair(x, y), w) );
    }

    frac ans;
    rep(i,0,N) {
        int x = vs[i].first.first, y = vs[i].first.second;
        int w = vs[i].second;
        chmax(ans, frac{w, 1});

        rep(j,0,4) {
            int sum = 0;
            rep(k,0,4) {
                int nx = x + dx[j][k], ny = y + dy[j][k];
                if(!mp.count(nx)) continue;
                if(!mp[nx].count(ny)) continue;
                sum += mp[nx][ny];
            }
            chmax(ans, frac{sum, 1});
        }
    }

    int g = __gcd(ans.a, ans.b);
    ans.a /= g, ans.b /= g;
    printf("%lld / %lld\n", ans.a, ans.b);
    return 0;
}

Measured memory_bytes: 20768
#include <stdio.h>

int main(void)
{
    char s[11];
    int n, k;

    char t;
    int i;

    scanf("%d", &n);
    scanf("%s", s);
    scanf("%d", &k);

    t = s[k-1];

    for(i=0;i<n;i++){
        if(s[i] == t){
            printf("%c", t);
        }else{
            printf("*");
        }
    }

    return 0;
}

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

template <class Itr>
auto Median(Itr first,Itr last){
    typename iterator_traits<Itr>::difference_type n = distance(first, last);
    sort(first,last);
    if(n % 2 == 1){
        return *(first+n/2);
    } else {
        return (*(first+n/2)+*(first+n/2-1))/2;
    }
}

signed main(){
    int n; cin >> n;
    vector<int>v(n);
    int ofs = 1;
    for(auto &i :v)
        cin >> i,i-=ofs++;
    int m = Median(v.begin(), v.end());
    int ans = 0;
    for(auto i :v)ans += abs(i-m);
    cout << ans << endl;
}




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

int main()
{
	int n; cin>>n;
	array<int, 4> a={n/1000, n/100%10, n/10%10, n%10};

    for(int i=0; i<(1<<3); ++i) {
        int x=a[0];
        for(int j=0; j<3; ++j) x+=(i>>j)&1 ? a[j+1] : -a[j+1];
        if (x==7) {
            cout<<a[0];
            for(int j=0; j<3; ++j) cout<<"-+"[(i>>j)&1]<<a[j+1];
            cout<<"=7"<<endl;
            return 0;
        }
    }
}

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

int main(){
  int k;
  cin>>k;
  int sum=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int m=1;m<=k;m++){
         sum+=__gcd(i,__gcd(j,m));
     }
   }
 }
          cout<<sum<<endl;
 return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int x,a,b,m,n;
    while(scanf("%d%d%d",&x,&a,&b)!=EOF)
    {
        if(a>x)
        m=a-x;
        else
        m=x-a;
        if(b>x)
        n=b-x;
        else
        n=x-b;
        if(m>n)
        cout<<"B"<<endl;
        else
        cout<<"A"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)3e5 + 5

//bool cmp(const string& s1,const string &s2) {
//	ll i;
//	for(i=0;;++i) {
//		if(s1[i] == 0 && s[i])
//	}
//}

int main() {
	ll i, j, k, l;
	int N, L;
	cin >> N >> L;
	vector<string> s(N);
	rep(i, N) {
		cin >> s[i];
	}
	sort(ALL(s));
	rep(i, N) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;

int main() {
  int N;
  cin >> N;
  vector<int> nums(100001,0);
  REP(n,N){
    int d;
    cin >> d;
    nums[d] += 1;
  }

  int ans = 0;
  int nL = 0;
  int nR = N;

  REP(n,100001){
    int k = n+1;
    nL += nums[k];
    nR -= nums[k];
    if (nL == nR) ans += 1;
  }
  cout << ans << endl;

}


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

int main() {
  int h, w, num;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) cin >> s.at(i);

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s.at(i).at(j) == '.') {
        num = 0;
        if (i - 1 >= 0 && j - 1>= 0)
          if (s.at(i - 1).at(j - 1) == '#') num++;
        if (i - 1 >= 0)
          if (s.at(i - 1).at(j) == '#') num++;
        if (i - 1 >= 0 && j + 1 < w)
          if (s.at(i - 1).at(j + 1) == '#') num++;
        if (j - 1 >= 0)
          if (s.at(i).at(j - 1) == '#') num++;
        if (j + 1 < w)
          if (s.at(i).at(j + 1) == '#') num++;
        if (i + 1 < h && j - 1 >= 0)
          if (s.at(i + 1).at(j - 1) == '#') num++;
        if (i + 1 < h)
          if (s.at(i + 1).at(j) == '#') num++;
        if (i + 1 < h && j + 1 < w)
          if (s.at(i + 1).at(j + 1) == '#') num++;
        s.at(i).at(j) = num + '0';
      }
    }
  }
  for (int i = 0; i < h; i++) cout << s.at(i) << endl;
}

Measured memory_bytes: 3588
#include <stdio.h>

int n;
int a[15];
int x[15][15],y[15][15];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        for(int j=0;j<a[i];j++)
        scanf("%d %d",&x[i][j],&y[i][j]);
    }

    int max=0;
    for(int i=0;i<1<<n;i++)
    {
        int tmpmax=0;
        bool judge=false;
        for(int j=0;j<n;j++)
        {
            if(i&1<<j)
            {
                tmpmax++;
                for(int k=0;k<a[j];k++)
                {
                    if(y[j][k]==1) if(i&(1<<(x[j][k]-1))) continue;
                    if(y[j][k]==0) if((i&(1<<(x[j][k]-1)))==0) continue;
                    judge=true;
                    break;
                }
            }
            if(judge) break;
        }
        if(!judge)
        {
            // printf("YES %d %d\n",i,tmpmax);
            if(max<tmpmax) max=tmpmax;
        }
    }
    printf("%d\n",max);
}

Measured memory_bytes: 128
import scala.io.Source.stdin

object Main {
  def sieve(n:Int) = {
    val primes = Array.tabulate(n+1) { _ % 2 }
    primes(1) = 0
    primes(2) = 1

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
      if(primes(i) == 1)
        (i*i to n by i*2).foreach { primes(_) = 0 }
    primes
  }

  def main(args:Array[String]) = {
    val p = sieve(51000)
    for(i <- stdin.getLines){
      val n = i.toInt
      val l = (n+1 to 51000).find(p(_)==1).get
      val s = (n-1 to 1 by -1).find(p(_)==1).get
      println(s + " " + l)
    }
  }
}

Measured memory_bytes: 44880
#include<stdio.h>
#include<stdlib.h>
long int max(long int a,long int b)
{
    long int x;
    if(a>=b) x=a;
    else x=b;
    return x;
}
int main()
{
    int x[100],y[100],n,a=0,i,j,CX=0,CY=0,count=0;
    long int h[100],H0=0,H=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d%d%ld",&x[i],&y[i],&h[i]);
    for(i=0;i<n;i++)
        if(h[i]!=0)
        {
            a=i;
            break;
        }
    for(i=0;i<=100;i++)
    {
        for(j=0;j<=100;j++)
        {
            count=0;
            H0=h[a]+abs(x[a]-i)+abs(y[a]-j);
            int m;
            for(m=0;m<n;m++)
            {
                if(h[m]==max((H0-abs(x[m]-i)-abs(y[m]-j)),0)) count++;
                else break;
            }
            if(count==n)
            {
                CX=i;
                CY=j;
                H=H0;
                break;
            }
        }
        if(count==n) break;
    }
    printf("%d %d %ld",CX,CY,H);
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;i--)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);i--)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int a[10],b[10];

int main() {
	int n=in();
	rep(i,n){
		rep(j,9)cin>>a[j];
		rep(j,9)cin>>b[j];
		vint per;
		rep(j,9){
			per.PB(j);
		}
		double res=0;
		do{
//rep(j,9)debug<<a[j]<<" "<<b[per[j]]<<" ";
//debug<<endl;
			int s=0;
			rep(j,9){
				if(a[j]>b[per[j]]){
					s+=a[j]+b[per[j]];
				}else{
					s-=a[j]+b[per[j]];
				}
			}
//debug<<s<<endl;
			if(s>0)res+=1;
		}while(next_permutation(all(per)));
//debug<<res<<endl;
		repn(j,1,9){
			res/=j;
		}
		printf("%.5f %.5f\n",res,1-res);
	}
	return 0;
}

Measured memory_bytes: 984
import java.util.Scanner;

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

	public void run() {
		while(true){

			String s=sc.nextLine();
			if("-".equals(s))break;
			int count=sc.nextInt();
			for(int i=0;i<count;i++){
				int index=sc.nextInt();
				s=s.substring(index)+s.substring(0,index);
			}sc.nextLine();
			ln(s);
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<math.h>

int main(void)
{
	int n, i;
	double s[1001],sum,m;
	
	while( 1 ) {
		scanf( "%d", &n );
		if( 0 == n ) { break; }
		
		
		sum = m = 0;
		for( i=0; i<n; i++ ) {
			scanf( "%lf", &s[i]);
			sum += s[i];
		}
		m = sum/n;
		sum = 0;
		for( i=0; i<n; i++ ) {
			sum += pow(s[i]-m,2)/n;
		}
		printf( "%lf\n", sqrt( sum ) );
	}
	
	return 0;
}


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

int main () {
  char X, Y;
  cin >> X >> Y;

  if (X < Y) {
    cout << "<" << endl;
  }
  else if (X > Y) {
    cout << ">" << endl;
  }
  else {
    cout << "=" << endl;
  }
}


Measured memory_bytes: 256
using System;

class P
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);

            int count = 0;

            for(int i = a; i <= b; i++)
            {
                if((c % i) == 0)
                {
                    count++;
                }
            }
            Console.WriteLine(count);
    }
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

LL N,M;
LL dfs(vector<vector<LL>>& graph,map<pii, LL>& visit,vector<bool>& vv,vector<pii>& res,vector<LL>& cnt,LL idx,LL prev){
  LL sum = 0;
  vv[idx] = true;
  REP(i, graph[idx].size())
  {
    LL next = graph[idx][i];
    if(prev==next){
      continue;
    }
    if(visit[{idx,next}]==0){
      if(vv[next]){
          //->here
          res.push_back({next, idx});
          sum++;
          visit[{idx, next}] = 2;
          visit[{next, idx}] = 1;
      }
      else
      {
        LL a = dfs(graph, visit,vv, res, cnt, next, idx);
        if (a % 2 == 0)
        {
          //there<-
          visit[{idx, next}] = 1;
          visit[{next, idx}] = 2;
        }
        else
        {
          //->here
          sum++;
          visit[{idx, next}] = 2;
          visit[{next, idx}] = 1;
        }
    }
    }
    else
    {
      if(visit[{idx,next}]==1){
        //idx->next
      }else{
        //next->idx
        sum++;
      }
    }
  }
  
  if(sum%2==0){
    res.push_back({idx, prev});
    return 1;
  }
  else
  {
    res.push_back({prev, idx});
    return 0;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> N >> M;
  vector<vector<LL>> graph(N);
  map<pii, LL> visit;

  REP(i,M){
    LL A, B;
    cin>>A>>B;
    A--;
    B--;
    graph[A].push_back(B);
    graph[B].push_back(A);
    visit[{A, B}] = 0;
    visit[{B, A}] = 0;
  }

  if(M%2==1){
    cout << -1 << endl;
  }else{
    vector<LL> cnt(N, 0);
    vector<bool> vv(N, false);
    vector<pii> res;
    dfs(graph, visit,vv,res, cnt, 0, -1);
    
    REP(i,res.size()){
      if(res[i].first!=-1&&res[i].second!=-1){
        cout << res[i].second+1 SP res[i].first+1<< endl;
      }
    }
  }
}


Measured memory_bytes: 39028
#include <cstdio>

int n, y, m, d, ans;

void next(int &y, int &m, int &d){
	if(m%2 || y%3 == 0 ){
		if(d == 20){
			m ++;
			d = 1;
		}else d++;
	}else{
		if(d == 19){
			m ++;
			d = 1;
		}else d++;
	}
	if( m==11 ){
		y++;
		m = 1;
	}
}

int main(){
	scanf("%d", &n);
	while(n-->0){
		ans = 0;
		scanf("%d %d %d", &y, &m, &d);
		while(y!=1000 || m!=1 || d!=1){
			ans ++;
			next(y, m, d);
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main(){
  string s;cin>>s;
  int r=0,b=0;
  int n=s.size();
  for(int i=0;i<n;i++){
    if(s[i]=='0') r++;
    else b++;
  }
  cout<<n-abs(r-b)<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

#define MOD 1000000007

ll calcz(ll x, ll y){
  ll a = x, b = MOD;
  ll tmp;
  vector<ll> syo;
  while(a > 1){
    syo.push_back(b / a);
    tmp = b % a;
    b = a;
    a = tmp;
  }
  ll dp1 = 0, dp2 = 1;
  rrep(i, syo.size()){
    ll tmp = (dp2 * (-syo[i]) + dp1) % MOD;
    dp1 = dp2;
    dp2 = tmp;
  }
  y = (y + MOD) % MOD;
  dp2 = (dp2 + MOD) % MOD;
  return (y % 10000 * dp2 % MOD + (y / 10000) * dp2 % MOD * 10000) % MOD;
}

ll comb(int n, int r) {
  ll val = 1;
  repi(a, n-r+1, n+1) val = (val * a) % MOD;
  repi(a, 1, r+1) val = calcz(a, val);
  return val;
}

ll f_sum(ll m, ll n){
  ll val = 0;
  repi(i, 1, m+1)
    val = (val + i * i + (m-i+1) * (m-i+1)) % MOD;
  val = (val * n * n) % MOD;
  return val;
}

int main(){
  ll N, M, K;
  cin >> N >> M >> K;

  ll ans = (f_sum(N, M) + f_sum(M, N) - M*N*(2*M*N+M+N)) % MOD;
  ans = (ans * comb(K, 2)) % MOD;
  ans = (ans * comb(M*N, K)) % MOD;
  ans = calcz(2*M*N*(M*N-1), ans);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll N, K;
  cin >> N >> K;
  vector<Pi> Query(N);
  REP(i, N) cin >> Query.at(i).first >> Query.at(i).second;
  ll num = 0, tmp;
  sort(Query.begin(), Query.end());
  for (auto a : Query) {
    tmp = a.first;
    num += a.second;
    if (num >= K) {
      cout << tmp << endl;
      return 0;
    }
  }
  cout << tmp << endl;
  return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
ps = [int(p)-1 for p in input().split()]
xys = [tuple(int(x)-1 for x in input().split()) for _ in range(m)]

union = {node:node for node in range(n)}
depth = {node:0 for node in range(n)}

def root(node):
    if union[node] == node:
        return union[node]
    union[node] = root(union[node])
    return union[node]

for x, y in xys:
    a, b = sorted((root(x), root(y)), key=lambda z:depth[z])
    union[a] = b
    depth[b] = max(depth[b], depth[a]+1)

print(sum(root(i) == root(p) for i, p in enumerate(ps)))

Measured memory_bytes: 44840
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;
		for (int n = 0;n < N ;n++ ) {
			String S = scan.next();
			switch (S) {
				case "AC":
					AC++;
					break;
				case "WA":
					WA++;
					break;
				case "TLE":
					TLE++;
					break;
				case "RE":
					RE++;
					break;
			}
		}
		scan.close();
		System.out.printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",AC,WA,TLE,RE);
	}

}


Measured memory_bytes: 58000
#include <iostream>

using namespace std;

class A {
	int a, b;
public:
	void solve()
	{
		if ((a & 1) && (b & 1)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	A()
	{
		cin >> a >> b;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
    FASTIO;
    int k;
    cin>>k;
    vector<int>v;
    int z=0;
    string str="";
    int cnt=1;
    int x=7;
    while(x%k)
    {
        x*=10;
        x+=7;
        x=x%k;
        cnt++;
        z++;
        if(z>k)
            break;
    }
    if(x%k==0)
    {
        cout<<cnt;
    }
    else
        cout<<-1;
    return 0;
}


Measured memory_bytes: 3632
n,m = map(int,input().split())
ans_l = None
ans_r = None
for i in range(m):
    
    l,r = map(int,input().split())

    
    if i == 0:
        ans_l = l
        ans_r = r

    else:
        ans_r = min(r,ans_r)
        ans_l = max(l,ans_l)
        
    if ans_r - ans_l < 0:
        print(0)
        exit()


print(ans_r-ans_l+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int N;
  cin >> N;
  int result;
  vi A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    if(i == 0) result = A.at(0);
    else{
      result = __gcd(result, A.at(i));
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
    string s,t;
    cin>>s>>t;
    int a,b;
    a=s.size();
    b=t.size();
    int nanika=0,ans=a;
for (int i = 0; i < a-b+1; i++)
{
    for (int j = 0; j < b; j++)
    {
       if (t.at(j)!=s.at(i+j))
       {
           nanika++;
       }
        
    }
    if (ans>nanika)
    {
        ans=nanika;
    }
    nanika=0;
    
}
cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636