akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
reqs = [[int(x) for x in input().split()] for _ in range(m)]

for i in range(10**(n-1) if n!=1 else 0, 10**n):
    n = str(i)
    for s,c in reqs:
        if s-1 >= len(n) or n[s-1] != str(c):
            break
    else:
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 3060
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
begin
   Get (A);
   Get (B);
   if A >= 13 then
      Put_Line (Integer'Image (B));
   elsif A >= 6 then
      Put_Line (Integer'Image (B/2));
   else
      Put_Line ("0");
   end if;
end Solve;

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

int main() {
  std::vector<int> ABC(5);
  for(auto &abc: ABC)
    std::cin >> abc;
  
  int min_10 = 10;
  int sum = 0;
  for(auto &abc:ABC){
    int mod = abc%10;
    if(mod > 0 && mod < min_10)
      min_10 = mod;
    sum += ((abc+9)/10)*10;
  }
  if(min_10 != 10)
    sum += min_10 - 10;
  std::cout << sum << std::endl;
  return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }else{
        int a, b; cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}


Measured memory_bytes: 3560
uses
  SysUtils,
  Classes;

var
	i, j, t : Integer;
	atype : array of Integer;
	str : String;
	strlist : TStringList;
begin
	setLength(atype, 3);
	
	readln(str);
	strlist := TStringList.Create;
	try
		strlist.Delimiter := ' ';
		strlist.DelimitedText := str;
		for i := 0 to 2 do
			atype[i] := StrToInt(strlist.Strings[i]);
	finally
		strlist.free;
		end;
		
	for i := 0 to 2 do
		begin
		for j := 2 downto i + 1 do
			begin
				if atype[j - 1] > atype[j] then
					begin
					t := atype[j - 1];
					atype[j - 1] := atype[j];
					atype[j] := t;
					end;
			end;
		end;
		t := atype[2] - atype[0];
		writeLn(t);
end.


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 int n;
	 cin>>n;
	 string s;
	 map<string , int>mp;
	 map<int , int>mp1;
	 mp1[0]=0;
	 for(int i=1;i<=n;i++)
     {
        cin>>s;
        mp[s]=i;
        int a;
        cin>>a;
        mp1[i]=a;
     }
     for(int i=n-1;i>=0;i--)
     {
         mp1[i]=mp1[i]+mp1[i+1];
     }
     string x;
     cin>>x;
     int b=mp[x];
     b++;
     cout<<mp1[b]<<"\n";
     return 0;
}


Measured memory_bytes: 256
n, m = [int(x) for x in input().split()]
values = [list(map(lambda x:int(x), input().split())) for x in range(m)]
max = -1
min = values[0][1]

for (left, right) in values:
    if(right < min):
        min = right
    if(left > max):
        max = left

if(max > min):
    print(0)
else:
    print(min - max + 1)


Measured memory_bytes: 27352
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, A, B;
  cin >> N;
  long ans = 1;
  for(int i = 1; i <= N; i++) {
    ans *= i;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,k=mii()
arr=limii()

b=[10**100]*n
b[0]=0
if n==2:
    print(abs(arr[1]-arr[0]))
    exit()

for i in range(1,n):
    ans=10**100
    for j in range(1,k+1):
        ans = min(ans,b[i-j]+abs(arr[i]-arr[i-j]))
    b[i]= ans

print(b[-1])


Measured memory_bytes: 78900
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}

priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;

int main() {
    int w, b;
    scanf("%d %d", &w, &b);
    if (b >= w) return !printf("unsafe");
    printf("safe");
}

Measured memory_bytes: 3828
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;

int main() {
	int n, q; cin >> n >> q;
	vector<ll> a(n);
	for(int i=0;i<n;i++) cin >> a[i];

	for (int j = 0; j < q; j++) {
		ll x; cin >> x;
		ll res = 0;
		ll sum = 0;
		int right = 0;
		for (int left = 0; left < n; left++) {
			while (right < n && sum + a[right] <= x) {
				sum += a[right];
				right++;
			}
			res += (right - left);
			if (left == right)right++;
			else sum -= a[left];
		}
		cout << res << endl;
	}
}



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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    string str;
    cin >> str;

    if(str.back()-'0' == 2 || str.back()-'0' == 4 || str.back()-'0' == 5 || str.back()-'0' == 7 || str.back()-'0' ==  9) cout << "hon" << endl;
    else if(str.back()-'0' == 0 || str.back()-'0' == 1 || str.back()-'0' == 6 || str.back()-'0' == 8) cout << "pon" << endl;
    else cout << "bon" << endl;

    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
using namespace std;
int ans,n,p[25],c[25],v[25];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	scanf("%d",v+i);
	for(int i=1;i<=n;i++)	scanf("%d",c+i);
	for(int i=1;i<=n;i++)	p[i]=max(p[i-1],p[i-1]+(v[i]-c[i]));
	printf("%d",p[n]);
	return 0;
}

Measured memory_bytes: 128
from collections import Counter
n=int(input())
alist=list(map(int,input().split()))
a1=[]
a2=[]
for i,a in enumerate(alist):
  a2.append(i-a)
  a1.append(i+a)
aa=Counter(a2)
count=0
for k in a1:
  count+=aa.get(k,0)
print(count)

Measured memory_bytes: 50784
import sys
sys.setrecursionlimit(10 ** 9)

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

r = []
u = [False for _ in range(n)]
def dfs(x):
  if u[x]:
    return x
  else:
    u[x] = True
    r.append(x)
    return dfs(a[x]-1)

b = dfs(0)
for i in range(len(r)):
  if b == r[i]:
    break
#print(b,i,r)
if k >= i:
  print(r[i+(k-i)%(len(r)-i)]+1)
else:
  print(r[k]+1)

Measured memory_bytes: 244800
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[10005],b[10005],c[10005],d[10005];
	int i,j;
	scanf("%s",a);
	int n=strlen(a);
	for(i=0,j=n-1;i<n;i++,j--)
	b[j]=a[i];
	for(i=0;i<n;i++)
	{
		if(b[i]!=a[i])
		break; 
	}
	if(i!=n)
	{
		printf("No\n");
	}
	
	else
	{
		for(i=0,j=(n-1)/2-1;i<(n-1)/2;i++,j--)
		c[j]=a[i];
		for(i=0;i<(n-1)/2;i++)
	    {
		    if(c[i]!=a[i])
		    break; 
	    }
	    if(i!=(n-1)/2)
	    {
	    	printf("No\n");
		}
	    
	    else
	    {
	    		for(i=(n+3)/2-1,j=n-1;i<n;i++,j--)
		d[j]=a[i];
		for(i=(n+3)/2-1;i<n;i++)
	    {
		    if(d[i]!=a[i])
		    break; 
	    }
	    if(i!=n)
	    {
	    	printf("No\n");
		}
	    
	    else
	    printf("Yes\n");
		}
	}
} 

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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    
    for ( int i = 0; i < 200; ++i){
        C -= B;
        if ( C <= 0 ){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if ( A <= 0 ){
            cout << "No" << endl;
            break;
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3624
N = int(input())
L = [int(l) for l in input().split()]
ans = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
        if L[i] + L[j] > L[k] and L[k] + L[j] > L[i] and L[i] + L[k] > L[j]:
          ans += 1
          #print(i+1,j+1,k+1)
print(ans)

Measured memory_bytes: 9204
#include <iostream>                                                  
#include <cstdio>                                                    
#include <cctype>                                                    
using namespace std;                                                 
                                                                     
int main() {                                                         
  char ch;                                                           
  while (true) {                                                     
    scanf("%c", &ch);                                                
    if (islower(ch)) {                                               
      ch = toupper(ch);                                              
    } else if (isupper(ch)) {                                        
      ch = tolower(ch);                                              
    }                                                                
    cout << ch << flush;                                             
    if (ch=='\n') {                                                  
      break;                                                         
    }                                                                
  }                                                                  
  return 0;                                                          
}                                                                    
       

Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#define int long long
#define MAX(a,b) ((a) > (b)) ? (a) : (b)
#define MIN(a,b) ((a) < (b)) ? (a) : (b)
using namespace std;

struct tree
{
	int id;
	vector<int> next;

	tree(int id)
	{
		this->id = id;
	}
};

vector<int> v;
vector<tree> t;

signed main()
{
	int n, m;
	cin >> n >> m;

	for (int i = 1; i < n; i++)
	{
		v.push_back(i + 1);
	}
	for (int i = 0; i <= n; i++) //0も作る
	{
		t.push_back(tree(i));
	}

	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		t[a].next.push_back(b);
		t[b].next.push_back(a);
	}

	int cnt = 0;
	do
	{
		bool ok = true;
		int cur = 1;
		for (int i : v)
		{
			vector<int>& next = t[cur].next;
			if (find(next.begin(), next.end(), i) == next.end())
			{
				ok = false;
				break;
			}
			cur = i;
		}
		if (ok)
		{
			cnt++;
		}
	} while (next_permutation(v.begin(), v.end()));

	cout << cnt;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
g=array(N)
N.times do|i|
    g[i]=gets.to_i-1
end

def bfs(g,s,f)
    cost=array(N,-1)
    cost[s]=0
    queue=[]
    queue.push(s)
    until queue==[]
      cur=queue.shift
      next if cost[g[cur]]!=-1
      cost[g[cur]]=cost[cur]+1
      queue.push(g[cur])
    end
    return cost[f]
end
puts bfs(g,0,1)

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

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

  int a, b, c, k; cin >> a >> b >> c >> k;

  while (k && a >= b) {
    --k; b *= 2;
  }
  while (k && b >= c) {
    --k; c *= 2;
  }
  cout << (a < b && b < c ? "Yes" : "No") << endl;
  
  return 0;
}


Measured memory_bytes: 3660
n = int(input())
a = list(map(int, input().split()))

s = sum(a)
b = [a[i] for i in range(n) if i % 2 == 1]
x1 = s - 2 * sum(b)
x = []
x.append(x1)
xi = x1
for i in range(0, n-1, 1):
    #print(a[i])
    xi_1 = 2 * a[i] - xi
    x.append(xi_1)
    #print(xi_1)
    xi = xi_1
    
print(" ".join(map(str, x)))

Measured memory_bytes: 19912
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  int H, W, D; cin >> H >> W >> D;
  vector<P> v(H * W + 1);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
     int A; cin >> A;
      v[A] = {i, j};
    }
  }
  vector<int> dp(H * W + 1, 0);
  auto f = [](P p1, P p2) { return abs(p2.first - p1.first) + abs(p2.second - p1.second); };
  for (int i = 1; i <= H * W - D; i++) dp[i + D] = dp[i] + f(v[i], v[i + D]);
  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    int L, R; cin >> L >> R;
    cout << dp[R] - dp[L] << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;

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

        int A = scanner.nextInt();
        int B = scanner.nextInt();

        
        int max = Math.max(A, B);
        
        if(A == B){
            System.out.println(max * 2);
        }else {
            System.out.println(max * 2 - 1);
        }

    }
}


Measured memory_bytes: 20564
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ld long double
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define mp map<long, long>
#define um unordered_map<long, long>
#define st set<long> 
#define us unordered_set<long>
#define vt vector<long>
#define fl(i, x, y) for(long i=x;i<y;++i)
#define flr(i, x, y) for(long i=x;i>=y;--i)

int main()
{
    char c;
cin>>c;
cout<<(char)(c+1)<<endl;
	return 0;
}


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

int K;
int ans[555][555];

void print(int n) {
    printf("%d\n", n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            printf("%d ", ans[i][j] + 1);
        }
        printf("\n");
    }
}

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

    if(K == 1) {
        printf("1\n1");
        return 0;
    }

    int n = (K + 3) / 4 * 2;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i % 2) ans[i][j] = (i + j) % n;
            else ans[i][j] = n + (i + j) % n;
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(ans[i][j] >= K) {
                ans[i][j] -= n;
            }
        }
    }
    print(n);
}


Measured memory_bytes: 2304
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
const double pi=acos(-1.0);
double n;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    scanf("%lf",&n);
    n=2.0*pi*n;
    printf("%.20f",n);
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N;
    cin >> N;
    int sum = 0;
    rep(i, N) {
        sum += (1 + i);
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
from fractions import gcd
from functools import reduce

n,m,*alst = list(map(int,read().split()))
mm=2*m
def lcm(x,y):
  g=gcd(x,y)
  if x//g %2==0 or y//g%2==0:
    return 0
  g=x*y//g
  if g>mm:
    return 0
  return g
f=lambda x,y:0 if x==0 else lcm(x,y)
g=reduce(f,alst)
if g==0:
  print(0)
  quit()
else:
  res=(mm//g)
  print(res//2+res%2)


Measured memory_bytes: 14532
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, D, X; cin >> N >> D >> X;
    vector<int> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    int ans = X;
    for(int i = 0; i < N; i++)
    {
        ans += (D-1)/A.at(i) + 1;
    }
    cout << ans << endl;
}

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

using namespace std;

bool solve() {
  int n, m;
  cin >> n >> m;
  if (n == 0 && m == 0) {
    return false;
  }
  vector<vector<int>> p(m, vector<int>(n));
  for (auto &i : p) {
    for (int &j : i) {
      cin >> j;
    }
  }
  int result = 0;
  for (int i = 0; i < n; ++i) {
    int s = 0;
    for (int j = 0; j < m; ++j) {
      s += p[j][i];
    }
    if (result < s) {
      result = s;
    }
  }
  cout << result << endl;
  return true;
}

int main() {
  while (solve()) {
  }
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 3e5 + 5;

int n, ans;
LL d, x, y;

int main() {
	cin>>n>>d;
	rep(i, 1, n) {
		cin>>x>>y;
		if(x*x + y*y <= d*d) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;

int main()
{
	string w;
	cin >> w;
	vector<int> alp(26);
	for (int i = 0; i < 26; i++)
	{
		alp[i] = 0;
	}
	for (int i = 0; i < w.length(); i++)
	{
		alp[w[i] - 'a']++;
	}
	bool bre = false;
	for (int i = 0; i < 26; i++)
	{
		if (alp[i] % 2 == 1)
		{
			bre = true;
			break;
		}
	}
	if (bre)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
  int n;
  cin >> n;
  cout << (n-2)*180 << endl;
}

Measured memory_bytes: 256
# heapqの方針で上手くいかなかった
# 解説放送を見てimosにした

def main():
    from collections import namedtuple
    from heapq import heappop, heappush
    import sys
    input = sys.stdin.readline

    Prog = namedtuple('Prog', 'L R')
    Prog.__eq__ = lambda self, other: self.R == other.R
    Prog.__lt__ = lambda self, other: self.R < other.R

    N, C = map(int, input().split())
    ps = tuple([] for _ in range(30))
    for _ in range(N):
        l, r, ch = map(int, input().split())
        heappush(ps[ch - 1], Prog(l, r))

    imos = [0] * (10 ** 5 + 1)
    for ps_ch in ps:
        while ps_ch:
            l, r = heappop(ps_ch)
            while ps_ch and ps_ch[0].L == r:
                r = ps_ch[0].R
                heappop(ps_ch)
            else:
                imos[l - 1] += 1
                imos[r] -= 1

    for i in range(10 ** 5):
        imos[i + 1] += imos[i]

    print(max(imos))


if __name__ == '__main__':
    main()


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

int main(){
    int n,m,l;
    cin>>n>>m>>l;
    
    long long a[100][100]={{}};
    long long b[100][100]={{}};
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>a[i][j];
        }
    }
    for(int i=0; i<m; i++){
        for(int j=0; j<l; j++){
            cin>>b[i][j];
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            long long o=0;
            for(int k=0; k<m; k++){
                o+=a[i][k]*b[k][j];
            }
            if(j==0)cout<<o;
            else cout<<' '<<o;
        }
        cout<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    string s; cin >> s;
    int gx, gy; cin >> gx >> gy;
    vector<int> x, y = {0};

    int pos = 0;
    char now = 'x'; int count = 0;
    while (pos < s.size()) {
        if (s[pos] == 'F') {
            count++;
        } else {
            if (now == 'x') {
                x.push_back(count);
                now = 'y'; count = 0;
            } else {
                y.push_back(count);
                now = 'x'; count = 0;
            }
        }
        pos++;
    }
    if (count > 0) {
        if (now == 'x') {
            x.push_back(count);
        } else {
            y.push_back(count);
        }
    }

    int ZERO = 8010, ABS_MAX = 2*ZERO;
    vector<vector<bool>> dp_x(s.size(), vector<bool>(ABS_MAX, false)),
            dp_y(s.size(), vector<bool>(ABS_MAX, false));
    dp_x[0][ZERO + x[0]] = true;
    dp_y[0][ZERO + y[0]] = true;
    for (int i = 1; i < x.size(); i++) {
        for (int j = 0; j < ABS_MAX; j++) {
            if (dp_x[i - 1][j] == true) {
                dp_x[i][j - x[i]] = true;
                dp_x[i][j + x[i]] = true;
            }
        }
    }
    for (int i = 1; i < y.size(); i++) {
        for (int j = 0; j < ABS_MAX; j++) {
            if (dp_y[i - 1][j] == true) {
                dp_y[i][j - y[i]] = true;
                dp_y[i][j + y[i]] = true;
            }
        }
    }

    if (dp_x[x.size() - 1][ZERO + gx] == true and dp_y[y.size() - 1][ZERO + gy] == true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 32512
<?php   
    fscanf(STDIN,"%d",$k);
    fscanf(STDIN,"%s",$n);
	//explode(" ",trim(fgets(STDIN));
	
if($k<strlen($n)){
 $re = substr($n,0,$k);
  $re .= "...";
  echo $re."\n";
}else{
  echo $n."\n";
}
  

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

using namespace std;
#define REP(i, n) for(int i=0; i < (int)(n); ++i)
#define REPR(i, n) for(int i=n; i>= 0; --i)
#define FOR(i, m, n) for(int i=m; i<(n); ++i)

#define ll long long

int main(){
    string S;
    cin >> S;
    int cnt = 0;
    char before = 'D';
    REP(i, S.size()){
        if(S[i] != before){
            cnt++;
            before=S[i];
        }
    }
    cout << cnt-1 << endl;
    return 0;
}

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

int main(){
	string Imput;
	getline(cin, Imput);
	string Output = Imput;

	for(int i = 0; i < Imput.size(); i++){
	   if('a' <= Imput[i] && Imput[i] <= 'z') Output[i] += 'A' - 'a';
	   if('A' <= Imput[i] && Imput[i] <= 'Z') Output[i] += 'a' - 'A';
	}

	cout << Output << endl;
//	system("pause");
	return 0;
}

Measured memory_bytes: 1180
from collections import deque
n = int(input())
e = [[] for i in range(n)]
num = 0

for i in range(n-1):
    a,b = map(int,input().split())

    e[a-1].append([b-1,i])
    e[b-1].append([a-1,i])
    num = max(num,len(e[a-1]),len(e[b-1]))

ans = [-1]*(n-1)

q = deque([])
q.append((0,-1))

while q:
    bef,pn = q.popleft()
    c = 0
    for nex in e[bef]:
        if ans[nex[1]] == -1:
            c += 1
            if c == pn:
                c += 1
            ans[nex[1]] = c
            q.append((nex[0],c))

print(num)        
for i in ans:
    print(i)

Measured memory_bytes: 46404
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    *t++;
    while(t != V.end()) {
        cout << " " << *t++;
        // if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int n = 0;

void maxHeapify(vector<int> &A, int i) {
    int largest;
    int l = i * 2;
    int r = i * 2 + 1;
    if(l <= n) {
        largest = (A[l] > A[i]) ? l : i;
        if(r <= n) {
            if(A[r] > A[largest]) largest = r;
        }

        if(largest != i) {
            swap(A[i], A[largest]);
            maxHeapify(A, largest);
        }
    } else {
        largest = i;
    }
}
void buildMaxHeap(vector<int> &A) {
    for(int i = n / 2; i >= 1; i--)
        maxHeapify(A, i);
}

void insertHeap(vector<int> &A, int k) {
    A[++n] = k;
    int i = n;
    while(i > 1 && A[i / 2] < A[i]) {
        swap(A[i / 2], A[i]);
        i /= 2;
    }
}

void extractHeap(vector<int> &A) {
    cout << A.at(1) << endl;
    A.at(1) = A.at(n--);
    maxHeapify(A, 1);
}

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

    int k;
    string s;
    vector<int> Heap(2000000);
    while(1) {
        cin >> s;
        if(s == "insert") {
            cin >> k;
            insertHeap(Heap, k);
        } else if(s == "extract") {
            extractHeap(Heap);
        } else {
            break;
        }
    }
}



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

int main() {
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
}


Measured memory_bytes: 256
//Date:
#include<iostream>
#include<cstdio>
using namespace std;
inline int read(){
	register int x;register char c(getchar());register bool k;
	//while((c<'0'||c>'9')&&c^'-')if((c=getchar())==EOF)exit(0);
	if(c^'-')x=c-'0',k=1;else x=0,k=0;
	for(c=getchar();c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+c-'0';
	return k?x:((~x)+1);
}
long long n;
long long num=0;
long long sum=0;
long long sums=0;
long long a[200200];
long long ans=0;
int main(){
	cin>>n;
	a[0]=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if((sum^a[i])!=(sums+a[i])){
			while((sum^a[i])!=(sums+a[i])){
				sum^=a[i-num];
				sums-=a[i-num];
				ans+=num;
				num--;
			}
		}
		num++,sum=(sum^a[i]),sums=(sums+a[i]);
	}
	ans+=(num+1)*num/2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5116
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
//const int SIZE=;
const double EPS=1e-6;

int main(){
	/*main function start*/
	long long n,k;
	long long ans=0;
	scanf("%lld%lld",&n,&k);
	if(k%2){
		long long r=n/k;
		ans=r*r*r;
	}
	else if((k/2)%2){
		long long r=n/(k/2);
		long long ro=r/2;
		long long rj=r-ro;
		ans=ro*ro*ro+rj*rj*rj;
	}
	else{
		long long sb=n/k;
		long long r_=n/(k/2);
		long long r=r_-r_/2;
		ans=r*r*r+sb*sb*sb;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
//CODE FESTIVAL 2017 qualB C
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;


vector<vector<int>> v(110000);
int color[110000];
long long B, W;

bool isBipartile() {
  queue<int> q;
  color[1] = 1;
  B++;
  q.push(1);
  while (! q.empty()) {
    int tmp = q.front(); q.pop();
    for (int vt : v[tmp]) {
      if (color[vt] == 0) {
        color[vt] = -color[tmp];
        if (color[vt] == 1) B++;
        else W++;
        q.push(vt);
      } else if(color[vt] == color[tmp]) {
        return false;
      }
    }
  }
  return true;
}

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

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    v[A].push_back(B);
    v[B].push_back(A);
  }

  if (! isBipartile()) cout << (N * (N - 1) / 2 - M) << endl;
  else cout << (B * W - M) << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
int N;
cin >> N;

vector<int>A(N);
for(int i=0;i<N-1;i++){
int t;
cin >> t;
A[t]++;
}

for(int i=0;i<N-1;i++){
cout << A[i+1] << endl;
}
cout << 0 << endl;

return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,t[200],a[200],b[200],c[200];
  cin>>d>>n;
  for(int i=0;i<d;i++)cin>>t[i];
  for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
  int dp[201][101];
  for(int i=0;i<201;i++)
    for(int j=0;j<101;j++)
      dp[i][j]=-1;
  for(int i=0;i<n;i++)
    if(a[i]<=t[0]&&t[0]<=b[i])dp[0][c[i]]=0;
      
  
  for(int i=0;i<d-1;i++){
    for(int j=0;j<101;j++){
      if(dp[i][j]==-1)continue;
      for(int k=0;k<n;k++)
	if(a[k]<=t[i+1]&&t[i+1]<=b[k]){
	  dp[i+1][c[k]]=max(dp[i+1][c[k]],dp[i][j]+abs(j-c[k]));
	  // cout<<i<<" "<<j<<endl;
	}
    }
  }
  int ans=0;
  for(int i=0;i<101;i++)ans=max(ans,dp[d-1][i]);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3156
N = int(input())
S = list(int(i) for i in input().split())  
dict = {}
count = 0

for i in range(N):
    if S[i] not in dict:
        dict[S[i]] = 1
    else:
        dict[S[i]] += 1

for key, value in dict.items():
    if key < value:
        count += (value-key)
    elif key > value:
        count += value

print(count)

Measured memory_bytes: 18168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, y = 0, count = 0, a = 0;
  cin >> N;
  
  for (int i = 0; ; i++) {
    
    int j = 0, x = 10;
    while (j < i) {
      x *= 10;
      j++;
    } 
    
    if (N == count % x)
      break;
    
    a = ( N % x - count ) / (x / 10);  
    
    y += a;
    count += a * (x / 10);
    
  }
  
  if (N % y == 0)
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

int main() {
    int N;
    cin >> N;
    vector<ld> v(N);
    rep(i, N) { cin >> v[i]; }

    sort(all(v));
    ld ans = (v[0] + v[1]) / 2;
    for (int i = 2; i < N; i++) {
        ans = (ans + v[i]) / 2;
    }

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		//		new Main().solveB2();
		//		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			if (numA > 16 / 2 || numB > 16 / 2) {
				System.out.println(":(");
				return;
			}

			System.out.println("Yay!");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numD = 0;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numD = scanner.nextInt();
			numN = scanner.nextInt();
			if (numN == 100) {
				numN++;
			}
			switch (numD) {
			case 0:
				System.out.println(numN);
				break;
			case 1:
				System.out.println(numN * 100);
				break;
			case 2:
				System.out.println(numN * 10000);
				break;
			default:
				break;
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int getFunc(int x) {
		int res = 0;
		while (x % 100 == 0) {
			x = x / 100;
			res++;
		}
		return res;
	}

	private int getFuncSaiki(int x) {
		if (x % 100 != 0) {
			return 0;
		}
		return getFuncSaiki(x / 100) + 1;
	}

	private void solveB2() {
		Scanner scanner = null;
		int numD = 0;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numD = scanner.nextInt();
			numN = scanner.nextInt();

			int count = 0;
			int val = 0;

			while (count != numN) {
				val++;
				if (getFunc(val) == numD) {
					count++;
				}
			}
			System.out.println(val);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private long dpSolveC(long[] wk) {
		int cnt = 0;
		for (int i = 0; i < wk.length; i++) {
			long wkNum = wk[i];
			while (wkNum % 2 == 0) {
				wkNum /= 2;
				cnt++;
			}
		}
		return cnt;

	}

	/**
	 * a[i]の操作終了条件は「2で割れなくなったとき」
	 * a[i]を3倍しても「2で割る事の出来る回数は増えない」
	 * そのため、a[i]を2で割れる回数の総計が操作可能回数。
	 */
	private void solveC() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			long[] wk = new long[numN];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextLong();
			}

			System.out.println(dpSolveC(wk));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 25172
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000
void merge(int [],int,int,int);
void mergeSort(int [],int,int);

int cnt,n;
int L[MAX/2+2],R[MAX/2+2];

int main()
{
  int S[MAX],i;
  cnt=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergeSort(S,0,n);
  for(i=0;i<n;i++){
    if(i!=0) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n%d\n",cnt);
  
  return 0;
}
  
void merge(int S[], int left, int mid,int right){
  int i,j,k;
  
  int n1 = mid - left;
  int n2 = right - mid;
  //L[0...n1], R[0...n2] を生成
  for(i=0;i<n1;i++) L[i] = S[left + i];
  for(i=0;i<n2;i++) R[i] = S[mid + i];
  L[n1]=R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      S[k]=L[i++];
    }
    else{
      S[k]=R[j++];
    }
  }
}

void mergeSort(int *S, int left, int right){
  int mid,i;
  if(left+1<right){
    mid=(left + right)/2;
    mergeSort(S, left, mid);
    mergeSort(S, mid, right);
    merge(S, left, mid, right);
  }
}



Measured memory_bytes: 5704
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,M;cin>>N>>M;
  vector<long>A(N);for(long i=0;i<N;i++)cin>>A[i];
  //vector<long>C(M,0);//割った余りがiである回数
  unordered_map<long,long>C;
  long s=0;//累積和%M
  long ans=0;
  for(long i=0;i<N;i++){
    s=(s+A[i])%M;
    //r=iで条件を満たす組は, 
    //それより左で累積和がM-sになるもの
    //s[r] -s[l-1] %M==0 ; 余りが等しい回数
    ans+=C[s];
    C[s]++;if(s==0)ans++;
  }
  cout<<ans;
}



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



signed main(){
    int a,b,c;
    cin >> a >>b >>c;
    if(c<=a+b+1)cout << c+b;
    else{
    cout << a+b+1+b;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

typedef std::pair<long, long> P;

long n, m;
std::set<long> edge[100005];//second:erased
bool visited[100005];
std::set<P> erased;

void del(long a, long b){
    erased.insert(P(a, b));
    erased.insert(P(b, a));
}

long er_cnt(long a, long b){
    return erased.count(P(a, b)) + erased.count(P(b, a));
}

void dfs(long par, long vis){
    visited[vis] = true;
    for(auto it = edge[vis].begin(); it != edge[vis].end(); it++){
        if(er_cnt(vis, *it) == 0 && !visited[*it]){//visitedならerasedなのでは?
            dfs(vis, *it);
        }
    }
    long cnt = 0;
    //printf("  %ld %ld\n", par, vis);
    for(auto it = edge[vis].begin(); it != edge[vis].end(); it++){
        if(*it != par && er_cnt(vis, *it) == 0){
            cnt++;
            printf("%ld %ld\n", vis, *it);
            del(vis, *it);
        }
    }
    if(cnt % 2){
        printf("%ld %ld\n", vis, par);
        del(vis, par);
    }
}

int main(){
    scanf("%ld%ld", &n, &m);
    for(int i = 0; i < m; i++){
        long a, b;
        scanf("%ld%ld", &a, &b);
        edge[a].insert(b);
        edge[b].insert(a);
    }
    if(m % 2){
        printf("-1\n");
        return 0;
    }
    dfs(1, 1);
    return 0;
}


Measured memory_bytes: 32768
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var A = parts[0];
var B = parts[1];
var C = parts[2];
var satisfy: boolean = A.charAt(A.length - 1) == B.charAt(0) && B.charAt(B.length - 1) == C.charAt(0);
console.log(satisfy ? "YES" : "NO");

Measured memory_bytes: 7372
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    ll N ;
    cin >> N ;

    map<ll , ll> hyou ;
    for(ll j = 0 ; j < N  ; j++ ){
        hyou[j] = 0 ;
    }
    ll a[N-1] ;
    for(ll i = 0 ; i < N -1 ; i++){
        cin >> a[i] ;
        if(a[i] != 0){
            hyou[a[i]-1]++ ;
        }
    }
    
    for(ll j = 0 ; j < N ; j++){
        cout << hyou[j] << endl;
    }
    

    

    return 0 ;
}

 


Measured memory_bytes: 17700
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    int sum1=0,sum2=0,n1=n,n2=n;
    while(n1>0){
        n1-=a;
        sum1+=b;
    }
    while(n2>0){
        n2-=c;
        sum2+=d;
    }
    cout<<min(sum1,sum2)<<endl;
}


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

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

    int r, g, b, n, ans = 0;
    cin >> r >> g >> b >> n;

    for (int i = 0; i * r <= n; i++)
        for (int j = 0; j * g + i * r <= n; j++) {
            int left = n - i * r - j * g;
            ans += (left % b == 0);
        }
    cout << ans << '\n';
}


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

int main(){

	long long int n;
	cin>>n;
	long long int h[n+1];
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	long long int dp[n+1];
	dp[1]=0;
	dp[0]=0;
	dp[2] = abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]) , dp[i-1]+ abs(h[i]-h[i-1])); 
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1792
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;
inline void add(int&x,const int&y){x+=y;if(x>=mod)x-=mod;}

char s[300111];
int n,dp[300111][3][2][3];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);s[++n]='1';
	dp[1][0][0][0]=1;
	for(int i=1;i<=n;i++)for(int v=0;v<3;v++)for(int p=0;p<2;p++)for(int cur=0;cur<3;cur++)
	{
		if(s[i]!='1')add(dp[i+1][v==0?1:3-v][p][cur],dp[i][v][p][cur]);
		if(s[i]!='0')
		{
			if(v==1)add(dp[i+1][0][p][cur],dp[i][v][p][cur]);
			else
			{
				int nc=cur;
				if(cur==0&&v==0&&!p)nc=1;
				else if(cur==1&&v==0&&p)nc=2;
				add(dp[i+1][0][p^1][nc],dp[i][v][p][cur]);
			}
		}
	}
	printf("%d\n",(dp[n+1][0][0][2]+dp[n+1][0][1][2])%mod);
	return 0;
}

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

using ll = long long;
template <class T>
using V = vector<T>;

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)

int main(){
    int N;
    cin >> N;
    V<int> A(N);
    rep(i, N) cin >> A.at(i);
    V<ll> rui(N);
    const ll m = 1000000007;
    rui.at(N - 1) = A.at(N - 1);
    per(i, N - 1) rui.at(i) = (rui.at(i+1) + A.at(i)) % m;
    ll sum = 0;
    rep(i, N-1){
        sum += A.at(i) * rui.at(i+1) % m;
        sum %= m;
    }
    cout << sum << endl;
}

Measured memory_bytes: 5628