akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    set<int> st;
    map<int, int> mp;
    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        st.insert(a);
        mp[a]++;

    }

    vector<int> v;
    for(auto it = st.begin(); it != st.end(); ++it) {
        v.pb(mp[*it]);

    }
    sort(all(v));

    LL res = 0;
    for(int i = 0; i < int(v.size()) - k; ++i) {
        res += v[i];

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



Measured memory_bytes: 20216
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int arr['z'+1]={0};
    int len=s.size();
    for (int i=0;i<len;i++){
        arr[s[i]]+=1;
    }
    for(int i='a';i<='z';i++){
        if (arr[i]==0){
            printf("%c",i);
            return 0;
        }
    }
    printf("None");
}

Measured memory_bytes: 512
#include <stdio.h>
#include <cassert>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
#include <iomanip>
 
#ifdef LOCAL_CODE
	#define DEBUG(x) cerr << "[" << #x << '=' << x << "]" << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int i = (N)-1; i >= 0; i--)
#define REP(i, N) for(int i = 0; i < (int)(N); i++)
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.first >> p.second; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.first << ' ' << p.second; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

void solve(istream& cin, ostream& cout) {
	int n;
	cin >>n;
	vector<pair<int,int>> V(n);
	cin>>V;
	sort(ALL(V));
	if(n % 2 == 1) {
		int medAtLeast = V[n/2].first;
		sort(ALL(V), [](pair<int,int> A, pair<int,int> B) {
			return mp(A.second,A.first) > mp(B.second, B.first);
		});
		int medAtMost = V[n/2].second;
		cout << medAtMost-medAtLeast+1 <<endl;
	} else {
		ll medAtLeast1 = V[(n-1)/2].first, medAtLeast2 = V[n/2].first;
		sort(ALL(V), [](pair<int,int> A, pair<int,int> B) {
			return mp(A.second,A.first) > mp(B.second, B.first);
		});
		ll medAtMost1 = V[(n-1)/2].second, medAtMost2 = V[n/2].second;
		cout << (medAtMost2+medAtMost1-medAtLeast1-medAtLeast2+1) << endl;
	}
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const ll mod=1000000007;
int main()
{
    int h,w;
    cin>>h>>w;
    char a[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    ll s[h][w];
    s[h-1][w-1]=1;
    for(int i=h-2;i>=0;i--){
        if(a[i][w-1]=='#'){s[i][w-1]=0;}
        else{
            s[i][w-1]=s[i+1][w-1];
        }
    }
    for(int i=w-2;i>=0;i--){
        if(a[h-1][i]=='#'){s[h-1][i]=0;}
        else{
            s[h-1][i]=s[h-1][i+1];
        }
    }
    for(int i=h-2;i>=0;i--){
        for(int j=w-2;j>=0;j--){
            if(a[i][j]=='#'){s[i][j]=0;}
            else{
                s[i][j]=(s[i][j+1]+s[i+1][j])%mod;
            }
        }
    }
    cout<<(s[0][0])%mod;
}


Measured memory_bytes: 9088
<?php

$_cache = array();

while($line = trim(fgets(STDIN))) {
	list($m, $n) = explode(' ', $line);
	$count = 0;
	for ($i = $m; $i <= $n; $i++) {
		if (isHamming($i)) {
			$count++;
		}
	}
	echo $count . "\n";
}

function isHamming($i) {
	global $_cache;
	if (isset($_cache[$i])) {
		return $_cache[$i];
	}
	if ($i < 1) {
		return false;
	}
	if ($i == 0) {
		return true;
	}
	$num = $i;
	while ($num > 1) {
		if ($num % 2 == 0) {
			$num /= 2;
			continue;
		}
		if ($num % 3 == 0) {
			$num /= 3;
			continue;
		}
		if ($num % 5 == 0) {
			$num /= 5;
			continue;
		}
		// ここにきたらNG
		$_cache[$i] = false;
		return false;
	}
	$_cache[$i] = true;
	return true;
}

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

int main(){
    int d, m;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26));
    vector<int> t(d);
    for(auto &&n : c) cin >> n;
    for(auto &&n1 : s) for(auto &&n2 : n1) cin >> n2;

    vector<int> l(26);
    vector<double> v(26);
    
    rep(i, d){
        rep(j, 26){
            v[j] = s[i][j] / 10;
            v[j] /= c[j];
        }
        m = 0;
        for(int j=1; j<26; ++j) if(v[j] > v[m]) m = j;
        cout(m+1);

        l[m] = 0;

    }
}


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

long long X, Y, A, B, C;

int main(){
	cin >> X >> Y >> A >> B >> C;

	priority_queue<long long, vector<long long>, greater<long long> > RED;
	priority_queue<long long, vector<long long>, greater<long long> > GREEN;
	priority_queue<long long> NO;

	for(long long i = 0; i < A; i++) {
		long long tmp;
		cin >> tmp;
		RED.push(tmp);
	}

	for(long long i = 0; i < B; i++) {
		long long tmp;
		cin >> tmp;
		GREEN.push(tmp);
	}

	for(long long i = 0; i < C; i++) {
		long long tmp;
		cin >> tmp;
		NO.push(tmp);
	}

	while(RED.size() > X) {
		RED.pop();
	}

	while(GREEN.size() > Y) {
		GREEN.pop();
	}

	while(!NO.empty()) {
		if(RED.top() < GREEN.top()) {
			//REDに変更
			if(RED.top() < NO.top()) {
				RED.pop();
				RED.push(NO.top());
				NO.pop();
			} else {
				break;
			}
		} else {
			//GREENに変更
			if(GREEN.top() < NO.top()) {
				GREEN.pop();
				GREEN.push(NO.top());
				NO.pop();
			} else {
				break;
			}
		}
	}

	long long ans = 0;
	while(!RED.empty()) {
		ans += RED.top();
		RED.pop();
	}

	while(!GREEN.empty()) {
		ans += GREEN.top();
		GREEN.pop();
	}
	cout << ans << endl;



}



Measured memory_bytes: 6432
#include<bits/stdc++.h>
using namespace std;
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;
}
int main(){
    string s;
	cin>>s;
	int n = s.length();
    for(int i=0;i<n;i++){
      cout<<"x";
    }
	return 0;
}

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

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

enum Tenki
{
    Sunny,
    Cloudy,
    Rainy
};

int main()
{
    ll n, m;
    cin >> n >> m;
    cout << ((n % 3 == 0 || m % 3 == 0 || (n + m) % 3 == 0) ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main() {

	
	
	char s[11];
	int i, k, n;

	scanf("%d",&n);
	scanf("%s", s);
	scanf("%d", &k);

	for (i = 0; i < n; i++) {
		if (s[k - 1] != s[i])
			s[i] = '*';

	}
	printf("%s", s);
	return 0;

}

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

using namespace std;

int memo[100][100][2][2];

int w, h;

int rec(int i, int j, int vec, int f)
{
	if ((i < 0 || i >= w) || (j < 0 || j >= h)) return 0;

	if (i == w - 1 && j == h - 1) return 1;

	if (memo[i][j][vec][f] >= 0) return memo[i][j][vec][f];

	int res;

	if (vec == 0) {
		if (f) {
			res = rec(i + 1, j, 0, 0);
		} else {
			res = rec(i + 1, j, 0, 0) + rec(i, j + 1, 1, 1);
		}
	} else {
		if (f) {
			res = rec(i, j + 1, 1, 0);
		} else {
			res = rec(i + 1, j, 0, 1) + rec(i, j + 1, 1, 0);
		}
	}

	return memo[i][j][vec][f] = res % 100000;
}

int main()
{
	while (cin >> w >> h, w || h) {
		memset(memo, -1, sizeof(memo));

		cout << (rec(1, 0, 0, 0) + rec(0, 1, 1, 0)) % 100000 << endl;
	}
}

Measured memory_bytes: 1336
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
//#define REP(i,n)  for(int i =0;i<n;++i)
#define mod (ll)(1e9+7)
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N = 0;
    string s1,s2;
    cin >> N >> s1 >> s2;
    int x = 0;
    ll ans =0;
    int pre = 0;
    if(s1[0]==s2[0]){
        ans = 3;
        x = 1;
    }else{
        ans = 6;
        x = 2;
        pre = 1;
    }
    while(x<N){
        if(s1[x]==s2[x]){
            if(pre==0){
                ans *= 2;
            }
            pre=0;
            x+=1;
        }else{
            if(pre==0){
                ans *= 2;
            }else{
                ans *= 3;
            }
            pre=1;
            x+=2;
        }
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll x;
  cin >> x;
  ll v = 100;
  ll ans = 0;
  while(v<x){
    v *= 1.01;
    ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
    if V[i]-C[i]>0:
        ans += V[i]-C[i]
print(ans)


Measured memory_bytes: 5044
#include <stdio.h>

int main(void)
{
  long n, k;
  scanf("%ld %ld", &n, &k);
  
  long mod = n;
  while (mod / k > 0)
  {
    mod = mod % k;
  }
  
  if (-1 * (mod - k) < mod)
  {
    mod = -1 * (mod - k);
    printf("%ld", mod);
    return 0;
  }
  printf("%ld", mod);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    String str1 = null;
    String str2 = null;
    int x = 0;

    for(int i = 0;i < n;i++) {
      s[i] = sc.next();
    }

    for(int i = 0;i < n-1;i++) {

      for(int j = i+1;j < n;j++) {
        if(s[i].equals(s[j])) {
          x = 1;
          break;
        }
      }

      str1 = s[i].substring(s[i].length()-1,s[i].length());
      str2 = s[i+1].substring(0,1);

      if(str1.compareTo(str2) != 0) {
        x = 1;
      }

      if(x == 1) break;

    }

    if(x == 1) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }

}


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

// #include<iostream>
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) 
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) 
#define forrc(i,l,r) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

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


#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)


#define present(c,x) ((c).find(x) != (c).end())


#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())


 using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;
int main(){
  int n;
  cin >> n;
  int h[n];
  for0(i,n){
    cin >> h[i];
  }
  int dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0])+dp[0];
  forc(i,2,n-1){
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  }
  cout << dp[n-1];
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# coding: utf-8

# In[18]:


import math


# In[23]:


A,B = map(int, input().split())


# In[24]:


# #nの約数を全て求める
# def divisor(n): 
#     i = 1
#     table = []
#     while i * i <= n:
#         if n%i == 0:
#             table.append(i)
#             table.append(n//i)
#         i += 1
#     table = list(set(table))
#     return table


# In[29]:


# def func():
#     mylist = []
#     tmp = 1
#     if A<=B:
#         for x in divisor(A):
#             if B%x==0 and math.gcd(tmp,x)==1:
#                 mylist.append(x)
#                 tmp *= x
#     else:
#         for x in divisor(B):
#             if A%x==0 and math.gcd(tmp,x)==1:
#                 mylist.append(x)
#                 tmp *= x
# #     print(mylist)
#     print(len(mylist))
# if __name__=="__main__":
#     func()


# In[30]:


gcd=math.gcd(A,B)
m = gcd
pf = {}
for i in range(2, int(m**0.5)+1):
    while m % i == 0:
        pf[i] = pf.get(i, 0)+1
        m //= i
if m > 1:
    pf[m] = 1
print(len(pf)+1)


# In[ ]:






Measured memory_bytes: 9440
package main

import (
	"fmt"
)

func main() {
	var S []byte
	fmt.Scan(&S)
	ans := BArr{
		init: S,
		head: make([]byte, 0, 100000),
		tail: make([]byte, 0, 100000),
	}

	var Q int
	fmt.Scan(&Q)

	for i := 0; i < Q; i++ {
		var T int
		fmt.Scan(&T)
		switch T {
		case 1:
			ans.swap = !ans.swap
		case 2:
			var F int
			fmt.Scan(&F)
			var C []byte
			fmt.Scan(&C)
			switch F {
			case 1:
				if ans.swap {
					ans.addTail(C)
				} else {
					ans.addHead(C)
				}
			case 2:
				if ans.swap {
					ans.addHead(C)
				} else {
					ans.addTail(C)
				}
			default:
				panic("invalid")
			}
		default:
			panic("invalid")
		}
	}
	fmt.Println(ans.string())
}

type BArr struct {
	init []byte
	head []byte
	tail []byte
	swap bool
}

func (b *BArr) addHead(a []byte) {
	b.head = append(b.head, a...)
}

func (b *BArr) addTail(a []byte) {
	b.tail = append(b.tail, a...)
}

func (b *BArr) string() string {
	if b.swap {
		swap(b.init)
		swap(b.tail)
		return string(b.tail) + string(b.init) + string(b.head)
	}
	swap(b.head)
	return string(b.head) + string(b.init) + string(b.tail)
}

func swap(arr []byte) {
	for i := 0; i < len(arr)/2; i++ {
		arr[i], arr[len(arr)-1-i] = arr[len(arr)-1-i], arr[i]
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++)
    cin >> d.at(i);
  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++)
      ans += d.at(i)*d.at(j);
  }
  cout << ans << endl;  
}

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

using namespace std;

int main() {
	long long n; cin >> n;
	long long a,b; cin >> a >> b;
	n%=12;
	for(int i=0;i<n;++i) {
		if(i&1) b=a+b;
		else a=a-b;
	}
	cout << a << " " << b << endl;
	
	return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int n;
// initiating from dfs("",'a');
void dfs(string s, char ch)
{
	if (s.size() == n)
	 {
		cout << s << en;
	}
	else
	{
		for (char c = 'a'; c <= ch; c++)
		{
			if (c == ch)
			{
				dfs(s + c, ch + 1);
			}
			else
			{
				dfs(s + c, ch);
			}
		}
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	cin >> n;
	dfs("", 'a');




	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long ll;

ll d;
ll c[29];
ll a[369][29];
ll t[369];
ll b[29];

int main()
{
    scanf("%lld", &d);
    srand(time(NULL));
    for(ll i = 1; i <= 26; i++)
    {
        scanf("%lld", &c[i]);
    }
    for(ll i = 1; i <= d; i++)
    {
        for(ll j = 1; j <= 26; j++)
        {
            scanf("%lld", &a[i][j]);
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= d; i++)
    {
        ll mx = -4e18, mi = 0;
        for(ll ii = 1; ii <= 26; ii++)
        {
            t[i] = ii;
            ll ans2 = 0;
            ll tt = b[t[i]];
            b[t[i]] = d;
            for(ll j = 1; j <= 26; j++)
            {
                ans2 -= (d - b[j]) * c[j];
            }
            ans2 += a[i][t[i]];
            if(mx < ans2) mx = ans2, mi = ii;
            b[t[i]] = tt;
        }
        t[i] = mi;
        b[t[i]] = d;
        for(ll j = 1; j <= 26; j++)
        {
            ans -= (d - b[j]) * c[j];
        }
        ans += a[i][t[i]];
    }
    ll loop = 10000;
    while(loop--)
    {
        ll x = rand() % d;
        ll y = rand() % 26 + 1;
        ll z = t[x];
        t[x] = y;
        ll ans2 = 0;
        for(ll i = 1; i <= d; i++)
        {
            ll mx = -4e18, mi = 0;
            ll tt = b[t[i]];
            b[t[i]] = d;
            for(ll j = 1; j <= 26; j++)
            {
                ans2 -= (d - b[j]) * c[j];
            }
            ans2 += a[i][t[i]];
        }
        if(ans2 > ans) {ans = ans2; continue;}
        else t[x] = z;
    }
    for(ll i = 1; i <= d; i++)
    {
        printf("%lld\n", t[i]);
    }
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            long N = long.Parse(s[0]);
            long K = long.Parse(s[1]);
            long[] A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).OrderByDescending(x => x).ToArray();
            int len = Convert.ToString(Math.Max(K, A[0]), 2).Length;
            string Kstr = Convert.ToString(K, 2).PadLeft(len, '0');
            string[] Astr = A.Select(x => Convert.ToString(x, 2).PadLeft(len, '0')).ToArray();
            long[] nums = new long[len];
            foreach (string a in Astr)
            {
                for (int i = 0; i < len; i++)
                {
                    if (a[i] == '0') { nums[i]++; }
                }
            }
            long res = 0;
            for (int i = 0; i < len; i++)
            {
                long restemp = 0;
                long temp = 1;
                
                if (Kstr[i] == '1')
                {
                    for (int j = len - 1; j > i; j--)
                    {
                        if (N - nums[j] < nums[j]) { restemp += temp * nums[j]; }
                        else { restemp += temp * (N - nums[j]); }
                        temp *= 2;
                    }
                    restemp += temp * (N - nums[i]);
                    temp *= 2;
                    for (int j = i - 1; j >= 0; j--)
                    {
                        if (Kstr[j] == '0') { restemp += temp * (N - nums[j]); }
                        else { restemp += temp * nums[j]; }
                        temp *= 2;
                    }
                }
                else
                {
                    for (int j = len - 1; j >= 0; j--)
                    {
                        if (Kstr[j] == '0') { restemp += temp * (N - nums[j]); }
                        else { restemp += temp * nums[j]; }
                        temp *= 2;
                    }
                }
                
                res = Math.Max(restemp, res);
            }
            Console.WriteLine("{0}", res);
        }
    }
}

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

using namespace std;

typedef long long ll;

const ll M = 1000000007;
ll n, m;
ll a;
ll b[100005];
ll fac[100005];
ll inv[100005];

ll pow(ll p, ll q)
{
    ll re = 1;
    for(; q; q >>= 1, p = p * p % M)
    {
        if(q & 1) re *= p, re %= M;
    }
    return re;
}

ll f(ll p, ll q)
{
    if(p < q) return 0;
    return fac[p] * inv[q] % M * inv[p - q] % M;
}

int main()
{
    scanf("%lld", &n);
    fac[0] = 1;
    for(ll i = 1; i <= n + 1; i++)
    {
        scanf("%d", &a);
        if(b[a] == 0)b[a] = i;
        else m = n - i + b[a];
        fac[i] = fac[i - 1] * i % M;
    }
    inv[n + 1] = pow(fac[n + 1], M - 2);
    for(ll i = n; i >= 0; i--)
    {
        inv[i] = inv[i + 1] * (i + 1) % M;
    }
    for(ll i = 1; i <= n + 1; i++)
    {
        printf("%lld\n", (f(n + 1, i) % M - f(m, i - 1) % M + M) % M);
    }
    return 0;
}


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

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

	int h, w;
	cin >> h >> w;

	int n;
	cin >> n;

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

	int res[h][w];
	int x = 0, y = 0;
	for(int i=0; i<n; ++i) {
		while(a[i]--) {
			res[x][y] = i+1;

			if(x % 2 == 0) {
				if(y == w-1) ++x;
				else ++y;
			}
			else {
				if(y == 0) ++x;
				else --y;
			}
		}
	}

	for(int i=0; i<h; ++i) {
		for(int j=0; j<w; ++j) {
			if(j) cout << " ";
			cout << res[i][j];
		} cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int d = a + b;
    int e = a + c;
    int f = b + c;

    cout << min(min(d, e), f);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;

int main(){
	int n, cnt, ans;
	scanf("%d", &n);
	int p[n];
	rep(i, n) scanf("%d", &p[i]);
	int i = 0;
	while (i < n){
		while (p[i] == i + 1){
			cnt++;
			i++;
		}
		if(cnt % 2 == 1) cnt = cnt / 2 + 1;
		else cnt /= 2;
		ans += cnt;
		cnt = 0;
		i++;
	}
	printf("%d", ans);
	return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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 ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

template<class T, int ME> class BIT {
	public:
	T bit[1<<ME],val[1<<ME];
	T total(int e) {T s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	T add(int e,T v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
	T set(int e,T v) { add(e,v-val[e]);}
	int lb(T v) {
		T tv=0; int i,ent=0;
		for(i=ME-1;i>=0;i--) if(tv+bit[ent+(1<<i)-1]<v) tv+=bit[ent+(1<<i)-1],ent+=(1<<i);
		return ent;
	}
};

int n, m, res;
vpii a;
BIT<int,20> b;

signed main() {
	cin >> n >> m;
	a.resize(m);
	rep(i,m) cin >> a[i].fi >> a[i].se;
	sort(rall(a));
	rep(i,m) if (b.total(a[i].se-1)-b.total(a[i].fi-1)==0) res++, b.add(a[i].fi,1);
	cout << res << ln;
}

Measured memory_bytes: 5504
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author lucasr
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ECoprime solver = new ECoprime();
		solver.solve(1, in, out);
		out.close();
	}

	static class ECoprime {
		static final int MAX = 1000001;

		public void solve(int testNumber, MyScanner sc, PrintWriter out) {
			int N = sc.nextInt();
			int[] vals = sc.nextIntArray(N);
			int[] smallerPrime = new int[MAX], next = new int[MAX];
			for (int i = 2; i < MAX; i++) {
				if (smallerPrime[i] == 0) {
					for (int j = 2 * i; j < MAX; j += i)
						if (smallerPrime[j] == 0) {
							smallerPrime[j] = i;
						}
				} else {
					int tmp = i;
					while (tmp % smallerPrime[i] == 0) {
						tmp /= smallerPrime[i];
					}
					next[i] = tmp;
				}
			}
			int[] count = new int[MAX];
			for (int i = 0; i < N; i++) {
				int cur = vals[i];
				while (smallerPrime[cur] != 0) {
					count[smallerPrime[cur]]++;
					cur = next[cur];
				}
				if (cur > 1) {
					count[cur]++;
				}
			}
			boolean pairwise = true;
			for (int i = 2; i < MAX; i++) {
				if (count[i] > 1) pairwise = false;
			}
			if (pairwise) {
				out.println("pairwise coprime");
				return;
			}
			long gcd = 0;
			for (int i = 0; i < N; i++) {
				gcd = MathLib.gcd(gcd, vals[i]);
			}
			out.println(gcd == 1 ? "setwise coprime" : "not coprime");
		}

	}

	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;

		public MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		}

	}

	static class MathLib {
		public static long gcd(long a, long b) {
			a = Math.abs(a);
			b = Math.abs(b);
			while (b != 0) {
				long tmp = b;
				b = a % b;
				a = tmp;
			}
			return a;
		}

	}
}



Measured memory_bytes: 68448
def d_FT_Robot(s, x, y):
    x_start = 0  # 最初の1回でどれだけ右に動いたか(ロボットは最初に右を向いているので、特別扱いする)
    f_count = 0  # Fが出てきた回数
    movex = []  # x軸方向に何度動くか(初回を除く)
    movey = []  # y軸方向に何度動くか
    is_directed_x = True  # x軸方向を向いてるか
    is_appeared_t = False  # 注目している文字の前にTが1度でも現れたか
    for c in s:
        if c == "F":
            f_count += 1
            continue
        elif c == 'T':
            if f_count > 0:
                if is_directed_x:
                    if is_appeared_t:
                        movex.append(f_count)
                    else:
                        # 最初にTが現れるまでに出てきたFの数によって
                        # 進んだところのx座標は、必ず到達できる
                        # そのためのちにdp_x[0][x_start]=Trueとする
                        x_start = f_count
                else:
                    movey.append(f_count)
        is_appeared_t = True
        is_directed_x = not is_directed_x
        f_count = 0
    # 最後にTが出たあとsの中にTが出ないままsの末尾にくるときのため
    if f_count > 0:
        if is_directed_x:
            if is_appeared_t:
                movex.append(f_count)
            else:
                x_start = f_count
        else:
            movey.append(f_count)

    # DPでいくが、リストだとうまくいかないので辞書型を使う
    # dp[i]には、i回目の移動で到達できる座標が辞書型で格納される
    dp_x = [{} for _ in range(len(movex) + 1)]
    dp_y = [{} for _ in range(len(movey) + 1)]
    dp_x[0][x_start] = True
    dp_y[0][0] = True

    # 座標dp_*[i]から到達できる座標の一覧をdp_*[i+1]に格納
    for i, dx in enumerate(movex):
        for j in dp_x[i]:
            dp_x[i + 1][j - dx] = True
            dp_x[i + 1][j + dx] = True
    for i, dy in enumerate(movey):
        for j in dp_y[i]:
            dp_y[i + 1][j - dy] = True
            dp_y[i + 1][j + dy] = True

    # 末尾の要素にゴール座標がなかった場合、ゴールには到達できないということ
    if x not in dp_x[len(movex)]:
        return 'No'
    if y not in dp_y[len(movey)]:
        return 'No'
    return 'Yes'
  
s = input()
x,y = [int(_) for _ in input().split()]
print(d_FT_Robot(s, x, y))

Measured memory_bytes: 324640
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

std::vector<size_t> make_vector(size_t n, size_t x) {
  return std::vector<size_t>(n, x);
}

template <class Tp>
std::vector<Tp> make_vector(size_t n, const Tp& x) {
  return std::vector<Tp>(n, x);
}

template <class... Ts>
auto make_vector(size_t n, size_t m, const Ts&... x) {
  return std::vector<decltype(make_vector(m, x...))>(n, make_vector(m, x...));
}

double rec(std::vector<std::vector<std::vector<double>>>& dp,
           size_t N, size_t x, size_t y, size_t z) {

  if (dp[x][y][z] >= 0.0) return dp[x][y][z];

  dp[x][y][z] = 0.0;
  if (z == N) return 0.0;

  double n = N;
  double e = n / (n-z);

  if (N > x) dp[x][y][z] += (rec(dp, N, x+1, y, z) + e) * (n-x) / (n-z);
  if (x > y) dp[x][y][z] += (rec(dp, N, x, y+1, z) + e) * (x-y) / (n-z);
  if (y > z) dp[x][y][z] += (rec(dp, N, x, y, z+1) + e) * (y-z) / (n-z);

  return dp[x][y][z];
}

int main() {
  size_t N;
  scanf("%zu", &N);

  size_t x = 0;
  size_t y = 0;
  for (size_t i = 0; i < N; ++i) {
    int a;
    scanf("%d", &a);
    if (a <= 2) ++x;
    if (a <= 1) ++y;
  }

  auto dp = make_vector(N+1, N+1, N+1, -1.0);
  dp[N][N][N] = 0;
  printf("%.12f\n", rec(dp, N, x, y, 0));
}


Measured memory_bytes: 216960
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 100000

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int A, B;
int main(int argc, char **argv) {
    cin >> A >> B;
    int res = 0;
    int plug = 1;
    for(res = 0; plug < B; ++res) {
        plug += A - 1;
    }


    cout << res << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    ans = set()
    for _ in range(N):
        A = int(input().strip())
        if A in ans:
            ans.remove(A)
        else:
            ans.add(A)

    return len(ans)


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


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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  for(int i = 1; i <= 10000000; ++i) {
    if(int(i * 0.08) == a && int(i * 0.1) == b) {
      cout << i << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}


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

taste =[]

for i in range(n):
    taste.append(l + i)

sum = 0

for i in range(n):
    sum += taste[i]

sa = 1000
ans = 0
for i in range(n):
    if sa > abs(sum - (sum - taste[i])):
        sa = abs(sum - (sum - taste[i]))
        ans = i

print(sum - taste[ans])

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

int main(){
	int H, W, i, j, k, ans = 0;
	scanf("%d%d", &H, &W);
	int **c = (int **)malloc(sizeof(int *) * 10);
	for(i = 0; i <= 9; i++){
		c[i] = (int *)malloc(sizeof(int) * 10);
		for(j = 0; j <= 9; j++){
			scanf("%d", &c[i][j]);
		}
	}
	int **A = (int **)malloc(sizeof(int *) * H);
	for(i = 0; i < H; i++){
		A[i] = (int *)malloc(sizeof(int) * W);
		for(j = 0; j < W; j++){
			scanf("%d", &A[i][j]);
		}
	}
	for(k = 0; k <= 9; k++){
		for(i = 0; i <= 9; i++){
			for(j = 0; j <= 9; j++){
				if(c[i][k] + c[k][j] < c[i][j]){
					c[i][j] = c[i][k] + c[k][j];
				}
			}
		}
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			if(A[i][j] >= 0){
				ans += c[A[i][j]][1];
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
P za[3005];
int main()
{
    srand((unsigned int)time(NULL));
    while(1)
    {
        int n;
        scanf("%d",&n); if(!n) return 0;
        static bool in[5005][5005]={};
        for(int i=1;i<=n;i++)
        {
            scanf("%d %d",&za[i].f,&za[i].s);
            in[za[i].f][za[i].s]=true;
        }
        int ret=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=n;j++)
            {
                int xa=za[i].f;
                int xb=za[j].f;
                int ya=za[i].s;
                int yb=za[j].s;
                if(xa+xb-yb+ya<0||ya+yb+xb-xa<0||xa+xb+yb-ya<0||ya+yb-xb+xa<0) continue;
                if(xa+xb-yb+ya>10000||ya+yb+xb-xa>10000||xa+xb+yb-ya>10000||ya+yb-xb+xa>10000) continue;
                if(in[(xa+xb-yb+ya)/2][(ya+yb+xb-xa)/2] && in[(xa+xb+yb-ya)/2][(ya+yb-xb+xa)/2]) ret=max(ret,(xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
            }
        }
        printf("%d\n",ret/2);
    }
}

Measured memory_bytes: 25068
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * A New Plan of Aizu Ski Resort
 * PCK2009 ??????9
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int x, y;
			x = parseInt(line.substring(0, line.indexOf(' ')));
			y = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((x | y) == 0) break;

			int[][] course = new int[y + 4][x + 2];
			int[][] dp = new int[y + 4][x + 2];

			for (int i = 0; i < y; i++) {
				words = br.readLine().split(" ");
				for (int j = 0; j < words.length; j++) {
					course[i + 2][j + 1] = parseInt(words[j]);
				}
			}

			//
			for (int i = 1; i < x + 1; i++) {
				if (course[2][i] == 0) dp[2][i] = 1;
			}

			for (int i = 2; i < y + 2; i++) {
				for (int j = 1; j < x + 1; j++) {
					switch (course[i][j]) {
						case 0:
							if (course[i - 1][j - 1] == 0) {
								dp[i][j] += dp[i - 1][j - 1];
							}
							if (course[i - 1][j] == 0) {
								dp[i][j] += dp[i - 1][j];
							}
							if (course[i - 1][j + 1] == 0) {
								dp[i][j] += dp[i - 1][j + 1];
							}
							if (course[i - 2][j] == 2) {
								dp[i][j] += dp[i - 2][j];
							}
							break;
						case 1:
							break;
						case 2:
							if (course[i - 1][j] == 0) {
								dp[i][j] += dp[i - 1][j];
							}
							if (course[i - 2][j] == 2) {
								dp[i][j] += dp[i - 2][j];
							}
							break;
					}
				}
			}
			for (int i = y + 2; i < y + 4; i++) {
				for (int j = 1; j < x + 1; j++) {
					if (course[i - 1][j] == 0) {
						dp[i][j] += dp[i - 1][j];
					}
					if (course[i - 2][j] == 2) {
						dp[i][j] += dp[i - 2][j];
					}
				}
			}

			//
			int sum = 0;
			for (int i = 1; i < x + 1; i++) sum += dp[y + 3][i];
			System.out.println(sum);
		}//end while
	}//end main
}

Measured memory_bytes: 24696
#include <iostream>

using namespace std;

int main() {
    string S, Z;
    cin >> S >> Z;
    bool flag=true;
    for(int i=0; i<S.size(); i++) {
        if(S[i]!=Z[i]) {
            flag=false;
            break;
        }
    }
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
    
}

Measured memory_bytes: 3624
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	s := strconv.Itoa(a) + "" + strconv.Itoa(b)
	x, _ := strconv.Atoi(s)
	for i := 0; i < 10000; i++ {
		if x == i * i {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

// -------- Library --------
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println("Failed to read int", err)
		os.Exit(1)
	}
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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 int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    ll ans = 0;
    srepn(i,1,n){
        if(1<=i&&i<=9)ans++;
        if(100<=i&&i<=999)ans++;
        if(i>=10000&&i<=99999)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	llong N, M, K;
	cin >> N >> M >> K;
	vector<llong> A(N);
	vector<llong> B(M);
	for(int i=0; i<N; ++i) cin >> A[i];
	for(int i=0; i<M; ++i) cin >> B[i];
	vector<llong> a(N+1);
	vector<llong> b(M+1);
	a[0]=0; b[0]=0;
	for(int i=0; i<N; ++i) a[i+1] = a[i]+A[i];
	for(int i=0; i<M; ++i) b[i+1] = b[i]+B[i];
	llong ans = 0;
	llong j = M;
	for(int i=0; i<N+1; ++i){
		if(a[i] > K) break;
		while(b[j]>K-a[i]){
			j -= 1;
		}
		ans = max(ans, i+j);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL inf = 2123456789;
LL N, M, R, res, ans;
std::vector<std::vector<LL>>dist;

void warshall_floyd(LL V)
{
	for (LL k = 1; k <= V; ++k)
	{
		for (LL i = 1; i <= V; ++i)
		{
			for (LL j = 1; j <= V; ++j)
			{
				dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
}

int main()
{
	in >> N >> M >> R;
	std::vector<LL>r(R), A(M), B(M), C(M);
	dist.resize(N + 1);
	rep(i, dist.size()) dist[i].resize(N + 1);
	rep(i, N) rep(j, N) dist[i + 1][j + 1] = (i == j ? 0 : inf);
	rep(i, R) in >> r[i];
	rep(i, M)
	{
		in >> A[i] >> B[i] >> C[i];
		dist[A[i]][B[i]] = dist[B[i]][A[i]] = C[i];
	}
	warshall_floyd(N);
	ans = inf;
	std::sort(r.begin(), r.end());
	do
	{
		res = 0;
		rep(i, R - 1) res += dist[r[i]][r[i + 1]];
		ans = std::min(ans, res);
	} while (std::next_permutation(r.begin(), r.end()));
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){
    int n,k,a[1000000],top,sum;
    while(1){
        scanf("%d%d",&n,&k);
        if(n==0)return 0;
        sum=0;
        for(int i=0;i<k;i++){
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        top=sum;
        for(int i=k;i<n;i++){
            scanf("%d",&a[i]);
            sum+=a[i];
            sum-=a[i-k];
            if(sum>top)top=sum;
        }
        printf("%d\n",top);
    }
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
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;
}

ll dp[101][4][3];
ll info[101];
const int MOD = 10000;

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

    rep(i, K)
    {
        ll day, kind;
        cin >> day >> kind;
        info[day] = kind;
    }

    if (info[1])
        dp[1][info[1]][1] = 1;
    else
    {
        rep(i, 3) dp[1][i + 1][1] = 1;
    }

    repd(i, 2, N + 1)
    {
        if (info[i])
        {
            repd(j, 1, 4)
            {
                if (info[i] == j)
                    dp[i][info[i]][2] += dp[i - 1][j][1] % MOD;
                else
                {
                    repd(k, 1, 3)
                    {
                        dp[i][info[i]][1] += dp[i - 1][j][k] % MOD;
                    }
                }
            }
        }
        else
        {
            repd(j, 1, 4)
            {
                repd(k, 1, 4)
                {
                    if (j == k)
                    {
                        dp[i][j][2] += dp[i - 1][k][1] % MOD;
                    }
                    else
                    {
                        repd(l, 1, 3)
                        {
                            dp[i][j][1] += dp[i - 1][k][l] % MOD;
                        }
                    }
                }
            }
        }
    }

    ll ans = 0;
    repd(i, 1, 4)
    {
        ans += dp[N][i][1] + dp[N][i][2];
    }

    cout << ans % MOD << endl;

    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int K, odd = 0, even = 0;
    cin >> K;
    for (int i = 1; i <= K; ++i) {
        if (i % 2 == 0) {
            ++even;
        } else {
            ++odd;
        }
    }
    cout << (even * odd) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         long X=gl();
         long K=gl();
         long D=gl();

         long px=Math.abs(X);
         long a=Math.min(Math.floorDiv(px, D),K);
         K=K-a;

         long ans=0;
         if (K%2==0) {
        	 ans=px-a*D;
         } else {
        	 ans=px-a*D;
        	 ans=Math.abs(ans-D);
         }

         System.out.println(ans);
     }

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

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

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

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

Measured memory_bytes: 35540