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

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

using namespace std;

#define MOD 1000000007
#define INIT -1

vector<long long int> dijkstra(vector<vector<pair<int, int> > > graph, int s) {
	int n = graph.size();
	vector<long long int> ans(n, (long long int)MOD * MOD);
	priority_queue<pair<long long int, int> > qu;
	qu.push(make_pair(0, s));
	while (!qu.empty()) {
		long long int cost = -(qu.top()).first;
		int now = (qu.top()).second;
		qu.pop();
		if (ans[now] < cost) continue;
		ans[now] = cost;
		for (int i = 0; i < graph[now].size(); i++) {
			int next = graph[now][i].first;
			long long int nextcost = graph[now][i].second + cost;
			if (ans[next] > nextcost) {
				ans[next] = nextcost;
				qu.push(make_pair(-nextcost, next));
			}
		}
	}
	return ans;
}

int main() {
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--;
	t--;
	vector<vector<pair<int, int> > > moneyGraph(n);
	vector<vector<pair<int, int> > > snuukGraph(n);
	for (int i = 0; i < m; i++) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		moneyGraph[u].push_back(make_pair(v, a));
		snuukGraph[u].push_back(make_pair(v, b));
		moneyGraph[v].push_back(make_pair(u, a));
		snuukGraph[v].push_back(make_pair(u, b));
	}
	vector<long long int> moneyCost = dijkstra(moneyGraph, s);
	vector<long long int> snuukCost = dijkstra(snuukGraph, t);
	vector<long long int> ans(n);
	long long int initMoney = (long long int)pow(10, 15);
	ans[n - 1] = initMoney - moneyCost[n - 1] - snuukCost[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		ans[i] = max(ans[i + 1], initMoney - moneyCost[i] - snuukCost[i]);
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
}

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

int main() {
  int moji=0;
  string S,T;
  cin >> S >> T;
  for(int i=0;i<S.size();i++) {
    if(S.at(i)==T.at(i)) {
      moji++;
    }
  }
  cout << S.size()-moji << endl;
}

Measured memory_bytes: 3836
#include<stdio.h>
#define FREE 2
#define NOT_FREE 1
#define N 8


int k,row[N],col[N],dpos[2*N],dneg[2*N],A[N][N];

void printBoard(void){
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(A[i][j]){
	if(row[i]!=j){
	  return;
	}
      }
    }
  }

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j){
	printf("Q");
      }else{
	printf(".");
      }
    }printf("\n");
  }
}
  

void putQueen(int i){
  int j;
  if(i==N){
    printBoard();
  }

  for(j=0;j<N;j++){
    if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1]==NOT_FREE){
      continue;
    }
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    
    putQueen(i+1);
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}



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


  for(i=0;i<k;i++){
    scanf("%d%d",&x,&y);
    A[x][y]=1;
  }
  
  putQueen(0);
  
  return 0;
}




Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main() {
	int h,w;
	while(cin >> h >> w)
	{
		if(h==0)break;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				if((i+j)%2==0)
					cout << '#';
				else 
					cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}

}


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

const int maxn = 2e5;
int n, a[maxn + 3];

bool check(int k) {
	map<int, int> M;
	for (int i = 1; i <= n; i++) {
		if (a[i] <= a[i - 1]) {
			if (k == 1) {
				return false;
			}
			while (!M.empty() && M.rbegin() -> first > a[i]) {
				map<int, int>::iterator it = M.end();
				M.erase(--it);
			}
			for (int j = a[i]; j >= 0; j--) {
				if (j == 0) {
					return false;
				}
				if (++M[j] == k) {
					M[j] = 0;
				} else {
					break;
				}
			}
		}
	}
	return true;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	int l = 1, r = n, mid;
	while (l < r) {
		mid = (l + r) >> 1;
		if (check(mid)) {
			r = mid;
		} else {
			l = mid + 1;
		}
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _00011
{
    class Program
    {
        static void Main(string[] args)
        {
            // w：あみだくじの縦棒の本数
            // n：横棒の本数

            int w = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());
            int[] vertical = new int[w];

            for (int i = 0; i < w; i++)
            {
                vertical[i] = i + 1;
            }

            for (int i = 0; i < n; i++)
            {
                int[] input = Console.ReadLine().Split(',').Select(int.Parse).ToArray();
                int num = vertical[input[0] - 1];
                vertical[input[0] - 1] = vertical[input[1] - 1];
                vertical[input[1] - 1] = num;
            }

            foreach (int result in vertical)
            {
                Console.WriteLine(result);
            }
        }
    }
}



Measured memory_bytes: 14160
#include<iostream>

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

    int f;

    for (int n=1; n<=N;++n) {
        f=0;
        for (int x=1;x*x< n;++x){
            for (int y=1; y*y < n - x*x - x*y ;++y){
                for (int z=1;z*z <= n - x*x - y*y - x*y - y*z - z*x ;++z) {
                    if (x*x + y*y + z*z + x*y + y*z + z*x == n){
                        ++f;
                    }
                }
            }
        }
        std::cout << f << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

int main(){
    int k, n, a1, preA, curA;
    std::cin >> k >> n >> a1;
    int maxDist = 0;
    preA = a1;
    for(int i = 1; i < n; i++){
        std::cin >> curA;
        int dist = curA - preA;
        maxDist = std::max(maxDist, dist);
        preA = curA;
    }
    maxDist = std::max(maxDist, k + a1 - curA);
    std::cout << k - maxDist << std::endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i=0; i<n; i++) {
        cin >> p.at(i);
    }

    int ans = 0;
    for (int i=0; i<n-2; i++) {
        if (p.at(i+1) != min(min(p.at(i), p.at(i+1)), p.at(i+2)) && 
            p.at(i+1) != max(max(p.at(i), p.at(i+1)), p.at(i+2))) {
                ans++;
            }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    a = na()
    a.append(INF)

    # dp[i][j] : aのi個めからj-1個めまでを合体した時の最小値　a[i,j)
    dp = [[0 if _ == __ else INF for _ in range(n + 1)] for __ in range(n + 1)]

    for i in range(n):
        dp[i][i + 1] = 0

    for d in range(2, n + 1):
        for i in range(n + 1 - d):
            j = i + d
            total = sum(a[i:j])
            for k in range(1, d):
                dp[i][j] = min(dp[i][j], dp[i][i + k] + dp[i + k][j] + total)

    print(dp[0][n])


if __name__ == '__main__':
    main()


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

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

	// 010...
	int x1 = 0;
	int i = 0;
	for (char c : s) {
		if (i % 2 == 0) {
			if (c != '0') {
				x1++;
			}
		}
		else {
			if (c != '1') {
				x1++;
			}
		}
		i++;
	}

	// 101...
	int x2 = 0;
	i = 0;
	for (char c : s) {
		if (i % 2 == 0) {
			if (c != '1') {
				x2++;
			}
		}
		else {
			if (c != '0') {
				x2++;
			}
		}
		i++;
	}

	cout << min(x1, x2) << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a+b==15)
	    printf("+");
	else if(a*b==15)
	    printf("*");
	else if(a+b!=15&&a*b!=15)
	    printf("x");
	return 0;		 
}

Measured memory_bytes: 256
n, y = list(map(int, input().split()))

iteration_number = n + 1


def find_combination(iter_num):
    for i in range(iter_num):
        for j in range(iter_num - i):
            sum_money = (10000 * i) + (5000 * j) + (1000 * (n - i - j))
            if sum_money == y:
                return [i, j, n - i - j]
    return [-1, -1, -1]


combination_list = find_combination(iteration_number)

print(*combination_list, sep=" ")


Measured memory_bytes: 3060
main = do
  li <- getLine
  let [n,t] = map read $ words li
  li <- getLine
  let ts = map read $ words li
  let ans = compute t ts
  print ans

{-
時刻0にまず先頭の人が押している。
それを原点とした絶対時刻がts
前の人との時間差 ti+1 - ti = di を求めて、
t <= di ならiの人はtだけフルに流れ、
t > di ならdiまでしか流れないで次の押し込みの分になる。
つまりmin t di
最後の人の分は必ずt流れる
-}

compute :: Int -> [Int] -> Int
compute t ts = t + sum ds
  where
    ds = zipWith f ts (0:ts)
    f t1 t0 = min t (t1 - t0)


Measured memory_bytes: 70012
use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        k: i64,
    };

    let mut rk = k;
    let na = std::cmp::min(rk, a);
    rk -= na;
    let nb = std::cmp::min(rk, b);
    rk -= nb;
    let nc = std::cmp::min(rk, c);
    let ans = na - nc;
    println!("{}", ans);
}


Measured memory_bytes: 2108
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(c,i) for(i = c.begin(); i != c.end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e;++i)
#define forsn(i,s,e) for(int i = s; i < e;++i)
#define rforn(i,s) for(int i = s; i >= 0;--i)
#define rforsn(i,s,e) for(int i = s; i >= e;--i)
# define INF 0x3f3f3f3f 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;

ll dp[105][100005];
int main()
{
    ll i,j,k,m,n;
    string s,t;
    cin>>s>>t;
    ll n1=s.length(),n2=t.length();
    ll lcs[n1+5][n2+5];
    for(i=0;i<n1;i++)
    {
        for(j=0;j<n2;j++)
        {
            if(s[i]==t[j])
            {
                if(i>0 && j>0)
                    lcs[i][j]=lcs[i-1][j-1]+1;
                else
                    lcs[i][j]=1;
            }
            else
            {
                ll x1=0,x2=0;
                if(i>0)
                    x1=lcs[i-1][j];
                if(j>0)
                    x2=lcs[i][j-1];
                lcs[i][j]=max(x1,x2);
            }
        }
    }
    string res;
    i=n1-1;
    j=n2-1;
    while(i>=0 && j>=0)
    {
        if(s[i]==t[j])
        {
            res.push_back(s[i]);
            i--;
            j--;
        }
        else
        {
            ll x1=0,x2=0;
            if(i>0)
                x1=lcs[i-1][j];
            if(j>0)
                x2=lcs[i][j-1];
            if(lcs[i][j]==x1)
            {
                i--;
            }
            else
            {
                j--;
            }
        }
    }
    reverse(res.begin(),res.end());
    cout<<res<<"\n";
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100000;
int n;
int d[MAX_N];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;
  forn(i,n) cin >> d[i];

  sort(d,d+n);

  int res = 0;
  int i = 0;
  for (int k = 1; k <= 100000; k++) {
    while (i < n && d[i] < k) i++;
    if (i == n-i) res++;
  }

  cout << res << endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int nn = ceil(double(double(n)/1000));
    cout << nn*1000-n << endl;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#define INF 1000001LL
#define INF2 100000001000000LL
using namespace std;

typedef long long ll;

#define N 100000

struct cord{
  int d;
  vector<ll> c;
  cord(void){d = 0;c.clear();}
  cord(vector<ll> v){d = v.size(); c = v;}

  ll dis(cord &a){
    if(a.d != d)return INF;
    ll res = 0;
    for(int i=0;i<d;i++)res += (a.c[i]-c[i]) * (a.c[i]-c[i]);
    return res;
  }
};

struct KDTree{
  int n,d;
  vector<cord> v,tmp;

  KDTree(void){n = d = 0;v.clear();}
  KDTree(vector<cord> x){
    n = x.size();
    if(!n)return;
    d = x[0].c.size();
    if(!d)return;
    v = x;
    tmp.resize(n);
    compose(0,n,0);
  }

  void merge(int l,int r,int k){
    if(r-l<=1)return;
    int mid = (l+r)/2;
    
    merge(l,mid,k); merge(mid,r,k);
    int x=l,y=mid,pos=l;

    while(x<mid && y<r){
    if(v[x].c[k]>v[y].c[k])tmp[pos++] = v[y++];
    else tmp[pos++] = v[x++];
    }
    while(x<mid)tmp[pos++] = v[x++];
    while(y<r)tmp[pos++] = v[y++];
    
    for(int i=l;i<r;i++)v[i] = tmp[i];
  }

  void compose(int l, int r, int depth){
    if(r-l<1)return;
    merge(l,r,depth);

    compose(l,(l+r)/2,(depth+1)%d);
    compose((l+r)/2+1,r,(depth+1)%d);
  }

  void search(int l,int r,vector<ll>& b, cord& p, int depth, ll& dist){
    if(r-l<1)return;

    int mid = (l+r)/2;
    ll tmp;
    dist = min(dist,p.dis(v[mid]));

    for(int i=0;i<d;i++){
      tmp = b[2*i]-p.c[i];
      if(tmp>0 && tmp*tmp >= dist)return;
      tmp = b[2*i+1]-p.c[i];
      if(tmp<0 && tmp*tmp >= dist)return;
    }

    for(int i=0;i<3;i++){
      if(p.c[depth]>v[mid].c[depth] && i==2)continue;
      if(p.c[depth]<=v[mid].c[depth] && i==0)continue;
      int f = i&1;
      tmp = b[2*depth+f];
      b[2*depth+f] = v[mid].c[depth]; 
      if(f)search(l,mid,b,p,(depth+1)%d,dist);
      else search(mid+1,r,b,p,(depth+1)%d,dist);
      b[2*depth+f] = tmp;
    }
  }
};

int n,q,m;
vector<cord> v;
cord p,r;
vector<ll> tmp;   

int main(){
  vector<ll> box;
  for(int i=0;i<3;i++){
    box.push_back(-INF); 
    box.push_back(INF);
  }

  while(scanf("%d%d",&n,&q)!=EOF,n||q){
    v.resize(n); tmp.resize(3);

    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++)scanf("%lld",&tmp[j]);
      v[i] = cord(tmp);
    }

    KDTree kd(v);

    for(int i=0;i<q;i++){
      scanf("%d",&m);
      double ans = 0;
      ll now,prv;

      for(int j=0;j<3;j++)scanf("%lld",&tmp[j]);
      p = cord(tmp); prv = INF2;
      kd.search(0,n,box,p,0,prv);

      for(int j=1;j<m;j++){
	for(int k=0;k<3;k++)scanf("%lld",&tmp[k]);
	r = cord(tmp); now = INF2;
	kd.search(0,n,box,r,0,now);

	ans += min(sqrt(prv) + sqrt(now), sqrt(p.dis(r)) );
	prv = now; p = r;
      }
      printf("%.9lf\n",ans);
    }
  }
}

Measured memory_bytes: 25824
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int x,k,r[100005],t,num;
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
int main (){
	int i,j,q;
	x=read();k=read();
	for (i=1;i<=k;i++)
	{r[i]=read();}
	int a,minn=0,maxn=x,pos=1,ansmin=0,ansmax=x,num=0;
	q=read();
	while (q--)
	{t=read();a=read();
	while (pos<=k&&r[pos]<t)
	{ansmin-=(r[pos]-r[pos-1]);
	if (ansmin<0) ansmin=0;
	ansmin=x-ansmin;
	ansmax-=(r[pos]-r[pos-1]);
	if (ansmax<0) ansmax=0;
	ansmax=x-ansmax;
	if (pos&1) {num-=(r[pos]-r[pos-1]);}
	else {num+=(r[pos]-r[pos-1]);}
	if (num<0) {minn=max(minn,-num);}
	if (num>0) {maxn=min(maxn,x-num);}
	pos++;
	}
	//printf ("%d %d\n",ansmin,ansmax);
	int tpans;
	if (a<=minn) {tpans=ansmin;}
	if (a>=maxn) {tpans=ansmax;}
	if (a>minn&&a<maxn) {tpans=ansmin+(a-minn)*((ansmin>ansmax)?-1:1);}
	tpans-=(t-r[pos-1]);
	if (tpans<0) tpans=0;
	if ((pos-1)&1) {tpans=x-tpans;}
	printf ("%d\n",tpans);
	}
	return 0;
}
	
	

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, t;
  cin >> n >> t;
  int res = numeric_limits<int>::max();
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (b <= t)
      res = min(res, a);
  }
  if (res == numeric_limits<int>::max())
    cout << "TLE";
  else
    cout << res;
  return 0; 
}

Measured memory_bytes: 256
#include<cstdio>

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

using namespace std;

typedef	long long	ll;

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

int w,h,sx,sy;
ll endstat,nbr[7][7];
ll vline[7],vline_above[7],vline_below[7];
ll hline[7],hline_above[7],hline_below[7];

bool searchHamiltonCycle(ll stat,int x,int y){
	stat|=1LL<<(y*w+x);

	if((hline[y]&stat)==hline[y]){
		if((hline_above[y]&stat)!=hline_above[y]
		&& (hline_below[y]&stat)!=hline_below[y])	return false;
	}
	if((vline[x]&stat)==vline[x]){
		if((vline_above[x]&stat)!=vline_above[x]
		&& (vline_below[x]&stat)!=vline_below[x])	return false;
	}

	if(stat==endstat){
		rep(i,4){
			int xx=x+dx[i],yy=y+dy[i];
			if(0<=xx && xx<w && 0<=yy && yy<h){
				if(yy==sy && xx==sx)	return true;
			}
		}
	}
	else{
		if((nbr[sy][sx]&stat)==nbr[sy][sx])	return false;
		rep(i,4){
			int xx=x+dx[i],yy=y+dy[i];
			ll nextstat=stat|(1LL<<(yy*w+xx));
			if(0<=xx && xx<w && 0<=yy && yy<h && stat!=nextstat){
				if(searchHamiltonCycle(nextstat,xx,yy))	return true;
			}
		}
	}

	return false;
}

int main(){
	for(;scanf("%d%d",&w,&h),w;){
		int even=0,odd=0;
		ll inistat=0;
		endstat=(1LL<<(w*h))-1;
		rep(i,h)rep(j,w){
			int t;	scanf("%d",&t);
			if(!t){
				sx=j,sy=i;
				if((i+j)%2)	odd++;
				else		even++;
			}
			else	inistat|=1LL<<(i*w+j);
		}

		if(even!=odd){ puts("No"); continue; }

		rep(y,h)rep(x,w){
			nbr[y][x]=0;
			rep(i,4){
				int xx=x+dx[i],yy=y+dy[i];
				if(0<=xx && xx<w && 0<=yy && yy<h)	nbr[y][x]|=1LL<<(yy*w+xx);
			}
		}
		rep(x,w){
			vline[x]=vline_above[x]=vline_below[x]=0;
			rep(y,h){
				vline[x]|=1LL<<(y*w+x);
				rep(i,x)				vline_above[x]|=1LL<<(y*w+i);
				for(int i=x+1;i<w;i++)	vline_below[x]|=1LL<<(y*w+i);
			}
		}
		rep(y,h){
			hline[y]=hline_above[y]=hline_below[y]=0;
			rep(x,w){
				hline[y]|=1LL<<(y*w+x);
				rep(i,y)				hline_above[y]|=1LL<<(i*w+x);
				for(int i=y+1;i<h;i++)	hline_below[y]|=1LL<<(i*w+x);
			}
		}

		puts(searchHamiltonCycle(inistat,sx,sy)?"Yes":"No");
	}

	return 0;
}

Measured memory_bytes: 732
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> xs(n);
  for(int i=0;i<n;i++) cin>>xs[i];
  int ans=1e9;
  for(int p=0;p<=100;p++){
    int res=0;
    for(int x:xs) res+=(x-p)*(x-p);
    chmin(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int price1 = Math.max(x, y) * 2 * c;
        int price2 = a * x + b * y;
        int price3;
        if (x > y)
            price3 = y * 2 * c + (x - y) * a;
        else
            price3 = x * 2 * c + (y - x) * b;
        System.out.println(Math.min(Math.min(price1, price2), price3));
    }
}


Measured memory_bytes: 23764
#include<iostream>
#define ll long long 
using namespace std;
const int MAXN = 301;
ll dis[MAXN][MAXN];
int main()
{
    int n, m, L; scanf("%d%d%d", &n, &m, &L);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            dis[i][j] = 1e18;
    for (int i = 1, x, y, z; i <= m; i++)
    {
        scanf("%d%d%d", &x, &y, &z);
        dis[x][y] = dis[y][x] = min(dis[x][y], (ll)z);
    }
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            dis[i][j] = dis[i][j] <= L ? 1 : 1e18;
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
    int q; scanf("%d", &q);
    for (int i = 1, s, t; i <= q; i++)
    {
        scanf("%d%d", &s, &t);
        if (dis[s][t] <= n) printf("%lld\n", dis[s][t] - 1);
        else puts("-1");
    }
    return 0;
}

Measured memory_bytes: 1280
import java.text.DecimalFormat;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n =sc.nextInt();
			if( n == 0 ) break;
			int[][] map = new int[n][n];
			for(int i=0;i<n;i++) for(int j=0;j<n;j++) {
				map[ ( n/2+1 + j + i ) % n][ ( n/2 + j - i + n ) % n ] = i * n + j + 1;
			}
			for(int i=0;i<n;i++)for(int j=0;j<n;j++) System.out.printf("%4d%s",map[i][j], (j==n-1? "\n": ""));
		}
	}
}

Measured memory_bytes: 12000
n = int(input())

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

flag = 1
i = 0
count = 0

while flag:
    flag = 0
    for j in range(n-1,i,-1):
        if a[j] < a[j-1]:
            a[j],a[j-1] = a[j-1],a[j]
            count += 1
        flag = 1
        
    i += 1

for w in range(n):
    if w != n-1:
        print(a[w],end=" ")
    else:
        print(a[w])
print(count)

Measured memory_bytes: 7724
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
	return 0;
} 

Measured memory_bytes: 256
n = int(input())
a = tuple(map(int,input().split()))
MOD = 10**9+7

N = 2
FAC = [1]
INV = [1]
for i in range(1,N+1):
  FAC.append((FAC[i-1]*i) % MOD)
  INV.append(pow(FAC[-1],MOD-2,MOD))
#print(INV[2])
  
s = 0
for ai in a:
  s += ai
  s %= MOD
ans = 0
for ai in a:
  ans += ai*(s-ai)
  ans %= 10**9+7
print((ans*INV[2])%MOD)
#print((10**9)**2%MOD)

Measured memory_bytes: 104888
#include<stdio.h>

int main(){
  int a,b,c,d,e;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  
  if(a==0){printf("1");return 0;}
  if(b==0){printf("2");return 0;}
  if(c==0){printf("3");return 0;}
  if(d==0){printf("4");return 0;}
  if(e==0){printf("5");return 0;}
}

Measured memory_bytes: 1648
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

      vector<ll>v;


      cin>>a>>b>>c;
      v.eb(a);
      v.eb(b);
      v.eb(c);

      sort(vll(v),greater<ll>());

      sum=v[0]*10;
      sum+=v[1]+v[2];

      cout<<sum<<endl;













}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const ll maxx = 1e4+5,mod=1e9+7;
ll n ;
ll arr[maxx+5];
map < ll,ll > brr ;
void calco(ll x)
{
    ll f=0;
    while(x%2==0 && x>0)
    {
        f++;
        x=x/2;
    }
    if(brr[2]<f){brr[2]=f;}
    for(ll i=3;i*i<=x;i+=2)
    {
        f=0;
        while(x%i==0 && x>0)
        {
            f++;
            x = x/i;
        }
        if(brr[i]<f){brr[i]=f;}
    }
    if(x>1 && brr[x]==0)
    {
        brr[x]=1;
    }
    return ;
}
ll fastpow(ll x,ll p)
{
    ll ans = 1 ;
    while(p>0)
    {
        if(p&1)
        {
            ans = (ll)(ans*x)%mod;
        }
        p = p >> 1 ;
        x = (ll)(x*x)%mod;
    }
    return ans ;
}
int main()
{
    cin >> n ;
    for(int i=1;i<=n;i++)
    {
        ll x;
        cin >> x ;
        arr[i]=x ;
        calco(x);
    }
    ll ans = 1 ;
    for(auto x : brr)
    {
        ll a = x.first , p = x.second ;
        ans = (ans*fastpow(a,p))%mod;
    }
    ll ret = 0;
    for(ll i=1;i<=n;i++)
    {
        ll x =  ans*fastpow(arr[i],mod-2)  ;
        ret = (ret+x+mod)%mod;
    }
    cout << ret <<  endl;
    return 0 ;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        int a = sc.nextInt();
                        int b = sc.nextInt();
                        int ans = 0;
                        for (int i = 0; i < N; i++) {
                                int n = sc.nextInt();
                                if (!(a <= n && n < b)) {
                                        ans++;
                                }
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 9808
def rotated(a):
    b = []
    for i in range(len(a[0])):
        b.append("")
        for j in range(len(a)):
            b[-1] += a[j][i]
    return b

H, W = map(int, input().split())
a = []

for i in range(H):
    ai = input()
    if "#" in ai:
        a.append(ai)

a = rotated(a)

for i in range(len(a) - 1, -1, -1):
    if "#" not in a[i]:
        a.remove(a[i])

a = rotated(a)

print("\n".join(a))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N)cin >> a[i];
    ll ans = INF;
    for(int i = 1; i <= 99 ; i++){
        ll tmp = 0;
        for(int j = 0; j < N; j++){
            tmp += (a[j] - i) * (a[j] - i);
        }
        if(ans > tmp)ans = tmp;
    }
    cout << ans << endl;
    
}

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

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0 ; i < n ; i++) {
            h[i] = sc.nextInt();
        }
        Arrays.sort(h);
        long sum = 0;
        for (int i = 0 ; i < n - k ; i++) {
            sum += (long) h[i];
        }
        System.out.println(sum);

    }

}


Measured memory_bytes: 66588
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    a=[parseMap(split(readline())) for i in 1:3]
    n=parseInt(readline())
    for i in 1:n
        b=parseInt(readline())
        for j in 1:3
            for k in 1:3
                if a[j][k]==b
                    a[j][k]=1000
                end
            end
        end
    end
    ans="No"
    for i in 1:3
        if a[i][1]==a[i][2]==a[i][3]==1000 || a[1][i]==a[2][i]==a[3][i]==1000
            ans="Yes"
        end
    end
    if a[1][1]==a[2][2]==a[3][3]==1000 || a[1][3]==a[2][2]==a[3][1]==1000
        ans="Yes"
    end
    println(ans)
end
main()

Measured memory_bytes: 112560
#include <stdio.h>

int main(void)
{
	int k,s;
	scanf("%d %d",&k,&s);
	int x,y,z,cnt=0;
	
	for(x=0;x<=k;x++){
		if(0<=s-x && s-x<=2*k){
			for(y=0;y<=k;y++){
				if(s-x-y<=k && 0<=s-x-y){
					cnt++;
				}
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll N, M;
  cin >> N >> M;
  pair<ll, ll> p[N];
  for(int i = 0; i < N; i++) cin >> p[i].second >> p[i].first;
  sort(p, p + N);
  reverse(p, p + N);

  set<ll> st;
  for(int i = 1; i <= M; i++) st.insert((ll)i);

  ll ans = 0;
  for(int i = 0; i < N; i++){
    ll a = p[i].second;
    auto it = st.lower_bound(a);
    if(it != st.end()){
      st.erase(it);
      ans += p[i].first;
    }
  }

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

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

bool v[200005];

vector<ll>xx[200005];

void check(ll ind)
{
    if(v[ind]==1) return;
    v[ind]=1;

    for(ll i=0;i<xx[ind].size();i++)
    {
        ll nx=xx[ind][i];
        if(v[nx]==0)
        {
            check(nx);
        }
    }
}

int main()
{
    ll a,c,d,e,n,m,i,j,k=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a>>c;
        xx[a].push_back(c);
        xx[c].push_back(a);
    }

    for(j=1;j<=n;j++)
    {
        if(v[j]==0)
        {
            k++;
            check(j);
        }
    }
    cout<<k-1<<endl;
}


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

int main(void){
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i=0;i<m;i++) cin >> b[i];
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];

    int count = 0;
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j<m;j++){
            sum += b[j]*a[i][j];
        }
        if(sum+c>0) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;

signed main()
{
	int n=read(),m=read(),t=read();
	if(m*t>=n) cout<<"Yes";
	else cout<<"No";
	return 0;
}




Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];

struct yo {
	long long a, b;
};

int main()
{
	long long N, M, cnt = 0, tmp1, tmp2, ans = 0;
	cin >> N >> M;
	vector<long long> a(M), b(M), s(N);
	vector<yo> y(M);

	for (int i = 0; i < M; i++) {
		cin >> tmp1 >> tmp2;
		a[i] = tmp1 - 1;
		b[i] = tmp2 - 1;
		y[i].a = a[i];
		y[i].b = b[i];

	}

	sort(y.begin(), y.end(), [](yo l, yo r) {return l.b < r.b; });

	vector<bool> sub(M, false);
	sub[0] = true;
	int j = 0;
	for (int i = 1; i < M; i++) {
		if (y[j].b <= y[i].a) {
			sub[i] = true;
			j = i;
		}
	}

	for (int i = 0; i < M; i++) {
		if (sub[i]) ans++;
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 4224
n = int(input())
ans = 0
num_table = [[0 for i in range(10)] for j in range(10)]

for i in range(1, n + 1):
    i = list(str(i))
    head = int(i[0])
    tail = int(i[-1])
    num_table[head][tail] += 1

for i in range(10):
    for j in range(10):
        ans += num_table[i][j] * num_table[j][i]

print(ans)


Measured memory_bytes: 40684
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n+1)

    # 検索
    # 根ならその番号を返す
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m=map(int,input().split())
kl=[list(map(int,input().split())) for i in range(n)]
uf=UnionFind(m)
for i in range(n):
    for j in range(2,kl[i][0]+1):    
        uf.union(kl[i][1], kl[i][j])

for i in range(1,n):
    if not uf.same_check(kl[0][1],kl[i][1]):
        print("NO")
        quit()
print("YES")

Measured memory_bytes: 71132
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

int main()
{
    vector<ll> A(3);
    for (ll i = 0; i < 3; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    cout << A[2] - A[0] << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	doublade();
	// w(t) {
		ll n;
		cin >> n;
		if(n>=30) cout<<"Yes\n";
		else cout<<"No\n";
	// }
	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
typedef struct cityStruct {
  int cityNum;
  int pref;
  int year;
  int id_of_pref;
} city_t;
int compare_city_year(const void* x, const void* y) {
  city_t* a = (city_t*)x;
  city_t* b = (city_t*)y;
  /*
    a < b => -1
    a ==b =>  0
    a > b =>  1
  */
  if (a->year < b->year) return -1;
  if (a->year > b->year) return 1;
  return 0;
}
int compare_city_num(const void* x, const void* y) {
  city_t* a = (city_t*)x;
  city_t* b = (city_t*)y;
  /*
    a < b => -1
    a ==b =>  0
    a > b =>  1
  */
  if (a->cityNum < b->cityNum) return -1;
  if (a->cityNum > b->cityNum) return 1;
  return 0;
}
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  
  int pref[N];
  city_t cities[M];
  for (int i = 0; i < N; ++i) pref[i] = 0;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d", &cities[i].pref, &cities[i].year);
    cities[i].cityNum = i;
    cities[i].pref -= 1;
  }
  
  qsort(cities, M, sizeof(city_t), &compare_city_year);
  for (int i = 0; i < M; ++i) {
    cities[i].id_of_pref = ++pref[cities[i].pref];
  }
  qsort(cities, M, sizeof(city_t), &compare_city_num);
  for (int i = 0; i < M; ++i)
    printf("%06d%06d\n", cities[i].pref + 1, cities[i].id_of_pref);
  return 0;
}

Measured memory_bytes: 4964
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
vector<int> array(n);int sum=0;
for(int i=0;i<n;i++)
cin>>array[i];
vector<bool> dp(k+1,false);
    for(int stones=0;stones<=k;++stones)
    {
        for(int i=0;i<n;++i)
        {
        if(stones>=array[i] && !dp[stones-array[i]])
        dp[stones]=1;
        }
    }

if(dp[k])
cout<<"First";
else
cout<<"Second";
return 0;
}

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

int main()
{
	int n;
	int a[101];
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int sum = 0;
	for (int i = 1; i <= n; i+=2)
	{
		if (a[i] & 1) sum++;
	}
	cout << sum;

	return 0;
}

Measured memory_bytes: 3584
a,b,c,d = map(int, input().split())

a_li = [0 for i in range(100)]
b_li = [0 for i in range(100)]
a_li[a:b] = [1 for i in range(a,b)]
b_li[c:d] = [1 for i in range(c,d)]

li = []
for i,j in zip(a_li, b_li):
  li.append(i+j)

print(li.count(2))

Measured memory_bytes: 3064
import java.util.Scanner;

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

        String N = scan.next();
        String M = scan.next();
        int[] a = new int[Integer.parseInt(M)];
        int sum = 0;
        for(int i = 0; i < Integer.parseInt(M);i++){
            sum += Integer.parseInt(scan.next());
        }

        if(Integer.parseInt(N) - sum < 0)System.out.println("-1");
        else System.out.println(Integer.parseInt(N) - sum );

    }
}


Measured memory_bytes: 41492
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>b){
		for(int i=0;i<a;i++)
			cout<<b;
	}
	if (b>a){
		for(int i=0;i<b;i++)
			cout<<a;
	}
	if (a==b){
		for(int i=0;i<b;i++)
			cout<<a;
	}

	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N 10

int main(void){
    int n,d;
    int x[N][N];
    int i,j,k;
    int a,b;
    double c;
    int count = 0;
    
    scanf("%d %d", &n, &d);
    for(i = 0; i < n; i++){
        for(j = 0; j < d; j++){
            scanf("%d", &x[i][j]);
        }
    }
    
    for(i = 0; i < n; i++){
        for(j = i+1; j < n; j++){
            a = 0;
            for(k = 0; k < d; k++){
                b = (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
                a += b;
            }
            c = sqrt(a);
            b = (int)c;
            if(c == (double)b){
                count++;
                //printf("%d,%d\n", i, j);
            }
        }
    }
    
    printf("%d",count);
    
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    long n=gl();
	     
	    long i=0;
	    while(i*i<=n) {
	    	i++;
	    }

	    System.out.print((i-1)*(i-1));
//	    if (s.contains("AC")) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int A,B;cin>>A>>B;
  int output=1;
  int ans=0;
  while(output<B){
    output+=A-1;
    ans++;
  }
  print(ans)
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  long long s, s1;
  cin >> n >> k >> s;
  if (s != 1000000000) {
    s1 = s + 1;
  } else {
    s1 = s - 1;
  }
  for (int i = 0; i < n; i++) {
    if (k > 0) {
      cout << s << " ";
      k--;
    } else {
      cout << s1 << " ";
    }
  }
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(br.readLine());
		}
		br.close();

		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 1) {
				System.out.println("first");
				return;
			}
		}
		System.out.println("second");
	}
}


Measured memory_bytes: 30648
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	for n > 0 {
		v := f(n)
		fmt.Println(v)
		n -= v
	}
}

// nをについての最小最大数
func f(n int) int {
	i := 0
	sum := 0
	for sum < n {
		i++
		sum += i
	}
	return i
}


Measured memory_bytes: 1820
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int a[100010]; 
int main() {
  int n; 
  cin >> n;
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  int ans = 0;
  int x = a[0];
  int i = 0;

  //vector<int> g;
  while (i < n)
  {
    int num = 0;
    while (a[i] == x)
    {
      num++;
      i++;
    }
    if (num == x) continue;
    else if (num < x) ans += num;
    else  ans += num-x;
    x = a[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    string s; cin>>s;
    int n=s.size();
    int a,z;
    for(int i=0;i<n;i++){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='Z'){
            z=i;
            break;
        }
    }
    cout<<z-a+1<<endl;
}


Measured memory_bytes: 640
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define ran(x) (x).begin(),(x).end()
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define plli pair<lli,lli>
#define paf(L,R) pair<L,R>
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    string s, t;
    cin >> s >> t;
    if(s == t)
        return cout << 0 << endl, 0;
    int cou = 0;
    if(s.length() == t.length()) {
        for(int i = 0; i < s.length(); ++i) {
            if(s[i] == t[i])
                ++cou;
        }
        cout << s.length() - cou << endl;
        return 0;
    }
    int ma = 0;
    for(int i = 0; i < s.length()-t.length(); ++i) {
        int cou = 0;
        for(int j = 0; j <t.length(); ++j) {
            if(s[j+i] == t[j])
                ++cou;
        }
        ma = max(ma, cou);
    }
    cout << t.length() - ma << endl;
}

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

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int& i : A) cin >> i;
	vector<int> tmp1 = A, tmp2 = A;
	for (int i = 1; i < N; ++i) tmp1[i] = gcd(tmp1[i - 1], tmp1[i]);
	for (int i = N - 1; i > 0; --i) tmp2[i - 1] = gcd(tmp2[i - 1], tmp2[i]);
	int ans = tmp2[1];
	for (int i = 1; i < N - 1; ++i) ans = max(gcd(tmp1[i - 1], tmp2[i + 1]), ans);
	ans = max(tmp1[N - 2], ans);
	cout << ans;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    string s,ans="No";
    cin>>s;
    if(s[2]-s[3]==0&&s[4]-s[5]==0) ans="Yes";
    cout<<ans<<endl;
}

Measured memory_bytes: 256