akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

N=int(input())
E=[[] for _ in range(N)]
for i in range(N-1):
  a,b = map(int, input().split())
  E[a-1].append((b-1,i))
ans=[[] for _ in range(N-1)]
def sub(p, n):
  m=1
  for b,i in E[p]:
    if m == n: m+=1
    ans[i]=m
    sub(b,m)
    m+=1
sub(0,0)
print(max(ans))
for a in ans:
  print(a)

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

int main() {

	int n, m;
	cin >> n >> m;

	vector<int> a(m); 
	for (int i = 0; i < m; i++)
		cin >> a[i];

	vector<int> dp(n+1, -1);
	for (int i = 0; i < m; i++)
		dp[a[i]] = 0;

	if(dp[0]!=0)
		dp[0] = 1; 
	if(dp[1]!=0)
		dp[1] = 1;

	for (int i = 2; i <= n; i++) {
		if (dp[i] != 0) {
			dp[i] = dp[i - 1] + dp[i - 2];
			if (dp[i] > 1000000007)
				dp[i] %= 1000000007;
		}
	}

	cout << dp[n] << endl;
}

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

using namespace std;

template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
	o << "{";
	for (int i = 0; i < (int)v.size(); i++)
		o << (i > 0 ? ", " : "") << v[i];
	o << "}";
	return o;
}

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

void solve()
{
	int H, W;
	cin >> H >> W;
	vector<string> maze(H);
	for (int i = 0; i < H; i++)
	{
		cin >> maze[i];
	}
	long ans = 0;

	bitset<402*402> vst;

	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
		{
			if (vst[i*W+j]) continue;
			long b = 0, w = 0;
			queue<int> q;
			q.push(i*W+j);
			while(!q.empty())
			{
				int v = q.front();
				q.pop();
				if (maze[v/W][v%W] == '#') b++;
				else w++;

				vst[v] = 1;

				for (int d = 0; d < 4; d++)
				{
					int ni = v/W + dx[d], nj = v%W + dy[d];
					//cout << ni << ' ' << nj << endl;
					if (0 <= ni && ni < H && 0 <= nj && nj < W)
					{
						if (vst[ni*W+nj]) continue;
						if (maze[ni][nj] != maze[v/W][v%W])
						{
							vst[ni*W+nj] = 1;
							q.push(ni*W+nj);
						}
					}
				}
			}
			ans += w * b;
			//cout << i << ' ' << j << ' ' << w << ' ' << b << endl;
		}

	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

int main() { 
    long long n, x, y, h;
    vector<tuple<long long, long long, long long>> xyh;
    tuple<long long, long long, long long> G;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> x >> y >> h;
        xyh.push_back(make_tuple(x, y, h));
        // h>=1が必ずある && 複数あってもHは一意に定まる
        if(h >= 1) G = make_tuple(x, y, h); 
    }

    // 入力が一つならそれが答え
    if(xyh.size() == 1) {
        cout << get<0>(xyh[0]) << " " << get<1>(xyh[0]) << " " << get<1>(xyh[0]) << '\n';
        return 0;
    }

    // 全探索
    for(int cx = 0; cx <= 100; ++cx) {
        for(int cy = 0; cy <= 100; ++cy) {
            // 最初にh>=1の組から中心高さHを算出
            long long H = get<2>(G) + abs(get<0>(G) - cx) + abs(get<1>(G) - cy);
            bool flag = true;
            for(int i = 0; i < n; ++i) {
                x = get<0>(xyh[i]), y = get<1>(xyh[i]), h = get<2>(xyh[i]);
                long long hh = H - abs(cx - x) - abs(cy - y);
                hh = max(hh, 0LL);
                if(hh != h) {
                    // 矛盾があればbreak
                    flag = false;
                }
            }
            // 矛盾が無ければそれが答え
            if(flag == true) {
                cout << cx << " " << cy << " " << H << '\n';
                return 0;
            }
        }
    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int64_t> L(n+1, 0);
  
  L[0] = 2;
  L[1] = 1;
  for (int i=2; i<n+1; i++) {
    L[i] = L[i-1] + L[i-2];
  }

  cout << L[n] << endl;
}


Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<char,int> P;

class mycmp{
public:
	bool operator() (const P p1,const P p2){
		return p1.second < p2.second;
	}
};

int main(){

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		for(int i=0;i<n;i++){
			string str;
			cin >> str;

			vector<P> order;
			map<char,int> data;		
			set<char> alpha;

			for(int j=0;j<str.size();j++){
				if(isalpha(str[j])){
					alpha.insert(str[j]);
				}
			}

			int j=0;
			for(set<char>::iterator it = alpha.begin(); it != alpha.end(); it++){
				data[*it]=j++;
			}

			for(int k=0;k<alpha.size();k++){
				for(int j=0;j+3<str.size();j+=3){
					string tmp = str.substr(j,4);
					if(tmp.substr(1,2)=="<-"){
						if(data[tmp[0]] < data[tmp[3]]){
							swap(data[tmp[0]],data[tmp[3]]);
						}
					}
					else if(tmp.substr(1,2)=="->"){
						if(data[tmp[0]] > data[tmp[3]]){
							swap(data[tmp[0]],data[tmp[3]]);
						}
					}
				}
			}

			for(map<char,int>::iterator it = data.begin(); it != data.end();it++){
				order.push_back(P(it->first,it->second));
			}

			sort(order.begin(),order.end(),mycmp());

			for(vector<P>::iterator it = order.begin(); it != order.end();it++){
				cout << it->first;
			}

			cout << endl;
		}
	}
}

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

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            var a = new long[n];
            var kazu = new long[n + 1];
            for (int i = 0; i < n; i++)
            {
                a[i] = long.Parse(str[i]);
                kazu[a[i]]++;
            }

            var comb = new long[n + 1];
            long sum = 0;
            for(int i = 0; i < n+1; i++)
            {
                comb[i] = kazu[i] * (kazu[i] - 1) / 2;
                sum += comb[i];
            }


            for(int i = 0; i < n; i++)
            {
                long ans = sum - comb[a[i]] ;
                if (kazu[a[i]] > 2)
                {
                    ans += (kazu[a[i]]-1)*(kazu[a[i]]-2)/ 2;
                }
                Console.WriteLine(ans);
            }




            //ここまで
        }



    }

}


Measured memory_bytes: 37836
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


int main() {
	double n;
	cin >> n;
	ll a = (n + 1) / 2;
	cout << (double)a / n << endl;
}


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

int main(){
    int H,W;
    
    while(1){
        cin >> H >> W;
        if( H==0 && W==0 ) break;
        
        for( int i=0; i < H; i++ ){
            for( int j=0; j < W; j++ ){
                if( i == 0 || i == H-1 || j == 0 || j == W-1 ){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
const int N = 405, MOD = 1e9 + 7;
int g[N], a[N], b[N], cnt_union[N][N], dp[N][N][N / 3], ra[N], rb[N];
int main() {
	int n3, n;
	scanf("%d", &n3);
	n = n3 / 3;
	g[0] = 1;
	for (int i = 1; i <= n; ++ i) {
		g[i] = 1LL * ((i - 1) * 3 + 1) * ((i - 1) * 3 + 2) % MOD * g[i - 1] % MOD;
	}
	for (int i = 1; i <= n3; ++ i) {
		scanf("%d", &a[i]);
		ra[a[i]] = i;
	}
	for (int i = 1; i <= n3; ++ i) {
		scanf("%d", &b[i]);
		rb[b[i]] = i;
	}
	for (int i = 1; i <= n3; ++ i) {
		for (int j = 1; j <= n3; ++ j) {
			static bitset<N> all; all.reset();
			for (int k = 1; k <= i; ++ k) all[a[k]] = 1;
			for (int k = 1; k <= j; ++ k) all[b[k]] = 1;
			cnt_union[i][j] = all.count();
		}
	}
	dp[0][0][0] = 1;
	for (int i = 0; i <= n3; ++ i) {
		for (int j = 0; j <= n3; ++ j) {
			for (int k = 0; k <= n; ++ k) {
				if (!i && !j && !k) continue;
				dp[i][j][k] = 0;
				if (i) (dp[i][j][k] += dp[i - 1][j][k]) %= MOD;
				if (j) (dp[i][j][k] += dp[i][j - 1][k]) %= MOD;
				if (i && j) (dp[i][j][k] += MOD - dp[i - 1][j - 1][k]) %= MOD;
				if (rb[a[i]] <= j || ra[b[j]] <= i) continue;
				if (i && j && k) {
					int f = n3 - 3 * (n - k) - cnt_union[i][j];
					//printf("%d %d %d f = %d * %d\n", i, j, k, f, dp[i - 1][j - 1][k - 1]);
					if (f >= 1) (dp[i][j][k] += 1LL * dp[i - 1][j - 1][k - 1] * f % MOD) %= MOD;
				}
			}
		}
	}
	int ans = 1LL * dp[n3][n3][n] * g[n] % MOD;
	printf("%d\n", ans);
}


Measured memory_bytes: 86912
#include<iostream>
#include<string>
using namespace std;
int main(){
    string w,t;
    cin >> w;
    for(int i = 0; i < w.size(); i++){
        if('A' <= w[i]&&w[i] <= 'Z'){
            w[i] += 'a' - 'A';
        }
    }
    int o = 0;
    cin >> t;
    while(t!="END_OF_TEXT"){
        for(int i = 0; i<t.size(); i++){
            if('A' <= t[i]&&t[i]<='Z'){
                t[i] += 'a' - 'A';
            }
        }
        if(w==t) o++;
        cin >>t;
    }
    cout << o << endl;
    
    return 0;
}


Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int now,n,l;

int main(){
  int ans=0;
  
  cin >> n>>l;
  int idx=-1;
  if (l>0){
    idx=0;
  }else{
    if (l+n<1)idx=n-1;
  }
  
  for(int i=0;i<n;i++){
    if (i==idx)continue;
    ans+=l+i;
  }
  cout<<(ans)<<endl;

  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        int[][] days = new int[n][3];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                days[i][j] = in.nextInt();
            }
        }
        int[] max = new int[3];
        max[0] = days[0][0];
        max[1] = days[0][1];
        max[2] = days[0][2];
        for (int i = 1; i < n; i++) {
            int a = days[i][0] + Math.max(max[1], max[2]);
            int b = days[i][1] + Math.max(max[0], max[2]);
            int c = days[i][2] + Math.max(max[0], max[1]);

            max[0] = a;
            max[1] = b;
            max[2] = c;
        }

        System.out.println(Math.max(max[2], Math.max(max[0], max[1])));
    }
}


Measured memory_bytes: 95220
s = input()
t = input()

l_s = [[] for _ in range(26)]

for i, x in enumerate(s):
    l_s[ord(x) - 97].append(i)

l_t = [[] for _ in range(26)]
for i, x in enumerate(t):
    l_t[ord(x) - 97].append(i)

for l in l_s:
    if len(l) > 0:
        if l_t[ord(t[l[0]]) - 97] != l:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 26396
import math

n = int(input())
a = list(map(int,input().split()))

def segfunc(x, y):
    return math.gcd(x,y)

def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])

def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2])

def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element
ide_ele = 0

# num: n以上の最小の2のべき乗
num = 2**(n-1).bit_length()
seg = [ide_ele]*2*num

a=init(a)

ans=1
for i in range(n):
    ans=max(ans,math.gcd(query(0,i),query(i+1,n)))


print(ans)

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

int32_t main() {
    int n; cin >> n;
    long long ans = 0, p; cin >> p;
    for (int i = 1; i < n; i++) {
        int q; cin >> q;
        if (q < p) ans += p - q;
        else p = q;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define MAX 1e9
using namespace std;
int frog1(vector<int>arr,int n)
{
    vector<int>dp(n+1);
    dp[1]=0;
    for(int i=2;i<=n;++i)
    {
        int op1,op2;
        //op1=op2=INT_MAX;
        op1=abs(arr[i]-arr[i-1])+dp[i-1];
        op2=(i==2)? MAX:abs(arr[i]-arr[i-2])+dp[i-2];
        dp[i]=min(op1,op2);
    }
    return dp[n];
    
}
int main()
{
    int n;
    scanf("%d",&n);
    vector<int>arr(n+1);
    for(int i=1;i<=n;++i)
        scanf("%d",&arr[i]);
    //int dp[MAX]={0};
    cout<<frog1(arr, n)<<endl;
    
}


Measured memory_bytes: 4232
import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container;
import core.bitop, std.datetime;

void main(){
    auto N = readln.chomp.to!int;
    auto A = readln.split.to!(int[]);
    auto ans = int.max;

    foreach(x; -100 .. 101){
        ans = min(ans, A.map!(a => (a - x)^^2).sum);
    }

    ans.writeln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
#define MOD 998244353
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,r,timer,mx,l, cnt,s,col;
pii a[300500];
multiset<pii> f;
vector<pii> bad;
vector<pii> g[605][605];
ll used[605][605];
ll Abs(ll x) {
    return x>0?x:-x;
}
void dfs(ll x, ll y, ll val) {

    ll nextval;
    if (val == 2)
        nextval = 3;
    else
        nextval = 2;
    used[x][y] = val;
    for (int i = 0; i < g[x][y].size(); i++) {
        ll nx = g[x][y][i].X;
        ll ny = g[x][y][i].Y;
        if (used[nx][ny] == 0) {
            dfs(nx, ny, nextval);
        }
    }
}

void dfs2(ll x, ll y, ll val) {

    ll nextval;
    if (val == 4)
        nextval = 5;
    else
        nextval = 4;
    used[x][y] = val;
    for (int i = 0; i < g[x][y].size(); i++) {
        ll nx = g[x][y][i].X;
        ll ny = g[x][y][i].Y;
        if (used[nx][ny] == 2) {
            dfs2(nx, ny, nextval);
        }
    }
}
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n >> x >> y;

    for (int i = 0; i <= 1000; i++) {
        if (x-i*i >= 0) {
            ll t = int(sqrt(x-i*i)+0.5);
            if (t*t == x-i*i) {
                bad.push_back(mp(t, i));
                bad.push_back(mp(-t, i));
            }
        }
    }
    for (int i = 0; i < 2*n; i++)
    for (int j = 0; j < 2*n; j++) {
        for (int k = 0; k < bad.size(); k++) {
            ll dx = bad[k].X;
            ll dy = bad[k].Y;
            if (dx+i >= 0 && dx+i < 2*n && dy+j >= 0 && dy+j < 2*n) {
                g[i][j].push_back(mp(dx+i, dy+j));
                g[dx+i][dy+j].push_back(mp(i, j));
            }
        }
    }
    for (int i = 0; i < 2*n; i++)
        for (int j = 0; j < 2*n; j++)
    if (!used[i][j]) {
        dfs(i, j, 2);
    }

    bad.clear();
    for (int i = 0; i < 2*n; i++)
        for (int j = 0; j < 2*n; j++)
            g[i][j].clear();

    for (int i = 0; i <= 1000; i++) {
        if (y-i*i >= 0) {
            ll t = int(sqrt(y-i*i)+0.5);
            if (t*t == y-i*i) {
                bad.push_back(mp(t, i));
                bad.push_back(mp(-t, i));
            }
        }
    }
    for (int i = 0; i < 2*n; i++)
    for (int j = 0; j < 2*n; j++) {
        for (int k = 0; k < bad.size(); k++) {
            ll dx = bad[k].X;
            ll dy = bad[k].Y;
            if (dx+i >= 0 && dx+i < 2*n && dy+j >= 0 && dy+j < 2*n) {
                g[i][j].push_back(mp(dx+i, dy+j));
                g[dx+i][dy+j].push_back(mp(i, j));
            }
        }
    }
    for (int i = 0; i < 2*n; i++)
        for (int j = 0; j < 2*n; j++)
    if (used[i][j] == 2) {
        dfs2(i, j, 4);
    }
    ll cnt = 0;
    for (int i = 0; i < 2*n; i++)
    for (int j = 0; j < 2*n; j++) {
        if (used[i][j] == 4) {
            cnt++;
            cout << i << " " << j << endl;
            if (cnt == n*n)
                return 0;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 208000
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
vector<int>G[9];
int n,m;
int cnt=0;
bool visit[9]={};
void dfs(int s){
    visit[s]=true;
    for(int i=0;i<G[s].size();i++){
        if(visit[G[s][i]]==false){
            dfs(G[s][i]);
            visit[G[s][i]]=false;
        }
    }
    bool all=true;
    for(int i=1;i<=n;i++){
        if(visit[i]==false)all=false;
    }
    if(all)cnt++;
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(1);
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100;
const ll mod = 1000000007;
int main(){
string s;
cin>>s;
vector<int>a((int)s.size(),0);
int bfo=0;
for(int i=0;i<s.size()-1;i++){
if (s.at(i)=='R'&&s.at(i+1)=='L'){
    a.at(i)+=1;
    a.at(i+1)+=1;
    int cnt=0;
    int k=i;
    while(k-1>=0&&s.at(k-1)=='R'){//左見る
        cnt++;
        if(cnt%2==0)a.at(i)++;
        else a.at(i+1)++;
        k--;
    }
    cnt=0;
    int j=i+1;
    while(j+1<s.size()&&s.at(j+1)=='L'){//右見る
        cnt++;
        if(cnt%2==0)a.at(i+1)++;
        else a.at(i)++;
        j++;
    }
    i=j;
    bfo=j;
}
}
for(int i=0;i<s.size();i++)cout<<a.at(i)<<" ";
cout<<endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main()
{
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << W*H*0.5 << " ";
    if(x == W*0.5 && y == H*0.5) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    String S = sc.next();
    String T = sc.next();
    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
      if (S.charAt(i) == T.charAt(i)) ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21972
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
  int x,A[100],c=0,y;
  char s[100];
  
  while(1){
   y=scanf("%s",s);
   if(y==EOF) break;

 if ( s[0] == '+' ){ //演算子+
      A[c-2]+=A[c-1];
      c--;
    } 
    else if ( s[0] == '-' ){ //演算子-
      A[c-2]-=A[c-1];
      c--;
    } 
  
    else if ( s[0] == '*' ){ //演算子*
      A[c-2]*=A[c-1];
      c--;
    } 
    else {
      //配列に数字をつっこむ
      x = atoi(s);
      A[c]=x;
      c++;
    }
   
  }
  printf("%d\n",A[c-1]);
  return 0;
}

Measured memory_bytes: 548
#include <cstdio>
#include <cstring>
int main()
{
    int sum;
    char num[1100];
    for (int i = 0; i < 1100; i++){
        num[i] = 0;
    }

    while (true){
        scanf(" %s", num);
        if (strcmp(num, "0") == 0){
            break;
        }
        sum = 0;
        for (int i = 0; num[i] != '\0'; i++){
            sum += num[i] - '0';
        }

        printf("%d\n", sum);
    }

    return 0;
}
            

Measured memory_bytes: 964
/*
* @Author: 王文宇
* @Date:   2018-03-17 23:59:48
* @Last Modified by:   王文宇
* @Last Modified time: 2018-03-18 00:35:09
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

typedef unsigned long long ll;
const int maxn=(int)2e5+5;
int n;
ll a[maxn],b[maxn],c[maxn];

void merge (ll *p,ll mod) {   //在给定的mod下归并排序
	int i,j,k,m;
	for(i=1;i<=n;i++) {
		c[i]=p[i];
		if(p[i]>=mod)c[i]=p[i]%mod;
	}
	c[n+1]=mod<<1;
	sort(c+1,c+1+n);
	for(int i=1;i<=n;i++)p[i]=c[i];
}

ll bigthan (ll m) {             //大于m的数对对数
	int i,j=n;ll ans=0;
	for (i=1;i<=n;i++) {
		while ((a[i]+b[j])>=m&&j>0) j--;
		ans+=n-j;
	}
	return ans;
}

bool get (ll mod) {               //考虑mod位是否为1
	merge (a,mod<<1);
	merge (b,mod<<1);
	ll ans = bigthan(mod) + bigthan(3*mod) - bigthan(mod<<1);
	if ( ans%2 ) return true;
	return false;
}

int main () 
{
//	freopen("aa.txt","r",stdin);
	int cas,T,i;ll mod,ans;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%I64d",a+i);
	for(i=1;i<=n;i++) scanf("%I64d",b+i);
	sort(a+1,a+n+1);sort(b+1,b+n+1);
	ans=0;mod=(ll)1<<28;
	while(mod) {
		if (get(mod)) 
			ans+=mod;
		mod=mod>>1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
/*************************************************************************
  >         File: D.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sun 23 Oct 2016 08:39:58 PM CST
*************************************************************************/
#include <bits/stdc++.h>
using LL = long long;

const int N = 333;
char mp[N][N];
int h, w;
LL f[2][N][N], dp[N][N];
bool visited[N][N];

LL Dfs(int a, int b) {
  if (a == h || b == h) return 0;
  else if (visited[a][b]) return dp[a][b];
  else {
    visited[a][b] = 1;
    LL &ans = dp[a][b];
    ans = std::min(Dfs(a + 1, b), Dfs(a, b + 1));
    if (a < b) {
      ans += f[1][b - a][h - b];
    }
    else {
      ans += f[0][a - b][h - a];
    }
    return ans;
  }
}

LL Solve(int a) {
  int l = a, r = a + 1;
  memset(f, 0, sizeof(f));
  memset(dp, 0, sizeof(dp));
  memset(visited, 0, sizeof(visited));
  //l pushed more than r
  for (int i = 0; i < h; ++i) {
    //diff is i
    for (int y = 0; y < h; ++y) {
      int cost = y + i >= h ? 0 : mp[y][l] == mp[y + i][r];
      f[0][i][y + 1] = f[0][i][y] + cost;
    }
  }
  //l pushed less than r
  for (int i = 0; i < h; ++i) {
    for (int y = 0; y < h; ++y) {
      int cost = y + i >= h ? 0 : mp[y][r] == mp[y + i][l];
      f[1][i][y + 1] = f[1][i][y] + cost;
    }
  }
  for (int i = 0; i < h; ++i) assert(f[0][0][i] == f[1][0][i]);
  Dfs(0, 0);
  return dp[0][0];
}

int main() {
  std::ios::sync_with_stdio(0);
  std::cin >> h >> w;
  for (int i = 0; i < h; ++i) std::cin >> mp[i];
  LL ans = 0;
  for (int i = 0; i < w - 1; ++i) ans += Solve(i);
  std::cout << ans << std::endl;
  return 0;
}


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

int main(){
  int A,B,C;
  cin>> A >> B >> C;
  if (A == B){
    cout << C << endl;
  }
  if (B == C ){
    cout << A << endl;
  }
  if (C == A){
    cout << B << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int INF = 1e18;

void wf(vector<vector<int>> &dist,int n){
	rep(i,n)rep(j,n)rep(k,n){
		dist[j][k] = min(dist[j][k],dist[j][i] + dist[i][k]);
	}
}
signed main(){
	int n,m,l;cin >> n >> m >> l;
	vector<vector<int>> dist1(n,vector<int> (n,INF));
	rep(i,n)dist1[i][i] = 0;
	rep(i,m){
		int a,b,c;cin >> a >> b >> c;
		a--;b--;
		dist1[a][b] = dist1[b][a] = c;
	}
	wf(dist1,n);

	vector<vector<int>> dist2(n,vector<int>(n,INF));
	rep(i,n)dist2[i][i] = 0;
	rep(j,n)rep(i,j){
		// trace(i,j,dist1[i][j]);
		if(dist1[i][j] <= l){
			dist2[i][j] = dist2[j][i] = 1;
		}
	}
	wf(dist2,n);

	int q;cin >> q;
	while(q--){
		int s,t;cin >> s >> t;
		s--;t--;
		int ret = dist2[s][t];
		if(ret == INF)cout << -1 << endl;
		else cout << ret-1 << endl;
	}
	

	return 0;
}

Measured memory_bytes: 5068
N, M = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
class UnionFind:
  def __init__(self, n):
    self.table = [-1 for _ in range(n)]
    
  def root(self, x):
    if self.table[x] < 0:
      return x
    else:
      self.table[x] = self.root(self.table[x])
      return self.table[x]
  
  def unite(self, x, y):
    s1, s2 = self.root(x), self.root(y)
    if s1 != s2:
      if self.table[s1] != self.table[s2]:
        if self.table[s1] < self.table[s2]:
          self.table[s2] = s1
        else:
          self.table[s1] = s2
      else:
        self.table[s1] += -1
        self.table[s2] = s1
    return
  
  def findSet(self, x, y):
    return self.root(x) == self.root(y)
uf = UnionFind(N)
for i in range(M):
  px, py = map(int, input().split())
  px -= 1
  py -= 1
  uf.unite(px, py)
ans = 0
for i, v in enumerate(p):
  if uf.findSet(i,v):
    ans += 1
print(ans)

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

int main() {

  int n, k;

  cin >> n >> k;

  if(k==1) {
    cout << "0" << endl;
  }else if(n%k>0) {
    cout << n%k << endl;
  }else {
    cout << "0" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

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

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

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

vector<bool> IsPrime;
vector<ll> p;

void sieve(ll max)
{
    if(max+1 > IsPrime.size())
    {
        IsPrime.resize(max+1,true);
    }
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(ll i=2; i*i<=max; ++i)
    {
        if(IsPrime[i])
        {
            for(ll j=2; i*j<=max; ++j)
                IsPrime[i*j] = false;
        }
    }
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll q[78498];
ll m[78498];

void solve()
{
    IN(n);
    sieve(1000000LL);
    rep(i, 1000000LL)
    {
        if (IsPrime[i]) p.push_back(i);
    }
    ll s = 0;
    rep(i, n)
    {
        IN(a);
        ll k = a;
        rep(j, 168)
        {
            q[j] = 0;
            while (true)
            {
                if (k % p[j] == 0)
                {
                    k /= p[j];
                    ++q[j];
                }
                else break;
            }
            chmax(m[j], q[j]);
        }
        if (k > 1) m[lower_bound(p.begin(), p.end(), k)-p.begin()] = 1;
        s = (s + modinv(a, MOD)) % MOD;
    }
    ll t = 1;
    rep(j, p.size())
    {
        t = t * modpow(p[j], m[j], MOD) % MOD;
    }
    cout << t * s % MOD << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 1780
package main

import "fmt"

func main(){
	var k,a,b int
	var flag bool
	fmt.Scan(&k)
	fmt.Scan(&a,&b)
	for i:=a ; i<=b ; i++ {
		if i%k == 0 {
			flag = true
			break
		}
	}
	if flag {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}
}


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

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long f(long long N,long long M){
	long long k=0,j=0;
  	for(int i=0; i<M; i++){
      k+=j+((N-1)*N*(2*N-1)/6+(N-1)*N/2)/2;
      j+=N*N*(i+1)+(N-1)*N*(2*N-1)/6+(N-1)*N/2;
      k%=MOD;j%=MOD;
    }
  	return k;
}

int main(){
  COMinit();
  long long N,M,K;cin >> N >> M >> K;
  cout << (COM(N*M-2,K-2)*f(N,M))%MOD << endl;
}

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

int main(){
int a,b ;
int d,r ;
double f;

cin >> a >> b ;

d = a/b ;
r = a%b ;
f = 1.0*a/b ;

cout << d <<"  ";
cout << r << " ";
cout << fixed << f << "\n" ;

return 0 ;
}

Measured memory_bytes: 1244
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	int n;
	cin >> n;

	if (n == 1)
	{
		int a;
		cin >> a;
		if (!a)
			cout << 1 << endl;
		else
			cout << 0 << endl;
		return 0;
	}

	vi va(n);
	REP(i, n)
		cin >> va[i];
	sort(ALL(va));


	ll ans = 1;

	if (n & 1)
	{
		if (va[0] != 0 || va[1] == 0)
		{
			cout << 0 << endl;
			return 0;
		}

		int cnt = 1;
		int last = va[1];
		for (int i = 2; i < n; i++)
		{
			if (cnt == 1)
			{
				if (last != va[i])
				{
					cout << 0 << endl;
					return 0;
				}
				else
				{
					++cnt;
					ans = ans * 2 % MOD;
				}
			}
			else if (cnt == 2)
			{
				if (last == va[i])
				{
					cout << 0 << endl;
					return 0;
				}
				cnt = 1;
				last = va[i];
			}
		}
	}

	else
	{
		int cnt = 1;
		int last = va[1];
		REP1O(i, n)
		{
			if (cnt == 1)
			{
				if (last != va[i])
				{
					cout << 0 << endl;
					return 0;
				}
				else
				{
					++cnt;
					ans = ans * 2 % MOD;
				}
			}
			else if (cnt == 2)
			{
				if (last == va[i])
				{
					cout << 0 << endl;
					return 0;
				}
				cnt = 1;
				last = va[i];
			}
		}

	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>

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

int solve(void);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

int solve(void)
{
	ll N, K, R, S, P;
	string T, history;
	map<char, ll> win_score;
	map<char, char> win_te;

	cin >> N >> K >> R >> S >> P >> T;
	history = history.append(T.length(), 'x');

	{
		win_score['r'] = P;
		win_te['r'] = 'p';
		win_score['s'] = R;
		win_te['s'] = 'r';
		win_score['p'] = S;
		win_te['p'] = 's';
	}

	ll ans = 0;

	for (ll i = 0; i < T.length(); i++)
	{
		ll j = i - K;
		if (j >= 0 && history[j] == win_te[T[i]])
		{
			continue;
		}
		history[i] = win_te[T[i]];
		ans += win_score[T[i]];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
const ll mod = 998244353ll;
int k, n;
vector<string> a;
bool cc;
bool check(string& s) {
	int c;
	for(auto &i : a) {
		c = 0;
		for(int j = 0; j < n; j++)
			c += s[j] != i[j];
		if(c&&c!=2)
			return false;
//		if(cc==false&&c==0)
//			return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	int n, k;
	vector<pair<int, int>> a;
	cin >> n;
	for(int t, i = 1; i <= n; i++) {
		cin >> t;
		a.pb({t, i});
	}
	sort(all(a));
	for(auto i : a) cout << i.second << " ";
}


Measured memory_bytes: 1780
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> b(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }

    vector<int> ans;
    while (b.size() > 1) {
        bool possible = false;
        for (int i = b.size() - 1; i >= 1; --i) {
            if (b[i] == i) {
                ans.push_back(i);
                b.erase(b.begin() + i);
                possible = true;
                break;
            }
        }
        if (!possible) {
            cout << -1 << endl;
            return 0;
        }
    }

    reverse(ans.begin(), ans.end());

    for (int k : ans) {
        cout << k << endl;
    }
    return 0;
}

Measured memory_bytes: 256
R={"*":2,"/":2,"+":1,"-":1,"(":0,")":0}
for _ in[0]*int(input()):
 L=[];t=''
 for e in input()[:-1]:
  if e.isdigit():t+=e
  else:
   if t:L+=[t];t=''
   L+=e
 if t:L+=[t]
 P,S=[],[]
 for i in L:
  if"("==i:S+=i
  elif")"==i:
   while"("!=S[-1]:P+=S.pop()
   S.pop()
  elif i in R:
   while S and R[S[-1]]>=R[i]:P+=S.pop()
   S+=i
  else:P+=[i]
 while S:P+=S.pop()
 for x in P:
  S+=[str(int(eval(S.pop(-2)+x+S.pop())))if x in"+-*/"else x]
 print(*S)


Measured memory_bytes: 5608
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var K = one[1];
	var list = nextIntArray();
	for(var i = 0; i < K; i++){
		var imos = new Array(N + 1).fill(0);
		for(var j = 0; j < N; j++){
			var L = Math.max(j - list[j], 0);
			var R = Math.min(j + list[j], N - 1);
			imos[L]++;
			imos[R + 1]--;
		}
		myerr(imos);
		for(var j = 1; j < N; j++){
			imos[j] = imos[j] + imos[j - 1];
		}
		var isOK = true;
		for(var j = 0; j < N; j++){
			if(imos[j] != N){
				isOK = false;
				break;
			}
		}
		imos.pop();
		list = imos;
		if(isOK){
			break;
		}
	}
	myout(myconv(list, 8));
	
}


Measured memory_bytes: 71464
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n>>m;
    vector<int> h(n+1);
    for (int i=1;i<n+1;i++){
        cin >> h[i];
    }
    set<int> w;

    vector<vector<int>> p(n+1);
    for (int i=0;i<m;i++){
        int a,b;
        cin >> a>>b;
        p[a].push_back(b);
        p[b].push_back(a);
        w.insert(a);
        w.insert(b);

    }
    int e=n-w.size();

    int cnt=0;
    int ans=0;
    for (int i=1;i<n+1;i++){
        cnt=0;
        for (int j:p[i] ){
            
            if (h[i]<=h[j]){
                break;
            }
            else cnt+=1;      
            if (cnt==p[i].size()){
                ans+=1;
                // cout<<i;
                
            }
        }
 
    }
    ans+=e;
    cout<<ans;

    return 0;
}

Measured memory_bytes: 12704
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int n; 
    cin >> n;
    vll a(n+1);
    rep(i, n+1) cin >> a[i];
    
    if(n == 0){
        if(a[0] == 1){
            cout << 1 << endl;
        }else{
            cout << -1 << endl;
        }
        return;
    }
    
    vll ruiseki(n+2);
    ruiseki[n+1] = 0;
    
    rep3rev(i, n+1, 1){
        ruiseki[i-1] = ruiseki[i] + a[i-1];
    }

    vll mn(n+1), mx(n+1);
    mn[0] = mx[0] = 1 - a[0];
    
    for(int i = 1; i < n+1; i++){ // depth (n-1) までを見る
        mn[i] = max(0LL, mn[i-1] - a[i]);
        mx[i] = min(2 * mx[i-1] - a[i], ruiseki[i+1]);
        if(i < n && mx[i] <= 0) {
            // cout << "case1: " << i << endl;
            cout << -1 << endl;
            return;
        }
        if(i == n){
            if(0 < mn[n] || mx[n] < 0){
                // cout << "case2: " << mx[n] << " " << mx[n] << endl;
                cout << -1 << endl;
                return;
            }
        }
    }
    
    // rep(i, n+1) cout << mn[i] << " " << mx[i] << " " << a[i] << " " << ruiseki[i] << endl;
    
    ll ans = 0;
    
    rep(i, n+1){
        if(mx[i] <= ruiseki[i+1]){
            ans += mx[i] + a[i];
        }else{
            ans += ruiseki[i];
        }
    }
    
    cout << ans << endl;
	return;
}

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


Measured memory_bytes: 6368
#include<iostream>
#include<math.h>
using namespace std;
int N,D,X[10][20],ans=0;
double k=0;
int main(void){
	cin>>N>>D;
	for(int i=0;i<N;i++)for(int j=0;j<D;j++)cin>>X[i][j];
	for(int i=0;i<N-1;i++)
		for(int x=i+1;x<N;x++){
			k=0;
			for(int j=0;j<D;j++)k+=(X[i][j]-X[x][j])*(X[i][j]-X[x][j]);
			k=sqrt(k);
			if(k-floor(k)==0)ans++;
		}
	cout<<ans;
}


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

int main() {
  string n;
  cin>>n;
  for(int i=0;i<3;i++){
  if(n.at(i)=='1') n.at(i)='9';
    else n.at(i)='1';
  }
  cout<<n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int n, a, b;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	} else {
		cin >> a >> b;
		cout << (a + b) << endl;
	}
	return 0;
}
 

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


int main(){
  
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin>>n;
	ll mxcnt=0,cnt=0,pre=0,cur;
	//vector<int> v(n);

	for(int i=0; i<n; i++){
		cin>>cur;
		if(cur>pre){
			cnt=0;
		}
		else cnt++;
		mxcnt=max(cnt,mxcnt);
		pre=cur;
	}
	cout<<mxcnt;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n>> k;
    int co = 0;
    int num;
    while(n--)
    {
        cin >> num;
        if(num >= k)
            co++;
    }
    cout << co << endl;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int ans=0,cnt=0,t=-1;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a!=t){
      ans+=cnt/2;
      t=a;
      cnt=1;
    }
    else cnt++;
  }
  ans+=cnt/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools

A,B,C,D,E,F = map(int, input().split())

ope1 = [x for x in range(F//(100*A)+1)]
ope2 = [x for x in range(F//(100*B)+1)]
ope3 = [x for x in range(F//C+1)]
ope4 = [x for x in range(F//D+1)]

water = []
for a,b in itertools.product(ope1, ope2):
    temp = 100*a*A + 100*b*B
    water.append(temp)
water = sorted(list(set(water)))

sugar = []
for c,d in itertools.product(ope3, ope4):
    temp = c*C + d*D
    sugar.append(temp)
sugar = sorted(list(set(sugar)))

ans_list = []
for w,s in itertools.product(water, sugar):
    if w == 0:
        continue
    if s/(w//100) > E:
        continue
    if w+s > F:
        continue
    ans_list.append([s*100/(s+w),s+w,s])

if len(ans_list) > 0 :
    ans_list.sort(key=lambda x:x[0])
    print(ans_list[-1][1],ans_list[-1][2])
else:
    print(100*A,0)


Measured memory_bytes: 22600
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

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

    int n;
    cin >> n;
    vector<int> arr(n);
    map<int, int> a;
    map<int, int> b;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        a[i - arr[i]]++;
        b[i + arr[i]]++;
    }
    int tot = 0;
    for (int i = 1; i <= 4e5; i++) {
        tot += a[i] * b[i];
    }
    cout << tot << '\n';

    fflush(stdout);
    return 0;
}


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

int main(){
    int N,K;
    string S;
    cin >> N >> S >> K;
    char s = S.at(K-1);
    for(int i = 0;i< N;i++){
        if(S.at(i) != s){
            S.at(i) = '*';
        }
    }
    cout << S << endl;
    return 0;
}

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

using namespace std;

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

int main()
{
  IO;
	int n, c; cin >> n >> c;
	vector <vector <int>> d(c, vector <int> (c));
	for (int i = 0; i < c; ++i)
	for (int j = 0; j < c; ++j)
		cin >> d[i][j];

	vector <vector <int>> g(n, vector <int> (n));
	for (int i = 0; i < n; ++i)
	for (int j = 0; j < n; ++j)
		cin >> g[i][j];

	vector <int> color1(c), color2(c), color3(c);
	for (int i = 0; i < n; ++i)
	for (int j = 0; j < n; ++j) {
		if ((i + j) % 3 == 0) {
			for (int k = 0; k < c; ++k)
				color1[k] += d[g[i][j] - 1][k];
		}
		else if ((i + j) % 3 == 1) {
			for (int k = 0; k < c; ++k)
				color2[k] += d[g[i][j] - 1][k];
		}
		else if ((i + j) % 3 == 2) {
			for (int k = 0; k < c; ++k)
				color3[k] += d[g[i][j] - 1][k];
		}
	}

	int res = 1e9 + 7;
	for (int i = 0; i < c; ++i)
	for (int j = 0; j < c; ++j)
	for (int k = 0; k < c; ++k)
	if (i != j && i != k && j != k)
		res = min(res, color1[i] + color2[j] + color3[k]);

	cout << res << endl;
 
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (a < c && c < b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256