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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

vii dp;
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(30);

    int h,w; cin >> h >> w;
    vec<string> a(h); rep(i,h) cin >> a[i];
    dp.resize(h, vi(w));
    dp[0][0] = 1;

    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(i+1<h) {
                if(a[i+1][j] == '.') {
                    dp[i+1][j] += dp[i][j];  // 下に遷移
                    dp[i+1][j] %= mod;
                }
            }
            if(j+1<w) {
                if(a[i][j+1] == '.') {
                    dp[i][j+1] += dp[i][j];  // 右に遷移
                    dp[i][j+1] %= mod;
                }
            }    
        }
    }
    cout << dp[h-1][w-1] << '\n';
}

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
using graph = vector<vector<char>>;

graph g;
void h_(int i,int w){
  rep(j,w){
    if(g[i][j]=='#'){return;}
  }
  rep(j,w){g[i][j]='n';}
  return;
}
void w_(int j,int h){
  rep(i,h){
    if(g[i][j]=='#'){return;}
  }
  rep(i,h){g[i][j]='n';}
  return;
}
int main(){
  int h,w; cin>>h>>w;
  g.assign(h,vector<char>(w));
  rep(i,h){
    rep(j,w){cin>>g[i][j];}
  }
  int i=0;
  rep(i,h){ h_(i,w);}  
  rep(j,w){ w_(j,h);}
  rep(i,h){
    int c=count(g[i].begin(),g[i].end(),'#');
    rep(j,w){
      if(g[i][j]!='n')cout<<g[i][j];
      if(j==w-1&&c>0){cout<<endl;}
    }
  }
}



Measured memory_bytes: 256
#define LOCAL

#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 998244353LL;
const double PI = acos(-1);

int main() {
	IOS;
	string s; cin >> s;
	if (s[s.length() - 1] == 's') cout << s << "es";
	else cout << s << "s";
}

Measured memory_bytes: 3656
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int to[200001], ne[200001], he[100001], saidai, saidaiv;
void dfs1(int v, int mae, int d) {
	if (saidai < d) {
		saidai = d;
		saidaiv = v;
	}
	for (int i = he[v]; i; i = ne[i]) {
		if (to[i] != mae) dfs1(to[i], v, d + 1);
	}
}

int kazu[100000], n;
bool dfs2(int v, int mae) {
	bool ret = (saidaiv == v);
	int cnt = 0;
	for (int i = he[v]; i; i = ne[i]) {
		if (to[i] != mae) {
			ret |= dfs2(to[i], v);
			cnt++;
		}
	}
	if (ret) kazu[n++] = cnt;
	return ret;
}

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


	int N = getint();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		to[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		to[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	dfs1(1, 0, 0);
	int tmp = saidaiv;
	saidai = 0;
	dfs1(tmp, 0, 0);

	dfs2(tmp, 0);

	int s = n / 2 - 1;
	bool gyaku = 0;
	rep1(i, s) {
		if (kazu[i] > kazu[n - i - 1]) {
			gyaku = 1;
			break;
		}
		else if (kazu[i] < kazu[n - i - 1]) {
			break;
		}
	}
	k = 2;
	putint(1);
	if (gyaku) {
		for (int i = n - 2; i >= 1; i--) {
			rep1(j, kazu[i] - 1) putint(k + j);
			putint(k);
			k += kazu[i];
		}
	}
	else {
		rep1(i, n - 2) {
			rep1(j, kazu[i] - 1) putint(k + j);
			putint(k);
			k += kazu[i];
		}
	}
	putint(N);

	if (k != N) {
		printf("-1");
	}
	else {
		fwrite(dn, 1, di - dn, stdout);
	}

	Would you please return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
string s;
int a[101];
int b[101];
int main(){
    cin>>s;
    REP(i,s.size()){
        a[i]=s[i]-'a';
    }
    int ans=1000;
    REP(i,30){
        REP(j,s.size()){
            b[j]=a[j];
        }
        int num=0;
        REP(j,102){
            bool check=false;
            REP(k,s.size()-j){
                if(b[k]!=i)check=true;
            }
            if(check==false)break;
            REP(k,101){
                if(b[k]==i||b[k+1]==i)b[k]=i;
            }
            num++;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

const int M=105;
char s[M];

int main()
{
	scanf("%s",s);
	int n=strlen(s);
	int ans=0;
	for(int l=0,r=n-1;l<r;l++,r--)
	{
		if(s[l]!=s[r]) ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll ans,t,k;
int a[210001],i,j,n,m;
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	if (a[1]>0) t=a[1],k=0;else t=1,k=1-a[1];
	for (i=2,j=1;i<=n;i++){
		j*=-1;t+=a[i];
		if (j*t<=0) k+=(j==1)?1-t:t+1,t=j;
	}
	ans=k;
	if (a[1]<0) t=a[1],k=0;else t=-1,k=a[1]+1;
	for (i=2,j=-1;i<=n;i++){
		j*=-1;t+=a[i];
		if (j*t<=0) k+=(j==1)?1-t:t+1,t=j;
	}
	ans=min(ans,k);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h> 
#include<queue>
#include<string.h>
#include<stack>


using namespace std;

#define INF 1000000000
#define BL 1
#define WH 0
#define GL 2

int par[100001];
int r[100001];
int weight[100001];

void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		weight[i]=0;
		r[i]=0;
	}
}


int root(int x){
	if(par[x]==x){
		return x;
	}
	else {
		int temp=root(par[x]);
		weight[x]+=weight[par[x]];
		return par[x]=temp;
	}
}

bool same(int x,int y){
	return root(x)==root(y);
}


void unite(int x,int y,int w){
	par[x]=root(x);
	par[y]=root(y);
	int a=w-(weight[y]-weight[x]);

	//if(x==y)return;

	if(r[par[x]]>r[par[y]]){
		weight[par[y]]=a;
		par[par[y]]=par[x];
	}
	else{
		weight[par[x]]=-a;
		par[par[x]]=par[y];
		if(r[par[x]]==r[par[y]])r[par[y]]++;
	}
	/*
	x=root(x);
	y=root(y);
	int a=w-(weight[y]-weight[x]);
	if(r[x]>r[y]){
		weight[y]=a;
		par[y]=x;
	}
	else{
		weight[x]=-a;
		par[x]=y;
		if(r[x]==r[y])r[y]++;
	}
	*/
}

int diff(int x,int y){
	return weight[y]-weight[x];
}


int main(){
	int n,q;
	cin>>n>>q;
	int qu;
	int x,y,z;
	init(n);
	for(int i=0;i<q;i++){
		cin>>qu;
		if(qu==0){
			cin>>x>>y>>z;
			unite(x,y,z);
		}
		else if(qu==1){
			cin>>x>>y;
			if(same(x,y)){
				cout<<diff(x,y)<<endl;
			}
			else{
				cout<<"?"<<endl;
			}
		}
	}

	
	return 0;
}







Measured memory_bytes: 4256
#include<iostream>

using namespace std;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if((A+B) +1 >= C){
        cout << B+C << "\n";
    }
    else{
        cout << (A+B) + B + 1 <<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, x, y, z; cin >> n >> x >> y >> z;
  VV<lint> dp; assign(dp, 2, 1 << x + y + z);
  dp[0][1] = 1;
  for (int i = 0; i < n; i++) {
    assign(dp[i + 1 & 1], 1 << x + y + z);
    for (int a = 1; a < 11; a++) {
      (dp[i + 1 & 1][0] += dp[i & 1][0]) %= mod;
      for (int bit = 1; bit < 1 << x + y + z; bit++) {
        int bx = (bit & (1 << x + 1) - 1) << a | 1,
            by = (bit >> x & (1 << y + 1) - 1) << a + x,
            bz = (bit >> x + y & (1 << z) - 1) << a + x + y;
        if (bz & 1 << x + y + z) (dp[i + 1 & 1][0] += dp[i & 1][bit]) %= mod;
        else (dp[i + 1 & 1][bx & (1 << x + 1) - 1 | by & (1 << x + y + 1) - 1 | bz & (1 << x + y + z) - 1] += dp[i & 1][bit]) %= mod;
      }
    }
  }
  cout << emod(dp[n & 1][0]) << '\n';
}

Measured memory_bytes: 2304
import sys
def input(): return sys.stdin.readline().strip()
N=int(input())
A=[int(input()) for i in range(N-1)]
c=[[] for i in range(N)]
for i,a in enumerate(A):
    c[a-1].append(i+1)
import sys
sys.setrecursionlimit(10**7)
def f(i):
    if len(c[i])==0:
        return 0
    return max([e+i+1 for i,e in enumerate(sorted([f(j) for j in c[i]],reverse=True))])
print(f(0))

Measured memory_bytes: 245656
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.util.function.DoubleToLongFunction;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		System.out.println(N * (N + 1) / 2);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21076
from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += bisect_left(l, l[i]+l[j])-(j+1)
print(ans)

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

int main(){
    int d;
    cin >> d;
    vector<int> c(26);
    for(int i = 0; i < 26; i++) cin >> c[i];
    vector<vector<int>> s(d+1, vector<int>(26));
    for(int i = 1; i <= d; i++){
        for(int j = 0; j < 26; j++) cin >> s[i][j];
    }
    
    vector<int> last(26, 0);
    int score = 0;
    for(int i = 1; i <= d; i++){
        int type = 0;
        int downsum = 0;
        for(int j = 0; j < 26; j++){
            downsum += c[j]*(i-last[j]);
        }
        int maxscore = score - downsum;
        for(int j = 0; j < 26; j++){
            int newscore = score - downsum;
            newscore += c[j]*(i-last[j]);
            newscore += s[i][j];
            if(maxscore < newscore){
                maxscore = newscore;
                type = j;
            }
        }

        score = maxscore;
        last[type] = i;
        cout << type+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
while True:
    a, b, c = input().split()
    a = int(a)
    c = int(c)
    if b == "?":
        break
    if b == "+":
        print(a + c)
    if b == "-":
        print(a - c)
    if b == "*":
        print(a * c)
    if b == "/":
        print(a // c)


Measured memory_bytes: 5592
class SWAG():
    __slots__='unit','f','fold_r','fold_l','data_r','data_l'
    def __init__(self,unit,f,data):
        self.unit=unit
        self.f=f
        self.construct(data)
    def construct(self,data):
        self.fold_r=[self.unit]
        self.fold_l=[self.unit]
        self.data_r=[]
        self.data_l=[]
        sep=0--len(data)//2
        for t in data[sep:]:
            self.append(t)
        for t in data[sep-1::-1]:
            self.appendleft(t)
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.construct(self.data_l[::-1])
        if not self.data_r:
            return self.popleft()
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.construct(self.data_r)
        if not self.data_l:
            return False
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,k,*p=map(int,open(0).read().split())
c=[0]
for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
*c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
x=not f
s_min=SWAG(10**18,min,p[:k-1])
s_max=SWAG(0,max,p[1:k])
for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    s_min.append(p[i+k-1])
    s_max.append(b)
    if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1
    s_min.popleft()
    s_max.popleft()
print(x+f)

Measured memory_bytes: 121532
/********************************
*MAHBUBCSEJU                    *
*CSE 22                         *
*JAHANGIRNAGAR UNIVERSITY       *
*TIMUS:164273FU                 *
*UVA>>LIGHTOJ>>HUST:mahbubcseju */
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
//#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
template <class T>string NTS ( T Number )
{
    stringstream ss;
    ss << Number;
    return ss.str();
}
template <class T>T stringtonumber ( const string &Text )
{
    istringstream ss(Text);
    T result;
    return ss >> result ? result : 0;
}
template <class T>bool ISLEFT ( T a,T b,T c)
{
    if(((a.xx-b.xx)*(b.yy-c.yy)-(b.xx-c.xx)*(a.yy-b.yy))<0.0)return 1;//Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
#define mx 200000
#define md 1000000007ll
#define maxp 2050180000

typedef pair<int ,int > P;
typedef vector<int> V;

////////define value/////
ll qu(ll n,ll m,ll k)
{
     ll res=4e18;
     if(n%2==0||m%2==0||k%2==0)return 0;
   if(n>1)
   {
       ll h=n/2;
       ll hb=h+1;
       res=min(res,m*k);
   }
  return res;
}
int main()
{

   ll n,m,k;
   L3(n,m,k);
ll re=qu(n,m,k);
re=min(qu(m,n,k),re);
re=min(re,qu(k,n,m));
PL(re);


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int di(int a){
  if(a > 0){
    return a;
  }
  return -a;
}

int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(di(a - c) <= d || (di(a - b) <= d &&di(b - c) <= d)){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll x,y; cin >> x >> y;
    if(abs(x-y)<=1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
    return 0;
}


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

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

Measured memory_bytes: 81292
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int a,b,c;
long long k;
int main()
{
	cin>>a>>b>>c;
	scanf("%lld",&k);
	if(k&1) cout<<b-a;
	else cout<<a-b;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
//#define pp pair<pii,pii>
const int hell =1000000007;



int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a;
  int t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}

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

int digitsum(int x)
{
  while(x>9)
    {  int ans=0;
       while(x!=0)
       {
        ans+=x%10;
        x/=10;
       }
       x=ans;
    }
    return x;
}

int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){a=a*x;}
  return a;
}




int solve( ){


int a,b,c;
cin>>a>>b>>c;
cout<<(c/a)*b;

return 0;
}

signed main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);


 //sieve();
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;

    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
 // cout << "Processor time taken is "
   // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll a,b;
    cin >> a >> b;
    ll ini_a = a;
    ll ini_b = b;
    while(1) {
        if(a<b) {
            a += ini_a;
        }
        if(a>b) {
            swap(a,b);
            swap(ini_a,ini_b);
        }
        if(b==a) break;
    }
    cout << a << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		for(int i = 0; i < k; i++) {
			if(i % 2 == 0) {
				a /= 2;
				b += a;
			}else {
				b /= 2;
				a += b;
			}
		}
		System.out.print(a + " " + b);
	}
}

Measured memory_bytes: 38608
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = (arg[0].split(" ")[0]);
    
    console.log(S.slice(-1) == "s" ? S + "es" : S + "s");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29680
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll MOD = 1000000007;

ll N, A[300010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N; ++i) { cin >> A[i]; }
    
    ll ans = 0;
    for (int d = 0; d < 60; ++d) {
        ll v0 = 0, v1 = 0;
        for (int i = 0; i < N; ++i)
            (((A[i] >> d) & 1) == 0 ? v0 : v1)++;

        ll a = v0 * v1 % MOD;
        for (int i = 0; i < d; ++i)
            a = a * 2 % MOD;
        ans = (ans + a) % MOD;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>s;
			if(s=="snuke")
			{
				cout<<char(j-1+'A');
				cout<<i;
				cout<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x,y,a,b,c = mi()
p = li()
q = li()
r = li()

p.sort()
q.sort()
r.sort()


qp = True
qq = True
plef = a - x
qlef = b - y
ans = 0
rlen = len(r) -1
while True:
    if rlen <0:
        break
    
    if plef == a:
        if qlef == b:
            break
        else :
            ima = q[qlef]
            tmp = "q"
    elif qlef == b:
        ima = p[plef]
        tmp = "p"
    elif p[plef] >= q[qlef]:
        ima = q[qlef]
        tmp = "q"
    else:
        ima = p[plef]
        tmp = "p"
    if ima < r[rlen]:
        ans += r[rlen]
        rlen -= 1
        if tmp == "q":
            qlef += 1
        else:
            plef += 1
    
    else:
        break
if plef != a:
    for i in range(plef,a):
        ans += p[i]
if qlef != b:
    for i in range(qlef,b):
        ans +=q[i]
print(ans)




Measured memory_bytes: 105444
import sys
from collections import deque
sys.setrecursionlimit(100000)

h,w,k = map(int,input().split())
y1,x1,y2,x2 = map(int,input().split())
grid = []
grid.append(['@']*(w+2))
for i in range(h):
    grid.append(['@']+list(input())+['@'])
grid.append(['@']*(w+2))

q = set()
next_q = set()
next_q.add((y1,x1))
ans = 0
while True:
    if not next_q:
        print(-1)
        exit()
    for y,x in next_q:
        grid[y][x] = '@'
    q = next_q
    next_q = set()
    while q:
        y,x = q.pop()
        if (y,x) == (y2,x2):
            print(ans)
            exit()
        for i in range(1,k+1):
            if grid[y+i][x] == '@':
                break
            next_q.add((y+i,x))
        for i in range(1,k+1):
            if grid[y-i][x] == '@':
                break
            next_q.add((y-i,x))
        for i in range(1,k+1):
            if grid[y][x+i] == '@':
                break
            next_q.add((y,x+i))
        for i in range(1,k+1):
            if grid[y][x-i] == '@':
                break
            next_q.add((y,x-i))
    ans += 1

Measured memory_bytes: 158192
#include<bits/stdc++.h>
#define __2012_12_21__ 735224
#define MAX_YEAR 10000000

unsigned days[MAX_YEAR + 1];
int month[2][13] = {
  { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
  { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
};

bool urudosi(int year){
  return year % 400 == 0 || (year % 100 != 0 && year % 4 == 0);
}
void init_set() {
  for(int i = 1; i <= MAX_YEAR; i++) {
    days[i] = days[i - 1] + 365 + urudosi(i - 1);
  }
}

int main(){
  char buff[256];
  int y, m, d; //西暦
  int b, ka, t, w, ki; //マヤ長期歴

  init_set();
  while(strcmp(fgets( buff, sizeof(buff), stdin),"#\n") != 0){
    if(sscanf( buff, "%d.%d.%d.%d.%d", &b, &ka, &t, &w, &ki) == 5){
      unsigned allday = b * 144000 + ka * 7200 + t * 360 + w * 20 + ki + __2012_12_21__;
      y = std::lower_bound( days, days + MAX_YEAR, allday) - days - 1;
      allday -= days[y];
      bool uru = urudosi(y);
      m = std::lower_bound( month[uru], month[uru] + 13, allday) - month[uru];
      d = allday - month[uru][m - 1];
      printf("%d.%d.%d\n", y, m, d);
    }else{
      unsigned allday = days[b] + month[urudosi(b)][ka - 1] + t - __2012_12_21__;
      ki = allday % 20;
      w = allday / 20 % 18;
      t = allday / 360 % 20;
      ka = allday / 7200 % 20;
      b = allday / 144000 % 13;
      printf("%d.%d.%d.%d.%d\n", b, ka, t, w, ki);
    }
  }
}

Measured memory_bytes: 40260
#include<stdio.h>
int main()
{
	int n,a[4],i,j,t,l,s,o=0;
	while(1)
	{
		o=0;
		scanf("%d",&n);
		if(n==0)
		{
			break;
		}
		while(1)
		{

			if(n==1111||n==2222||n==3333||n==4444||n==5555||n==6666||n==7777||n==8888||n==9999)
			{
				printf("NA\n");
				break;
			}
			if(n==6174)
			{
				printf("%d\n",o);
				break;
			}
			a[0]=n/1000;
			a[1]=n%1000/100;
			a[2]=n%1000%100/10;
			a[3]=n%1000%100%10;
	
			for(i=0;i<4;i++)
			{
				for(j=i+1;j<4;j++)
				{
					if(a[i]<a[j])
					{	
						t=a[i];
						a[i]=a[j];
						a[j]=t;
					}
	
				}
			}
			l=a[0]*1000+a[1]*100+a[2]*10+a[3];
			s=a[3]*1000+a[2]*100+a[1]*10+a[0];
			n=l-s;
			o++;
		}
 
	}
return 0;
}

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



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;
	set<string> list;

	for (unsigned i = 0; i < n; ++i) {
		string s;
		cin >> s;
		list.insert(s);
	}

	cout << list.size();



}


Measured memory_bytes: 19264
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Y cout<<"YES"<<endl
#define N cout<<"NO"<<endl
map<char,ll>mpp;
map<ll,ll>mp;

int main()
{
    ll q,n,m,i,j,t=0,x,y,x1,y1,k;


    string s,str;

    cin>>s>>str;

    string kk=str.substr(0,(str.size()-1));

    //cout<<kk<<endl;

    if(kk==s){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


    return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,n;
	cin>>x>>n;
	int a[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}

	int ans=169,diff=169;
	for(int i=0;i<=101;i++)
	{
		int f=1;
		for(int j=0;j<n;j++)
		{
			if(i==a[j])
			{
				f=0;break;
			}
		}
		if(f&&diff>abs(i-x)){ans=i;diff=abs(i-x);} 

	}
	cout<<ans<<endl;





	return 0;

}

Measured memory_bytes: 3596
/*author:anshumanc007
   created on:12/01/2019
            */
//:P
#include <bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std;
#define MAX 100005
long long int MOD=998244353;
long long int INF=1e18;
long long int dp[MAX];
//knapsack2:O
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int i,j,k,l,m,n,o,p,maxi=0,w;
    cin>>n>>w;
    long long int W[n];
    long long int V[n];
    for(i=0;i<n;i++)
    {
        cin>>W[i]>>V[i];
        
    }
    for(i=0;i<=100000;i++)
    {
        dp[i]=INF;
    }
    dp[0]=0;
    
        for(i=0;i<n;i++)
        {
            for(j=100000;j>=0;j--)
    {
            if(j>=V[i])
            {
                dp[j]=min(dp[j],dp[j-V[i]]+W[i]);
            }
        }
       
    }
    for(j=0;j<=100000;j++)
    {
         if(dp[j]<=w)
    { 
            if(j>maxi)
    {
                maxi=j;            
            }
        }
    }
    
    cout<<maxi<<endl;
}
    

Measured memory_bytes: 1024
import sys
from sys import stdin

mod = 1000000007

n = int(input())
# s = stdin.readline().rstrip()
# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in input().split()]

a = sorted(a)
predict = [n - (((n - i + 1) // 2) * 2) + 1 for i in range(0, n)]
if a != predict:
    print(0)
    sys.exit()
print(pow(2, (n // 2), mod))
# print(*data, sep='\n')


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

int main(){
    string s;
    cin >> s;
    char a;
    string ans="Good";
    for (int i = 0; i < s.size(); i++)
    {
        if(a==s.at(i)){
            ans="Bad";
        }
        a=s.at(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vs = vector<string>;
using ii = vector<vector<long long>>;
int main() {
	ll a, b;
	cin >> a >> b;
	ll x = pow(2, b);
	if (b == 0) {
		x = 1;
	}
	ll z = x * b * 1900 + x * (a-b) * 100;
	cout << z << endl;
}

Measured memory_bytes: 4044
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = float("inf")
for i in range(M):
  x,y,c = map(int,input().split())
  ans = min(a[x-1]+b[y-1]-c,ans)
  
ans = min(ans,min(a)+min(b))
    
print(ans)
    

Measured memory_bytes: 24712
parseInt(x) = parse(Int,x)

function main()
  S = chomp(readline())
  s = [0,0,0,0]
  for i = 1:4
    s[i] = parseInt(S[i])
  end
  c = 0
  for bit = 0:((1<<3)-1)
    op = zeros(Int,3)
    t = []
    for i = 0:2
      bit & (1 << i) != 0 ? op[i+1] = 1 : op[i+1] = -1 
    end
    for i = 1:3
      op[i] == 1 ? push!(t,"+") : push!(t,"-") 
    end
    u = s[1] +(op[1]*s[2])+(op[2]*s[3])+(op[3]*s[4])
    if u == 7 && c == 0
      println(s[1],t[1],s[2],t[2],s[3],t[3],s[4],"=7")
      c = 1
    end
  end
end

main()

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

def rating(X):
    if X <= 599: return 8
    if X <= 799: return 7
    if X <= 999: return 6
    if X <= 1199: return 5
    if X <= 1399: return 4
    if X <= 1599: return 3
    if X <= 1799: return 2
    if X <= 1999: return 1

    assert(False)


X = int(input())
print(rating(X))

Measured memory_bytes: 61684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int d,n;cin>>d>>n;
    ll tmp=1;
    rep(i,d) tmp*=100;
    if(n==100){
        n++;
    }
    tmp*=n;
    cout<<tmp<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  char str[300],pr[300];int i=0,j=0;
  scanf("%s",str);
  while(str[i]!='\0')
    i++;
  
  while(i>0){
    i--;
    pr[j]=str[i];
    j++;
  }
  pr[j]='\0';
  printf("%s\n",pr);
  return(0);
}

Measured memory_bytes: 524
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    	long startTime = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);

        String s = sc.nextLine();
        String t = sc.nextLine();

        if(t.substring(0, t.length() - 1).equals(s)) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }

    }
}

Measured memory_bytes: 26988
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int main(){

  int b1,b2,b3;
  cin>>b1>>b2>>b3;
  if((b1==1&&b2==0&&b3==0)||(b1==0&&b2==1&&b3==0)||(b1==0&&b2==0&&b3==0))
    cout<<"Close"<<endl;
  else cout<<"Open"<<endl;

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define inf 1e18
using namespace std;
typedef long long ll;
inline ll rd()
{
	ll x=0,p=1;
	char a=getchar();
	while((a<48||a>57)&&a!='-')a=getchar();
	if(a=='-')p=-p,a=getchar();
	while(a>47&&a<58)
	{
		x=(x<<1)+(x<<3)+(a&15);
		a=getchar();
	}
	return x*p;
}
inline void swap(ll &x,ll &y){ll t=x;x=y;y=t;}
const int N=100002;
ll n,l,q,d[N][40],a[N],lgn;
inline int div(ll k)
{
	int l=1,r=n,mid,ans;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(a[mid]>k)r=mid-1;
		else l=mid+1;
	}
	return r;
}
int main()
{
	n=rd();lgn=log2(n);
	for(int i=1;i<=n;i++)a[i]=rd();
	l=rd();q=rd();
	for(int i=1;i<=n;i++)d[i][0]=div(a[i]+l);
	for(int j=1;j<=lgn;j++)
		for(int i=1;i<=n;i++)
			d[i][j]=d[d[i][j-1]][j-1];
	while(q--)
	{
		ll x,y,ans=0;
		x=rd();y=rd();
		if(x>y)swap(x,y);
		for(int j=lgn;j>=0;j--)
			if(d[x][j]<y)x=d[x][j],ans+=(1<<j);
		printf("%lld\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 32896
#include <bits/stdc++.h>
using namespace std;
int pow(int a,int b){
    if(b==0) return 1;
    else if(b%2==0) return pow(a,b/2)*pow(a,b/2);
    return pow(a,(b-1)/2)*pow(a,(b-1)/2)*a;
}   
int main() {
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=100000;i++){
        if(pow(k,i-1)<=n && n<=pow(k,i)-1){
            cout<<i;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int a, b, c, d;
int main() {
	cin >> a >> b >> c >> d;
	a = max(a, c); b = min(b, d);
	cout << max(b - a, 0) << endl;
	return 0;
}

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

int main() {
	int n,count,flag;
	while(1){
		count = 0;
		cin >> n;
		if(n == 0)break;
		else if(n == 1){
			cout << 1 <<endl;
			continue;
		}
		else if(n%2 == 0){
			for(int i = n+1;i < n*2;i+=2){
				flag = 0;
				for(int j = 3;j <= sqrt(i);j+=2){
					if(i%j == 0){
						flag = 1;
						break;
					}
				}
				if(flag == 0)count++;
			}
		}
		else if(n%2 == 1){
			for(int i = n+2;i < n*2;i+=2){
				flag = 0;
				for(int j = 3;j <= sqrt(i);j+=2){
					if(i%j == 0){
						flag = 1;
						break;
					}
				}
				if(flag == 0)count++;
			}
		}
		cout << count <<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define pb push_back
#define MOD 1000000007
#define sz5 100005
#define sz6 1000005
#define UP upper_bound
#define LB lower_bound
#define F first
#define S second
#define PI pair<int,int>
#define PL pair<ll,ll>
#define VI vector<int>
#define VL vector<ll>

void test_case(void) {

}

int main() {
    FAST

    #ifndef ONLINE_JUDGE
        // freopen("in", "r", stdin);
        // freopen("out", "w", stdout);
    #endif

    ll n,k,la,lb;
    cin>>n>>k;
    ll height[n+5], dp[n+5];
    for(la=1;la<=n;la++)
        cin>>height[la];

    dp[0]=dp[1]=0;
    
    for(la=2;la<=n;la++){
        dp[la]=INT_MAX;
        for(lb=la-1;lb>=max(1LL, la-k);lb--)
            dp[la]=min(dp[la], dp[lb]+abs(height[la]-height[lb]));
    }

    cout<<dp[n]<<endl;


    return 0;
}

Measured memory_bytes: 5184
#include <iostream>

using namespace std;
typedef long long ll;
int main()
{
   int m;
   cin >> m;
   ll r = 0;
   ll num = 0;
   for(int i = 0; i<m; i++){
       int d;
       cin >> d;
       ll c;
       cin >> c;
       ll nine = (d*c+r)/9;
       r = (d*c+r)%9;
       if(r==0){
           r = 9;
           nine--;
       }
       num += c+nine;
   }
   num--;
   cout << num << endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int n;
  cin >> n;
  int i=1;
  for(int i = 1; i <= n; i++){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
    cout << " " << i;
    break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, k, a[2005], memo[2005];
signed main() {
	cin >> n >> k;
	rep(i, n) {
		memo[i] = inf;
		cin >> a[i];
	}
	int ans = inf;
	rep(i, n) {
		int sum = 0;
		rep(j, n) {
			memo[j] = min(memo[j], a[(i - j + n) % n]);
			sum += memo[j];
		}
		sum += k * i;
		ans = min(ans, sum);
	}
	cout << ans << endl;
}


Measured memory_bytes: 764
import numpy as np

s=input()
t=input()
s_cnt=np.zeros(26)
s_letterPlace=[[] for _ in range(26)]
for i,si in enumerate(s):
    num=ord(si)-ord('a')
    s_cnt[num]+=1
    s_letterPlace[num].append(i)

s_multiLetter=[]
for cnt,place in zip(s_cnt,s_letterPlace):
    if cnt>1:
        s_multiLetter.append(place)

t_cnt=np.zeros(26)
t_letterPlace=[[] for _ in range(26)]
for i,ti in enumerate(t):
    num=ord(ti)-ord('a')
    t_cnt[num]+=1
    t_letterPlace[num].append(i)

t_multiLetter=[]
for cnt,place in zip(t_cnt,t_letterPlace):
    if cnt>1:
        t_multiLetter.append(place)
# print(len(s_multiLetter))
# print(len(t_multiLetter))

flag=1
if len(s_multiLetter)!=len(t_multiLetter):
    flag=0
elif len(s_multiLetter)==0 & len(t_multiLetter)==0:
    flag=1
elif len(s_multiLetter)*len(t_multiLetter)==0:
    flag=0
else:
    for s_place in s_multiLetter:
        if(flag==1):
            for t_place in t_multiLetter:
                if(s_place==t_place):
                    flag=1
                    break
                else:
                    flag=0

print('Yes' if flag==1 else 'No')

Measured memory_bytes: 29692
n, y = map(int, input().split())

a, b, c = (-1, -1, -1)
for i in range(n + 1):
  for j in range(n + 1 - i):
    k = n - (i + j)
    if 10000 * i + 5000 * j + 1000 * k == y:
      a, b, c = (i, j, k)
      break
print(a, b, c)

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int H, W;
    cin >> H >> W;

    vector<string> a(H);
    rep(i, H) cin >> a[i];

    vector<int> b(30);
    rep(i, H) {
        rep(j, W) {
            char c = a[i][j];
            b[c - 'a']++;
        }
    }

    int g1, g2, g4;
    
    if (H * W % 2 == 1) {
        g1 = 1;
        g2 = H / 2 + W / 2;
        g4 = H / 2 * W / 2;
    } else if (H % 2 == 0 && W % 2 == 0) {
        g1 = 0;
        g2 = 0;
        g4 = H * W / 4;
    } else {
        g1 = 0;
        g2 = (H % 2 == 0)? H / 2 : W / 2;
        g4 = H / 2 * W / 2;
    }

    rep(i, g4) {
        rep(j, 30) {
            if (4 <= b[j]) {
                b[j] -= 4;
                break;
            }
        }
    }

    rep(i, g2) {
        rep(j, 30) {
            if (2 <= b[j]) {
                b[j] -= 2;
                break;
            }
        }
    }

    rep(i, g1) {
        rep(j, 30) {
            if (1 <= b[j]) {
                b[j] -= 1;
                break;
            }
        }
    }

    bool ans = true;
    rep(i, 30) {
        if (b[i] > 0) {
            ans = false;
            break;
        }
    }

    if (ans) {
        puts("Yes");
    } else {
        puts("No");
    }
}

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

int main()
{
	int n, s;
	int x[100], y[100], h[100];
	bool f;

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i] >> h[i];

	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			int u = 0;
			while (h[u] == 0)
				u++;
			s = h[u] + abs(x[u] - i) + abs(y[u] - j);
			f = 1;
			for (int k = 0; k < n; k++) {
				if ((h[k] > 0 && h[k] + abs(x[k] - i) + abs(y[k] - j) > s) ||
					h[k] + abs(x[k] - i) + abs(y[k] - j) < s) {
					f = 0;
					break;
				}
			}
			if (f) {
				cout << i << " " << j << " " << s << endl;
				break;
			}
		}
		if (f)
			break;
	}

	return 0;
}

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

using namespace std;

#define pb push_back
typedef vector<int> vi;

const int mod = 1e9 + 7;
int n, K, ans;
vi prime, dp;

int fpow(int a, int m) {
    int res = 1;
    for(; m; m >>= 1, a = (1LL * a * a) % mod) if(m & 1) res = (1LL * res * a) % mod;
    return res;
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> K;
    for (int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            prime.pb(i);
            if(i < n / i) prime.pb(n / i);
        }
    }
    sort(prime.begin(), prime.end() );
    dp.resize(prime.size() );

    for(int i = 0; i < prime.size(); ++i) {
        dp[i] = fpow(K, (prime[i] + 1) >> 1);
        for(int j = 0; j < i; ++j) {
            if( (prime[i] % prime[j]) == 0) dp[i] -= dp[j], dp[i] %= mod;
        }
        ans += (1LL * (prime[i] & 1 ? prime[i] : prime[i] >> 1) * dp[i]) % mod;
        ans %= mod;
    }

    cout << (ans + mod) % mod;

    return 0;
}


Measured memory_bytes: 256