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

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

int main() {
    int N, thousand;
    cin >> N;
    thousand = N / 1000;
    if (thousand * 1000 - N == 0) {
        cout << 0 << endl;
    } else {
        cout << (thousand + 1) * 1000 - N << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
int MAX=0;
vector<LL> A;
vector<LL> B;
vector<vector<int>> G;
vector<int> ans;

void dfs(int u, int p) {
	int cMAX = MAX;
	vector<LL>::iterator itr = lower_bound(B.begin(), B.end(), A[u]);
	int pervIndex = itr-B.begin();
	LL prevValue = *itr;
	(*itr) = A[u];
	MAX = max(MAX, pervIndex+1);
	ans[u] = MAX;

	for (int v : G[u]) {
		if (v == p)continue;
		dfs(v, u);
	}
	
	MAX = cMAX;
	(*itr) = prevValue;
}
void solve() {
	int N;
	cin >> N;
	A =vector<LL>(N);
	IN(A);
	G = vector<vector<int>>(N);
	B = vector<LL>(N + 1, LINF);
	ans = vector<int>(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0, -1);
	for (int i = 0; i < N; ++i) {
		cout << ans[i] << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 32500
#include<stdio.h>
#include<string.h>

int main(void){
    char S[264], T[264];
    int j = 0;
    scanf("%s",&S);
    scanf("%s",&T);
    if(strlen(S)+1 == strlen(T)){
        if(strlen(S) == 1){
            if(S[0] == T[0]){
                printf("Yes\n");
            }
            else{
                printf("No\n");
            }
        }
        else{
            for(int i = 0; i < strlen(S); i++){
                if(S[i] != T[i]){
                  j++;  
                }
            }
            if(j == 0){
                printf("Yes\n");
            }
            else{
                printf("No\n");
            }
        }
    }
    else{
        printf("No\n");
    }
    return 0;
}

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

int main() {
    int n, l;
    cin >> n >> l;

    int apple[n];
    int total = 0;
    int ans;
    int min_abs = 100000;
    rep(i, n) {
        apple[i] = l + i;
        total += apple[i];
        if(min_abs > abs(apple[i])) {
            min_abs = abs(apple[i]);
            ans = apple[i];
        }
    }
    cout << total - ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
     
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        Dice[] list = new Dice[n];
        for(int i = 0; i < n; i++) {
            list[i] = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
        }
        for(int i = 0; i < n; i++) {
            for(int j = i+1; j < n; j++) {
                if(solv(list[i],list[j],0)) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
    public static boolean solv(Dice f, Dice dice,int count) {
        if(dice.Top == f.Top && dice.S == f.S && dice.Bottom == f.Bottom && dice.E == f.E && dice.N == f.N && dice.W == f.W) return true;
        if(count == 6) return false;
        Dice tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnN();
        if(solv(f,tmp,count+1)) {
            return true;
        }
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        if(solv(f,tmp,count+1)) {
            return true;
        }
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnE();
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnW();
        if(solv(f,tmp,count+1)) {
            return true;
        }
         
        return false;
    }
     
     
     
}
class Dice {
    int Top; //1
    int Bottom; //6
    int N; //   5
    int S; //   2
    int W; //左 4
    int E; //右 3
    Dice(int a, int b, int c, int d, int e, int f) {
        Top = a;
        S = b;
        E = c;
        W = d;
        N = e;
        Bottom = f;
    }
    public void TurnN() {
        int tmp = Top;
        Top = S;
        S = Bottom;
        Bottom = N;
        N = tmp;
    }
    public void TurnW() {
        int tmp = Top;
        Top = E;
        E = Bottom;
        Bottom = W;
        W = tmp;
    }
    public void TurnE() {
        int tmp = Top;
        Top = W;
        W = Bottom;
        Bottom = E;
        E = tmp;
    }
    public void TurnS() {
        int tmp = Top;
        Top = N;
        N = Bottom;
        Bottom = S;
        S = tmp;
    }
     
}


Measured memory_bytes: 93936
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}

ll mulmod(ll a, ll b, ll mod){ 
    ll res = 0; 
    a = a % mod; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % mod;
        }
        a = (a * 2) % mod; 
        b /= 2; 
    } 
    return res % mod; 
} 

 
int main()
{
	ios_base::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	if((a+b)%2){
	    cout << "IMPOSSIBLE" << endl;
	    return 0;
	}
	else{
	    cout << (a+b)/2 << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
#define inf 1e12+7
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int ans;
    if(s == "SUN") ans = 7; 
    if(s == "MON") ans = 6; 
    if(s == "TUE") ans = 5; 
    if(s == "WED") ans = 4; 
    if(s == "THU") ans = 3; 
    if(s == "FRI") ans = 2; 
    if(s == "SAT") ans = 1; 
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int x; cin>>x;
    if(x==3||x==5||x==7)coutY;
    else coutN;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
	int n,b,f,r,v=0,k,i,j;
	int a[4][3][10]={0};
	/*入力*/
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d%d%d", &b,&f,&r,&v);
		a[b-1][f-1][r-1] += v;
	}

	/*出力*/
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d", a[i][j][k]);
			}printf("\n");
		}
		if(i!=3)printf("####################\n");
	}
return 0;
}


Measured memory_bytes: 2048
import java.util.*;

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

    String s = sc.next();
    String p = sc.next();
    String ans = "No";

    for(int i = 0; i < s.length(); i++){
      if(i + p.length() > s.length()){
        if(p.equals(s.substring(i) + s.substring(0, i + p.length() - s.length()))){
          ans = "Yes";
        }
      } else {
        if(p.equals(s.substring(i, i + p.length()))){
          ans = "Yes";
        }
      }
    }

    System.out.println(ans);
  }
}



Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A;
  cin >> A;
  cout << 180 * (A - 2) << endl;
}

Measured memory_bytes: 3524
n = int(input())
a,b=[],[]

for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)

a=list(reversed(a))
b=list(reversed(b))

OK=0
for i in range(n):
    A=a[i]+OK
    if A<b[i]:
        ok=b[i]-A
    if A==b[i]:
        continue
    else:
        ok=-(-A//b[i])*b[i]-A
    OK+=ok

print(OK)


Measured memory_bytes: 17568
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	int n, a;
	cin >> n >> a;
	cout << (n % 500 <= a ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
long long X,Y,t;	
long long ans;
const long long inf = 1e18;
long long gcd(long long x,long long y)
{
	return !y ? x : gcd(y,x%y);
}
int main()
{
	cin >> X >> Y;
	t = gcd(X,Y);
	if (t==Y) 
	{
		puts("-1");
		return 0;
	}
	Y /= t;
	if (Y == 2) ans = X * 3;else ans = X * 2;
	if(ans>inf) puts("-1");
	else cout << ans<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
int w, h, n;
int x[101], y[101], a[101];
int xmin, xmax, ymin, ymax;
scanf("%d %d %d", &w, &h, &n);
for(int i=1; i<n+1; i++){
	scanf("%d %d %d", &x[i], &y[i], &a[i]);
}
xmin =0;
ymin=0;
xmax=w;
ymax=h;

for(int i=1; i<n+1; i++){
	switch(a[i]){
		case 1:
		if(xmin<=x[i])
		{xmin = x[i];}
		break;
		case 2:
		if(xmax>=x[i])
		{xmax = x[i];}
		break;
		case 3:
		if(ymin<=y[i])
		{ymin = y[i];}
		break;
		case 4:
		if(ymax>=y[i])
		{ymax = y[i];}
		break;
	}
}

if(xmax>xmin && ymax>ymin) printf("%d\n", (xmax-xmin)*(ymax-ymin));
else printf("0\n");
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int>> p(m);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        p[i] = make_tuple(x, y, i);
    }

    sort(all(p));

    int cur = 1;

    vector<string> res(m);

    rep(i, m) {
        if (i > 0 && get<0>(p[i]) != get<0>(p[i-1])) cur = 1;
        string pi = to_string(get<0>(p[i]));
        while (pi.size() < 6) pi = "0" + pi;
        string x = to_string(cur);
        while (x.size() < 6) x = "0" + x;
        cur++;
        res[get<2>(p[i])] = pi + x;
    }

    rep(i, m) cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define N 10010
using namespace std;
int n,m,s;
int a[N],now=1;
int ans[110][110];
int main()
{
	int i,j;
	scanf("%d %d %d",&n,&m,&s);
	for(i=1;i<=s;i++) scanf("%d",&a[i]);
	for(i=1;i<=n;i+=2)
	{
		for(j=1;j<=m;j++)
		{
			if(a[now]==0) now++;
			ans[i][j]=now; a[now]--;
		}
		if(i+1<=n)
			for(j=m;j>=1;j--)
			{
				if(a[now]==0) now++;
				ans[i+1][j]=now; a[now]--;
			}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
			printf("%d ",ans[i][j]);
		puts("");	
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int >visited(n,-1);
    vector<vector<int > >adj(n);
    for(int i=0,a,b;i<m;i++){
        cin>>a>>b;
        adj[a-1].push_back(b-1);
        adj[b-1].push_back(a-1);
    }
    queue<int >q;
    visited[0]=0;
    q.push(0);
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int i=0,v;i<adj[u].size();i++){
            v = adj[u][i];
            if(visited[v]==-1){
                visited[v]=u;
                q.push(v);
            }
        }
    }
    for(int i=1;i<n;i++)if(visited[i]==-1){cout<<"No";return 0;}
    cout<<"Yes\n";
    for(int i=1;i<n;i++)cout<<visited[i]+1<<'\n';
}

Measured memory_bytes: 10140
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, N = MAP()
A, B = [0]*N, [0]*N

for i in range(N):
	A[i], B[i] = MAP()

dp = [[INF]*(H+max(A)+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
	for j in range(H+max(A)+1):
		if j-A[i] >= 0:
			dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]]+B[i])
		else:
			dp[i+1][j] = dp[i][j]

print(min(dp[N][H:]))


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

typedef long long LL;

int n;
map <LL,int> vis;
int a[200005];
LL psa[200005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		psa[i]=psa[i-1]+a[i];
	}
	LL ans=0LL;
	vis[0]=1;
	for(int i=1;i<=n;i++)
	{
		ans+=vis[psa[i]];
//		cout << ans << endl;
		vis[psa[i]]++;
	}
	printf("%lld\n",ans);
	return 0;
}

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

bool judgeOdd(const char c) {
    return (c == 'R') || (c == 'U') || (c == 'D');
}

bool judgeEven(const char c) {
    return (c == 'L') || (c == 'U') || (c == 'D');
}

int main() {
    string S; cin >> S;
    S = ' ' + S;
    bool easy = true;
    for (size_t i = 1; i < S.size(); i++) {
        // 奇数
        if ((i % 2) == 1) {
            if (!judgeOdd(S[i])) {
                easy = false;
                break;
            }
        }
        // 偶数
        else {
            if (!judgeEven(S[i])) {
                easy = false;
                break;
            }
        }
    }

    if (easy) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
using System;

namespace Atc_0026
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());

            var B = int.Parse(Console.ReadLine());

            if (A != 1 && B != 1)
            {
                Console.WriteLine(1);
            }

            if (A != 2 && B != 2)
            {
                Console.WriteLine(2);
            }

            if (A != 3 && B != 3)
            {
                Console.WriteLine(3);
            }
        }
    }
}


Measured memory_bytes: 27372
#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<"\n";
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
// #define find(m,i) (m.find(i)!=m.end())
// #define find(m,i) (m.find(i)==m.end())
#define cYES cout<<"YES\n";
#define cNO cout<<"NO\n";
#define ins insert
#define imax 1000000000000000000
#define imin -1000000000000000000
// #define NP 50000
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
//  IIITA
//SUNEET KUMAR -->  ਸੁਨੀਤ
 
// scanning numbers extremely fast/////////
void fs(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}
// ========================================
int power(int a,int x)
{
        a%=mod;
    int res=1;
    while(x>0)
    {
        if(x&1)
        res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int max(int a,int b)
{
    if(a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
int min(int a,int b)
{
    if(a>b)
    {
        return b;
    }
    else
    {
        return a;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans%mod;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
 
void nhi_degi()
{
    //  int n,x;cin>>n;
   string s;cin>>s;
   if(s=="ABC")
   {
       cout<<"ARC\n";
   }
   else
   {
       cout<<"ABC\n";
   }
}
signed main()
{
    // cases(t)
    // {
        nhi_degi();
    // }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  while (N > 0) {
    N /= K;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ARC58C
import sys

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
k=hoge[1]

d=[]
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
for i in range(0,k):
	d.append(hoge[i])

payment=0
for i in range(0,100000):
	payment=n+i
	for j in range(0,k):
		if(str(d[j]) in str(payment)):
			break
		if(j==k-1):
			print(payment)
			sys.exit()

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

using namespace std;

#define LL           long long
#define ULL          long long unsigned
#define LD           long double
#define ff              first
#define ss              second
#define FOR(i,n)     for(int i=0;i<n;i++)
#define FLR(i,n)     for(LL i=0;i<n;i++)
#define RFOR(i,n)    for(int i=n-1;i>=0;i--)
#define RFLR(i,n)    for(LL i=n-1;i>=0;i--)
#define rep(i,a,b)   for(int i=a;i<=b;i++)
#define repl(i,a,b)  for(LL i=a;i<=b;i++)
#define fast         ios_base::sync_with_stdio(0);cin.tie(0);
#define all(a)       a.begin(),a.end()
#define ABS(x)       ((x)<0?-(x):(x))
#define NL           "\n"
#define pb           push_back
#define mk              make_pair
#define pi           acos(-1.0)
#define prec(n)      fixed << setprecision(n)
#define sq(a)          (a)*(a)
#define asi          cout<<"check"<<" ";
#define all_set(arr,val) memset(arr,val,sizeof(arr))

int main()
{
    fast;
    LL i,j,k,x,sum=0,n,kount=0;
    vector<LL>vec;
    cin>>n;
    FLR(i,3*n){
        cin>>x;
        vec.pb(x);
    }
    sort(all(vec));
    for(i=3*n-2;i>=0;i-=2){
        sum+=vec[i];
        kount++;
        //cout<<vec[i]<<NL;
        if(kount==n)break;
    }
    cout<<sum;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    int a,b; cin>>a>>b;
    if(a>b) swap(a,b);
    if(a==1&&b==2) cout<<3;
    else if(a==1&&b==3) cout<<2;
    else cout<<1;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

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

int main(void){
    ll M=0, A=0, R=0, C=0, H=0;
    ll ans=0;

    int N; cin >> N;
    for(int i=0; i<N; i++){
        string s; cin >> s;
        switch(s[0]){
            case 'M':
                M++; break;
            case 'A':
                A++; break;
            case 'R':
                R++; break;
            case 'C':
                C++; break;
            case 'H':
                H++; break;
            default:
                break;
        }
    }

    ans+=M*A*(R+C+H)+M*R*(C+H)+M*C*H+A*R*(C+H)+A*C*H+R*C*H;
    cout << ans << endl;
}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int main(){
  int H,W,D;
  cin>>H>>W>>D;
  int A[300][300];
  vector<pair<int,int>> p(H*W+1);
  for(int i(0);i<H;i++){
    for(int j(0);j<W;j++){
      cin>>A[i][j];
      p[A[i][j]] = {i+1,j+1};
    }
  }
  ll dist[100000] = {0};
  for(int i(1);i<=D;i++){
    int now = i;
    while(now+D <= H*W){
      int next = now+D;
      int kyori = abs(p[now].first - p[next].first) + abs(p[now].second - p[next].second);
      dist[next] = dist[now] + kyori;
      now = next;
    }
  }
  int Q;
  cin>>Q;
  for(int i(0);i<Q;i++){
    int l,r;
    cin>>l>>r;
    cout << dist[r] - dist[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}


int main() {
	int i, j, k;
	int N, M, K;
	int X;
	cin >> N >> M >> X;
	int maxN = pow(2, N);
	int A[12][13] = { {0} };
	rep(i, 0, N) {
		cin >> A[i][0];
		rep(j, 1, M+1) {
			cin >> A[i][j];
		}
	}
	ll Ans = 100000000;
	rep(i, 0, maxN) {
		j = 1;
		int p = 0;
		int m[13] = { 0 };
		ll cost = 0;
		while (j <= i) {
			if ((i & j) != 0) {
				rep(k, 1, M+1) {
					m[k] += A[p][k];
				}
				cost += A[p][0];
			}
			j *= 2;
			p++;

		}
		bool isClear = true;
		rep(j, 1, M+1) {
			if (m[j] < X) {
				isClear = false;
				break;
			}
		}
		if (!isClear) {
			continue;
		}
		Ans = Min(Ans, cost);
	}
	if (Ans == 100000000) {
		cout << "-1";
		return 0;
	}
	cout << Ans;
	return 0;

}


Measured memory_bytes: 4064
# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    ab = list()
    ans = 0

    for i in range(n):
        ai, bi = map(int, input().split())
        ab.append((ai, bi))

    for aj, bj in sorted(ab, key=lambda x: x[0]):
        if m >= bj:
            ans += aj * bj
            m -= bj
        else:
            ans += aj * m
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18976
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	string s;getline(cin , s);
	string ans;
	for(auto i:s){
		if(islower(i)){
			ans += toupper(i);
		}else{
			ans += tolower(i);
		}
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3232
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
using namespace std;

class Point{
public:
  short a[70],x,y,d;
  Point(short x = 0,short y = 0,short d = 0):x(x),y(y),d(d){}
};

Point maxu(Point,Point);

int main(){
  while(1){
    int i,j,w,h,n[70][70];
    string str;
    Point max;
    Point b[70][70];
    cin >> w >> h;
    if(w == 0 && h == 0) break;

    for(i=0;i<h;i++){
      cin >> str;
      for(j=0;j<w;j++){
	if('0' <= str[j] && str[j] <= '9') n[i][j] = str[j] - '0';
	else n[i][j] = -1;
      }
    }

    for(i=0;i<70;i++){
      max.a[i] = 0;
      for(j=0;j<h;j++){
	for(int k=0;k<w;k++) b[j][k].a[i] = 0;
      }
    }

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(n[i][j] > 0 && b[i][j].d == 0){
	  b[i][j].a[0] = n[i][j];
	  b[i][j].d = 1;
	  max = maxu(max,b[i][j]);
	}

	bool f1 = false,f2 = false;
	Point u,v;
	if(i > 0 && n[i][j] >= 0 && b[i-1][j].d > 0){
	  u = b[i-1][j];
	  f1 = true;
	}
	if(j > 0 && n[i][j] >= 0 && b[i][j-1].d > 0){
	  v = b[i][j-1];
	  f2 = true;
	}
	if(f1 && f2){
	  b[i][j] = maxu(u,v);
	  b[i][j].a[b[i][j].d++] = n[i][j];
	  max = maxu(max,b[i][j]);
	}
	else if(f1){
	  b[i][j] = u;
	  b[i][j].a[b[i][j].d++] = n[i][j];
	  max = maxu(max,b[i][j]);
	}
	else if(f2){
	  b[i][j] = v;
	  b[i][j].a[b[i][j].d++] = n[i][j];
	  max = maxu(max,b[i][j]);
	}
      }
      
    }
    for(i=0;i<max.d;i++) cout << max.a[i];
    cout << endl;
  }
  return 0;
  }

Point maxu(Point a,Point b){
  if(a.d > b.d) return a;
  else if(a.d < b.d) return b;
  else if(a.d == b.d){
    for(int i=0;i<a.d;i++){
      if(a.a[i] > b.a[i]){
	return a;
	break;
      }
      else if(a.a[i] < b.a[i]){
	return b;
	break;
      }
    }
  }
  return a;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n, k;
    cin >> n >> k;
    if (k > (n-1)*(n-2)/2){
        cout << -1 << endl;
    }else{
        vector<pint> vert;
        int now = (n - 1) * (n - 2) / 2 - k;
        REP(i, n - 1)
        {
            vert.eb(make_pair(1, i + 2));
        }
        int st = 2, en = 3;
        while(now > 0){
            vert.eb(make_pair(st, en));
            en++;
            if (en > n){
                st++;
                en = st + 1;
            }
            now--;
        }
        cout << vert.size() << endl;
        for (auto ite = vert.begin(); ite != vert.end(); ++ite)
        {
            cout << ite->FI << " " << ite->SE << endl;
        }
    }
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int r = in.nextInt();

            if (n >= 10) {
                out.println(r);
            } else {
                out.println(r + (100) * (10 - n));
            }


        }

    }
}



Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#include<numeric>
#include<random>
 
using namespace std;

int partition(vector<int>::iterator b, vector<int>::iterator e) {
	int i{ 1 };
	int j{ e - b - 1 };
	int x = *b;
	while (true) {
		while (b[i] <= x && i<j) i++;
		while (b[j] > x) j--;
		if (j <= i) break;
		swap(b[i], b[j]);
	}
	swap(b[0], b[j]);
	return j;
}


int select(vector<int>::iterator b, vector<int>::iterator e,int i) {
	sort(b, e);
	return b[i];
/*
    int mine = *min_element(b, e);
	int maxe = *max_element(b, e);
	if (i == 0||mine== maxe) return mine;
	if (i == e - b - 1) return maxe;
	int j = partition(b, e);
	if (i == j) return b[j];
	if (i < j) return select(b, b + j, i);
	else return select(b + j + 1, e, i - j - 1);
	*/
}




int main() { 
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a;
	int k;
	for (int i = 1; i <= n; i++) {
		cin >> k;
		a.push_back(k - i);
	}
	mt19937 get_rand_mt;
    shuffle( a.begin(), a.end(), get_rand_mt );
	int med = select(a.begin(), a.end(), n / 2);
	long long ans{ 0 };
	for (auto e : a) {
		ans += abs(e - med);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
#define fi first
#define se second
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a.at(i);
    int ans=0;
   for(int i=0;i<n;i++){
       if(i+1<n&&a.at(i)==a.at(i+1))continue;
       if(i+1<n&&a.at(i)<a.at(i+1)){
           while(i+1<n&&a.at(i)<=a.at(i+1))i++;
       }
       else{
           while(i+1<n&&a.at(i)>=a.at(i+1))i++;
       }
       ans++;
   }
cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  ll N;
  cin >> N;
  ll A = 100;
  for(int i=1;i<3766;i++)
  {
    A *= 1.01;
    if(A>=N)
    {
      cout << i <<endl;
      break;
    }
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  ll m = 999;
  string S;
  cin >> S;
  for (ll j=0; j < S.size(); ++j) {
    ll i = stoi(S.substr(j, 3));
    m = min(m, abs(753-i));
  }
  cout << m << endl;
}

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

ans = -float('inf')
current = 0
for i in range(1, n):
    if L[i-1] >= L[i]:
        current += 1
    else:
        ans = max(current, ans)
        current = 0

ans = max(current, ans)
print(ans)



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

struct Day{
	int happiness[3];
};

int vacation(int pos,int N,int prev,int DP[][3],Day days[]){
	if(pos>=N) return 0;
	if(DP[pos][prev]) return DP[pos][prev];
	int ret=0;
	for(int j=0;j<3;j++){
		if(prev==j) continue;
		ret=max(ret,vacation(pos+1,N,j,DP,days)+days[pos].happiness[j]);
	}
	return DP[pos][prev]=ret;
}

int main(){
	int N,ans=0;
	cin>>N;
	int DP[N][3]={};
	Day days[N];
	for(int i=0;i<N;i++){
		for(int j=0;j<3;j++){
			cin>>days[i].happiness[j];
		}
	}
	
	for(int j=0;j<3;j++){
		ans=max(ans,vacation(1,N,j,DP,days)+days[0].happiness[j]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include<cstdio>
#define mod 1000000007
#define MN 2001000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int p[MN+5],inv[MN+5],a1,a2,a3,a4,a5,a6,b1,b2,b3,b4,b5,b6,ans;
inline int C(int n,int m){return 1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
inline int W(int a,int b,int c,int d){return C(c-a+d-b,c-a);}
int Solve(int a,int b,int c,int d)
{
    c+=2;d+=2;int res=1LL*(a4-a3+1)*(b4-b3+1)%mod;
    res=((0LL+res-W(a,b,a4,b4)-W(a,b,a3-1,b3-1)+W(a,b,a3-1,b4)+W(a,b,a4,b3-1))%mod+mod)%mod;
    res=((0LL+res-W(a3,b3,c,d)-W(a4+1,b4+1,c,d)+W(a3,b4+1,c,d)+W(a4+1,b3,c,d))%mod+mod)%mod;
    for(int i=a3;i<=a4;++i)
        res=(res+1LL*W(a,b,i,b3-1)*W(i,b3,c,d)%mod*(b4-b3+a4-i+1))%mod,
        res=(res+1LL*W(a,b,i,b4)*W(i,b4+1,c,d)%mod*(mod-(a4-i)))%mod;
    for(int i=b3;i<=b4;++i)
        res=(res+1LL*W(a,b,a3-1,i)*W(a3,i,c,d)%mod*(a4-a3+b4-i+1))%mod,
        res=(res+1LL*W(a,b,a4,i)*W(a4+1,i,c,d)%mod*(mod-(b4-i)))%mod;
    return res;
}
int main()
{
    inv[0]=inv[1]=p[0]=p[1]=1;
    for(int i=2;i<=MN;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<=MN;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
    a1=read();a2=read();a3=read()+1;a4=read()+1;a5=read();a6=read();
    b1=read();b2=read();b3=read()+1;b4=read()+1;b5=read();b6=read();
    ans=((0LL
          +Solve(a1,b1,a6,b6)-Solve(a1,b1,a5-1,b6)-Solve(a1,b1,a6,b5-1)+Solve(a1,b1,a5-1,b5-1)
          +Solve(a2+1,b2+1,a6,b6)-Solve(a2+1,b2+1,a5-1,b6)-Solve(a2+1,b2+1,a6,b5-1)+Solve(a2+1,b2+1,a5-1,b5-1)
          -Solve(a1,b2+1,a6,b6)+Solve(a1,b2+1,a5-1,b6)+Solve(a1,b2+1,a6,b5-1)-Solve(a1,b2+1,a5-1,b5-1)
          -Solve(a2+1,b1,a6,b6)+Solve(a2+1,b1,a5-1,b6)+Solve(a2+1,b1,a6,b5-1)-Solve(a2+1,b1,a5-1,b5-1)
          )%mod+mod)%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).rbegin(), (v).rend())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define DESC(v) sort((v).rbegin(), (v).rend())
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

ll sumdigit(ll n) {
    ll ret = 0;
    while(n > 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

void solve() {
    ll N;
    cin >> N;
    cout << (N % sumdigit(N) == 0 ? "Yes" : "No") << endl;
}

int main() {
    FIO;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
class dice
{
private:
	int _top, _botom, _front, _back, _right, _left;
public:
	dice(int top, int botom, int front, int back, int right, int left): _top(top), _botom(botom), _front(front), _back(back), _right(right), _left(left) {};
	void roll(char dir)
	{
		int temp;
		switch(dir)
		{
			case 'E':
				temp = _top;
				_top = _left;
				_left = _botom;
				_botom = _right;
				_right = temp;
				break;
			case 'W':
				temp = _top;
				_top = _right;
				_right = _botom;
				_botom = _left;
				_left = temp;
				break;
			case 'S':
				temp = _top;
				_top = _front;
				_front = _botom;
				_botom = _back;
				_back = temp;
				break;
			case 'N':
				temp = _top;
				_top = _back;
				_back = _botom;
				_botom = _front;
				_front = temp;
				break;
			case 'R':
				temp = _front;
				_front = _left;
				_left = _back;
				_back = _right;
				_right = temp;
				break;
			case 'L':
				temp = _front;
				_front = _right;
				_right = _back;
				_back = _left;
				_left = temp;
				break;
		}
	}
	int top()const
	{
		return _top;
	}
	int botom()const
	{
		return _botom;
	}
	int front()const
	{
		return _front;
	}
	int back()const
	{
		return _back;
	}
	int right()const
	{
		return _right;
	}
	int left()const
	{
		return _left;
	}
	bool operator==(dice*&d)const
	{
		return _top == d->top() && _botom == d->botom() && _front == d->front() && _back == d->back() && _right == d->right() && _left == d->left();
	}
};
int main()
{
	dice**d = new dice*[2];
	int top, botom, front, back, right, left;
	std::cin >> top >> back >> right >> left >> front >> botom;
	d[0] = new dice(top, botom, front, back, right, left);
	std::cin >> top >> back >> right >> left >> front >> botom;
	d[1] = new dice(top, botom, front, back, right, left);
	for(int i = 0; i < 2; i++)
	{
		const int top_i = 1, back_i = 2;
		if(top_i == d[i]->botom())
		{
			d[i]->roll('N');
			d[i]->roll('N');
		}
		else if(top_i == d[i]->front())
		{
			d[i]->roll('S');
		}
		else if(top_i == d[i]->back())
		{
			d[i]->roll('N');
		}
		else if(top_i == d[i]->right())
		{
			d[i]->roll('W');
		}
		else if(top_i == d[i]->left())
		{
			d[i]->roll('E');
		}
		if(back_i == d[i]->front())
		{
			d[i]->roll('R');
			d[i]->roll('R');
		}
		else if(back_i == d[i]->right())
		{
			d[i]->roll('R');
		}
		else if(back_i == d[i]->left())
		{
			d[i]->roll('L');
		}
	}
	std::cout << (*d[0] == d[1] ? "Yes" : "No") << std::endl;
	delete d[0];
	delete d[1];
	delete[]d;
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
#define MOD 1000000007
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = 2147493647;
const double pi = acos(-1);
const double EPS = 1e-9;

int main(){
    ll n;
    cin >> n;
    cout << n/2 + (n%2 ? 0 : -1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(){
	ll n, m; cin >> n >> m;
	char arr[n][m];
	for(ll i = 0; i < n; ++i){
		for(ll j = 0; j < m; ++j){
			cin >> arr[i][j];
		}
	}
	for(ll i = 0; i < n; ++i){
		for(ll j = 1; j < m - 1; ++j){
			if(arr[i][j] == '.' && arr[i][j - 1] == '#' && arr[i][j + 1] == '#'){
				cout << "Impossible";
				return 0;
			}
		}
	}
	ll last = 0;
	for(ll i = 0; i < n; ++i){
		for(ll j = 0; j < m; ++j){
			if(arr[i][j] == '#'){
				if(last > j){
					cout << "Impossible";
					return 0;
				}
				last = j;
			}
		}
	}
	cout << "Possible";
    return 0;
}


Measured memory_bytes: 3644
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

count = 0

for i in range(N):
    detect = 0
    A = list(map(int, input().split()))
    for j in range(M):
        detect += A[j] * B[j]
    if detect + C > 0:
        count += 1
print(count)



Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;



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

	ll a,b;
	cin >> a >> b;
	ll ans = 0;
	if(a==b){
		ans = a*2;
	}else{
		ans = max(a,b)*2-1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// Atcoder150 - B
function main(input) {
  var inputs = input.split('\n');
  var n = parseInt(inputs[0], 10);
  var s = inputs[1];

  s += 'X' + 'X';
  var sArr = Array.from(s);

  var counter = 0;
  for (var i = 0; i < sArr.length - 2; i++) {
    if (sArr[i] === 'A') {
      counter += sArr[i + 1] === 'B' && sArr[i + 2] === 'C' ? 1 : 0;
    }
  };
  console.log(counter);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int N;
    string s;
    cin >> N >> s;
    string t = s.substr(N/2);

    if (s == t+t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        if(N<=K){
            System.out.print(N*X);
        }else{
            System.out.print(K*X+Y*(N-K));
        }
    }         
}


Measured memory_bytes: 35832
// https://beta.atcoder.jp/contests/abc078
// status:

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(F F
)");
    stringstream stream(program_input);
#endif
    char X, Y;
    stream >> X >> Y;

    if (X < Y) cout << "<" << endl;
    else if (X > Y) cout << ">" << endl;
    else cout << "=" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()
	as := make([]int, n)
	for i := range as {
		as[i] = getInt() - 1
	}
	bs := getIntSlice(n)
	cs := getIntSlice(n - 1)

	ans := 0
	for i, a := range as {
		ans += bs[a]

		if i > 0 {
			pa := as[i-1]
			if a == pa+1 {
				ans += cs[pa]
			}
		}
	}

	fmt.Println(ans)
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int W = sc.nextInt();
			int H = sc.nextInt();
			if (W == 0 && H == 0) {
				break;
			}
			
			char[][] tile = new char[W][H];
			boolean[][] visited = new boolean[W][H];
			
			int sx = 0;
			int sy = 0;
			for(int i = 0; i < H; i++) {
				String line = sc.next();
				for(int j = 0; j < W; j++) {
					tile[j][i] = line.charAt(j);
					
					if(tile[j][i] == '@') {
						sx = j;
						sy = i;
					}
				}
			}
			LinkedList<XY> queue = new LinkedList<XY>();
			
			// init 
			int count = 0;
			queue.offer(new XY(sx, sy));
			
			while(queue.size() > 0) {
				bfs(W, H, queue, tile, visited);
				count++;
			}
			System.out.println(count);
		}
	}
	
	public static void bfs(int W, int H, LinkedList<XY> queue, char[][] tile, boolean[][] visited) {
		XY current = queue.poll();
		int cx = current.x;
		int cy = current.y;
		
		int[] dx = new int[]{0, 1, 0, -1};
		int[] dy = new int[]{1, 0, -1, 0};
		for(int i = 0; i < dx.length; i++) {
			int x = cx + dx[i];
			int y = cy + dy[i];
			if (x >= 0 && x < W && y >= 0 && y < H && !visited[x][y] && tile[x][y] == '.') {
				queue.offer(new XY(x, y));
				visited[x][y] = true;
			}
		}
	}
}

class XY {
	int x;
	int y;
	XY(int x, int y) { 
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 29104