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

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

        int n = sc.nextInt();
        ArrayList<String> s = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            s.add(sc.next());
        }

        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            String t = sc.next();
            s.remove(t);
        }
        s.sort(null);

        int max = 0;
        if (s.size() > 0) {
            int cnt = 1;
            for (int i = 1; i < s.size(); i++) {
                if (s.get(i).equals(s.get(i-1))) {
                    cnt++;
                    max = Math.max(max, cnt);
                } else {
                    cnt = 1;
                }
            }
            max = Math.max(max, cnt);
        }

        System.out.print(max);
    }
}

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

int main() {
	int n;
	cin>>n;
	map<string,int> m;
	m["AC"]=0;
	m["WA"]=0;
	m["TLE"]=0;
	m["RE"]=0;
	while(n--){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<"\n";
	cout<<"WA x "<<m["WA"]<<"\n";
	cout<<"TLE x "<<m["TLE"]<<"\n";
	cout<<"RE x "<<m["RE"]<<"\n";

  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int N, D;
    int count = 0;

    cin >> N >> D;
    vector< vector<int> > d(N, vector<int>(D));

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            int t;
            cin >> t;
            d[i][j] = t;
        }

        for (int j = i - 1; j >= 0; j--) {
            int t = 0;
            for (int k = 0; k < D; k++) {
                t += pow(abs(d[i][k] - d[j][k]), 2);
            }
            double a = sqrt(t);
            if (ceil(a) == floor(a)) {
                count += 1;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define M 2000000
 
int main(void) 
{
  
  int n,p[N],m[N][N];
  int i,j,k,l,q;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d%d",&p[i],&j);
  
  p[n] = j;;
  for(i=1;i<=n;i++)
    m[i][i] = 0;
  
  for(l=2;l<=n;l++) 
    {
      for(i=1;i<=n-l+1;i++) 
	{
	  j = i + l - 1;
	  m[i][j] = M;
	  for(k=i;k<=j-1;k++) 
	    {
	      q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	      
	      if(m[i][j] > q)
		m[i][j] = q;
	    }
	}
    }
  printf("%d\n",m[1][n]);
  
  return 0;
}

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

int D, N;

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

  int k = 1;
  rep(i,D) k *= 100;

  cout << k * N + (N == 100 ? k : 0) << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import deque
 
N = int(input())
Ass = tuple(deque(map(int, input().split())) for _ in range(N))
 
Q = set(range(N))
ans = -1
while Q:
    ans += 1
    Q2 = Q.copy()
    Q.clear()
    for i in Q2:
        if not Ass[i]:
            continue
        t = Ass[i][0] - 1
        if Ass[t][0] == i + 1:
            Q.add(i)
            Q.add(t)
    for i in Q:
        Ass[i].popleft()

if any(Ass):
    print(-1)
else:
    print(ans)

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

using namespace std;
using ll=long long;

int main() {
    ll N, M, res = 0;
    cin >> N >> M;

    if (N > 1) {
        res += (N * (N - 1)) / 2;
    }
    if (M > 1) {
        res += (M * (M - 1)) / 2;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

bool ans;
int c[4][4],a[4],b[4];
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++){
            cin>>c[i][j];
        }
    }
    for(int t=0;t<=c[1][1];t++){
        a[1] = t;
        b[1] = c[1][1] - a[1];
        b[2] = c[1][2] - a[1];
        b[3] = c[1][3] - a[1];
        a[2] = c[2][1] - b[1];
        a[3] = c[3][1] - b[1];

        bool valid=true;
        for(int i=1;i<=3;i++){
            for(int j=1;j<=3;j++){
                if(c[i][j]!= a[i]+b[j]){valid=false;}
            }
        }
        if(valid)ans=true;
    }
    if(ans){cout<<"Yes\n";}
    else{cout<<"No\n";}
}


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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	map<string, int> m;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		m[s]++;
	}
	
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"];
}

Measured memory_bytes: 3668
import java.util.ArrayList;
import java.util.Scanner;

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

		boolean flag = true;
		
		int nico = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < nico; i++) {
			String[] param = sc.nextLine().split(" ");
			
			int large = 0;
			int small = 0;
			for (int j = 0; j < 10; j++) {
				int tmp = Integer.parseInt(param[j]);
				
				if (large < tmp) {
					large = tmp;
				} else if (small < tmp) {
					small = tmp;
				} else {
					flag = false;
					break;
				}
			}
			if (flag) System.out.println("YES");
			else System.out.println("NO");
		}
		
	}
}

Measured memory_bytes: 26080
//author:happylkx
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string.h>
#include <set>
#include <string>
using namespace std;
typedef long long LL;

char a[51], b[51];
int main()
{
	cin.getline(a, 51);
	cin.getline(b, 51);
	int lena = strlen(a);
	int lenb = strlen(b);

	set<string> list;
	bool found = false;
	int i;
	for (i = lena - 1;i >= lenb - 1;i--) {
		bool valid = true;
		for (int j = 0;j < lenb;j++) {
			if ((a[i - j] == b[lenb - 1 - j]) || (a[i - j] == '?')) {
				continue;
			}
			else {
				valid = false;
				break;
			}
		}

		if (valid) {
			found = true;
			char tmp[51];
			strcpy(tmp, a);
			for (int j = 0;j < lenb;j++) {
				tmp[i - j] = b[lenb - 1 - j];
			}
			for (int j = 0;j < lena;j++) {
				if (tmp[j] == '?')tmp[j] = 'a';
			}
			string temp(tmp);
			list.insert(temp);
		}
	}

	if (found) {
		cout << *list.begin();
	}
	else {
		cout << "UNRESTORABLE";
	}
	return 0;
}


Measured memory_bytes: 256
using System;

namespace AOJ.Volume1
{
    public class FrequencyDistributionOfHeight
    {
        public static int Main()
        {
            int st = int.Parse(Console.ReadLine());
            // fq[0]…h < 165.0
            // fq[1]…165.0 <= h < 170.0
            // fq[2]…170.0 <= h < 175.0
            // fq[3]…175.0 <= h < 180.0
            // fq[4]…180.0 <= h < 185.0
            // fq[5]…h >= 185.0
            var fq = new string[6] { "", "", "", "", "", "" };

            for (int i = 0; i < st; i++)
            {
                double h = double.Parse(Console.ReadLine());
                if (h < 165) { fq[0] += "*"; }
                else if (h < 170) { fq[1] += "*"; }
                else if (h < 175) { fq[2] += "*"; }
                else if (h < 180) { fq[3] += "*"; }
                else if (h < 185) { fq[4] += "*"; }
                else { fq[5] += "*"; }
            }

            for (int i = 0; i < 6; i++)
            {
                Console.WriteLine((i + 1).ToString() + ":" + fq[i]);
            }
            return 0;
        }
    }
}

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

int main(){
	int n;
	cin >> n;
	int hmax = 0;
	int ans = 0;
	for(int i=0; i<n; i++){
		int h;
		cin >> h;
		if(hmax <= h) ans++;
		hmax = max(hmax, h);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES;
#include <math.h>
#include <cstdio>
#include <iostream>
#include <limits>
#include <algorithm>
using namespace std;

void Koch(double p1x, double p1y, double p2x, double p2y, int n)
{
	if (n <= 0)return;
	double sx = (2.0 * p1x + 1.0 * p2x) / 3.0;
	double sy = (2.0 * p1y + 1.0 * p2y) / 3.0;
	double tx = (1.0 * p1x + 2.0 * p2x) / 3.0;
	double ty = (1.0 * p1y + 2.0 * p2y) / 3.0;
	double ux = (tx - sx) * cos(M_PI* 60.0 / 180.0) - (ty - sy) * sin(M_PI * 60.0 / 180.0) + sx;
	double uy = (tx - sx) * sin(M_PI * 60.0 / 180.0) + (ty - sy) * cos(M_PI * 60.0 / 180.0) + sy;
	Koch(p1x, p1y, sx, sy, n - 1);
	printf("%.8f %.8f\n", sx, sy);
	Koch(sx, sy, ux, uy, n - 1);
	printf("%.8f %.8f\n", ux, uy);
	Koch(ux, uy, tx, ty, n - 1);
	printf("%.8f %.8f\n", tx, ty);
	Koch(tx, ty, p2x, p2y, n - 1);

}
void C()
{
	int N = 0;
	scanf("%d", &N);
	printf("%.8f %.8f\n",0.0,0.0);
	Koch(0, 0, 100, 0, N);
	printf("%.8f %.8f\n", 100.0, 0.0);

}

int main()
{
	C();
	return 0;
}

Measured memory_bytes: 1224
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a, b = LI()
    ans = [str(a) * b, str(b) * a]
    ans.sort()
    print(ans[0])
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
#include <iostream>
#include <algorithm>
#include <math.h>

typedef long long ll;
using namespace std;

int main()
{
  int n, i;
  ll a[200001]={0};
  ll p[200001]={0};
  cin >> n;

  for(i=1; i<=n; i++){
    cin >> a[i];
    p[i] = a[i] + p[i-1];
  }

  ll ans = 1e16;
  ll diff[4];

  ll l=1, r=3;

  for(i=2; i<=n; i++){
    while(l<i && abs(p[l]-(p[i]-p[l])) >= abs(p[l+1]-(p[i]-p[l+1]))) l++;
    while(r<n && abs((p[r]-p[i])-(p[n]-p[r])) >= abs((p[r+1]-p[i])-(p[n]-p[r+1]))) r++;
    
    diff[0]=p[l];
    diff[1]=p[i]-p[l];
    diff[2]=p[r]-p[i];
    diff[3]=p[n]-p[r];

    sort(diff, diff+4);
    ans = min(ans, diff[3]-diff[0]);
  }

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


Measured memory_bytes: 3328
n=gets.chomp.to_i
ary=Array.new
for i in 0..n-1
	ary=ary.push(gets.chomp.to_i)
end


def insertion(ary,n,g)
	for i in g..n-1
		v=ary[i]
		j=i-g
		while j>=0 && ary[j]>v
			ary[j+g]=ary[j]
			j-=g
			@count+=1
		end
		ary[j+g]=v
	end
end

g=1
while 3*g+1<=n
	g=3*g+1
end


@count=0

k=Array.new
while g>=1 
	insertion(ary,n,g)
	k=k.push(g)
	g=(g-1)/3
end
puts(k.size)

puts(k.join(" "))
puts @count
puts (ary)

Measured memory_bytes: 16580
def main():

    H, W, K = map(int, input().split())
    S = []
    for _ in range(H):
        S.append(input())

    div = [[]]
    for i in range(1, H+1):
        temp = []
        for lv in div:
            temp.append(lv + [i])
            if i < H:
                temp.append(lv)
        div = temp

    ans = float('inf')
    for lv in div:
        accum = [0 for _ in range(len(lv))]
        count = 0
        chk = []
        is_invalid = False
        for j in range(W):
            k = 0
            to_add = []
            v = 0
            for i in range(H):
                if i == lv[k]:
                    k += 1
                    to_add.append(v)
                    v = 0
                if S[i][j] == '1':
                    v += 1
            to_add.append(v)
            if any(to_add[i] > K for i in range(len(lv))):
                is_invalid = True
                break
            elif any((accum[i] + to_add[i]) > K for i in range(len(lv))):
                count += 1
                accum = to_add
                chk.append(j)
            else:
                for i in range(len(lv)):
                    accum[i] += to_add[i]
        if not is_invalid:
            ans = min(ans, count + len(lv)-1)
    return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 55388
#include<stdio.h>
#include<string>
#include<vector>
#include<iostream>

using namespace std;

int main(void)
{
  	int N,X;
  	int *L;
  	int Dn = 0;
  	int cnt = 1;
  
  	scanf("%d",&N);
  	scanf("%d",&X);
  	L = new int[N];
  	for(int i=0;i<N;i++)
    {
		scanf("%d",&L[i]);
    }
  
  	for(int i=0;i<N;i++)
    {
		Dn = Dn + L[i];
      	if(Dn>X)
        {
			break;
        }
      	cnt++;
    }	
  
  	printf("%d\n",cnt);
  
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int x; cin >> x;
  int ans;
  
  while( x>=500){
    x -= 500;
    ans+=1000;
  }
  
  while( x>=5){
    x -= 5;
    ans+=5;
  }
  cout << ans;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
b=[]
ans=0

for _ in range(m):
  c,r=map(int,input().split())
  
  a.append(c)
  b.append(r)
  
for i in range(n):
  ans=a.count(i+1)
  ans+=b.count(i+1)
  print(ans)

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

void Main() {
  long long a, b;
  cin >> a >> b;
  if (a % 2) { // 奇数から
    if (b % 2) { // 奇数まで
      if ((b - a) / 2 % 2) cout << (a ^ 1) << endl;
      else cout << a << endl;
    } else { // 偶数まで
      if ((b - a) / 2 % 2) cout << (a ^ 1 ^ b) << endl;
      else cout << (a ^ b) << endl;
    }
  } else { // 偶数から
    if (b % 2) { // 奇数まで
      if ((b + 1 - a) / 2 % 2) cout << 1 << endl;
      else cout << 0 << endl;
    } else { // 偶数まで
      if ((b - a) / 2 % 2) cout << (1 ^ b) << endl;
      else cout << b << endl;
    }
  }
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  char s[300];
  int len,max,i;
  scanf("%s",s);
  len = strlen(s);
  for(max=(len-1)/2;max>0;max--){
    for(i=0;i<max;i++){
      if(s[i]!=s[max+i])break;
    }
    if(i==max){
      printf("%d\n",max*2);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 128
//--------------------------------------------------------------------------------
// Code By:
//					######                  #               ######
//					##   #                  #               #
//					#####      ##       #####      ##       #   ###
//					##   #              #   #               #   # #
//					##    #	            #####               ##### #
//---------------------------------------------------------------------------------

#include<bits/stdc++.h>
using namespace std;

                             /* ----------------------------- START of Template ---------------*/
#define ll long long int
#define FOR(x,to) for(x=0;x<(to);x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<long long int> >
#define vll vector<long long int>
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SZ(X) ((int)(X).size())
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second

void getZarr(string str, vll &Z)
{
    ll n = str.length();
    ll L, R, k;
    L = R = 0;
    for (ll i = 1; i < n; ++i)
    {
        if (i > R)
        {
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        }
        else
        {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else
            {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
   } } }}
vector<ll>isprime;
void seive(ll size){
	isprime.resize(size+1,1);
	ll i,j;
	isprime[0]=0;
	isprime[1]=0;
	for(i=2;i*i<=size;i++){
		if(isprime[i]){
			for(j=2;j*i<=size;j++)isprime[i*j]=0;
		}
	}
}
ll power(ll x,unsigned ll y, ll m){
	if(y==0)return 1;
	ll p=power(x,y/2,m);
	p=(p*p)%m;
	if(y%2!=0)p=(p*x)%m;
	return p;
}
ll modinverse(ll a,ll m){
	return power(a,m-2,m);
}


                       /* ----------------------          End Of Template --------------------------------*/

ll findans(){
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	ll ans=999999999999999999;
	if(k%2==0)ans=min(x,ans);
	ll steps=min(k,x/d);
	x-=steps*d;
	k-=steps;
	if(k%2==0)ans=min(ans,x);
	if(k>0){
		x-=d;
		k--;
		if(k%2==0)
		ans=min(ans,abs(x));
	}
	cout<<ans<<endl;
	return 0;
	



}

int main(){
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll t,i;
//	cin>>t;
t=1;
	for(i=0;i<t;i++){
		findans();
	}
return 0;
}





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

using pii = pair<int, int>;
using ll = long long;

constexpr ll INFLL = 1e18;
constexpr int Mod = 1e9 + 7;

using weight = ll;

struct edge {
    int to;
    weight cost;
};

using edges = std::vector<edge>;
using graph = std::vector<edges>;

void add_edge(graph& g, int from, int to, weight cost) {
    g[from].push_back(edge{to, cost});
    g[to].push_back(edge{from, cost});
}

vector<weight> dijkstra(graph const& g, int s, vector<ll>& dp) {
    std::vector<ll> d(g.size(), INFLL);
    dp.assign(g.size(), 0);
    d[s] = 0;
    dp[s] = 1;
    std::priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
    que.emplace(0, s);
    while(!que.empty()) {
        int v = que.top().second;
        ll cur_d = que.top().first;
        que.pop();
        if(cur_d > d[v]) {
            continue;
        }
        for(auto const& e : g[v]) {
            if(d[e.to] < cur_d + e.cost) continue;
            if(d[e.to] == cur_d + e.cost) {
                (dp[e.to] += dp[v]) %= Mod;
            }
            if(d[e.to] > cur_d + e.cost) {
                d[e.to] = cur_d + e.cost;
                que.emplace(d[e.to], e.to);
                dp[e.to] = dp[v];
            }
        }
    }
    return d;
}

int main() {
    int N, M, S, T;
    cin >> N >> M >> S >> T;
    S--, T--;
    graph g(N);
    for(int i = 0; i < M; ++i) {
        ll U, V, D;
        cin >> U >> V >> D;
        add_edge(g, U - 1, V - 1, D);
    }
    vector<ll> dp1, dp2;
    vector<bool> used(N), used2(N);
    auto d1 = dijkstra(g, S, dp1);
    auto d2 = dijkstra(g, T, dp2);
    ll dist = d1[T];
    for(int i = 0; i < N; ++i) {
        used[i] = (dist == d1[i] + d2[i]);
    }
    ll ans = 0;
    for(int v = 0; v < N; ++v) {
        if(!used[v]) continue;
        if(d1[v] * 2 == dist) {
            ll t = (dp1[v] * dp2[v]) % Mod;
            t = (t * t) % Mod;
            ans = (ans + t) % Mod;
        } else {
            for(auto& e : g[v]) {
                int to = e.to;
                if(d1[v] + d2[to] + e.cost != dist) continue;
                if(d1[v] * 2 < dist && dist < d1[to] * 2) {
                    ll t = (dp1[v] * dp2[to]) % Mod;
                    t = (t * t) % Mod;
                    ans = (ans + t) % Mod;
                }
            }
        }
    }
    ans = (dp1[T] * dp2[S] - ans + Mod) % Mod;
    cout << ans << endl;
}



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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

vector<int> dp(100500, 0);
vector<int> v;

int n;

void dfs(){
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i-1] + abs(v[i-1] - v[i]), dp[i-2] + abs(v[i-2] - v[i]));
  }

  // print(v);
  // print(dp);

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

int main(){
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

  dp[0] = 0;
  dp[1] = abs(v[0] - v[1]);

  dfs();


}


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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}

int main() {
  int n, ma, mb; cin >> n >> ma >> mb;
  vector<int> a(n), b(n), c(n);
  REP(i, n) cin >> a[i] >> b[i] >> c[i];

  const int MA = *max_element(a.begin(), a.end()) * n;
  const int MB = *max_element(b.begin(), b.end()) * n;
  const int inf = numeric_limits<int>::max();

  auto dp = make_v<int>(n+1, MA+1, MB+1);
  fill_v(dp, inf);
  dp[0][0][0] = 0;

  REP(i, n)REP(aa, MA+1)REP(bb, MB+1){
    if(dp[i][aa][bb] == inf) continue; 
    dp[i+1][aa][bb] = min(dp[i][aa][bb], dp[i+1][aa][bb]);
    dp[i+1][aa + a[i]][bb + b[i]] = min(dp[i][aa][bb] + c[i], dp[i+1][aa + a[i]][bb + b[i]]);
  }
  

  int ans = inf;
  REP(i, MA+1)REP(j, MB+1){
    if(i == 0 || j == 0) continue;
    if(i * mb == j * ma && dp[n][i][j] != inf) ans = min(ans, dp[n][i][j]);
  }

  cout << (ans == inf? -1: ans) << endl;

  return 0;
}


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

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

  int answer = 0;
  for (int i = A; i <= B; i++) {
    int x = i;
    int _5 = x % 10;
    x /= 10;
    int _4 = x % 10;
    x /= 100;
    int _2 = x % 10;
    x /= 10;
    int _1 = x % 10;
    if (_1 == _5 && _2 == _4) answer++;
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
class DisjointSet:

    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.rank = [0 for i in range(n)]

    def same(self, x, y):
        return self.findset(x) == self.findset(y)

    def findset(self, x):
        if x != self.p[x]:
            self.p[x] = self.findset(self.p[x])
        return self.p[x]

    def unite(self, x, y):
        self.link(self.findset(x), self.findset(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

def main():
    n, q = map(int, input().split(' '))

    ds = DisjointSet(n)

    for _ in range(q):
        c, a, b = map(int, input().split(' '))
        
        if c == 0:
            ds.unite(a, b)
        else:
            if ds.same(a, b):
                print(1)
            else:
                print(0)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6040
#include <stdio.h>

int main(void)
{
    int H, W;

    while(scanf("%d %d", &H, &W))
    {
        if(H == 0 && W == 0)
        {
            return 0;
        }

        int i;
        for(i = 0; i < H; ++i)
        {
            int j;
            for(j = 0; j < W; ++j)
            {
                printf("#");
            }

            printf("\n");
        }

        printf("\n");
    }
}

Measured memory_bytes: 572
#include<iostream>

using namespace std;

int main() {
	double ave;
	int ans,a,b, n,max,min;
	while (1) {
		ave = 0;
		cin >> n;
		b = 0;
		if (n == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> a;
			if (b == 0) {
				max = a;
				min = a;
			}
			else {
				if (a > max)max = a;
				if (a < min)min = a;
			}
			ave += a;
			b = 1;
		}
		ans = (ave - max - min) / (n - 2);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2980
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(s[int(input()) - 1])

Measured memory_bytes: 3064
using System;

namespace _5_C
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var hw = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var h = hw[0];
                var w = hw[1];
                if (h == 0 && w == 0) break;
                for (var i = 0; i < h; i++)
                {
                    for (var j = 0; j < w; j++)
                    {
                        if (i % 2 == 0)
                        {
                            if (j % 2 == 0)
                            {
                                Console.Write("#");
                            }
                            else
                            {
                                Console.Write(".");
                            }
                        }
                        else
                        {
                            if (j % 2 == 0)
                            {
                                Console.Write(".");
                            }
                            else
                            {
                                Console.Write("#");
                            }
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}



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

#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define ll long long int
#define mod 1000000007
const int N=1e5+5;

int n,k;
int cache[N];
int val[N];

int dp(int pos)
{
	if(pos==0)
		return cache[pos];
	for(int i=pos-1;i>=max(0,pos-k);i--)
	{
		cache[i]=min(cache[i],cache[pos]+abs(val[pos]-val[i]));
	}
	return dp(pos-1);
}

int32_t main()
{
	fastIO;
	
	int i;
	cin>>n;
	k=2;
	for(i=0;i<n;i++)
		cin>>val[i];
	for(i=0;i<n;i++)
		cache[i]=INT_MAX;
	cache[n-1]=0;
	
	cout<<dp(n-1);

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[][] stu = new int[N][2];
    for(int i = 0; i < N; i++){
      stu[i][0] = Integer.parseInt(sc.next());
      stu[i][1] = i+1;
    }
    Arrays.sort(stu, (a, b)-> Integer.compare(a[0],b[0]));
    
    for(int i = 0; i < N; i++){
      if(i == N-1){
        System.out.println(stu[i][1]);
      }else{
        System.out.print(stu[i][1]);
        System.out.print(" ");
      }
    }
  }
}


Measured memory_bytes: 55244
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef vector<vector<vector<double>>> VEC_3D_DBL;

int N;

double f(int c1, int c2, int c3, VEC_3D_DBL &dp)
{
    if (dp[c1][c2][c3] != -1)
        return dp[c1][c2][c3];

    double res = (double)N;
    if (c1 > 0)
        res += f(c1 - 1, c2, c3, dp) * (double)c1;
    if (c2 > 0)
        res += f(c1 + 1, c2 - 1, c3, dp) * (double)c2;
    if (c3 > 0)
        res += f(c1, c2 + 1, c3 - 1, dp) * (double)c3;
    res /= (double)(c1 + c2 + c3);
    dp[c1][c2][c3] = res;
    return res;
}

int main()
{
    cin >> N;
    vector<int> cnt(3, 0);
    rep(i, 0, N)
    {
        int val;
        cin >> val;
        cnt[--val]++;
    }

    int c1, c2, c3;
    c1 = cnt[0];
    c2 = cnt[1];
    c3 = cnt[2];

    VEC_3D_DBL dp(c1 + c2 + c3 + 1,
                  vector<vector<double>>(c2 + c3 + 1, vector<double>(c3 + 1, -1)));
    dp[0][0][0] = 0;

    double ans = f(c1, c2, c3, dp);
    printf("%.12f\n", ans);
    return 0;
}

/*
printfの方法を参照した
https://atcoder.jp/contests/dp/submissions/3936844

Python3, PyPy3でTLEしたのと同じ方法

# dp[x][y][z]:=1,2,3個の皿がx,y,z残っているときの期待値

# dp[now] =
# 1
# + dp[1個の皿を食べた] * p
# + dp[2個の皿を食べた] * p
# + dp[3個の皿を食べた] * p
# + dp[0個の皿を食べた==now] * p

*/

Measured memory_bytes: 216960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(), a.end());
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout<<"NO" <<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MIN(a,b) ((a) < (b) ? (a) : (b))

//整数と、リストの次要素を指すポインタをまとめた構造体slobjを定義
typedef struct slobj_{
    char direction; //そのブロックの人が左向きLか右向きRか
    int sum; //ブロックの中に何個文字があるか
    struct slobj_ *next;
    struct slobj_ *prev;
}*slobj;

//slobj型の変数のポインタをslist型と定義→いずれリストの先頭要素を指す
typedef struct{
    slobj head;
    slobj tail;
}*slist;

//cirectionにc, sumにnを持つリスト要素を作る関数
slobj slobj_new(char c, int n){
    slobj p;
    NEW(p,1);
    p->direction=c;
    p->sum=n;
    p->next=NULL;
    p->prev=NULL;
    return p;
}

//slist型の空リスト1つを作る関数
slist slist_new(void){
    slist L;
    NEW(L,1);
    L->head=NULL;
    L->tail=NULL;
    return L;
}

//slobj要素のメモリを解放する
void free_slobj(slobj p){
    free(p);
    return;
}

//slobj型の要素pをリストLの最後に挿入する関数
void slist_insert_tail(slist L,slobj p){
    if(L->head==NULL){ //もし最初に挿入するなら
        //p->prev=NULL;
        //p->next=NULL;
        L->head=p;
        L->tail=p;
    }
    else{ //それ以外なら
        p->prev=L->tail;
        //p->next=NULL;
        L->tail->next=p;
        L->tail=p;
    }
    
    return;
}




int main(void){
    int N;
    scanf("%d",&N);

    int K;
    scanf("%d",&K);

    char S[N+1];
    scanf("%s",S); //S[0]~S[N-1]まで文字列、S[N]は0

    //ここから文字列ブロック化、関数にしても良い

    //文字列をブロックリストLに格納
    slist L=slist_new();
    int block_sum=0; //ブロック総数

    char c=S[0]; //ブロックの文字
    int charn=0; //ブロックの中にある文字の数

    for(int i=0;i<N;i++){
        if(S[i]==c){
            charn+=1;
        }
        else{
            block_sum+=1;
            slobj p=slobj_new(c, charn);
            slist_insert_tail(L,p);
            c=S[i];
            charn=1;
        }

        if(i==N-1){ //もし最後だったら、それをリストに足す
            block_sum+=1;
            slobj p=slobj_new(c, charn);
            slist_insert_tail(L,p);
        }
    }

    /* このprintを使えば、ブロックリストに何が入っているのか、ブロックが総数いくつあるのか確認可能
    slobj q=L->head;
    while(q!=NULL){
        printf("%c %d\n",q->direction, q->sum);
        q=q->next;
    }
    printf("%d\n",block_sum);
    */

    int unhappy;
    if((block_sum/2)>K){
        unhappy=block_sum-K*2;
    }
    else{
        unhappy=1;
    }
    
    int ans=N-unhappy;
    printf("%d\n",ans);

    return 0;
}

//400
//未完

Measured memory_bytes: 3328
#include <iostream>


using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,k;
    bool at = true;
    cin >> a >> b >> k;
    while (k>0) {
        if (at) {
            if (a%2==1) a--;
            b += a/2;
            a /= 2;
        }
        else {
            if (b%2==1) b--;
            a += b/2;
            b /= 2;
        }
        k--;
        at = (at?false:true);
    }
    cout << a << ' ' << b << endl;
    return 0;
}


Measured memory_bytes: 256
#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 << 25;
const int MOD = 1e9+7;
ll six[10], nine[10];
int dp[100010];
int main() {
	int n;
	cin >> n;
	rep(i,10) {
		six[i] = (ll)pow(6,i+1);
		nine[i] = (ll)pow(9,i+1);
	}

	rep(i,n+1) dp[i] = INF;
	dp[0] = 0;
	rep(i,n+1) {
		rep(j,10) {
			if (six[j] > i) continue;
			dp[i] = min(dp[i], dp[i-six[j]]+1);
		}
		rep(j,10) {
			if (nine[j] > i) continue;
			dp[i] = min(dp[i],dp[i-nine[j]]+1);
		}
		if (i > 0) dp[i] = min(dp[i], dp[i-1]+1);
	}
	cout << dp[n] << endl;
	return 0;
}

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

vector<long long> divisor(long long n){
    vector<long long> res;
    for(long long i = 1; i*i <= n; i++){
        if(n%i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n;
    cin >> n;
    vector<long long> v = divisor(n);
    long long ans = 0;
    for(int i = 0; i < v.size(); i++){
        if(v[i] == 1) continue;
        if(n/(v[i]-1) == n%(v[i]-1)) ans += v[i]-1;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int N;
	string str1, str2;
	cin >> N;
	cin >> str1 >> str2;
	uint64_t answer = 1;
	for (int i = 0; i < N; i++) {
		if (str1[i] == str2[i]) { // tate
			if (i == 0) answer = answer * 3 % 1000000007;
			else if (str1[i - 1] == str2[i - 1]) answer = answer * 2 % 1000000007; // after tate
		}
		else if (i == 0) continue;
		else if (str1[i] == str1[i - 1]) { // yoko
			if (i == 1) answer = answer * 6 % 1000000007;
			else if (str1[i - 2] == str2[i - 2]) answer = answer * 2 % 1000000007; // after tate
			else answer = answer * 3 % 1000000007; // after yoko
		}
	}
	cout << answer << endl;
}

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

int main(){
  int N;
  cin >> N;
  int t[N+1], x[N+1], y[N+1];
  t[0] = x[0] = y[0] = 0;

  for(int i = 1; i < N + 1; i++){
    cin >> t[i] >> x[i] >> y[i];
  }

  for(int i = 0; i < N; i++){
    int xa = abs(x[i] - x[i+1]);
    int ya = abs(y[i] - y[i+1]);
    int a = xa + ya;
    int ta = t[i+1] - t[i];
    if( ta < a || (ta - a) % 2 == 1 ){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1408
//#include "bits\stdc++.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long LL;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a * b >= c * d)
    {
        cout << a * b << endl;
    }
    else
    {
        cout << c * d << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//https://atcoder.jp/contests/dp/tasks

int main(){
    int n;
    cin >> n;
    int k = n/2;
    vector<double> p(n);
    rep(i,n) cin >> p[i];

    vector<double> dp(n+1);
    dp[0] = 1;

    rep(i,n){
        vector<double> dq = dp;
        rep(j,i+1){
            if(j == 0) {
                dp[0] = dq[0]*p[i];
                continue;
            }
            dp[j] = dq[j-1]*(1-p[i]) + dq[j]*p[i];

        }
        dp[i+1] = dq[i]*(1-p[i]);
    }

    double ans = 0;
    rep(i,k+1) ans += dp[i];
    cout << fixed << setprecision(12);
    cout << ans<< endl;
}

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

int main(){
    int n,d;
    int x[10][10];
    cin >> n >> d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> x[i][j];
        }
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ll sum=0;
            for(int k=0;k<d;k++){
                sum+=(x[j][k]-x[i][k])*(x[j][k]-x[i][k]);
            }
            ll s = sqrt(sum);
            if(sum==s*s)    cnt++;
        }
    }
    cout << cnt << endl;
}  

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define fast ios::sync_with_stdio(false), cout.tie(), cin.tie();
#define sz(s) int(s.size())

int main(){
	int n;
	cin >> n;
	string s[n];
	int a[n], sum = 0;
	for (int i = 0; i < n; i++){
		cin >> s[i] >> a[i];
		sum += a[i];
	}
	string x;
	cin >> x;
	for (int i = 0; i < n; i++){
		if (x == s[i]){
			sum = 0;
			for (int j = i + 1; j < n; j++){
				sum += a[j];
			}
			break;
		}
	}
	cout << sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long int
//map<pair<ll, ll>, ll> pos;
vector<ll>Iraq;
vector<ll>Seria;
vector<ll>Afgan;
vector<ll>temp;
ll arrra[100008];
map<ll,ll>vis;
map<ll,ll>tmp_vis;
map<ll,ll>exact_pos;
ll F[200009];
ll tF[200009];
vector<ll>sub_s[29];
vector<ll>siz;
ll check=1;


int main() {
    
    ll t, i, h, c, big, end, mid,n,m=0,x,y=1,j,k,p,q,r,s=0,sum,tot=100;
    cin>>p>>q>>r;
    for(i=p;i<=q;i++)
    {
      if(i%r==0)
       m++;	
    }
    cout<<m;
    
     
 
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool flag = true;
  for (int i = 0; i < (n - 1)/2; i++) {
    if (s.at(i) != s.at((n - 1)/2 - i - 1)) {
      flag = false;
      break;
    }
  }
  for (int i = (n + 3)/2 - 1; i < n; i++) {
    if (s.at(i) != s.at(n - 1 - i)) {
      flag = false;
      break;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

const int MAX_N = 1000;
#define MAX_V MAX_N * (MAX_N - 1) / 2

int V;//頂点数
vector<int> G[MAX_V];//トポロジカルソートするグラフ
vector<int> T;//トポロジカルソート後のグラフ
// T.size() == V であればトポロジカルソートができた、そうでなければできなかったと判定できる

int dp[MAX_V];
int ans = 0;

void Tsort(){
    stack<int> st;//入次数が0の頂点の集合
    int indeg[V] = {};//頂点の入次数を管理する配列
    for(int i = 0; i < V; i++){
        for(int j = 0; j < G[i].size(); j++){
            indeg[G[i][j]]++;
        }
    }
    for(int i = 0; i < V; i++){
        if(indeg[i] == 0){
            st.push(i);
        }
    }
    while(!st.empty()){
        int u = st.top();
        st.pop();
        T.push_back(u);
        for(int i = 0; i < G[u].size(); i++){
            indeg[G[u][i]]--;//隣接する頂点の入次数を1減らす
            dp[G[u][i]] = max(dp[G[u][i]], dp[u] + 1);
            ans = max(ans, dp[G[u][i]]);
            if(indeg[G[u][i]] == 0){
                st.push(G[u][i]);//入次数が0になればstに追加
            }
        }
    }
}

signed main(){
    int n;
    cin >> n;
    int id[n][n];
    REP(i,n){
        for(int j = i + 1; j < n; j++){
            id[i][j] = V;
            V++;
        }
    }
    int num[n][n - 1];
    int a,b;
    REP(i,n){
        REP(j,n - 1){
            cin >> a;
            a--;
            b = i;
            if(a > b){
                swap(a, b);
            }
            num[i][j] = id[a][b];
        }
    }
    REP(i,n){
        REP(j,n - 2){
            G[num[i][j]].push_back(num[i][j + 1]);
        }
    }
    Tsort();
    if(T.size() != V){
        cout << -1 << endl;
        return 0;
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 41464
N = int(input())
AS = list(map(int, input().split()))
BS = list(map(int, input().split()))

AXOR = [AS[i] ^ AS[(i+1) % N] for i in range(N)]
BXOR = [BS[i] ^ BS[(i+1) % N] for i in range(N)]

def getZarr(string, z): 
    n = len(string) 
  
    # [L,R] make a window which matches 
    # with prefix of s 
    l, r, k = 0, 0, 0
    for i in range(1, n): 
  
        # if i>R nothing matches so we will calculate. 
        # Z[i] using naive way. 
        if i > r: 
            l, r = i, i 
  
            # R-L = 0 in starting, so it will start 
            # checking from 0'th index. For example, 
            # for "ababab" and i = 1, the value of R 
            # remains 0 and Z[i] becomes 0. For string 
            # "aaaaaa" and i = 1, Z[i] and R become 5 
            while r < n and string[r - l] == string[r]: 
                r += 1
            z[i] = r - l 
            r -= 1
        else: 
  
            # k = i-L so k corresponds to number which 
            # matches in [L,R] interval. 
            k = i - l 
  
            # if Z[k] is less than remaining interval 
            # then Z[i] will be equal to Z[k]. 
            # For example, str = "ababab", i = 3, R = 5 
            # and L = 2 
            if z[k] < r - i + 1: 
                z[i] = z[k] 
  
            # For example str = "aaaaaa" and i = 2,  
            # R is 5, L is 0 
            else: 
  
                # else start from R and check manually 
                l = i 
                while r < n and string[r - l] == string[r]: 
                    r += 1
                z[i] = r - l 
                r -= 1

string = list(BXOR) + [-1] + list(AXOR) + list(AXOR)[:-1]
Z = [0 for i in range(len(string))]
getZarr(string, Z)
# print(string)
res = []
for i in range(N, len(string)):
    # print(i, Z[i])
    if (Z[i] >= N):
        # print(AXOR[0], BXOR[i-N-1])
        res.append((i - N - 1, AS[i-N-1] ^ BS[0]))
res.sort()
for a, b in res:
    print(a, b)

Measured memory_bytes: 128080
#include <cstdio>
#include <map>

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  std::map<int, int> mp;
  for (int i = 0; i < m; ++i)
  {
    int a, b;
    scanf("%d%d", &a, &b);
    mp[a]++;
    mp[b]++;
  }
  for (int i = 1; i <= n; ++i)
  {
    printf("%d\n", mp[i]);
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
list_plan = []
for i in range(n):
    t, x, y = map(int, input().split())
    list_plan.append([t, x, y])

for i in list_plan:
    t, x, y = i[0], i[1], i[2]
    if x + y <= t and (t - x - y)%2 == 0:
        pass
    else:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 19532
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

char in[2005][2005];
char m[2005][2005];
int c[2005][2005];

int maximumRectangule(int h, int w){
	rep(i,w){
		int cnt = 0;
		rep(j,h){
			if(m[j][i] == '.'){
				cnt++;
				c[j][i] = cnt;
			}else{
				cnt = 0;
			}
		}
	}

	//rep(i,h){ rep(j,w){ cout << c[i][j]; } cout << endl; }

	int ans = 0;
	rep(i,h){
		vector<pair<int, int>> v; //height, pos
		rep(j,w + 1){
			if(v.empty()) v.emplace_back(c[i][j],j);
			else{
				if(v.back().first < c[i][j]) v.emplace_back(c[i][j],j);
				else{
					int target = j;
					while(not v.empty() && v.back().first >= c[i][j]){
						ans = max(ans, (v.back().first + 1) * (j - v.back().second + 1));
						target = v.back().second;
						v.pop_back();
					}
					v.emplace_back(c[i][j],target);
				}
			}
		}
	}
	return ans;
}


int main(){
	int h, w;
	cin >> h >> w;

	rep(i,h) cin >> in[i];
	rep(i,h) rep(j,w) m[i][j] = '.';

	rep(i,h - 1){
		rep(j,w - 1){
			int w = 0, b = 0;
			rep(k,2){
				rep(l,2){
					if(in[i + k][j + l] == '#') b++;
					else w++;
				}
			}
			if(w == 3 or b == 3){
				m[i][j] = '#';
			}
		}
	}

	//rep(i,h - 1){ rep(j,w - 1){ cout << m[i][j]; } cout << endl; }

	cout << max({maximumRectangule(h - 1, w - 1), h, w}) << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int input() {int a;cin>>a;return a;}
int kr(int a,int b) {
    if (!(a%b)) return b;
    return kr(b,a%b);
}

int n,a[100000],memo[100000],mmemo[100000],ans;

signed main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    memo[0] = a[0],mmemo[n-1] = a[n-1];
    rep11(i,n) memo[i] = kr(memo[i-1],a[i]);
    for(int i=n-2;i>=0;i--) mmemo[i] = kr(mmemo[i+1],a[i]);
    rep(i,n) {
        if (i==0) ans = max(ans,mmemo[1]);
        if (i==n-1) ans = max(ans,memo[n-2]);
        else ans = max(ans,kr(memo[i-1],mmemo[i+1]));
    }
    cout << ans << endl;

}




Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

double dist(double x0, double y0, double x1, double y1){
    double dx = x0-x1, dy = y0-y1;
    return sqrt(dx*dx + dy*dy);
}

double area(double a, double b, double c){
    double z = (a+b+c)/2;
    return sqrt(z*(z-a)*(z-b)*(z-c));
}

int main() {
    int n;
    while(cin >> n && n) {
        vector<pii> v(n);
        bool ok = true;
        rep(i,n) cin >> v[i].second >> v[i].first;
        sort(all(v));
        if(true){
            int sum = 0;
            rep(i,n){
                sum += v[i].second;
                if(sum > v[i].first){
                    ok = false;
                    break;
                }
            }
        } else {
            // do {
            //     bool f = true;
            //     int sum = 0;
            //     rep(i,n){
            //         sum += v[i].second;
            //         if(sum > v[i].first){
            //             f = false;
            //         }
            //     }
            //     if(f){
            //         ok = true;
            //         break;
            //     }
            // }while(next_permutation(all(v)));
        }
        puts(ok ? "Yes" : "No");
    }
}

Measured memory_bytes: 1148