akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	A := nextInt()
	B := nextInt()
	ans := A + B
	if ans >= 10 {
		fmt.Println("error")
		return
	}
	fmt.Println(ans)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


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

int main() {
  long long a, b;
  int count;
  cin >> a >> b;
  for (int i = a; i <= b; i++) {
    int r = 0;
    for (int j = i; j > 0; j/= 10) {
      r = r*10 + j % 10;
    }
    if (r==i) {
      count ++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const int inf=2147483647;
const long long Mod=1000000007;
struct ball
{
	int c,w;
}a[200010];
int n,b[200010],s[200010],cnt;
bool used[200010],can[200010];
long long fac[200010],inv[200010];
bool cmp(ball x,ball y)
{
	return x.w<y.w;
}
long long pw(long long x,long long y)
{
	long long res=1;
	while (y)
	{
		if (y&1)
		{
			res=res*x%Mod;
		}
		x=x*x%Mod;
		y>>=1;
	}
	return res;
}
int main()
{
	int x,y;
	scanf("%d%d%d",&n,&x,&y);
	fac[0]=1;
	for (int i=1;i<=n;i++)
	{
		fac[i]=fac[i-1]*i%Mod;
	}
	inv[n]=pw(fac[n],Mod-2);
	for (int i=n-1;i>=0;i--)
	{
		inv[i]=inv[i+1]*(i+1)%Mod;
	}
	for (int i=0;i<n;i++)
	{
		scanf("%d%d",&a[i].c,&a[i].w);
	}
	sort(a,a+n,cmp);
	int mn,mn2,k;
	mn=mn2=inf;
	for (int i=0;i<n;i++)
	{
		if (!used[a[i].c])
		{
			used[a[i].c]=true;
			b[a[i].c]=a[i].w;
			if (mn>a[i].w)
			{
				mn2=mn;
				mn=a[i].w;
				k=a[i].c;
			}
			else if (mn2>a[i].w)
			{
				mn2=a[i].w;
			}
		}
	}
	for (int i=1;i<=n;i++)
	{
		if (!used[i])
		{
			continue;
		}
		if (i==k)
		{
			if (b[i]+mn2<=y)
			{
				can[i]=true;
			}
		}
		else
		{
			if (b[i]+mn<=y)
			{
				can[i]=true;
			}
		}
	}
	for (int i=0;i<n;i++)
	{
		if (!can[a[i].c])
		{
			continue;
		}
		if (a[i].c==k)
		{
			if (a[i].w+mn2<=y)
			{
				s[a[i].c]++;
				cnt++;
				continue;
			}
		}
		else
		{
			if (a[i].w+mn<=y)
			{
				s[a[i].c]++;
				cnt++;
				continue;
			}
		}
		if (a[i].w+b[a[i].c]<=x)
		{
			s[a[i].c]++;
			cnt++;
		}
	}
	long long ans=fac[cnt];
	for (int i=1;i<=n;i++)
	{
		if (!can[i])
		{
			continue;
		}
		ans=ans*inv[s[i]]%Mod;
	}
	printf("%lld\n",ans);
    return 0;
}
//绿蚁新醅酒，红泥小火炉。
//晚来天欲雪，能饮一杯无？
//——白居易《问刘十九》

Measured memory_bytes: 6912
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long




//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string S;
  cin >> S;
  int a = 0;
  int b = 0;
  for(int i = 0; i < 3; i++){
  	if(S[i] == 'A'){
  		a++;
  	}
  	else{
  		b++;
  	}
  }
  if(a * b > 0){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 256
/* Isn't passion overrated?*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll se = n, fi = 1;
    ll j = 1;
    ll flag = 1;
    for(ll i = 0; i < k; i++){
    cout<<fi++<<" "<<se--<<endl;
    if(flag && (se-fi) <= n/2 && n%2 == 0)
    {
        flag = 0;
        se--;
    }
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll N,C=0,A;cin >> N;
  rep(i,N){
    cin >> A;
    while(A>0){
      if(A%2==0){
        A/=2;
        C++;
      }
      else{
        break;
      }
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10010],b[10010],dp[100010];
int main(){
   int h,n;
   cin>>h>>n;
   for(int i=1;i<=n;i++){
       cin>>a[i]>>b[i];
   }
   for(int i=0;i<=h;i++)dp[i]=2e9;
   dp[0]=0;
   for(int i=1;i<=n;i++) {
       for (int j = 0; j <= h; j++){
           //cout<<min(j + a[i], h)<<' '<<dp[j] + b[i]<<' ';
           dp[min(j + a[i], h)] = min(dp[min(j + a[i], h)], dp[j] + b[i]);
       }
       //cout<<'\n';

   }

   cout<<dp[h];

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace	std;
int main(){
	int a, b;
	cin >> a >> b;
	if((a == 1 && b == 2) || (a == 2 && b == 1)){
		cout << 3;
	}
	else if((a == 3 && b == 2) || (a == 2 && b == 3)){
		cout << 1;
    }
    else if((a == 1 && b == 3) || (a == 3 && b == 1)){
		cout << 2;
    }
	return 0;
}

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

using namespace std;

int main() {
	string n;
	cin >> n;
  
  	long long best = 0;
  	long long curr = 0;
  	
  	for (int i = 0; i < n.length(); i++) {
      if (n[i] == 'R')
        curr++;
      else {
        best = max(best, curr);
        curr = 0;
      }
      best = max(best, curr);
      
    }
  
  	cout << best << endl;
		
}

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

int main() {
    int n, a[100100];
    cin >> n;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    int b[100100];
    b[0] = sum;
    for (int i = 1; i < n; i += 2) {
        b[0] -= 2 * a[i];
    }

    for (int i = 1; i < n; i++) {
        b[i] = 2 * a[i - 1] - b[i - 1];
    }

    for (int i = 0; i < n; i++) {
        cout << b[i];
        if (i < n - 1) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,d,k,a,b,c,h;
string s,t;
int main()
{
  cin>>n>>s;
  if(n&1==1)return cout<<"No",0;
  if(s.substr(0,n/2).compare(s.substr(n/2,n/2))==0)return cout<<"Yes",0;
  cout<<"No";
}

Measured memory_bytes: 256
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
    IOS;
    int64 T=1;
    //cin>>T;
    while(T--)
    {
        int64 a,b;
        cin>>a>>b;
        int64 ans=1;
        if(b==1)
        {
            cout<<0;
            return 0;
        }
        while((ans*a)-(ans-1)<b)
            ans++;
        cout<<ans;
    
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
side=[]
i=0
while i<n-1:
  if A[i]==A[i+1]:
    side.append(A[i])
    i+=2
  else:
    i+=1
print(0 if len(side)<2 else side[0]*side[1])

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <vector>
using namespace std;
int main(){
    int n,a[10000];
    cin>>n;
    int c=0;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=a[i];j>0;j/=2){
            if(j%2==0)c++;
            else goto an;
        }
        an:;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
X = int(input())
val = X % 100
num = X // 100

n1 = val // 5
n2 = val % 5

if(n2 == 0):
  num2 = n1
else:
  num2 = n1 + 1

if(num >= num2):
  print('1')
else:
  print('0')


Measured memory_bytes: 2940
n, k = map(int, input().split())
cnt=0
if k==0:
    print(n*n)
else:
    for b in range(k+1,n+1):
        a_=int(n/b)
        cnt+=(b-k)*(a_)
        cnt+=max(n%b-k+1, 0)
    print(cnt)


Measured memory_bytes: 2940
import java.util.Scanner;

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

		int n = src.nextInt();

		//配列array
		int[] array = new int[n];
		
		for (int i=0; i<n; i++)
			array[i] = src.nextInt();

		int q = src.nextInt();

		for(int i=0; i<q; i++) {

			int b = src.nextInt();
			int e = src.nextInt();
			int t = src.nextInt();

			for(int k=0; k<(e - b); k++) {
				
				int tmp = array[b+k];
				array[b+k] = array[t+k];
				array[t+k] = tmp;
	
//					System.out.print(array[k] + "debug");
			}
		}
		for(int i=0; i<n-1; i++) {
			System.out.print(array[i] + " ");
		}
		System.out.println(array[n-1]);
	}
}


Measured memory_bytes: 36852
#include <iostream>
using namespace std;
int main() {
	int a[4],b[4],i,j,h,r;
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
		h=0; r=0;
		for (i=0;i<4;i++) for (j=0;j<4;j++)	if (a[i]==b[j] ) if (i==j) h++; else r++;
		cout << h << " " << r << endl;
	}
	return 0;
	}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdlib>
#include <iomanip>

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    
    double s = 0;
    for(int i = 1; i <= n; i++){
        double b =  1.0/n;
        double a = 1;
        int j = i;
        for(; j < k; j<<=1){
            a *= 0.5;
        }
        s += b*a;
    }

    std::cout<<std::fixed<<std::setprecision(12);
    cout << s << endl;

    return 0;
}


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

int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if (x1 == 0) {
    cout << 1 << endl;
  } else if (x2 == 0) {
    cout << 2 << endl;
  } else if (x3 == 0) {
    cout << 3 << endl;
  } else if (x4 == 0) {
    cout << 4 << endl;
  } else {
    cout << 5 << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

long long N, wa, K, W, ans;
string s[100000];

int main() {
	for (int i = 0; i < 3; i++) {
		cin >> s[i];
	}
		cout << s[0][0]<<s[1][1]<<s[2][2] << endl;
	

	return 0;
}




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

using namespace std;
using ll = long long;
using p = pair<int, int>;
#define rep(i,n)  for(int i = 0; i < n ; i++)

int main()
{
	int N;
	cin >> N;
	ll power = 1;
	for (int i = 1; i <= N; i++)
	{
		power = (power * i) % ((long)pow(10,9) + 7);
	}
	cout << power << endl;
}

Measured memory_bytes: 256
for _ in [0]*int(input()):
    s=input()
    cur=0
    for _ in [0]*int(input()):
        c=input()
        if c=='forward word':
            while cur<len(s) and s[cur]==' ':cur+=1
            while cur<len(s) and s[cur]!=' ':cur+=1
        elif c=='delete char' and cur!=len(s):s=s[:cur]+s[cur+1:]
        elif c=='backward word':
            while cur>0 and s[cur-1]==' ':cur-=1
            while cur>0 and s[cur-1]!=' ':cur-=1
        elif c=='forward char':cur=min(len(s),cur+1)
        elif c=='delete word':
            if s[cur:].count(' ') == len(s[cur:]): continue
            while cur<len(s) and s[cur]==' ':s=s[:cur]+s[cur+1:]
            while cur<len(s) and s[cur]!=' ':s=s[:cur]+s[cur+1:]
        elif c[0]=='i':
            c=c.split('"')[1]
            s=s[:cur]+c+s[cur:]
            cur+=len(c)
        elif 'backward char':cur=max(0,cur-1)
    print(s[:cur]+'^'+s[cur:])

Measured memory_bytes: 7700
#include <stdio.h>
 
int main(void) {
    int cards[52];
    int n;
    int i;
    char kindc[4]={'S','H','C','D'};
    char kind;
    int num;
    for(i=0;i<52;i++)cards[i]=0;
    scanf("%d",&n);
    for(i=0;i<n;i++) {
        scanf(" %c %d ",&kind,&num);
        switch(kind) {
            case 'D':num+=13;
            case 'C':num+=13;
            case 'H':num+=13;
        }
        cards[num-1]=1;
    }
    for(i=0;i<52;i++) {
        if(cards[i]==0)
            printf("%c %d\n",kindc[i/13],i%13+1);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    string s1,s2;
    ll dp[3005][3005];
    vector<char>res;
    ll recurse(ll pos1,ll pos2){
    	if(s1[pos1]=='\0'||s2[pos2]=='\0')
    	return 0;
    	if(dp[pos1][pos2]!=-1)
    	return dp[pos1][pos2];
    	else {
    		if(s1[pos1]==s2[pos2]){
    			return dp[pos1][pos2]=1+recurse(pos1+1,pos2+1);
			}
			else{
				return dp[pos1][pos2]=max(recurse(pos1+1,pos2),recurse(pos1,pos2+1));
			}
		}
	}
	void print(ll pos1,ll pos2){
		if(s1[pos1]=='\0'||s2[pos2]=='\0')
		return ;
		if(s1[pos1]==s2[pos2])
		{
			res.pb(s1[pos1]);
			print(pos1+1,pos2+1);
		}
		else{
			if(dp[pos1+1][pos2]>dp[pos1][pos2+1])
			print(pos1+1,pos2);
			else
			print(pos1,pos2+1);
		}
	}
    int main()
    {
        fastread;
        ll i,j,k,l,m;
        cin>>s1>>s2;
        for(i=0;i<3001;i++){
        	for(j=0;j<3001;j++)
        	dp[i][j]=-1;
		}
		ll kola=recurse(0,0);
		print(0,0);
		ll sz=res.size();
		for(i=0;i<sz;i++)
		cout<<res[i];
        return 0;
    }

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    vector<int> hoge(n);
    for (int i = 0; i < n; i++) {
        cin >> hoge[i];
    }
    
    vector<int> huga(m);
    for (int i = 0; i < m; i++) {
        cin >> huga[i];
    }

    vvi dp(n+1, vi(m+1, 0));
    rep(i, n+1) {
        dp[i][0] = 1;
    }
    rep(j, m+1) {
        dp[0][j] = 1;
    }
    Rep(i, n+1) {
        Rep(j, m+1) {
            dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + MOD) % MOD;
            if (hoge[i-1] == huga[j-1]) {
                dp[i][j] = (dp[i-1][j-1] + dp[i][j]) % MOD;
            }
        }
    }
    /*
    rep(i, n+1) {
        rep(j, m+1) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */

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

    return 0;
}


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

int main() {
    int A,B;
    cin >> A >> B;
    if(1 <= A and A<= 9) {
        if (1 <= B and B <= 9) {
            cout << A * B << endl;
            exit(0);
        }
    }
    cout << "-1" << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int N;
ll X[10];
ll Y[10];

int main(){
    cin >> N;

    REP(i,N){
        ll x, y;
        cin >> x >> y;
        X[i] = x;
        Y[i] = y;
    }

    vector<int> idx(N);
    REP(i,N) idx[i] = i;
    double ans = 0;
    ll num = 0;
    do{
        double tmp = 0;
        ll lastx = X[idx[0]];
        ll lasty = Y[idx[0]];
        REPi(i, 1, N){
            ll x = X[idx[i]];
            ll y = Y[idx[i]];
            ll diffx = (x - lastx) * (x - lastx);
            ll diffy = (y - lasty) * (y - lasty);
            double diff = sqrt(diffx + diffy);
            tmp += diff;
        }
        ans += tmp;
        num++;
    }while(next_permutation(idx.begin(), idx.end()));


    ans /= num;

    printf("%.15lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class UF{
	public int[] a;
	public UF(int size){
		Arrays.fill(a=new int[size],-1);
	}
	public int root(int t){
		return a[t]<0?t:(a[t]=root(a[t]));
	}
	public boolean connect(int p,int q){
		p=root(p);
		q=root(q);
		if(p==q)
			return false;
		if(a[p]>a[q]){
			a[q]+=a[p];
			a[p]=q;
		}else{
			a[p]+=a[q];
			a[q]=p;
		}
		return true;
	}
	public boolean isConnected(int a,int b){
		return root(a)==root(b);
	}
	public int groupSize(int t){
		return -a[root(t)];
	}
}

public class Main{
	public static void main(String[] $){
		var s=new Scanner(System.in);

		var n=s.nextInt();
		var q=s.nextInt();

		var uf=new UF(n);

		for(int i=0;i<q;++i)
			if(s.nextInt()==0)
				uf.connect(s.nextInt(),s.nextInt());
			else
				System.out.println(uf.isConnected(s.nextInt(),s.nextInt())?1:0);
	}
}


Measured memory_bytes: 59904
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];

        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());

        for (int i = 0; i < N; i++) {
            int n  = sc.nextInt();
            A[i]=n;
            pq.offer(n);
        }
        int max = pq.remove();
        int max2 = pq.remove();
        for (int i = 0; i < N; i++) {
            int n = A[i];
            if(n==max){
                System.out.println(max2);
            }else{
                System.out.println(max);
            }

        }


    }

}


Measured memory_bytes: 95304
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>


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

int main(){

    int n;
    cin >> n;
    //先頭、末尾0とし、[0,n+1]の数列を構成
    vector<int> a(n + 2,0);
    int s_ = 0;

    for(int i=1;i <n + 1;i++) {
        cin >> a[i];
        s_ += abs(a[i] - a[i-1]);
    }
    s_ += abs(a[n + 1] - a[n]);
    
    
    vector<int> s;
    for(int i=1;i < n + 1;i++){
        int tmp = s_ + abs(a[i + 1] - a[i -1]) - (abs(a[i-1] - a[i]) + abs(a[i] - a[i + 1]));
        s.push_back(tmp);
    }

    for(int i =0;i < n;i++){
        cout << s[i] << endl;

    }




    return 0;
}

Measured memory_bytes: 2168
from itertools import product
from collections import defaultdict
N = int(input())
S = defaultdict(int)
for i in range(1, N+1):
    s = str(i)
    S[s[0]+s[-1]] += 1
ans = 0
for s, e in product("123456789", repeat=2):
    ans += S[s+e]*S[e+s]
print(ans)

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N;
    cin >> N;
    
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        sum += --a;
    }

    cout << sum << endl;
    
    return 0;
}

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

int a, b;

int main() {
	cin >> a >> b;
	if (a == b)cout << "Draw" << endl;
	else if (a == 1) cout << "Alice" << endl;
	else if (b == 1) cout << "Bob" << endl;
	else if (a > b) cout << "Alice" << endl;
	else if (a < b) cout << "Bob" << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    map<string,ll> S;
    REP(i,0,N) {
        string s;
        cin >> s;
        ++S[s];
    }
    ll m = 0;
    FORR(s,S) m = MAX(m,s.second);
    FORR(s,S) {
        if(s.second == m) PR(s.first);
    }

    return 0;
}

/*



*/

Measured memory_bytes: 19232
N=int(input())
l=list(map(int,input().split()))
A=max(l)
mid=(A//2)+1 if A%2!=0 else A//2
dis_min=float("Inf")
l.sort()
ans=1
for i in l:
   if dis_min>abs(i-mid):
      dis_min=abs(i-mid)
      ans=i
print(A,ans)

Measured memory_bytes: 19996
fun main(args: Array<String>) {
    var N = readLine()!!.toList().map(Char::toString).map(String::toInt)
    //符号の24通りの組み合わせ生成
    0.until(8).map { n->
        0.until(3).map { i->
            if((n and (1 shl i)) != 0) {1} else {-1}
         }
        }.filter{N[0]+ it[0]*N[1]+it[1]*N[2]+it[2]*N[3] == 7}[0].let{
            var op = it.map{x-> when(x){ -1-> {'-'} else -> {'+'}}}
            println("${N[0]}${op[0]}${N[1]}${op[1]}${N[2]}${op[2]}${N[3]}=7")
        }

}


Measured memory_bytes: 31932
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll X;
  cin >> X;

  ll ans = 0;
  ans += X / 500 * 1000;
  X %= 500;
  ans += X / 5 * 5;
  X %= 5;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename t>
void read(t &x)
{
    char ch = getchar();
    x = 0;
    t f = 1;
    while (ch < '0' || ch > '9')
        f = (ch == '-' ? -1 : f), ch = getchar();
    while (ch >= '0' && ch <= '9')
        x = x * 10 + ch - '0', ch = getchar();
    x *= f;
}
//---------------https://lunatic.blog.csdn.net/-------------------//
#define wi(n) printf("%d ", n)
#define wl(n) printf("%lld ", n)
#define rep(m, n, i) for (int i = m; i < n; ++i)
#define rrep(m, n, i) for (int i = m; i > n; --i)
#define P puts(" ")
typedef long long ll;
#define MOD 1000000007
#define mp(a, b) make_pair(a, b)
#define N 100005
#define fil(a, n) rep(0, n, i) read(a[i])
ll power(ll a, ll b, ll p)
{
    ll ans = 1 % p;
    for (; b; b >>= 1)
    {
        if (b & 1)
            ans = ans * a % p;
        a = a * a % p;
    }
    return ans;
}
long long mm[500000];
void init(ll n, ll k)
{
    mm[1] = 1;
    for (ll i = 2; i <= n; i++)
    {
        mm[i] = ((mm[i - 1] * (k + i - 1)) % MOD * power(i - 1, MOD - 2, MOD)) % MOD;
        //cout<<mm[i]<<endl;
    }
}
ll a[N];
int main()
{
    int n, k;
    read(n), read(k);
    fil(a, n);
    sort(a, a + n);
    init(n, k - 1);
    long long sum = 0;
    rrep(n - 1, k - 2, i)
        sum = (sum + (mm[i - k + 2] * (a[i] - a[n - i - 1]) % MOD) % MOD) % MOD;
    while (sum < 0)
        sum += MOD;
    wl(sum%MOD);
    P;
}

Measured memory_bytes: 1792
import itertools
import collections
import bisect

def main():
    N = int(input())
    A = [0] + list(map(int, input().split())) + [0]

    total = 0
    for i in range(1, N + 2):
        total += abs(A[i] - A[i-1])

    for i in range(1, N + 1):
        org = abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i])
        skip = abs(A[i+1] - A[i - 1])
        diff = org - skip
        print(total - diff)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14304
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << " " << max((a+b)-n,0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n >> k;
   int mn = n;
   int kk = n/k;
   mn = min({mn,abs(n-kk*k),abs(n-(kk+1)*k)});
   cout << mn << '\n';
   return 0;
} 

Measured memory_bytes: 256
m,n=map(int,raw_input().split())
p=[int(raw_input()) for _ in xrange(m)]
ce=[map(int,raw_input().split()) for _ in  xrange(n)]
dp=[[float('inf')]*(m+1) for _ in xrange(n+1)]
for i in xrange(n+1):
    dp[i][0]=0

for i in xrange(n):
    for j in xrange(1,m+1):
        if j<ce[i][0]:
            dp[i+1][j]=min(dp[i][j],ce[i][1])
            continue
        dp[i+1][j]=min(dp[i][j],dp[i][j-ce[i][0]]+ce[i][1])

p.sort()
p.reverse()
sump=[0]*(m+1)
for i in xrange(m):
    sump[i+1]+=sump[i]+p[i]

ans=0
for i in xrange(1,m+1):
    ans=max(ans,sump[i]-dp[n][i])
print(ans)

Measured memory_bytes: 57908
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int[][] c = new int[10][10];
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j< 10; j++) {
        c[i][j] = sc.nextInt();
      }
    }
    warshallFloyd(c);
    
    int ans = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int A = sc.nextInt();
        if (A >= 0) {
          ans += c[A][1];
        }
      }
    }
    
    System.out.println(ans);
  }
  
  private static void warshallFloyd(int[][] c) {
    for (int k = 0; k < 10; k++) {
      for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
          c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
        }
      }
    }
  }
}

Measured memory_bytes: 43264
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

const int INF = 1e9;
const int MOD = 1000000007;

int main() {
  size_t N, M;
  cin >> N >> M;
  set<size_t> S;
  vector<size_t> H(N);
  for (size_t i = 0; i < N; ++i) {
    cin >> H[i];
    S.insert(i + 1);
  }
  vector<pair<size_t, size_t>> load(M);
  size_t A, B, count = 0;
  for (size_t i = 0; i < M; ++i) {
    cin >> A >> B;
    if (H[A - 1] < H[B - 1]) {
      S.erase(A);
    } else if (H[A - 1] > H[B - 1]) {
      S.erase(B);
    } else {
      S.erase(A);
      S.erase(B);
    }
  }

  cout << S.size() << endl;

  return 0;
}


Measured memory_bytes: 10388
N,L = map(int,input().split(' '))
ans = 300
flag = True
total = 0
for i in range(1,N+1):
    tmp = L+i-1
    if ans>abs(tmp):
        ans = abs(tmp)
        if tmp>=0:
            flag = True
        else:
            flag = False
    total += tmp

if flag:
    total -= ans
else:
    total += ans
print(total)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int N;
  cin >> N;
  long long int total = 0LL;
  
  vector<int> a(N);
  
  for(int i = 0; i < N; i++){
    cin >> a[i];
    total += a[i];
  }
  
  sort(a.begin(), a.end());
  long long int ans = 0LL;
  if(total % 10 == 0){
    for(int i = 0; i < N; i++){
      if(a[i] % 10 != 0){
        ans = total - a[i];
        break;
      }
    }
    cout << ans;
  }else{
    cout << total;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> as(n + 2);
    as.front() = as.back() = 0;
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> as[i];
        sum += abs(as[i] - as[i - 1]);
    }
    sum += abs(as[n + 1] - as[n]);

    for (int i = 1; i <= n; i++)
    {
        cout << (sum - abs(as[i] - as[i - 1]) - abs(as[i + 1] - as[i]) + abs(as[i + 1] - as[i - 1])) << endl;
    }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  rep(i, N) cin >> H.at(i);

  if (K >= N) {
    cout << 0 << endl;
  } else {
    sort(H.begin(), H.end());
    int64_t ans = accumulate(H.begin(), H.end() - K, 0LL);
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
    int n,l[1000000];
    cin>>n;
    int DP[1000000];
    for (int i=0;i<n;i++){
        cin>>l[i];
        // cout<<l[i];
    }
    for (int i=0;i<n;i++){
        DP[0]=0;
        if (i==1){
            DP[i]=DP[i-1]+abs(l[i]-l[i-1]);
            // cout<<"DP[i]"<<DP[i]<<endl;
        }else DP[i]=min(DP[i-1]+abs(l[i]-l[i-1]),DP[i-2]+abs(l[i]-l[i-2]));
    }
    cout<<DP[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 6528
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int k; cin >> k;
  int cur = 0;
  vector<bool> visited(k, false);
  for (int ans = 1; ; ++ans) {
    cur = (cur * 10 + 7) % k;
    if (visited[cur]) {
      cout << "-1\n";
      return 0;
    }
    visited[cur] = true;
    if (cur == 0) {
      cout << ans << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 3740
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int tmp = n,sum = 0;
	while(tmp){
		sum += tmp % 10;
		tmp /= 10;
	}
	cout << (n % sum == 0 ? "Yes\n" : "No\n");
	return 0;
}


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

int main() {
  string a,b;
  cin >> a >>b;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  if(a<b)
    cout <<"Yes" << endl;
  else
    cout << "No" <<endl;
  
      
  
}


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int t=in.nextInt();
		while(t-->0)
		{
			int n=in.nextInt();//家の数
			int k=in.nextInt();//発電機
			int a[]=new int[n];//家の位置
			for(int i=0;i<n;i++)
				a[i]=in.nextInt();
			if(k==1)
			{
				System.out.println(a[n-1]-a[0]);
			}
			else
			{
				int dis[]=new int[n-1];
				for(int i=0;i<n-1;i++)
					dis[i]=a[i+1]-a[i];
				Arrays.sort(dis);
				int cnt=0;
				for(int i=0;i<dis.length-k+1;i++)
					cnt+=dis[i];
				System.out.println(cnt);
			}
		}
	}
	
	static public void debug(Object... o)
	{
		System.err.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 113972
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	set<char> d;
	cin >> N;
	for(int i=0; i<N; i++){
		char temp;
		cin >> temp; 
		d.insert(temp);
	}
	if( d.size() == 3 ){
		cout << "Three" << endl;
	} else {
		cout << "Four" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

#define abs(N) (((N)>0)?(N):(-1)*(N))
typedef long long ll;

string pad(int digit,int num){
	stringstream ss;
	ss << std::setw(digit) << std::setfill('0') << num;
	return ss.str();
}

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

	vector<pair<ll,int> > v[N+1];
	for (int i = 0; i < M; ++i) {
		int p ;
		ll y;
		cin >> p >> y;
		v[p].push_back(make_pair(y,i));
	}

	string id[M];

	for (int i = 1; i <= N; ++i) {
		if(v[i].size()==0) continue;
		sort(v[i].begin(),v[i].end());
		int sz = v[i].size();
		for (int j = 0; j < sz; ++j) {
			id[v[i][j].second] = pad(6, i)+pad(6,j+1);
//			cout << id[v[i][j].second] << endl;
		}
	}
	for (int i = 0; i < M; ++i) {
		cout << id[i] << endl;
	}

}


Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n;
	cin >> n;
	vector<P> works(n);
	for(int i = 0; i < n; i++) {
		cin >> works[i].second >> works[i].first;
	}
	sort(works.begin(),works.end());
	ll now = 0;
	for(int i = 0; i < n; i++) {
		now += works[i].second;
		if(now>works[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#pragma region val
int n;
int u,v;
vector<int> ga[200100];
int vis[200100];
int mx[4];
int cnt[4];
int cz[3];
int res[200100];
#pragma endregion
#pragma region fun
void bipartite(int u,int co){//二分图染色 
	vis[u]=co;
	cz[co]++;
	for(int v:ga[u]){
		if(!vis[v]){
			bipartite(v,3-co);
		}
	}
}
void asgn(int vert,vector<int> ve){//把ve内容分配给vert 
	for(int i=0;i<ve.size();i++){
		if(mx[ve[i]]<cnt[ve[i]]){
			res[vert]=3*mx[ve[i]]+ve[i];
			mx[ve[i]]++;
			return;
		}
	}
}
#pragma endregion
#pragma region mn
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>u>>v;
		ga[u].push_back(v);
		ga[v].push_back(u);
	} 
	bipartite(1,1);
	cnt[3]=n/3;
	cnt[1]=n/3;
	cnt[2]=n/3;
	if(n%3==1){
		cnt[1]++;
	}
	if(n%3==2){
		cnt[1]++;
		cnt[2]++;
	}
	if(cz[1]>cz[2]){
		swap(cz[1],cz[2]);
		for(int i=1;i<=n;i++){
			if(vis[i]==1)
				vis[i]=2;
			else
				vis[i]=1;
		}
	}
	if(cz[1]<=cnt[3]){
		for(int i=1;i<=n;i++){
			if(vis[i]==1)
				asgn(i,{3});
			else
				asgn(i,{1,2,3});
		} 
	}
	else{
		for(int i=1;i<=n;i++){
			if(vis[i]==1){
				asgn(i,{1,3});
			}
			else{
				asgn(i,{2,3});
			}
		} 
	}
	for(int i=1;i<=n;i++)
		cout<<res[i]<<' ';
	cout<<endl;
	return 0;
}
#pragma endregion

Measured memory_bytes: 16640
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        a: [i64; n]
    }
    let sum = a .iter().fold(0, |acc, &x| acc + x);
    let mut a0 = vec![0;n];
    let mut a1 = vec![0;n];
    for i in 0..n {
        if i % 2 == 0 {
            a0[i] = a[i];
        } else {
            a1[i] = a[i];
        }
    }
    let a0cum = Cum::new(&a0);
    let a1cum = Cum::new(&a1);
    for i in 0..n {
        let mut ret = sum;
        let l = i + 1;
        let r = (l + n - 2) % n;
        if l % 2 == 0 {
            if l>r {
                ret -= (a0cum.sum(l, n) + a1cum.sum(0, r)) * 2;
            } else {
                ret -= a0cum.sum(l, r) * 2;
            }
        } else {
            if l>r {
                ret -= (a1cum.sum(l, n) + a0cum.sum(0, r)) * 2;
            } else {
                ret -= a1cum.sum(l, r) * 2;
            }
        }
        print!("{}", ret);
        if i != n-1 {
            print!(" ");
        }
    }
    println!("");
}

#[derive(Debug)]
#[allow(dead_code)]
struct Cum {
    s: Vec<i64>,
}
#[allow(dead_code)]
impl Cum {
    fn new(a: &Vec<i64>) -> Cum {
        let mut s = vec![0; a.len() + 1];
        for i in 0..a.len() {
            s[i + 1] = s[i] + a[i];
        }
        Cum { s: s }
    }
    #[doc = " [l,r)"]
    fn sum(&self, l: usize, r: usize) -> i64 {
        self.s[r] - self.s[l]
    }
}

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

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

  int ans = 0, div;
  while (true) {
    div = 0;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 == 0) {
        A[i] /= 2;
        div++;
      }
    }

    if (!div) break;
    ans += div;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

signed main(){
	int n,a[300000];
	cin >> n;
	for(int i = 0;i < n * 3;i++) cin >> a[i];
	sort(a,a + 3 * n,greater<int>());
	int ans = 0;
	for(int i = 0;i < n;i++) ans += a[i * 2 + 1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int main() {
	bool every[31];
	REP(i,1,31) {
		every[i] = false;
	}

	int index;
	rep(i,28) {
		cin >> index; 
		every[index] = true;
	}

	REP(i,1,31) {
		if (every[i] == false) {
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
class BinarySearchTree
	class Node
		attr_accessor :key, :left, :right
		def initialize(key)
			@key = key
		end
	end

	attr_accessor :root

	def insert(key)
		parent  = nil
		current = @root
		while current
			parent = current
			if key < current.key
				current = current.left
			else
				current = current.right
			end
		end

		new_node = Node.new(key)
		if !parent
			@root = new_node
		elsif key < parent.key
			parent.left = new_node
		else
			parent.right = new_node
		end
	end

	def keys_inorder
		inorder_helper(@root)
	end

	def keys_preorder
		preorder_helper(@root)
	end

	private
	def inorder_helper(node)
		return [] unless node
		result = []
		result.concat(inorder_helper(node.left))
		result << node.key
		result.concat(inorder_helper(node.right))
	end

	def preorder_helper(node)
		return [] unless node
		result = [node.key]
		result.concat(preorder_helper(node.left))
		result.concat(preorder_helper(node.right))
	end

end

tree = BinarySearchTree.new
n = STDIN.gets.to_i
n.times do
	command, param = STDIN.gets.split[0..1]
	if command == "insert"
		tree.insert(param.to_i)
	elsif command == "print"
		puts " #{tree.keys_inorder.join(" ")}"
		puts " #{tree.keys_preorder.join(" ")}"
	else
		raise "Unexpected input #{command}, #{param}"
	end
end

Measured memory_bytes: 117804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;

int main (){
  int n,M;
  cin>>n;
  switch (n % 10) {
 case 2:
 case 4:
 case 5:
 case 7:
 case 9:
 cout<<"hon";
 break;
 case 0:
 case 1:
 case 6:
 case 8:
 cout<<"pon";
 break;
 case 3:
 cout<<"bon";
  }
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cstdlib>
#include<cstring>


using namespace std;

int search(int arr[], int Get)
{
	int pos = -1;
	for(int i = 0; i < 9; i++)
	{
		if(arr[i] == Get)pos = i;
	}
	return pos;
}

int main()
{
	int* arr = new int[9];
	for(int i = 0; i < 3; i++)
	{
		scanf("%d %d %d", &arr[i * 3 + 0], &arr[i * 3 + 1], &arr[i * 3 + 2]);
	}
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		int Get;
		scanf("%d", &Get);
		int pos;
		pos = search(arr, Get);
		if(pos != -1)arr[pos] = 0;
	}
	bool bingo = false;
	for(int i = 0; i < 3; i++)
	{
		if(arr[i * 3 + 0] == 0 && arr[i * 3 + 1] == 0 && arr[i * 3 + 2] == 0)
		{
		    bingo = true;
		}
		if(arr[i] == 0 && arr[3 + i] == 0 && arr[6 + i] == 0)
		{
			bingo = true;
		}
	}
	if(arr[0] == 0 && arr[4] == 0 && arr[8] == 0) bingo = true;
	if(arr[2] == 0 && arr[4] == 0 && arr[6] == 0) bingo = true;
	if(bingo){printf("Yes");}
	else{printf("No");}
	return 0;

}

Measured memory_bytes: 256