akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

int dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  seen[start]=true;
  // cerr<<start<<" : "<<goal<<endl;
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    goal=dfs(g,next,goal+1,seen);
  }
  return goal;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

void primeFactor(ll val, map<ll,ll> &primeList){
  if(val<1){
    return;
  }
  for(int i=2;i*i<val;i++){
    while(val%i==0){
      primeList[i]++;
      val/=i;
    }
  }
  if(val!=1){
    primeList[val]=1;
  }
  return;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,m;cin>>n>>m;
  vector<vector<int>> g(n+1);
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    if(find(all(g[a]),b)==g[a].end()){
      g[a].push_back(b);
      g[b].push_back(a);
    }
  }
  int ans=-1;
  vector<bool> seen(n+1,false);
  for(int i=1;i<n+1;i++){
    if(seen[i]){
      continue;
    }
    int res=dfs(g,i,1,seen);
    ans=max(ans,res);
    // cerr<<"------"<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 23416
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
struct knapsack{
	ll weight;
	ll value;
};

int main(){
	ll n,w;
	cin>>n>>w;
	auto k = vector<knapsack>(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>k[i].weight>>k[i].value;
	}

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

	for (int i = 1; i <= w; ++i)
	{
		if (i<k[0].weight)
		{
			arr[0][i] = 0;
		}else{
			arr[0][i] = k[0].value;
		}
	}

	for (int i = 1; i < n; ++i)
	{
		for (int j = 1; j <= w; ++j)
		{
			if (j<k[i].weight)
			{
				arr[i][j]=arr[i-1][j];
			}else{
				arr[i][j] = max(arr[i-1][j],k[i].value+arr[i-1][j-k[i].weight]);
			}
		}
	}

	cout<<arr[n-1][w]<<endl;
	return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
    int N, M;
    cin>>N>>M;
    int Ans=0;
    Ans+=N*(N-1)/2;
    Ans+=M*(M-1)/2;
    cout<<Ans<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> fri(A);
    vector<int> mic(B);
    for (int i = 0; i < A; i++) {
        cin >> fri.at(i);
    }
    for (int i = 0;  i < B; i++) {
        cin >> mic.at(i);
    }
    vector<vector<int>> off(M, vector<int>(3));
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> off.at(i).at(j);
        }
    }
    int sum;
    int ans = 200000;
    for (int i = 0; i < M; i++) {
        sum = fri.at(off.at(i).at(0) - 1) + mic.at(off.at(i).at(1) - 1) - off.at(i).at(2);
        ans = min(ans, sum);
    }
    sort(fri.begin(), fri.end());
    sort(mic.begin(), mic.end());
    sum = fri.at(0) + mic.at(0);
    ans = min(ans, sum);
    cout << ans << endl;
}

Measured memory_bytes: 9572
#include<iostream>
using namespace std;
#include<vector>
template<typename T>
struct weightedUF{
	int n;
	vector<int>parent,rank;
	vector<T>dweight;
	weightedUF(int n_=0,T defvalue=0):n(n_),parent(n_),rank(n_,1),dweight(n_,defvalue)
	{
		for(int i=0;i<n;i++)parent[i]=i;
	}
	int find(int a)
	{
		if(parent[a]==a)return a;
		else
		{
			int ar=find(parent[a]);
			dweight[a]+=dweight[parent[a]];
			return parent[a]=ar;
		}
	}
	T weight(int a)
	{
		find(a);
		return dweight[a];
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b,int w)//a+w==b
	{
		w+=weight(a);w-=weight(b);
		a=find(a);b=find(b);
		if(a==b)return false;
		if(1||rank[a]<rank[b])
		{
			parent[a]=b;
			dweight[a]=-w;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			dweight[b]=w;
			rank[a]+=rank[b];
		}
		return true;
	}
	T diff(int a,int b)
	{
		return weight(b)-weight(a);
	}
};
main()
{
	int N,M;cin>>N>>M;
	weightedUF<int>UF(N);
	for(;M--;)
	{
		int L,R,D;cin>>L>>R>>D;
		L--,R--;
		if(UF.same(L,R))
		{
			if(UF.diff(L,R)!=D)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
		else
		{
			UF.unite(L,R,D);
		}
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
import java.util.*;
 
public class Main{
	public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
    	int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int ab[] =new int[num2 * 2];
		for(int i = 0; i < num2 * 2; i++){
			ab[i] = sc.nextInt();
        }
        int count[] = new int[num1];
        for(int n = 0; n < num1; n++){
        	 for(int i = 0; i < num2 * 2; i++){
             	if(n + 1 == ab[i]){
                	count[n]++;
                }
             }
        }
        for(int i = 0; i < num1; i++){
        	System.out.println(count[i]);
        }
	}
}

Measured memory_bytes: 35888
#include <iostream>
#include <forward_list>
#include <cstring>

#define INF 2000000000

using namespace std;

typedef struct
{
	int a;
	int b;
} bar;

int N,M,H,K;
int S[1000];
int F[1000];
forward_list<bar> B;
forward_list<bar> C;

int main(void)
{
	while(true)
	{
		cin >> N >> M >> H >> K;
		if(N == 0 && M == 0 && H == 0 && K == 0)
			exit(0);
		memset(S,0,sizeof(int[1000]));
		memset(F,0,sizeof(int[1000]));
		B.clear();
		C.clear();
		for(int i = 0;i < N;i++)
		{
			cin >> S[i];
			F[i] = i;
		}
		bar t;
		for(int i = 0;i < M;i++)
		{
			cin >> t.a >> t.b;
			t.a--;
			t.b--;
			B.push_front(t);
		}
		B.sort([](const bar& a,const bar& b){return a.b > b.b;});
		for(auto itr = B.begin();itr != B.end();itr++)
		{
			t.a = F[itr->a];
			t.b = F[itr->a] = F[(itr->a)+1];
			F[(itr->a)+1] = t.a;
			C.push_front(t);
		}
		t.a = t.b = 0;
		C.push_front(t);
		int s;
		int minn = INF;
		for(auto itr = C.begin();itr != C.end();itr++)
		{
			s = S[itr->a];
			S[itr->a] = S[itr->b];
			S[itr->b] = s;
			//S[F[index]];
			s = 0;
			for(int i = 0;i < K;i++)
			{
				s += S[F[i]];
			}
			minn = min(minn,s);
			s = S[itr->a];
			S[itr->a] = S[itr->b];
			S[itr->b] = s;
		}
		cout << minn << endl;
	}
}

Measured memory_bytes: 9296
#include <cstdio>
const int mod = 1000000007;
long long dp[1010][1010];
char a[1010][1010];
int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", a[i]);
	}
	dp[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				dp[i][j] = 0;
				continue;
			}
			dp[i][j] %= mod;
			dp[i+1][j] += dp[i][j];
			dp[i][j+1] += dp[i][j];
		}
	}
	printf("%lld\n", dp[h-1][w-1]);
	return 0;
}


Measured memory_bytes: 9088
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

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

int main() {

	int A, B, C, X, Y;
	scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
	/*
		bool C_A = 2 * C <= A, C_B = 2 * C <= B, C_AB = 2 * C <= A + B;

		if (C_A && C_B) {
			printf("%d\n", max(X, Y) * 2 * C);
			return 0;
		}
	*/
	int cost = 0;
	if (X < Y) {
		if (A * X + B * X < 2 * C * X) {
			cost += A * X + B * X;
			Y -= X;
		}
		else {
			cost += 2 * C * X;
			Y -= X;
		}
		if (B * Y < 2 * C * Y) {
			cost += B * Y;
		}
		else {
			cost += 2 * C * Y;
		}
	}
	else {
		if (A * Y + B * Y < 2 * C * Y) {
			cost += A * Y + B * Y;
			X -= Y;
		}
		else {
			cost += 2 * C * Y;
			X -= Y;
		}
		if (A * X < 2 * C * X) {
			cost += A * X;
		}
		else {
			cost += 2 * C * X;
		}
	}


	printf("%d\n", cost);

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"unsafe"
)

var (
	sc scanner
)

func main() {
	n, k := sc.nextInt(), sc.nextInt()
	fmt.Println(min(n%k, abs(n%k-k)))
}

/* template functions */

func init() {
	sc = scanner{
		buf: make([]string, 0, 10000),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 100)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}

func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}

func (s *scanner) resetCur() {
	s.cur = 0
}

func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}

func (s *scanner) nextByte() byte {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur][0]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i, _ := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}

func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur], 64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i, _ := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i], 64)
	}
	s.resetCur()
	return res
}

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

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

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// Searchable
// idx := lower_bound([]int{-199, -1, 0, 2, 4, 67, 100, 8435}, 60)
// => idx = 5
//
// No present
// idx := lower_bound([]int{-199, -1, 0, 2, 4, 67, 100, 8435}, 10000)
// => idx = 8

func lower_bound(a []int, x int) int {
	return sort.SearchInts(a, x)
}

func dump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}

func yes() {
	fmt.Println("Yes")
}

func no() {
	fmt.Println("No")
}


Measured memory_bytes: 640
N = int(input())
atime,ax,ay = 0,0,0
for i in range(N):
    btime,bx,by = map(int,input().split(" "))
    distance = abs(bx-ax)+abs(by-ay)
    time = btime-atime
    if (time >= distance)and((time-distance)%2 == 0):
        ax = bx
        ay = by
        atime = btime
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 3060
#!/usr/bin/env python3

N = int(input())

r = [0 for i in range(87)]
r[0] = 2
r[1] = 1
#print(r)
def ryuka(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        if r[n] != 0:
            return r[n]
        r[n] = ryuka(n-1) + ryuka(n-2)
        return r[n]
#print(r)
print(ryuka(N))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int K,A,B,C,tmp,ans=0;
priority_queue<int> Q;
int main(){
  cin >> A >> B >> C >> K;
  Q.push(A);
  Q.push(B);
  Q.push(C);
  for(int i=0;i<K;i++){
    tmp=Q.top();
    Q.pop();
    Q.push(tmp*2);
  }
  while(! Q.empty()){
    ans+=Q.top();
    Q.pop();
  }
  cout << ans << endl;
  return 0;
}


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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 1<<17|1
int n,a,b;
int dif,sam;
int cnt(int x){
	int res=0;
	while(x){
		if(x&1)++res;x>>=1;
	}return res;
}
void dft(int a,int b,int t){
	if(!t){
		printf("%d ",a);
		return;
	}
	int dif=a^b;
	int i=lb(dif&t);dif-=i;
	int j=a^lb(t-i);
	dft(a,j,t-i);
	dft(j^i,b,t-i);
	return;
	
}
int main(){
	read(n);read(a);
	read(b);dif=a^b;
	sam=(1<<n)-dif-1;
	if(cnt(dif)&1)puts("YES");
	else return puts("NO"),0;
	dft(a,b,(1<<n)-1);
	return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
void print_line(vector<int> &line) {
    for (int i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int count = 0;

    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (a[j] < a[minj]) {
                minj = j;
            }
        }


        if (i != minj) {
            swap(a[i], a[minj]);
            count++;
        }
    }
    print_line(a);
    cout << count << endl;
}



Measured memory_bytes: 3124
//  Created by liszt on 2019/08/04.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n; cin>>n;
    if(n<100){
        cout<<min(9,n)<<endl;
    }else if(n<10000){
        cout<<min(909,n-90)<<endl;
    }else{
        cout<<min(90909,n-9090)<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n;cin>>n;
    vi v(n);
    vi a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll x,y;
    rep(i,n)v[i]=i+1;
    ll i=1;
    do{
        if(a==v)x=i;
        if(b==v)y=i;
        i++;
    }while(next_permutation(all(v)));
    cout<<abs(x-y)<<endl;
}

Measured memory_bytes: 256
#include <string>
#include<string.h>
#include <iostream>
int len = 0, N = 0;
char s1[101], s2[101];
bool f = false;
using namespace std;
int main(){
  cin >> len;
  cin >> s1 >> s2;
  N = len * 2;
    if(strcmp(s1,s2)==0){N/=2;}
    else {
      for(int i = 0; i<len; i++){
      f = true;
      for(int j = 0; j<len-i; j++){
        if(s1[i+j] != s2[j]){
          f = false;
          break;
        }
      }
      if(f) N -= len-i;
    }
  }
      cout << N;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scn = new Scanner(System.in);
		int h1 = scn.nextInt();
		int m1 = scn.nextInt();
		int h2 = scn.nextInt();
		int m2 = scn.nextInt();
		int k = scn.nextInt();
		int tt = (h2 * 60 + m2) - (h1 * 60 + m1);
		System.out.println(tt - k);
		return;
	}

}


Measured memory_bytes: 27040
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int D[100001], M[100001];

int main() {
  int N, result;
  int i, M0, Mi;
  scanf ("%d", &N);
  
  for (i=0;i<N;i++) {
      scanf("%d", &D[i]);
  }
  D[N] = D[0];
  
  M0 = 0;
  for (i=0;i<N;i+=2) {
    M0 += D[i];
  }
  for (i=1;i<N;i+=2) {
    M0 -= D[i];
  }
  
  printf("%d", M0);
  
  Mi=M0;
  for (i=1;i<N;i++) {
    Mi = D[i-1]*2 - Mi;
    printf(" %d", Mi);
  }
  return 0;
}




Measured memory_bytes: 1664
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    // 探索されるデータを入力
    int data_number = Integer.parseInt(scan.next());
    int data[] = new int[data_number];
    for (int i = 0; i < data_number; i++) {
      data[i] = Integer.parseInt(scan.next());
    }
    // 探索したいデータを入力
    int search_key_number  = Integer.parseInt(scan.next());
    int search_key[] = new int[search_key_number];
    for (int i = 0; i < search_key_number; i++) {
      search_key[i] = Integer.parseInt(scan.next());
    }



    // 探索を開始
    int count = 0;
    for (int i = 0; i < search_key_number; i++) {
      if (LinerSearch(search_key[i], data, data_number) != -1) {
        count++;
      }
    }

    System.out.println(count);
  }

  private static int LinerSearch(int search_key, int data[], int data_number) {
    for (int i = 0; i < data_number; i++) {
      if (search_key == data[i]) {
        return i;
      }
    }
    return -1;
  }
}



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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

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

void solve() {
    int n;
    cin >> n;
    string s;
    string t;
    cin >> s >> t;
    REP(i, n) {
        cout << s[i] << t[i];
    }
    cout << EOL;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
ll dp[1000][100] = {0},cnt[100] = {0},mod = 1000000007,h,w,k;
ll ret(int i){
	if(i>0) return cnt[i];
	return 1;
}

int main(){
	int i,j,l;
	cin >> h >> w >> k;
	for(i=0;i<w;i++){
		for(j=0;j<1<<i;j++){
			for(l=0;l<i;l++){
				if(j&1<<l && j&1<<(l+1)){
					break;
				}
				if(l==i-1) cnt[i]++;
			}
		}
	}
	
	dp[0][0] = 1;
	for(i=1;i<=h;i++){
		for(j=0;j<w;j++){
			(dp[i][j] += ret(j-1)*ret(w-j-2)*dp[i-1][j]) %= mod;
			if(j!=0){
				(dp[i][j] += ret(j-2)*ret(w-j-2)*dp[i-1][j-1]) %= mod;
			}
			if(j!=w-1){
				(dp[i][j] += ret(j-1)*ret(w-j-3)*dp[i-1][j+1]) %= mod;
			}
		}
	}
	cout << dp[h][k-1] << endl;
}

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

using namespace std;

int main(){
    int n, k, num;
    bool valid = true;
    vector<int> numbers(10,0);

    cin >> n >> k;

    for(int i=0; i<k; i++){
        cin >> num;
        numbers[num]++;
    }

    for(int i=n; i<100005; i++){
        num = i;

        for(int j=0; num > 0; j++){
            if(numbers[num % 10]){
                valid = false;
                break;
            }
            else
                num /= 10;
        }

        if(valid){
            cout << i << endl;
            break;
        }
        else
            valid = true;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(){
 int N;
  cin>> N;
 
  vector<int> Hs(N);
  for(int i =0 ; i < N;i++){
    cin >> Hs.at(i) ;
  }
  
  int max = Hs.at(0);
  int ans = 1;
  if(N>1){
    for(int i = 1 ; i <N;i++){
    if(max <= Hs.at(i) ) {
      ans ++;
      max = Hs.at(i);

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

Measured memory_bytes: 256
int(input())
a = str(input())
b = str(input())
c = str(input())
def f(a,b,c):
    ans = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            ans += 1
        if a[i] != c[i] and c[i] != b[i]:
                ans += 1 
    return ans
ans = min(f(a,b,c),f(b,c,a),f(c,a,b))
print(ans)
 

Measured memory_bytes: 3064
fn main() {
    let (a, b): (f64, f64) = (read::<f64>(), read::<f64>());
    for i in 0..1251 {
        if (i as f64 * 0.08).floor() == a && (i as f64 * 0.1).floor() == b {
            println!("{}", i);
            exit(0);
        }
    }
    println!("-1");
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

int main() {
  string S;
  cin>>S;
  
  int X=0;
  
  rep(i,S.length()){
   X+=S.at(i)-'0';
  }
  
  if(X%9==0){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
}


Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>

using namespace std;

string a,b,ans;

int main(){
	cin>>a>>b;
	for(int i=0;i<min(a.size(),b.size());i++){
		ans+=a[i];
		ans+=b[i];
	}
	if(a.size()>b.size()){
		ans+=a[a.size()-1];
	}
	if(a.size()<b.size()){
		ans+b[b.size()-1];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#B
N,M = map(int,input().split())
A = [int(input()) for i in range(N)]

for k in range(1,M+1):
    for i in range(N-1):
        if A[i]%k > A[i+1]%k:
            A[i],A[i+1] = A[i+1],A[i]
            
for a in A:
    print(a)




Measured memory_bytes: 5612
// nikkei_procon2019_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    
    // calculation
    vector<int> num(N, 3);
    REP(i, N) {
        if (A[i] == B[i]) num[i]--;
        if (B[i] == C[i]) num[i]--;
        if (C[i] == A[i]) num[i]--;
    }
    int res = 0;
    REP(i, N) {
        if (num[i] == 3) {
            res += 2;
        } else if (num[i] == 2) {
            res += 1;
        } else if (num[i] == 0) {
            res += 0;
        }
    }
    cout << res << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  int check = k;
  int ans = 1;
  while (true) {
    if (check > n) break;
    check *= k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod;
int fact(int n){
	int s=1;
	for(int i=1;i<=n;++i){
		s*=i;
		s%=mod;
	}
	return s;
}			 
int power(int x, unsigned int y, unsigned int m); 
int modInverse(int a, int m) 
{ 
    return power(a, m-2, m); 
} 
  
int power(int x, unsigned int y, unsigned int m) 
{ 
    if (y == 0) 
        return 1; 
    int p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
void q1(){
	int r;
	cin>>r;
	cout<<r*r;
}
void q2(){
	int n; cin>>n;
	if(n&1){
		cout<<"No\n";
		return ;
	}
	n/=2;
	string s;
	cin>>s;
	int fg=1;
	for(int i=0;i<n;++i)
	if(s[i]!=s[i+n])
	fg=0;
	fg==1 ? cout<<"Yes\n" : cout<<"No\n";
}
void q3(){
	int n;
	cin>>n;
	int x[n],y[n];
	for(int i=0;i<n;++i)
	cin>>x[i]>>y[i];
	double tp=0;
	for(int i=0;i<n;++i)
	for(int j=i+1;j<n;++j)
	tp+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
	tp*=2;	tp/=n;
	cout<<fixed<<setprecision(10)<<tp;
}
void q4(){
	int x,y;
	cin>>x>>y;
	int s=x+y;
	if(s%3!=0){
		cout<<"0\n";
		return ;
	}
	int xp=(2*x-y)/3;
	int yp=(2*y-x)/3;
	if(xp<0 || yp<0){
		cout<<"0\n";
		return ;
	}
	//cout<<xp<<" "<<yp<<endl;
	int pp=fact(xp);
	int ppp=fact(yp);
	int ans=fact(xp+yp);
	ans*=modInverse(pp,mod);	ans%=mod;
	ans*=modInverse(ppp,mod);	ans%=mod;
	cout<<ans;
}
int32_t main()
{
	mod=1e9+7;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q4();
	return 0;
}
	


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	int cnt[3] = {};
	int l[3];
	for(int i = 0; i < 3; i++){
		l[i] = s[i].length();
	}
	int nowplayer = 0;
	while(cnt[nowplayer] < l[nowplayer]){
		char c = s[nowplayer][cnt[nowplayer]];
		cnt[nowplayer]++;
		nowplayer = c - 'a';
	}
	cout << (char)toupper('a' + nowplayer) << endl;
	return 0;
}

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

using namespace std;
#define BUF (300005)
#define ll long long 
#define INF 1000000005
int n;
char s[BUF];

int main(void){
	cin >> n;
	cin >> s;
	int e=0;
	for(int i=0;i<n;i++) if(s[i]=='E')e++;
	int w = n-e;

	int cnt=0;
	int ans=INF;
	for(int i=0;i<n;i++){
		int tmp;
		if(s[i]=='W')cnt++;

		if(s[i]=='W'){
			tmp=cnt-1 + e-i-1+cnt;
		}else{
			tmp=cnt + e-i-1+cnt;
		}

		ans=min(ans,tmp);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
/*input
1
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
const int N =2e5+5;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int dp[N][2];
vector<int> adj[N];
void dfs(int node,int par)
{
	for(auto it:adj[node])
	{
		if(it==par)continue;
		dfs(it,node);
		dp[node][0]*=dp[it][1];
		dp[node][0]%=modd;
		dp[node][1]*=(dp[it][0]+dp[it][1]);
		dp[node][1]%=modd;
	}
}
signed main()
{
	speed
	int n;
	cin>>n;
	int x,y;
	rep(i,n-1)
	{
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	Rep(i,n)
	{
		dp[i][1]=1;
		dp[i][0]=1;
	}
	dfs(1,0);
	cout<<(dp[1][0]+dp[1][1])%modd<<endl;
	return 0;
}

Measured memory_bytes: 13184
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	N := getNextInt(scanner)
	A := make([]int, N)

	for i := 0; i < N; i++ {
		A[i] = getNextInt(scanner)
	}

	MAX := 1000005
	dp := make([]int, MAX)
	for _, v := range A {
		if dp[v] != 0 {
			dp[v] = 2
			continue
		}
		for i := v; i < MAX; i += v {
			dp[i]++
		}
	}
	ans := 0
	for _, v := range A {
		if dp[v] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 13920
program ABC060B
    implicit none
    integer(8)::A,B,C,i
    integer(8)::flg=0
    read(5,*)A,B,C

    do i=1,B
        if(mod(A*i,B)==C)then
            flg=1
            print'(A)',"YES"
            exit
        end if
    end do

    if(flg==0)then
        print'(A)',"NO"
    end if
end program ABC060B

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int X; cin >> X;
	map<int, bool>mp;
	map<int, int>key;
	FOR(i, 0, 1000) {
		int tmp = i * i*i*i*i;
		mp[tmp] = 1;
		if (mp[abs(X - tmp)]) {
			int ttmp = abs(X - tmp);
			if (tmp + ttmp == X) {
				cout << key[abs(X - tmp)] << " " << -i << endl;
				return 0;
			}
			else if (ttmp - tmp == X) {
				cout << key[abs(X - tmp)] << " " << i << endl;
				return 0;
			}
			else {
				cout << i << " " << key[abs(X - tmp)] << endl;
			}
		}
		key[tmp] = i;
	}
	FOR(i, 1, 1000) {
		int tmp = i * i*i*i*i;
		
	}
	return 0;
}



Measured memory_bytes: 3728
#include<iostream>
#include<iomanip>



int main()
{
	double r;
	double area;
	double circle;
	const double PI = 3.14159265358979323846;

	std::cin >> r;
	area = r*r*PI;
	circle = 2 * PI*r;

	std::cout <<std::fixed<<std::setprecision(20)<< area << ' ' << circle << '\n';

	return 0;

}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = 101;
const int MAX_S = 10010;

bool dp[MAX_N][MAX_S];

int main()
{
	memset(dp, false, sizeof(dp));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> s(N, 0);
	rep (i, N) cin >> s[i];

	dp[0][0] = true;
	rep(i, N){
		rep (j, MAX_S){
			if (dp[i][j]){
				dp[i+1][j+s[i]] |= dp[i][j];
				dp[i+1][j] |= dp[i][j];
			} // end if
		} // end rep
	} // end rep

	int res = 0;
	for (int j = MAX_S - 1; j >= 0; --j){
		if (dp[N][j] && (j % 10 != 0)){
			res = j;
			break;
		} // end if
	} // end for

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

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }

}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n,m,a;
  while(true){
    cin >> n  >> m >>a;
    if(n==0) break;
    int line[1001][1001]={0};
    for(int i=0;i<m;i++){
      int h,p,q;
      cin >> h >> p >>q;
      line[p][h]=q;
      line[q][h]=p;
    }
    for(int hei=1000;0<hei;hei--){
      if(line[a][hei]!=0) a=line[a][hei];
    }
    cout << a << endl;
  }
}

Measured memory_bytes: 7044
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define sett(a,b) memset(a,b,sizeof(a))
#define copy(a,b) memcpy(a,b,sizeof(a))
#define prq priority_queue
using namespace std;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	ll k,a,b;
	cin>>k>>a>>b;
	if(k<=a||b-a<=2)cout<<k+1;
	else cout<<(k-(a-1))/2*(b-a)+a+(k-(a-1))%2;
	return 0;
}


Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, k;
  cin >> n >> k;
  n %= k;
  print(min(n, k-n));
}


Measured memory_bytes: 256
H, W = map(int, input().split())
data = []
for i in range(H):
  data.append(input().split())
print("#" * (W+2))
for i in range(H):
  print("#", end='')
  for j in data[i]:
    print(j, end='')
  print("#")
print("#" * (W + 2))

Measured memory_bytes: 63476
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> b(n, 0);
    ll r = 0;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (int t = i - a; t > 0) r += b[t];
        if (int t = i + a; t < n) b[t]++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 4000
import java.util.Scanner;

public class Main {
    public static void main(String... args){
        Scanner scan = new Scanner(System.in);
        int i = 1;
        while(true){
            int x = scan.nextInt();
            if(x == 0)break;
            System.out.println("Case " + i++ + ": " + x);
        }
        scan.close();
    }
}


Measured memory_bytes: 42756
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Card{
public:
	string color;
	int num;

	Card() : color(""),num(0){}
	bool operator<(const Card& c) const{
		if(color == c.color){
			return num < c.num;
		}
		return color < c.color;
	}
};

int main(){
	int n;

	while(~scanf("%d",&n)){

		for(int idx=0;idx<n;idx++){
			vector<Card> cards;
			int num[10];
			for(int j=0;j<9;j++){
				scanf("%d",&num[j]);
			}

			string str;
			for(int j=0;j<9;j++){
				cin >> str;
				Card c;
				c.color = str;
				c.num = num[j];

				cards.push_back(c);
			}

			sort(cards.begin(),cards.end());

			bool fail = false;

			for(int i=0;i<9;){
				int prev_num = cards[i].num;
				string prev_c = cards[i].color;

				bool isok = true;
				//3つ連続
				for(int j=0;j<2;j++){			
					if(cards[i+j+1].num == prev_num
						&& cards[i+j+1].color == prev_c){

					}
					else{
						isok = false;
						break;
					}
					prev_num = cards[i+j+1].num;
					prev_c = cards[i+j+1].color;

				}

				if(isok) {
					i+=3;
					continue;
				}

				isok = true;

				//昇順
				for(int j=0;j<2;j++){
					if(cards[i+j+1].num == prev_num + 1
						&& cards[i+j+1].color == prev_c){

					}
					else{
						isok = false;
						break;
					}

					prev_num = cards[i+j+1].num;
					prev_c = cards[i+j+1].color;
				}

				if(isok){
					i+=3;
					continue;
				}

				isok = true;

				if(i+6 >= 9){
					fail = true;
					break;
				}

				//七対子			
				for(int j=0;j<6;j+=2){
					if(cards[i+j].color == cards[i+j+1].color
						&& cards[i+j].num == cards[i+j+1].num){

					}
					else{
						isok = false;
					}
				}

				if(isok){
					i+=6;
					continue;
				}

				fail = true;
				break;
			}

			printf("%d\n",fail ? 0 : 1);
		}

	}
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef pair<ll, ll> pint;


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



void print(const vint& v)
{
  for(int i=0; i+1<v.size(); ++i){
    std::cout << v[i] << " ";
  }
  cout<<v.back()<<endl;
  // std::for_each(v.begin(), v.end()-1, [](int x) {
  //   std::cout << x << " ";
  // });
  // std::cout << std::endl;
}

ll bubbleSort(vint &a){
  ll cnt = 0;
  ll n = a.size();

  bool f = true;
  while(f){
    f = false;
    for(ll j=n-1; j>0; j--){
      if(a[j] < a[j-1]) {swap(a[j], a[j-1]); f = true; cnt++;}
    }
  }


  return cnt;
}

int main() {


  cout<<fixed<<setprecision(10);

  ll n; cin>>n;
  vint a(n); rep(i,n) cin>>a[i];

  ll cnt = bubbleSort(a);
  print(a);
  cout<<cnt<<endl;


}





//




Measured memory_bytes: 3108
<?php
$p = array(
     'A' => array('B', 'D'),
     'B' => array('A', 'C', 'E'),
     'C' => array('B', 'F'),
     'D' => array('A', 'E', 'G'),
     'E' => array('B', 'D', 'F', 'H'),
     'F' => array('C', 'E', 'I'),
     'G' => array('D', 'H'),
     'H' => array('G', 'E', 'I'),
     'I' => array('F', 'H'),
);

while ($line = trim(fgets(STDIN))) {
  $str = str_split($line);
  $len = count($str);
  $ok = true;
  for ($i=0; $i<$len-1; ++$i) {
    if (in_array($str[$i+1], $p[$str[$i]])) {
      // OK
    } else {
      // NG
      $ok = false;
      break;
    }
  }
  if ($ok) echo "$line\n";
}

Measured memory_bytes: 15436
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> A = new ArrayList<Integer>();

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] B = new int[n][m];
        int[] C = new int[m];
        int[] D = new int[n];

        for (int i=0; i<n; i++) {
            for (int j=0; j<m; j++) {
                B[i][j] = sc.nextInt();
            }
        }
        for (int i=0; i<m; i++) {
            C[i] = sc.nextInt();
        }
        for (int i=0; i<n; i++) {
            for (int j=0; j<m; j++) {
                D[i] += B[i][j] * C[j];
            }
        }
        for (int i=0; i<n; i++) {
            System.out.println(D[i]);
        }


    }
}


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

int main(){
  int N ,M ,X;
  cin >> N >> M >> X;
  vector<int>C(13); //値段の配列,0-indexなのに注意
  vector<vector<int>>A(13,vector<int>(13)); //M冊の，N個のアルゴリズムの情報が入った配列
  
  //入力
  for(int i = 0; i < N; i++){
    cin >> C.at(i);
    for(int j = 0; j < M; j++){
      cin >> A.at(i).at(j);
    }
  }
  
  int minC = 10000000; //理解度を十分満たす最小の合計金額　十分大きい数字にしておく
  
  //bit全探索
  
  for(int bit = 0; bit < (1 << N); bit++){
    //試行回数bit回目
    vector<int>AL(M); //アルゴリズムの理解度を入れる配列．M種類
    int sum = 0; //合計金額を入れる
    for(int i = 0; i < N; i++){
      if(bit & (1 << i)){ //i番目のフラグが立っていたら，つまりi番目の本を買ったら
        sum += C.at(i); //金額を加算;
        for(int j = 0; j <M ;j++){
          AL.at(j) += A.at(i).at(j); //理解度を増やす
        }
      }
    }
    //ここまでにループで，どの本を買って金額がいくらになり，理解度がどれだけ増えたかわかっている
    bool flag = 0;
    for(int i =0; i < M; i++){
      if(AL.at(i) < X)flag = 1;
    }
    if(!flag)minC = min(minC,sum); //条件を満たしかつ最小の金額ならば更新する
  }
  if(minC == 10000000) cout << -1 <<endl;
  else cout << minC << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

typedef vector<int> vi;

int N;
vector<int> a(100010), b(100010);
vector<vi> G(100010);           // G[i] := 点iと隣接している点の集合
vector<vi> dist(2, vi(100010)); // dist[c][i] := 色c(1：黒，0：白)のスタート地点から点iまでの距離

void bfs(int color, int start)
{
  REP(i, N)
  dist[color][i] = -1;
  dist[color][start] = 0;
  queue<int> que;
  que.push(start);
  while (que.size())
  {
    int p = que.front();
    que.pop();
    REP(i, G[p].size())
    {
      int q = G[p][i];
      if (dist[color][q] == -1)
      {
        que.push(q);
        dist[color][q] = dist[color][p] + 1;
      }
    }
  }
}

int main()
{
  cin >> N;
  REP(i, N - 1)
  {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  bfs(1, 0);
  bfs(0, N - 1);
  int fennec = 0;
  int snuke = 0;
  REP(i, N)
  {
    if (dist[1][i] <= dist[0][i])
      fennec++;
    else
      snuke++;
  }
  cout << (fennec > snuke ? "Fennec" : "Snuke") << endl;
  return 0;
}


Measured memory_bytes: 7416