akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std; typedef long long  ll;
#define all(a) a.begin() , a.end()
#define print(x)   cout<<x<<"\n";
const ll M = ll(1e9 + 7);
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]\n"; return os;}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{os << "["; for (auto it : v) {os << it; if (it != *v.rbegin())os << ", ";} os << "]\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{for (auto it : v)os << it.first << " : " << it.second << "\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{os << "("; os << v.first << ", " << v.second << ")"; return os;}
/***********************************************************************/
ll dp[105][100005];
const ll inf = ll(1e15);
int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll n, w;
    cin >> n >> w;
    vector<ll> value, weight;
    ll maxx = 0;
    for (ll i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        weight.push_back(x);
        value.push_back(y);
        maxx += y;
    }
    for (ll i = 0; i < 105; i++)
    {
        for (ll j = 1; j < 100005; j++)
        {
            dp[i][j] = inf;
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= maxx; j++)
        {
            if (value[i - 1] > j)
            {
                dp[i][j] = dp[i - 1][j];
            }
            else
            {
                dp[i][j] = min(weight[i - 1] + dp[i - 1][j - value[i - 1]], dp[i - 1][j]);
            }
            if (dp[i][j] <= w)
                ans = max(ans, j);
        }
    }
    cout << ans;
}

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

bool check(string s);

int main() {
    double l, ans;
    cin >> l;
    ans = pow(l / 3, 3);
    cout << fixed << setprecision(10) << ans << endl;
}

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

#define M INT_MAX
#define F first
#define S second
typedef pair<int,int> P;

int c[5000],r[5000]; //i番目のタクシーの運賃　i番目のタクシーの進める数
vector<int> rin1[5000]; //隣接行列       r
vector<int> rin2[5000]; //new隣接行列    c
int flg[5000][5000];
int i,j;
int n,k; //町の数　道路の本数
priority_queue<P,vector<P>,greater<P> > que; //ダイクストラ法
int a,b; //町 Aj と町 Bj との間に道路が存在する
int q;
int leng[5000];

int func(int,int);

int main(void)
{
	clock_t start, end;
	
	
	//入力,初期化
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>c[i]>>r[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++) flg[i][j]=0;
	}
	for(i=0;i<n;i++) flg[i][i]=1;
	for(i=0;i<k;i++){
		cin>>a>>b;
		a-=1; b-=1;
		//隣接行列 作成
		rin1[a].push_back(b),rin1[b].push_back(a);
		rin2[a].push_back(b),rin2[b].push_back(a);
		flg[a][b]=1,flg[b][a]=1;
	}
	
	
	//現在日時を取得
	start=clock();
	
	//隣接行列　確認
	/*cout<<"rin1"<<endl;
	for(i=0;i<n;i++){
		for(j=0;j<rin1[i].size();j++) cout<<rin1[i][j]+1<<" ";
		cout<<endl;
	}
	cout<<endl;*/
	
	//new隣接行列 作成
	for(i=0;i<n;i++){
		for(j=0;j<rin1[i].size();j++){
			//cout<<"j="<<j<<"r[i]-1="<<r[i]-1<<endl;
			func(rin1[i][j],r[i]-1);  //もとから一つは繋がっている
		}
	}
	
	//new隣接行列　確認
	/*cout<<"rin2"<<endl;
	for(i=0;i<n;i++){
		for(j=0;j<rin2[i].size();j++) cout<<rin2[i][j]+1<<" ";
		cout<<endl;
	}
	cout<<endl;*/
	
	//ダイクストラ法
	for(i=0;i<n;i++) leng[i]=M;
	leng[0]=0;
	que.push(P(0,0)); //数値　現在地
	while(!que.empty()){
	
		/*for(i=0;i<n;i++) cout<<leng[i]<<" ";
		cout<<endl;*/
		
		P q=que.top(); que.pop();
		if(leng[q.S]>q.F) continue;
		for(i=0;i<rin2[q.S].size();i++){
			if(leng[rin2[q.S][i]]>q.F+c[q.S]){
				leng[rin2[q.S][i]]=q.F+c[q.S];
				que.push(P(leng[rin2[q.S][i]],rin2[q.S][i]));
			}
		}
	}

	cout<<leng[n-1]<<endl;
	
	//経過時間を取得
	/*end = clock();
	printf("time=%f\n",(double)(end-start)/CLOCKS_PER_SEC);*/
	
	return 0;
}

//new隣接行列 作成
int func(int w,int x){ //現在地 進める数
	if(x!=0){
		for(int l=0;l<rin1[w].size();l++){
			if(flg[i][rin1[w][l]]==0){
				flg[i][rin1[w][l]]=1;
				rin2[i].push_back(rin1[w][l]);
				func(rin1[w][l],x-1);
			}
		}
	}
}


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

struct complex {
	int re;
	int im;
	bool overflow;
};

bool check(complex &z) {
	return (z.re > 10000 || z.re < -10000 || z.im > 10000 || z.im < -10000);
}

complex operate(const complex &a, const complex &b, char o) {
	complex c;
	if (o == '+') {
		c.re = a.re + b.re;
		c.im = a.im + b.im;
	} else if (o == '-') {
		c.re = a.re - b.re;
		c.im = a.im - b.im;
	} else /* if (0 == '*') */ {
		c.re = a.re*b.re - a.im*b.im;
		c.im = a.re*b.im + a.im*b.re;
	}
	c.overflow = a.overflow || b.overflow ? true : check(c);
	return c;
}

complex expr(string&);
complex term(string&);
complex fctr(string&);

complex expr(string &s) {
	complex a = term(s);
	while (s[0] == '+' || s[0] == '-') {
		char o = s[0];
		s.erase(0, 1);
		complex b = term(s);
		a = operate(a, b, o);
	}
	return a;
}

complex term(string &s) {
	complex a = fctr(s);
	while (s[0] == '*') {
		s.erase(0, 1);
		complex b = fctr(s);
		a = operate(a, b, '*');
	}
	return a;
}

complex fctr(string &s) {
	complex z = {0, 0, false};
	if (s[0] == '(') {
		s.erase(0, 1);
		z = expr(s);
		s.erase(0, 1);
		return z;
	}

	int sign = 1;
	if (s[0] == '+')
		s.erase(0, 1);
	else if (s[0] == '-') {
		s.erase(0, 1);
		sign = -1;
	}

	if (s[0] == 'i') {
		s.erase(0, 1);
		z.im = sign;
		return z;
	}
	
	int i = 0;
	while (s[i] >= '0' && s[i] <= '9') {
		z.re = z.re * 10 + s[i] - '0';
		i++;
		if (z.re > 10000) z.overflow = true;
	}
	z.re *= sign;
	s.erase(0, i);
	return z;
}

void print(const complex &z) {
	if (z.im == 0)
		cout << z.re << endl;
	else if (z.re == 0)
		cout << z.im << "i" << endl;
	else {
		cout << z.re;
		if (z.im > 0)
			cout << "+";
		cout << z.im << "i" << endl;
	}
}

int main() {
	string s;
	while (cin >> s) {
		complex z = expr(s);
		if (z.overflow)
			cout << "overflow" << endl;
		else
			print(z);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
 
using namespace std;
 
bool isPrime (int x) {
    for(int i=2; i*i <=x; i++) {
        if(x%i==0) return false;
    }
    return true;
}
 
int N;
int main () {
    cin >> N;
    long long int ans = 1;
    for(int i=2; i<=N; i++) {
        if(isPrime(i)) {
            long long int r = 1;
            for(int x=N; x/=i; r+=x);
            ans = ans * r % 1000000007;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N;
    bool flag = false;
    cin >> N;

    for(int i=1; i<=3; i++) {
        if (N%10==7) {
            flag = true;
            break;
        }
        N /= 10;
    }

    if (flag) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
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;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  ll N, A, B;
  cin >> N >> A >> B;
  if (N % (A+B) <= A) {
    cout << N-N/(A+B)*B << endl;
  }
  else
    cout << N/(A+B)*A+A << endl;
}


Measured memory_bytes: 256
n=int(input())
a=[int(x)-1 for x in input().split()]
b=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]

s=0
p=n
for i in range(n):
  s += b[a[i]]
  if p == a[i]-1:
    s += c[p]
  p=a[i]

print(s)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
   int A,B,C,D,E,a,b;
   cin >> A >> B >> C >> D >> E;
   if(A<0){
       a=-(A*C);
       b=B*E;
       cout << a+D+b << endl;
   }else if(A>0){
       a=B-A;
       b=a*E;
       cout << b << endl;
   }else if(A==0){
       a=B*E;
       cout << D+a << endl;
   }
 }


Measured memory_bytes: 3108
S = input()
N = len(S)

r_S = S[::-1]

head_S = S[0: int((N - 1) / 2)]
r_head_S = head_S[::-1]

end_S = S[int((N+3)/2 - 1) : N+1]
r_end_S = end_S[::-1]

if S == r_S and head_S == r_head_S and end_S == r_end_S:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 8832
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,t = LI()
    g = LIR(n)
    g.sort()
    dp = [0]*(t+3001)
    ans = 0
    for i in range(n):
        w,v = g[i]
        for j in range(w,t+3001)[::-1]:
            nd = dp[j-w]+v
            if j-w < t:
                if ans < nd:
                    ans = nd
            if dp[j] < nd:
                dp[j] = nd
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


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

int main() {
  int a, b;
  cin >> a >> b;

  if ( a%2 == 1 && b%2 == 1 ) {
    cout << "Yes" << endl;  
  }
  else {
    cout << "No" << endl; 
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const MAXP = 1e6;
bool is_prime[MAXP];

int main() {
  int64_t A, B, mAB; std::cin >> A >> B;
  mAB = std::min(A, B);
  std::fill_n(is_prime, MAXP, true);
  int ans = 1;
  for(int64_t p = 2; p*p < mAB; ++p) if(is_prime[p]) {
    for(int j = p*2; j < MAXP; j += p) is_prime[j] = false;
    if(A%p == 0 && B%p == 0) ++ans;
    while(A%p == 0) A/=p;
    while(B%p == 0) B/=p;
  }
  while(A > 0){ int64_t r = B%A; B=A; A=r; }
  if(B > 1) ++ans;
  fin(ans);
  return 0;
}


Measured memory_bytes: 1280
#include<cstdio>

int main(){
    int count[1000];
    char ch;
    while(scanf("%c",&ch) != EOF){
        if(ch >= 'a' && ch <= 'z'){
            count[ch - 'a']++;
        }
        else if(ch >= 'A' && ch <= 'Z'){
            count[ch - 'A']++;
        }
    }
    for(int j = 0;j < 26; j++){
        printf("%c : %d\n",j + 'a',count[j]);
    }
    return 0;
}


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

int main(void){
    int N,X,cnt=0,min=9999999;
    cin>>N>>X;
    int data[N];
    for(int lop=0;lop<N;lop++){
        cin>>data[lop];
        X-=data[lop];
        cnt++;
        if(min>data[lop]){
            min=data[lop];
        }
    }
    cnt = X/min+cnt;

    cout<<cnt<<"\n";
    return 0;
}

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

#define DEBUG

using namespace std;

const int N = 2e5+7;
const int MOD = 1e9+7;
typedef pair<int, int> pii;

int n;
int a[N], b[N], c[N<<1], d[N], nex[N];

inline void GetNext()
{
    for (int i = 2, k = 0; i < n; ++i) {
        while (k && d[k+1] != d[i]) k = nex[k];
        if (d[k+1] == d[i]) ++k;
        nex[i] = k;
    }
}

inline void KMP()
{
    for (int i = 1, j = 0, k; i <= 2*n-2; ++i) {
        while (j && c[i] != d[j+1]) j = nex[j];
        if (d[j+1] == c[i]) ++j;
        if (j == n-1) {
            k = i-n+1;
            cout << k << " " << (a[k]^b[0]) << endl;
            j = nex[j];
        }
    }
}

inline void solve()
{
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];

    if (n == 1) { cout << 0 << " " << (a[0]^b[0]) << endl; return; }
    for (int i = 1; i <= 2*n-2; ++i) c[i] = a[(i-1)%n]^a[i%n];
    for (int i = 1; i < n; ++i) d[i] = b[i-1]^b[i];
    GetNext();
    KMP();
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 8192
import math
import time
from collections import deque
from copy import deepcopy

t = time.time()
def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret

def makemaze(H, W):
    maze = []
    for i in range(H):
        s = input()
        a = []
        for c in s:
            if c == ".":
                a.append(1000)
            if c == "#":
                a.append(9999)
        maze.append(a)
        #print(maze)
    return maze

def maxroot(maze, x, y, w, h):
    sn = 0
    if maze[y][x] == 9999:
        return 0

    maze = deepcopy(maze)
    maze[y][x] = 0
    que = deque()
    que.append((y, x))


    while que:
        xy = que.popleft()
        y = xy[0]
        x = xy[1]
        if maze[y][x] == 9999:
            continue

        minlist = []
        if x > 0:
            minlist.append((y, x-1))
        if y > 0:
            minlist.append((y-1, x))
        if x < w-1:
            minlist.append((y, x+1))
        if y < h-1:
            minlist.append((y+1, x))

        dd = min(maze[y][x] for y, x in minlist) + 1
        dd = min(dd, maze[y][x])
        maze[y][x] = dd

        for y, x in minlist:
            #if maze[y][x] != 9999 and maze[y][x] > dd+2:
            if maze[y][x] == 1000 and (y, x) not in que:
                que.append((y, x))
                sn += 1
                if sn > 500:
                    print(maze)
                    print(que)
                    raise Exception
            #print(sn)

    maxx = 0
    for line in maze:
        try:
            maxa = max([i for i in line if i < 1000])
        except:
            maxa = 0
        maxx = max(maxx, maxa)
    return maxx


def main():
    H, W = iip()
    maze = makemaze(H, W)

    maxx = 1
    for y in range(H):
        for x in range(W):
            maxx = max(maxx, maxroot(maze, x, y, W, H))
            pass

    print(maxx)
    #print(maxroot(maze, 0, 2, W, H))


main()

Measured memory_bytes: 56536
//***********************
//Author:kibi11
//Quarantine Days
//***********************

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fr(i, n) for(int i = 0; i < n; i++)
#define fr1(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,k) for(int i=a;i>=k;i--)
#define same int t;cin>>t;while(t--)
#define check(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define f first
#define s second
#define XOX

//////////////////////////////////////////////////////////////////////////
/////////////////DEBUGING ZONE//////////////////////////////

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
///////////////////////////////////////////////////////////////////////////
 
ll powermod(ll base, ll exp, ll mod) {
	ll result = 1;
	while (exp != 0) {
		if ((exp % 2) == 1) {
			result = (result * base) % mod;
		}
		base = (base * base) % mod;
		exp /= 2;
	}
	return result;
}

///////////////////////////////////////////////////////////////////////////
//Fuctions if any:





///////////////////////////////////////////////////////////////////////////
int main() 
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = clock();
//ios_base& scientific (ios_base& str);
	// #ifndef ONLINE_JUDGE
	// 	freopen("C:\\Users\\arpan\\Documents\\prog c++\\IN.txt","r",stdin);
	// 	freopen("C:\\Users\\arpan\\Documents\\prog c++\\OUT.txt","w",stdout);
	// 	freopen("C:\\Users\\arpan\\Documents\\prog c++\\Error.txt","w",stderr);
	// #endif
int n,k;
cin>>n>>k;
int a[n];
int dp[n];
memset(dp,0,sizeof(dp));
fr(i,n)
cin>>a[i];
fr1(i,1,n)
{
	dp[i]=INT_MAX;
	// check(dp[i]);
	fr(j,k)
	{
		// debug(j);
		if((i-j-1)>=0)
		{

			
			dp[i]=min({dp[i-j-1]+abs(a[i]-a[i-j-1]),dp[i]});
			// check(dp[i]);
			

		}
	}

}
// fr(i,n)
// cout<<dp[i]<<" ";
cout<<dp[n-1]<<endl;
cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
return 0;
}

Measured memory_bytes: 1024
import java.io.InputStream;
import java.util.Scanner;

public class Main {


	public static void main(String args[]) {
        InputStream inputStream = System.in;
        Scanner sc = new Scanner(inputStream);
        String out;
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A+B==15) {
        System.out.print("+");
        }
        else if(A*B==15) {
            System.out.print("*");
            }
        else {
            System.out.print("x");
            }
	}

}

Measured memory_bytes: 23636
a=int(input())
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=list(map(int,input().split()))

ans=c[b[0]-1]
for i in range(1,a):
  ans+=c[b[i]-1]
  if b[i]-1==b[i-1]:
    ans+=d[b[i]-2]
print(ans)

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  map<ll, int> cnts;
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    cnts[a]++;
  }

  vector<ll> va;
  for (auto it = cnts.begin(); it != cnts.end(); it++) {
    if (it->second >= 4) {
      va.push_back(it->first);
      va.push_back(it->first);
    } else if (it->second >= 2) {
      va.push_back(it->first);
    }
  }

  sort(va.begin(), va.end(), greater<ll>());
  if (va.size() < 2) {
    cout << 0 << '\n';
  } else {
    cout << va[0] * va[1] << '\n';
  }

  return 0;
}

Measured memory_bytes: 9856
#include<iostream>
#include<algorithm>
int a[3];
int main(){
	for(int i=0;i<3;++i){
		std::cin>>a[i];
	}
	std::sort(std::begin(a),std::end(a));
	std::cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<std::endl;
	return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>

int main(void){

	int a,b,c,count;
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	
	for(count=0; a<=b; ++a){
		if( c%a == 0 ){
			++count;
		}
	}
	
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 2728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            int ans = 0;
            for(int i = 0; i < N; i++)
            {
                for(int j = i + 1; j < N; j++)
                {
                    if(L[i] != L[j])
                    {
                        for(int k = j + 1; k < N; k++)
                        {
                            if(L[i] != L[k] && L[j] != L[k])
                            {
                                if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[k] + L[j] > L[i])
                                {
                                    ans++;
                                }
                            }
                        }
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 28288
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef long long int lli;



int main(void){
	int n;
	int i;
	int j;
	lli t;
	lli p,q;
	lli x;
	lli *a;
	lli **d;
	lli ans=0;
	scanf("%d%lld",&n,&x);
	a = calloc(sizeof(lli),n);
	d = calloc(sizeof(lli*),n);
	for(i = 0;i < n;i++){
		d[i] = calloc(sizeof(lli),n);
		scanf("%lld",&a[i]);
		ans += d[i][0] = a[i];
	}
	for(i = 1;i < n;i++){
		t = i*x;
		for(j = 0;j < n;j++){
			p = a[(j-i+n)%n];
			q = d[j][i-1];
			t += d[j][i] = p<q?p:q;
		}
		ans = ans<t?ans:t;
	}
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 31488
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int N;
string S[10004];

int main() {
	cin >> N;
	for_(i,0,N) cin >> S[i];
	
	int ans = 0;
	for_(i,0,N) {
		int m = S[i].size();
		for_(j,0,m-1) if (S[i].substr(j,2) == "AB") ++ans;
	}
	
	int a = 0, b = 0, ba = 0;
	for_(i,0,N) {
		if (S[i][0] == 'B' && S[i].back() == 'A') ++ba;
		else if (S[i][0] == 'B') ++b;
		else if (S[i].back() == 'A') ++a;
	}
	
	if (ba > 0) {
		ans += ba - 1;
		
		if (b > 0) {
			++ans;
			--b;
		}
		
		if (a > 0) {
			++ans;
			--a;
		}
		
		ans += min(a, b);
	}
	else {
		ans += min(a, b);
	}
	
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

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

int fib(int n, int *dp){
  if(n == 0 || n == 1)
    return dp[n] = 1;
  if(dp[n] != -1)
    return dp[n];
  return dp[n] = fib(n-1, dp) + fib(n-2, dp);
}

int main(){
  int *dp;
  int n, i;

  dp = (int *)malloc(sizeof(int) * 45);

  for(i = 0; i < 45; i++)
    dp[i] = -1;

  scanf("%d", &n);

  printf("%d\n", fib(n, dp));

  free(dp);
  return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>
 
int main(void) {

int a, h, m, s;

scanf("%d\n", &a);
 
s = a % 60;
a = (a - s) / 60;
m = a % 60;
a = (a - m) / 60;
h = a;
 
printf("%d:%d:%d\n", h, m, s);

return 0;
}

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


#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N, C, K;
    cin >> N >> C >> K;
    vector<lli> T(N);
    REP (i, 0, N) cin >> T[i];
    sort(T.begin(), T.end());
    lli cnt = 0;
    int index = 0;

    while (index != N) {
        int sum = 0;
        int t = T[index] + K;

        while (index < N && T[index] <= t) {
            sum++;
            index++;
            if (index == N) break;
            if (sum == C) {
                t = T[index] + K;
                sum = 0;
                cnt++;
            }
        }
        cnt += ((sum + C - 1) / C);
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque

n,m = map(int,input().split())
aisle=[[] for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    aisle[a-1].append(b)
    aisle[b-1].append(a)

queue = deque([1])
visited = [-1] * n
parent = [0] * n
now = 1

visited[0]=0

while len(queue) > 0:
    now = queue.popleft()
    for i in aisle[now-1]:
        if visited[i-1]==-1:
            queue.append(i)
            visited[i-1]=visited[now-1]+1
            parent[i-1] = now


print('Yes')
for i in range(2,n+1):
    print(parent[i-1])


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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

double dp[310][310][310];

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

  vi a(n), c(4);
  int sum = 0;
  rep(i, n){
    cin >> a[i];
    c[a[i]]++;
  }

  rep(k, n+1) rep(j, n+1) rep(i, n+1){
    int sum = i + j + k;
    if(sum == 0) continue;

    dp[i][j][k] = 1.0*n/sum;
    if(i) dp[i][j][k] += dp[i-1][j][k]*i/sum;
    if(j) dp[i][j][k] += dp[i+1][j-1][k]*j/sum;
    if(k) dp[i][j][k] += dp[i][j+1][k-1]*k/sum;
  }

  printf("%.10f\n", dp[c[1]][c[2]][c[3]]);

  return 0;
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n;
	cin>>n;
	string s[4]={"AC","WA","TLE","RE"};
	int c[4]={0};
	string ss;
	for(int i=0;i<n;i++){
		cin>>ss;
		for(int j=0;j<4;j++){
			if(ss==s[j])
				c[j]++;
		}
	}
	for(int i=0;i<4;i++){
		cout<<s[i]<<" x "<<c[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-6
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 2e5+10;
const int N = 1e5+10;
const int E = 1e6+10; 
string s;
ll n,k;
ll ans;

ll solve_1(ll del){
	ll res = 0;
	while(s[0+del]=='0'&&del<n) del++;
	if(del>=n) return 0;
	res+=(ll)(s[0+del]-'0')+9*(n-1-del);
	return res;
}

ll solve_2(ll del){
	ll res = 0;
	while(s[0+del]=='0'&&del<n) del++;
	if(del>=n) return 0;
	for(ll i=0+del;i<n;i++){
		if(i==0+del){
			res+=solve_1(del+1)+(ll)(s[0+del]-'0'-1)*9*(n-1-del);
		}
		else{
			res+=9*9*(n-i-1);
		}
	}
	return res;
}

ll solve_3(ll del){
	ll res = 0;
	for(ll i = 0+del;i<n;i++){
		if(i==0+del){
			res+=solve_2(del+1)+(ll)(s[0]-'0'-1)*(((n-1)*(n-2))/2)*81;
		}
		else{
			res+=9*(((n-i-1)*(n-i-2))/2)*81;
		}
	}
	return res;
}

int main(){
	cin>>s>>k;
	n = s.size();
	if(n<k){
		printf("0\n");
		return 0;
	}
	if(k==1) ans = solve_1(0);
	if(k==2) ans = solve_2(0);
	if(k==3) ans = solve_3(0);
	cout<<ans<<endl; 
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int paper[16][16] = {0};
    int x, y;
    int size;
    int white;
    int maximum;
    int i, j;

    while (scanf("%d,%d,%d", &x, &y, &size) == 3){
        paper[y + 2][x + 2]++;
        paper[y - 1 + 2][x + 2]++;
        paper[y + 1 + 2][x + 2]++;
        paper[y + 2][x - 1 + 2]++;
        paper[y + 2][x + 1 + 2]++;

        if (size >= 2){
            paper[y - 1 + 2][x - 1 + 2]++;
            paper[y - 1 + 2][x + 1 + 2]++;
            paper[y + 1 + 2][x - 1 + 2]++;
            paper[y + 1 + 2][x + 1 + 2]++;
        }
        if (size >= 3){
            paper[y - 2 + 2][x + 2]++;
            paper[y + 2 + 2][x + 2]++;
            paper[y + 2][x - 2 + 2]++;
            paper[y + 2][x + 2 + 2]++;
        }
    }

    white = 0;
    maximum = 0;
    for (i = 2; i < 12; i++){
        for (j = 2; j < 12; j++){
            if (paper[i][j] == 0){
                white++;
            }
            if (maximum < paper[i][j]){
                maximum = paper[i][j];
            }
        }
    }
    printf("%d\n", white);
    printf("%d\n", maximum);

    return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, m; cin >> n >> m;
    vll a(m); REP(i, m) cin >> a[i];
    ll sum = accumulate(ALL(a), 0);
    if (n < sum) cout << -1 << endl;
    else cout << n - sum << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;
const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int main() {
    int h,w; cin >> h >> w;
    vector<vector<char>> v(h, vector<char> (w));
    vector<int> disph(h, 0);
    vector<int> dispw(w, 0);
 
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> v[i][j];
            if(v[i][j] == '#') {disph[i]=1; dispw[j] = 1;}
        }
    }
 
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(disph[i] && dispw[j]) cout << v[i][j];
        }
        if(disph[i])cout << endl;
    }
}

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

int main() {
  int n, m, l, a[100][100], b[100][100];
  cin >> n >> m >> l;
  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 ans = 0;
      for (int k = 0; k < m; k++)
        ans += a[i][k] * b[k][j];
      if (j) cout << ' ';
      cout << ans;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>
int main(void){
	int i,a[100];
 	int n,flag=0;
  	scanf("%d",&n);
	for(i=0;i<n;i++){
  		scanf("%d",&a[i]);
    }
  	for(i=0;i<n;i++){
   		if(a[i]%2==0){
         	if(a[i]%3!=0&&a[i]%5!=0){
              printf("DENIED");
              return 0;
            }
        }
    }
  	printf("APPROVED");
}

Measured memory_bytes: 1732
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		String str =sc.next();
		String aaa="";
		String bbb="";
		if(str.length()%2==0&&str.length()==N) {
			for(int i=0;i<(N/2);i++){
			aaa = aaa+str.charAt(i);
			bbb = bbb+str.charAt(i+(N/2));
			}
			if(aaa.equals(bbb)) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
		}
		else {
			System.out.print("No");
		}
		sc.close();
		}
	}

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

const int INF=1001001001;

int N,Ma,Mb;
int A[44],B[44],C[44];

int dp[41][500][500];

signed main(){
    cin>>N>>Ma>>Mb;
    rep(i,N)cin>>A[i]>>B[i]>>C[i];
    fill_n(**dp,41*500*500,INF);
    dp[0][0][0]=0;
    rep(i,N){
        rep(j,500)rep(k,500){
            if(dp[i][j][k]==INF)continue;
            chmin(dp[i+1][j][k],dp[i][j][k]);
            chmin(dp[i+1][j+A[i]][k+B[i]],dp[i][j][k]+C[i]);
        }
    }

    int ans=INF;
    for(int i=1;i*Ma<500&&i*Mb<500;i++)chmin(ans,dp[N][i*Ma][i*Mb]);
    if(ans==INF)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 80384
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    string s; cin>>s;
    int bcnt = 0;
    int n = s.size();

    ll ans = 0;
    for(int i=0; i<n; i++){
        if(s[i] == 'B') bcnt++;
        else ans += bcnt;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
LL a, b, x;
/**********************************************/

signed main(){
    cin >> a >> b >> x;
    if(a == 0){
        cout << b / x + 1 << endl;
    }else{
        cout << b / x - (a-1) / x << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int n;
    cin >> n;
    cout << n / 3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;

    int y = stoi(s.substr(0, 4));
    int m = stoi(s.substr(5, 2));
    int d = stoi(s.substr(8, 2));

    if (y >= 2020) {
        cout << "TBD" << endl;
    } else if (y == 2019) {
        if (m >= 5) {
            cout << "TBD" << endl;
        } else {
            cout << "Heisei" << endl;
        }
    } else {
        cout << "Heisei" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ASeptember9 {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string n;
	    in >> n;
	    if(n[0] == '9' || n[1] == '9') ans(true, out);
	    else ans(false, out);
	}
};


int main() {
	ASeptember9 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{					/*		  1  2  3  4  5  6  7  8  9 10 11*/
	static int fullDays[11]={31,29,31,30,31,30,31,31,30,31,30};
	int week,month,day,
		i;
	
	while(week=4,scanf("%d %d",&month,&day),month!=0){
		if(month-1>0){						/*ツオツーツバツーツフツδ債ーツ防ツ止*/
			for(i=0; month-(2+i) >=0 ;i++)
				week += fullDays[month-(2+i)];
		}
		week += day-1;
		switch(week%7){
			case 1:printf("Monday\n");break;
			case 2:printf("Tuesday\n");break;
			case 3:printf("Wednesday\n");break;
			case 4:printf("Thursday\n");break;
			case 5:printf("Friday\n");break;
			case 6:printf("Saturday\n");break;
			case 0:printf("Sunday\n");break;
		}
	}
	
	return 0;
}

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

int main(){
    int n;  cin >> n;
    vector<ll> a(n), b(n), c(n);
    for(int i=0; i<n; i++)  cin >> a.at(i);
    for(int i=0; i<n; i++)  cin >> b.at(i);
    for(int i=0; i<n; i++)  cin >> c.at(i);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll ans=0;
    for(auto mid: b){
        auto top = lower_bound(a.begin(),a.end(), mid);
        auto bottom = upper_bound(c.begin(), c.end(), mid);
        if(top!=a.begin() && bottom!=c.end())
            ans += (top-a.begin())*(n-(bottom-c.begin()));
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
if a+b == 15:
    print('+')
elif a*b == 15:
    print('*')
else:
    print('x')

Measured memory_bytes: 27132
#include <iostream>

using namespace std;

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

bool done[22][22];
int w, h;
bool field[22][22];
int ofs[4][2] = {
  {0,1},
  {1,0},
  {-1,0},
  {0,-1}
};
int dfs(int x, int y) {
  if( !field[y][x] ) return 0;
  if( done[y][x] ) return 0;
  done[y][x] = true;
  int cnt = 1;
  rep(i, 4) {
    int nx = x + ofs[i][0];
    int ny = y + ofs[i][1];
    cnt += dfs(nx, ny);
  }
  return cnt;
}

int main()
{
  while(cin >> w >> h, (w|h)) {
    rep(i, 21) rep(j, 21) {
      field[i][j] = done[i][j] = false;
    }
    int sx, sy;
    rep(y, h) {
      rep(x, w) {
        char c;
        cin >> c;
        field[y + 1][x + 1] = c != '#';
        if( c == '@' ) {
          sx = x + 1;
          sy = y + 1;
        }
      }
    }

    cout << dfs(sx, sy) << endl;
  }
  return 0;
}

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

int main(){
	int H[25565] = {0};
	int W[25565] = {0};
	int i = 0;
	do{
		cin >> H[i] >> W[i];
		i++;
	}while(H[i-1] != 0 && W[i-1] != 0);
	i = 0;
	do{
		for(int j=0;j<H[i];j++){
			for(int k=0;k<W[i];k++){
				if((j+k) % 2 == 0){
					cout << "#";
				}else{
				cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
		i++;
	}while(H[i] != 0 && W[i] != 0);
}

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

int sum[501][501] = {};

// 二次元累積和によるO(N^2)解法

int main(){ 
    int n, m, Q;
    scanf("%d %d %d\n", &n, &m, &Q);

    int l, r, p, q;
    for(int i = 0; i < m; i++){
        scanf("%d %d\n", &l, &r);
        sum[l][r]++;
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            sum[i][j] = sum[i][j] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
        }
    }

    for(int i = 0; i < Q; i++){
        scanf("%d %d\n", &p, &q);
        printf("%d\n", sum[q][q] - sum[p-1][q] - sum[q][p-1] + sum[p-1][p-1]);
    }

    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
using namespace std;

int main() {

	//cout << fixed << setprecision(10);
	long long int a, b, q, s[200000], t[200000], x[200000];
	long long int tmp,left_zin, left_tera, right_zin, right_tera;
	cin >> a >> b >> q;
	for (int i = 1; i <= a; i++) {
		cin >> s[i];
	}
	for (int i = 1; i <= b; i++) {
		cin >> t[i];
	}
	for (int i = 1; i <= q; i++) {
		cin >> x[i];
	}


	s[0] = -9999999999999;
	t[0] = -9999999999999;
	s[a + 1] = 9999999999999;
	t[b + 1] = 9999999999999;

	for (int i = 1; i <= q; i++) {
		left_tera = 0;
		left_zin = 0;
		right_tera = b+1;
		right_zin = a+1;
		while (right_tera - left_tera != 1) {
			tmp = (right_tera + left_tera) / 2;
			if (t[tmp] <= x[i]) {
				left_tera = tmp;
			}
			else {
				right_tera = tmp;
			}
		}

		while (right_zin - left_zin != 1) {
			tmp = (right_zin + left_zin) / 2;
			if (s[tmp] <= x[i]) {
				left_zin = tmp;
			}
			else {
				right_zin = tmp;
			}
		}

		tmp = min(max(x[i] - s[left_zin], x[i] - t[left_tera]), max(s[right_zin] - x[i], t[right_tera] - x[i]));
		
		tmp = min(tmp, 2 * s[right_zin] - x[i] - t[left_tera]);
		
		tmp = min(tmp, s[right_zin] + x[i] - 2*t[left_tera]);
		
		tmp = min(tmp, 2 * t[right_tera] - x[i] - s[left_zin]);
		
		tmp = min(tmp, t[right_tera] + x[i] - 2*s[left_zin]);

		cout << tmp << endl;
	}



}



Measured memory_bytes: 5504
#include<iostream>
#include<climits>
#define MAX 500001
using namespace std;

int cnt = 0;
void merge(int *A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	int L[MAX], R[MAX];
	
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];

	}

	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	
	}
	
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
}


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

int main() {
	int n, A[MAX];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	
	mergeSort(A, 0, n);
	for (int i = 0; i < n; i++) {
		cout << A[i];
		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 6924
N, K = map(int, input().split())

has_snack = [False]*N

for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        has_snack[a-1] = True

print(sum([1 for h in has_snack if h == False]))


Measured memory_bytes: 67604
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val m = sc.nextInt

  val abl = Vector.fill(m)((sc.nextInt, sc.nextInt))

  val from1 = abl.filter(_._1 == 1).map(_._2)
  val toN   = abl.filter(_._2 == n).map(_._1)

  val res = if(from1.intersect(toN).nonEmpty) "POSSIBLE" else "IMPOSSIBLE"

  println(res)
}

Measured memory_bytes: 116624
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	ll N;
	cin >> N;

	
	ll ans = LLINF;
	for (ll i = 1; i <= sqrt(N) + 1; i++)
	{
		if (N % i == 0)
		{
			ll A = i;
			ll B = N / i;

			ll p = 1;
			while (true)
			{
				if (A < pow(10, p) && B < pow(10, p))
				{
					break;
				}
				p++;
			}

			ans = min(ans, p);


		}
	}

	cout << ans << endl;





}





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

int main(void) {
	char s[128], p[128], *i;
	char sp[256];
	if (fgets(s, sizeof(s), stdin) == NULL) return 1;
	if (fgets(p, sizeof(p), stdin) == NULL) return 1;
	if ((i = strchr(s, '\n')) != NULL) *i = '\0';
	if ((i = strchr(p, '\n')) != NULL) *i = '\0';
	strcpy(sp, s);
	strcat(sp, s);
	if(strstr(sp,p) != NULL)    printf("Yes\n");
	else                        printf("No\n");
	return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

void solve() {
    int n, q;
    std::cin >> n >> q;

    std::vector<int> xs(n * 2);
    std::iota(xs.begin(), xs.end(), 1);
    std::vector<int> ys(n * 2);

    while (q--) {
        int k;
        std::cin >> k;

        if (k > 0) {
            std::rotate(xs.begin(), xs.begin() + k, xs.end());

        } else {
            for (int i = 0; i < n * 2; ++i) {
                ys[i / n + (i % n) * 2] = xs[i];
            }
            std::swap(xs, ys);
        }
    }

    for (auto x : xs) std::cout << x << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3180
n, m = map(int, input().split())
cakes = [list(map(int, input().split())) for _ in range(n)]

import itertools

ans = 0
for a, b, c in itertools.product([-1, 1], repeat=3):
    li = []
    for i in range(n):
        x = a*cakes[i][0] + b*cakes[i][1] + c*cakes[i][2]
        li.append(x)
    li.sort(reverse=True)
    ans = max(ans, sum(li[:m]))
print(ans)

Measured memory_bytes: 40560