akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using LL = int64_t;
const LL INF=1e18;
double a[1005];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;cin>>n;
    double t,b;cin>>t>>b;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        a[i]=t-a[i]*0.006;
    }
    int ans=1;
    for(int i=1;i<=n;i++) if(fabs(a[i]-b)<fabs(a[ans]-b)) ans=i;
    cout<<ans;
    return 0;
}


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

int main(){
	int n,d1,d2,d3,d4,res;
	set<int> st;
	cin >> n;
	if(n == 1){
		cin >> d1;
		st.insert(d1);
	}
	else if(n == 2){
		cin >> d1 >> d2;
		st.insert(d1);
		st.insert(d2);
		st.insert(d1*10 + d2);
	}
	else{
		cin >> d1 >> d2 >> d3;
		for(int i = 3;i <= n;i++){
			st.insert(d1);
			st.insert(d2);
			st.insert(d3);
			st.insert(d1 * 10 + d2);
			st.insert(d2 * 10 + d3);
			st.insert(d1 * 100 + d2 * 10 + d3);
			if(i == n)break;
			d1 = d2;
			d2 = d3;
			cin >> d3;
		}
	}
	for(int i = 0;i < 1000;i++){
		if(st.count(i) == 0){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct res { ll num; ll top; ll size; };

int main() {
  int N; cin >> N;
  map<int, priority_queue<int, vector<int>, greater<int>>, greater<int>> a; a[0].push(0);
  rep(i,N) { int tmp; cin >> tmp; a[tmp].push(i); }

  vector<res> count;
  for (auto x: a) count.push_back({x.first,x.second.top(),(ll)x.second.size()});

  ll result[N] = {};
  ll now = 0;
  repr(i,1,count.size()) {
    now += count[i-1].size;
    count[i].top = min(count[i].top, count[i-1].top);
    result[count[i-1].top] += (count[i-1].num-count[i].num) * now;
  }
  rep(i,N) cout << result[i] << endl;
  return 0;
}

Measured memory_bytes: 15860
#include <limits.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>

namespace test {
std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
}
}  // namespace test

using namespace std;

int main(void) {
    int a,b,t; cin >> a >> b >> t;
    cout << (t / a) * b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <fstream>
#include <set>
#include <cmath>

using namespace std;

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

    int n, x;
    cin >> n >> x;

    int64_t ans = 0;
    int cur_val;
    cin >> cur_val;

    if (cur_val > x) {
        ans += cur_val - x;
        cur_val = x;
    }
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;

        int diff = max(0, cur_val + p - x);
        ans += diff;
        cur_val = p - diff;
    }
    cout << ans << endl;
    return 0;
}


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

int main(void)
{
	int N,i;
	long long int ans,tmp;
	
	scanf("%d",&N);
	
	ans = 1;
	i=1;
        tmp = pow(10,9) + 7;
	
	while(i <= N){
		ans = (ans * i) % tmp;
		i++;
	}
	
		
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

const int MOD = 1e9 + 7;

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

	long long N;
	cin >> N;

	long long result = 1;
	for (long long i = 1; i <= N; i++)
	{
		result *= i;
		result %= MOD;
	}

	cout << result;
	
	return 0;
}


Measured memory_bytes: 3612
import std.stdio, std.string, std.range, std.algorithm, std.math, std.typecons, std.conv;                                                                                                                                                                                                                                                                                               void main() {                                                                                                                                                                                 int M, N;                                                                                                                                                                                   readf("%d %d\n", &N, &M);                                                                                                                                                                   int[] cnt = new int[N];                                                                                                                                                                     foreach (i; 0..M) {                                                                                                                                                                           int a, b;                                                                                                                                                                                   readf("%d %d\n", &a, &b);                                                                                                                                                                   cnt[a-1]++;                                                                                                                                                                                 cnt[b-1]++;                                                                                                                                                                               }                                                                                                                                                                                           cnt.each!(a => a.writeln);                                                                                                                                                                }       

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////
int gcd(int p, int q){
if(p % q == 0)return q;
return gcd(q, p % q);
}

void solve()
{

    ll a,b,c;
    cin>>a>>b>>c;

    cout<<c<<" "<<a<<" "<<b;

    return;
}
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

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

using namespace std;

int main()
{
    int N;
    int A[100001];

    scanf("%d", &N);

    for (int i = 0; i < N; i++){
        scanf("%d", A + i);
        if (i & 1) A[i] ^= 1;
    }

    int ans = 0;

    vector<int> v;
    int len = 1;
    for (int i = 1; i < N; i++){
        if (A[i] != A[i - 1]){
            v.push_back(len);
            len = 1;
        }
        else len++;
    }
    v.push_back(len);
    v.push_back(0); v.push_back(0);

    for (int i = 0; i <= (int)v.size() - 3; i++){
        ans = max(ans, v[i] + v[i + 1] + v[i + 2]);
    }

    printf("%d\n", ans);


    return (0);
}

Measured memory_bytes: 1800
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>

#define div 1000000000+7

typedef long long ll;

using namespace std;


int main() {
    long x;
    long count = 0;
    cin >> x;
    for(int i = 1; i < 2147483647; i++){
        x = x - i;
        count++;
        if(x <= 0){
            break;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,s;cin>>k>>s;
  int ans=0;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      int z=s-x-y;
      if(0<=z&&z<=k)ans++;
    }
  }
  cout<<ans;     
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;
    int M = S.size();

    vector<char> ans;
    REP(i,M){
        int c = S[i] - 'A';
        c = (c + N) % 26;
        ans.push_back(c + 'A');
    }

    for(auto&& a : ans){
        cout << a;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
A,B = map(int,input().split())
def lcm(a, b): # 最小公倍数
    def gcd(a, b): # 最大公約数
        a = abs(a)
        b = abs(b)
        while b:
            a, b = b, a % b
        return a # int
    return a * b // gcd(a, b) # int
print(lcm(A,B))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while(1){
        C-=B;
        if(C<=0){
            cout << "Yes" << endl;
            break;
        }
        A-=D;
        if(A<=0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(){

	int n,r,c,p,ar[50];
	while(cin>>n>>r){
		if(n==0 && r==0) return 0;
		for(int i=0; i<n; i++) ar[i]=n-i;
		for(int i=0; i<r; i++){
			cin>>p>>c;
			int t1[50],t2[50];
			for(int i=0; i<p-1; i++){
				t1[i] = ar[i];
			}
			for(int i=p-1; i<p+c-1; i++){
				t2[i-p+1] = ar[i];
			}
			for(int i=0; i<c; i++){
				ar[i]=t2[i];
			}
			for(int i=c; i<p+c-1; i++){
				ar[i]=t1[i-c];
			}
		}
		cout<<ar[0]<<endl;
	}

	return 0;
}

Measured memory_bytes: 3076
import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int X = ni();
		System.out.println(X / 500 * 1000 + (X % 500) / 5 * 5);
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21204
N = int(input())
S = list(input())
ans1 = 0
for i in range(1,N):
  ans = 0
  a = S[:i]
  b = S[i:]
  a.sort()
  c = a[0]
  if c in b:
    ans +=1
  for j in range(1,len(a)):
    if a[j]!=c and a[j] in b:
      ans +=1
      c = a[j]
  ans1 = max(ans,ans1)
print(ans1)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		if(x - r < 0 || x + r > W){
			System.out.println("No");
		}
		else if(y - r < 0 || y + r > H){
			System.out.println("No");
		}
		if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 26408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String p = "+";
		String m = "-";
		String w = "/";
		String k = "*";
		String n="?";
		while (true) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if (op.equals(n)) {
				break;
			}

			if (op.equals(p)) {
				System.out.println(a + b);
			} else if (op.equals(m)) {
				System.out.println(a - b);
			} else if (op.equals(w)) {
				System.out.println(a / b);
			} else if (op.equals(k)) {
				System.out.println(a * b);
			}
		}
	}
}



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

using namespace std;

int n, a;
int x[50];
int64_t dp[2][51][50*50+1] = {};

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

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

  dp[0][1][x[0]]++;
  for (int i = 1; i < n; i++) {
    for (int k = 1; k <= i+1; k++) {
      for (int v = 0; v <= 50*k; v++) {
        dp[i&1][k][v] = dp[(i+1)&1][k][v] + (v >= x[i] ? dp[(i+1)&1][k-1][v-x[i]] : 0);
      }
    }
    dp[i&1][1][x[i]]++;
  }

  int64_t c = 0;
  for (int k = 1; k <= n; k++) {
    c += dp[(n-1)&1][k][a*k];
  }

  cout << c << endl;

  return 0;
}


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

typedef long long ll;
ll mod=1e9+7;

ll modpow(ll a,ll b){
  ll ans=1;
  a%=mod;
  while(b){
    if(b&1) ans=ans*a%mod;
    a=a*a%mod;
    b>>=1;
  }
  return ans;
}

ll dp[100000][101];
ll sum[100000][101];

int main(){
  ll n,k;
  cin >> n >> k;
  ll t=sqrt(n);
  for(ll i=1;i<=t;i++) dp[i][1]=1;
  ll now=t+1;
  ll s;
  if((t+1)*t>=n) s=t-1;
  else s=t;
  for(ll i=s;i>=1;i--){
    dp[now][1]=n/i-n/(i+1);
    now++;
  }
  for(ll i=2;i<=k;i++){
    for(ll j=1;j<now;j++){
      sum[j][i-1]=(sum[j-1][i-1]+dp[j][i-1])%mod;
    }
    for(ll j=1;j<now;j++){
      dp[j][i]=(sum[now-j][i-1]*dp[j][1])%mod;
    }
  }
  ll ans=0;
  for(ll i=1;i<now;i++){
    ans=(ans+dp[i][k])%mod;
  }
  if(n!=2) cout << ans << endl;
  else{
    ll fib[110];
    fib[1]=2,fib[2]=3;
    for(ll i=3;i<110;i++) fib[i]=(fib[i-1]+fib[i-2])%mod;
    cout << fib[k] << endl;
  }
  //for(ll i=1;i<=10;i++) cout << dp[i][2] << endl;
}


Measured memory_bytes: 102656
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=10000000000;

void display(long j,vector<long> x){
    cout<<"data "<<j<<" display_start"<<endl;
    for(int i=0;i<x.size();i++){
        cout<<x.at(i)<<" ";
    }
    cout<<endl<<"display_end"<<endl<<endl;
}


//main
int main() {
    
    //入力
    long D,G;
    cin>>D>>G;
    vector<long> p(D+1),c(D+1);
    for(int i=1;i<=D;i++){
        cin>>p.at(i)>>c.at(i);
        c.at(i)/=100;
    }
    
    
    //計算
    long g=G/100;
    vector<long> dp(g+1,INF);
    dp.at(0)=0;//本質でない。
    for(int d=1;d<=D;d++){//d点目
        for(int j=g;j>=0;j--){//dp(j)の更新
            for(long k=1;k<=p.at(d);k++){//0<k<=p.at(d)個とる時
                long prescore=j-d*k-(k==p.at(d))*c.at(d);
                if(prescore<0) dp.at(j)=min(k,dp.at(j));
                else dp.at(j)=min(dp.at(prescore)+k,dp.at(j));
            }
        }
        //display(d,dp);
    }
    
    
    
    
    //出力
    cout<<dp.at(g)<<endl;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int a, b;
	cin >>a >>b;
	if((a<=0)&&(b>=0)) {
		cout <<"Zero" <<endl;
		return 0;
	}
	if (a>0) {
		cout <<"Positive" <<endl;
		return 0;
	}
	if (1==(b-a+1)%2)
		cout <<"Negative" <<endl;
	else
		cout <<"Positive" <<endl;
	return 0;
}



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

bool prime[1000009];

void era(){
    prime[0]=1;
    prime[1]=1;
    for(int i=2;i<1000009;i++){
        if(!prime[i]){
            for(int j=i+i;j<1000009;j+=i) prime[j]=1;
        }
    }
}

int dp[100009][2];

signed main(){
    era();
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    if(!prime[a[0]]){
        dp[0][0]=1;
        dp[0][1]=1;
    }
    for(int i=0;i<n;i++){

        // 1

        if( i+1<n && a[i]<a[i+1] &&!prime[a[i+1]] )dp[i+1][0] += dp[i][0];
        if( i+2<n && a[i]<a[i+1] &&!prime[a[i+1]] )dp[i+1][1] += dp[i][0];

        // 2

        if( i+2<n && a[i]<a[i+2] &&!prime[a[i+2]] )dp[i+2][0] += dp[i][1];
        if( i+3<n && a[i]<a[i+2] &&!prime[a[i+2]] )dp[i+2][1] += dp[i][1];

        dp[i+1][0]%=1000000007;
        dp[i+1][1]%=1000000007;
        dp[i+2][0]%=1000000007;
        dp[i+2][1]%=1000000007;
    }
    cout<<(dp[n-1][0]+dp[n-2][1])%1000000007<<endl;
}


Measured memory_bytes: 6400
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<vector>
#include<stack>
#define maxn 100005
using namespace std;

int main(void)
{
    int n;
    cin >> n;
    int h[maxn];
    for(int i=1; i<=n; i++){
        cin >> h[i];
    }
    int dp[maxn];
    dp[0]=0;
    dp[1]=0;

    for(int i=2; i<=n; i++){
        int a,b;
        a = dp[i-1] + abs(h[i]-h[i-1]);
        if(i-2 > 0)
            b = dp[i-2] + abs(h[i]-h[i-2]);
        else b=0x7fffffff;
        dp[i] = min(a, b);
    }
    cout << dp[n];
    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

char aChar = '.';
char bChar = '#';

void solve(long long A, long long B){
    if(A==1 && B ==1){
        cout << "1 2" << endl;
        cout << ".#" << endl;
        return;
    }
    if(B < A) {
        char tmp  = aChar;
        aChar = bChar;
        bChar = tmp;
        LL tmp2 = A;
        A = B;
        B = tmp2;
    }

    A--;
    if(A == 0) B++;
    vector<string> ans;
    while (B != 1) { 
        string tmp = "";
        REP(i, 100) {
            if(i % 2 == 0 && B != 1) {
                tmp += bChar;
                B--;
            } else {
                tmp += aChar;
            }
        }

        string tmp2(100, aChar);
        ans.PB(tmp);
        ans.PB(tmp2);
    }
    
    while (A != 0) { 
        string tmp = "";
        REP(i, 100) {
            if(i % 2 == 0 && A != 0) {
                tmp += aChar;
                A--;
            } else {
                tmp += bChar;
            }
        }

        string tmp2(100, bChar);
        ans.PB(tmp2);
        ans.PB(tmp);
        
    }

    cout << ans.size() << " 100" << endl;
    REP(i, ans.size()) {
        cout << ans[i] << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int w, h, n;
  cin >> w >> h >> n;
  int w1 = 0;
  int h2 = 0;
  rep(i, n){
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1){
      w1 = max(w1, x);
    }else if(a == 2){
      w = min(w, x);
    }else if(a == 3){
      h2 = max(h2, y);
    }else if(a == 4){
      h = min(h, y);
    }
  }
  if(w1 >= w || h2 >= h){
    cout << 0 << endl;
  }else{
    cout << (w - w1) * (h - h2) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}
const int maxn = 1e5+10;
char s[maxn];
 
int main()
{
    scanf("%s", s+1);
    int n = strlen(s+1);
    bool flg = 1;
    for(int i = 1; i < n; i++){
        if(s[i] != s[n-i])flg = 0;
    }
    if(s[1] != '1' || s[n] != '0')flg = 0;
    if(!flg)puts("-1");
    else{
        int rt = 1;
        for(int i = 2; i <= n; i++){
            printf("%d %d\n", rt, i);
            if(s[i-1] == '1')rt = i;
        }
    }
    return 0;
}


Measured memory_bytes: 1536
import itertools
N,M=map(int,input().split())
branch=[]
for _ in range(M):
    a,b=map(int,input().split())
    branch.append([a,b])
    branch.append([b,a])
ans=0
for perm in itertools.permutations(list(range(1,N+1))):
    f=True
    if perm[0]==1:
        for i in range(N-1):
            if not [perm[i],perm[i+1]] in branch:
                f=False
        if f:
            ans+=1
print(ans)

Measured memory_bytes: 9180
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

const int MAX_V = 100001;
struct edge {
  int num, to;
};
vector<edge> g[MAX_V];

int ans[MAX_V];
int p_color[MAX_V];
int K;

int N;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(edge{i, b});
    g[b].push_back(edge{i, a});
  }

  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int n = q.front();
    q.pop();
    int color = 0;
    for (int i = 0; i < g[n].size(); i++) {
      int next = g[n][i].to;
      int num = g[n][i].num;
      if (ans[num] != 0) {
        continue;
      }
      color++;
      if (color == p_color[n]) {
        color++;
      }
      ans[num] = color;
      p_color[next] = color;
      K = max(K, color);
      q.push(next);
    }
  }

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

Measured memory_bytes: 9344
n, m = map(int, input().split())
a = []
b = []
a = list(map(int, input().split()))
for i in range(m):
    b.append(list(map(int, input().split())))
a.sort()
b.sort(key=lambda x: x[1], reverse=True)
for i in range(n):
    if b == []:
        break
    if a[i] < b[0][1]:
        a[i] = b[0][1]
        if b[0][0] == 1:
            del b[0]
        else:
            b[0][0] -= 1
    else:
        break
print(sum(a))

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

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

    static class BCountingOfTrees {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            // cntする
            // 0->1, 1->x, 2->yなら1^x * x^yとなる
            // 0の根付き木だと思えばいい.
            int n = in.nextInt();
            int[] cnt = new int[n];
            ModInt res = new ModInt(1);
            int max = 0;
            for (int i = 0; i < n; i++) {
                int d = in.nextInt();
                if (i > 0 ^ d > 0) {
                    out.println(0);
                    return;
                }
                cnt[d]++;
                max = Math.max(max, d);
            }
            for (int i = 1; i < max; i++) {
                for (int j = 0; j < cnt[i + 1]; j++) {
                    res = res.mul(cnt[i]);
                }
            }
            out.println(res.getVal());

        }

    }

    static class ModInt {
        long val;
        int MOD = 998244353;

        public ModInt(long i) {
            this.val = (i + MOD) % MOD;
        }

        public ModInt mul(long l) {
            return new ModInt(this.val * l);
        }

        public long getVal() {
            return val;
        }

        public String toString() {
            return Long.toString(val);
        }

    }
}



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

string qwe("yuiophjklnm");

int main() {
	string s;
	while(cin >> s && s != "#"){
		int ans = 0, t = 0;
		for(int i = 0; i < qwe.size(); ++i){
			if(s[0] == qwe[i]){
				t = 1;
				break;
			}
		}
		for(int i = 1; i < s.size(); ++i){
			bool flag = false;
			for(int j = 0; j < qwe.size(); ++j){
				if(s[i] == qwe[j]){
					if(!t){
						ans++;
						t ^= 1;
					}
					flag = true;
					break;
				}
			}
			if(t && !flag){
				ans++;
				t = 0;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

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

int par[SIZE]; //親
int rnk[SIZE]; //木の深さ

//初期化(n要素0オリジン)
void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    rnk[i] = 0;
  }
}

//xの根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

//x,yの属する集合を併合
void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y)return;

  if(rnk[x] < rnk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rnk[x] == rnk[y])rnk[x]++;
  }
}

int n,m;
int a[55],b[55];

int main(){
  cin >> n >> m;
  rep(i,0,m){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
  }
  int ans=0;
  rep(i,0,m){ //i抜き
    init(n);
    rep(j,0,m){
      if(j!=i) unite(a[j],b[j]);
    }
    set<int> S;
    rep(j,0,n){
      S.insert(find(j));
    }
    if(S.size() != 1)ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 764
#include<iostream>
#define INF 100000000
#define MAX 17
using namespace std;
int main(){
	int dp[1<<MAX],n,t[MAX][MAX];
	while(cin>>n,n){
		for(int i=0;i<n;i++)
			for(int j=0;j<n+1;j++)
				cin>>t[i][j];
		for(int i=0;i<(1<<n);i++)
			dp[i]=INF;
		for(int i=0;i<n;i++)
			dp[1<<i]=t[i][0];
		dp[0]=0;
		for(int i=1;i<=n;i++){
			int comb=(1<<i)-1;
			while(comb<(1<<n)){
				for(int j=0;j<n;j++){
					if(comb&(1<<j)){
						for(int k=0;k<n;k++){
							if((comb&(1<<k))&&k!=j){
								dp[comb]=min(dp[comb],min(dp[comb&~(1<<j)]+t[j][k+1],dp[comb&~(1<<j)]+t[j][0]));
							}
						}
					}
				}
				int x=comb&-comb,y=comb+x;
				comb=((comb&~y)/x>>1)|y;
			}
		}
		cout<<dp[(1<<n)-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1128
#include <iostream>
#include <string>
//#include <cstring>
//#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
//#include <stack>
//#include <queue>
//#include <chrono>
//#include <numeric>
//#include <set>
//#define _USE_MATH_DEFINES
//#include <cmath>
//#include <math.h>
//#include <iomanip>
//#include <list>
//#include <limits>

using namespace std;
const int infty = static_cast <int> (pow(256, sizeof(int)) / 2 - 1);

class cRSQ
{
	int m_n;
	vector<int> va;

public:
	cRSQ(int n);
	void add(int i, int x);
	int getSum(int s, int t);

};

cRSQ::cRSQ(int n)
{
	m_n = n + 1;
	va.resize(m_n);
}

void cRSQ::add(int i, int x)
{
	while(i < m_n)
	{
		va[i] += x;
		i += i & -i;
	}

}

int cRSQ::getSum(int s, int t)
{
	int ss = 0 , st = 0;
	s--;
	while(s > 0)
	{
		ss += va[s];
		s -= s & -s;
	}
	while(t > 0)
	{
		st += va[t];
		t -= t & -t;
	}
	return st - ss;
}

int main()
{
	////ifstream fin("DSL_2_A_in3.txt");
	//ifstream fin("test.txt");
	//if (!fin.is_open())
	//{
	//	cout << "File not found." << endl;
	//	return 0;
	//}

	//fin.tie(0);
	//ios::sync_with_stdio(false);

	//int n,q;
	//fin >> n >> q;
	//fin.ignore();

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, q;
	cin >> n >> q;
	cin.ignore();

	int com, x, y;
	cRSQ cr(n);

	for (int i = 0; i < q; ++i)
	{
		cin >> com >> x >> y;
		//fin >> com >> x >> y;
		switch (com)
		{
		case 0:
			cr.add(x, y);
			break;
		case 1:
			cout << cr.getSum(x, y) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3256
N,M=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
B=sorted(A)
s=0
m=0
i=0
while s<M:
  if B[i][1]>0:
    m+=B[i][0]
    B[i][1]-=1
    s+=1
  else:
    i+=1
print(m)

Measured memory_bytes: 28652
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define maxn 503
using namespace std;
int g[maxn][maxn];
main(){
	int H, W, h, w;
	cin >> H >> W >> h >> w;	
	if(H%h==0 && W%w == 0){
		cout << "No";
	}	else	{		
		cout << "Yes\n";
		if(H%h!=0){
			For(i,0,H-1){
				int pr = 0;
				if(i%h==0){
					pr = 1000*(h-1)-1;					
				}	else	{
					pr =  -1000;
				}
				For(j,1,W)	{
					printf("%d ",pr);
				}
				printf("\n");
			}
		}	else	{
			int pr = 0;
			For(i,1,H){								
				For(j,0,W-1)	{					
					if(j%w==0){
						pr = 1000*(w-1)-1;
					}	else	{
						pr =  -1000;
					}
					printf("%d ",pr);
				}
				printf("\n");
			}
		}
	}
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<long long> a(n+1),b(n);

    for(int i=0;i<n+1;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    long long cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]<b[i]) {
            cnt+=a[i];
            cnt+=min(b[i]-a[i],a[i+1]);
            a[i+1]-=min(b[i]-a[i],a[i+1]);
        }else {
            cnt+=b[i];
        }

    }

    cout << cnt<<endl;

    return 0;
}


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

using namespace std;

int main()
{
	string s;

	cin >> s;

	int n = s.size();

	vector<int> res(n);

	for (int i = 1; i < n; i++) {
		if (s[i - 1] == 'R' && s[i] == 'L') {
			int j = i - 2;
			int k = i + 1;
			double left = 1;
			double right = 1;

			while (j >= 0 && s[j] == 'R') {
				right++;
				j--;
			}
			while (k < n && s[k] == 'L') {
				left++;
				k++;
			}

			int rightStaying = ceil(right / 2.0);
			int rightLeaving = right - rightStaying;
			int leftStaying = ceil(left / 2.0);
			int leftLeaving = left - leftStaying;
			res[i - 1] = rightStaying + leftLeaving;
			res[i] = leftStaying + rightLeaving;

			i = k;
		}
	}

	for (auto val : res) cout << val << " ";
}

Measured memory_bytes: 1024
n=int(input())
h=list(map(int, input().split()))
c=0
if n!=1:
    for i in reversed(range(n-1)):
        if h[i]==h[i+1]+1:
            h[i]-=1
        elif h[i]-h[i+1]>=2:
            c=1
    if c==0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Measured memory_bytes: 14252
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
 
        System.out.printf("%d %d\n", a * b, (a + b) * 2);
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(ll)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(ll)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b; cin>>a>>b;
    int k; cin>>k;
    set<ll> s;
    FOR(i,a,a+k-1){
        if (i>b) break;
        s.ins(i);
    }
    RFOR(i,b,b-k+1){
        if (i<a) break;
        s.ins(i);
    }
    for(auto e:s){
        cout<<e<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
 
namespace IO{
    const int insiz = 1 << 12, outsiz = 1 << 18;
    char in[insiz], *A(in), *B(in); char out[outsiz], *ptr(out);
    inline char getc(){
    	#ifndef LOCAL
        return (A == B) && (B = (A = in) + fread(in, 1, insiz, stdin), A == B) ? EOF : *A++;
        #endif
        return getchar();
    }
    template <typename T> inline T read(){
        T ret(0), p(1); char ch(getc());
        while(ch < '0' || ch > '9'){
            if(ch == '-') p = -1; ch = getc();
        }
        while(ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getc();
        return ret*p;
    }
    inline void flush(){ fwrite(out, 1, ptr - out, stdout); ptr = out; }
    template <typename T> inline void write(T x, char cmd = '\n'){
        if(x < 0) *ptr++ = '-', x = -x;
        if(x == 0) *ptr++ = '0';
        static char s[123]; int cnt = 0;
        for(; x; x /= 10) s[++cnt] = x % 10 + '0';
        for(; cnt; --cnt) *ptr++ = s[cnt];
        *ptr++ = cmd;
        if((outsiz >> 1) > ptr - out) flush();
    }
} using IO::getc; using IO::read; using IO::write; using IO::flush;
 
char out[212345], stay[212345]; 
int t; 

inline bool check(char o, char s, int xl, int xr){
	xr = -xr;
	int w = 0;
	for(int i(0); i < t; ++i){
		if(out[i] == o){
			++w; if(w > xl) return false;
		}
		if(stay[i] == s){
			--w; if(w < xr) ++w;
		}
	}
	return true;
}

int main(){
	int n, m; scanf("%d%d%d", &n, &m, &t);
	int x, y; scanf("%d%d", &x, &y);
	scanf("%s%s", out, stay);
	if(check('L', 'R', y - 1, m - y) && check('R', 'L', m - y, y - 1) &&
	check('U', 'D', x - 1, n - x) && check('D', 'U', n - x, x - 1)) 
		printf("YES\n");
	else 
		printf("NO\n");
	flush(); return 0;
}
 


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>

using namespace std;


int main(void)
{
    string n;
    while(cin>>n){
        for(int i=0; i<n.length(); i++){
            if(n[i]=='@'){
                i++;
                int re=n[i]-'0';
                i++;
                for(int j=0; j<re; j++){
                    cout<<n[i];
                }
            }else{
                cout<<n[i];
            }
        }
        cout<<endl;
    }
    
}

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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    deque<char> S;
    string s;
    cin >> s;
    rep(i,s.length()){
        S.push_back(s[i]);
    }
    int Q;
    cin >> Q;
    int i = 0;
    int T, F;
    char c;
    int revflag = -1;
    while(i<Q){
        cin >> T;
        if(T==1){
            revflag *= -1;
            i += 1;
        }
        else if(T==2){
            cin >> F;
            cin >> c;
            if(F==1){
                if(revflag==-1) S.push_front(c);
                else if(revflag==1) S.push_back(c);
            }
            else if(F==2){
                if(revflag==-1) S.push_back(c);
                else if(revflag==1) S.push_front(c);
            }
            i += 1;
        }
    }
    if(revflag==1) reverse(S.begin(), S.end());
    rep(i,S.size()){
        cout << S[i];
    }

    return 0;
}

Measured memory_bytes: 896
H,W,D=gets.chomp.split.map(&:to_i)
p = Array.new(H*W+1)
H.times do |i|
  gets.chomp.split.map(&:to_i).each_with_index do |v,j|
    p[v] = [i,j]
  end
end

d = [0] * (D+1)
(D+1).upto(H*W) do |i|
  d[i] = d[i-D] + (p[i][0] - p[i-D][0]).abs + (p[i][1] - p[i-D][1]).abs
end

Q=gets.to_i
Q.times do
  l,r = gets.chomp.split.map(&:to_i)
  puts d[r] - d[l]
end


Measured memory_bytes: 11644
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007
const int MAX=100000;

int main(int argc, char const *argv[]) {
  ll n,k,cnt[MAX];
  std::cin >> n >> k;
  for(int i=0; i<n; i++) cnt[i]=0;
  
  for(int i=0; i<n; i++){
    int a,b;
    std::cin >> a >> b;
    cnt[a]+=b;
  }

  for(int ans=1; ans<=MAX; ans++){
    if(k<=cnt[ans]){
      std::cout << ans << '\n';
      break;
    }
    k-=cnt[ans];
  }
  
  return 0;
}


Measured memory_bytes: 1024
/*

*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <deque>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define fi first
#define se second
 
using namespace std;

string s;

int main () {
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

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

int main() {
  ll N, X;
  cin >> N >> X;
  
  ll ans = N;
  ll a = max(N - X, X);
  ll b = min(N - X, X);
  
  while (true) {
    ans += a / b * 2 * b;
    if (a % b == 0) {
      ans -= b;
      break;
    } else {
      ll tmp = a;
      a = b;
      b = tmp % b;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
open Batteries

let solve (a, b) (x, y) =
  let ratio = max ((a-1) / x+1) ((b-1) / y+1) in
  (x*ratio, y*ratio)

let () =
  IO.lines_of stdin
  |> Enum.skip 1
  |> Enum.map (fun l -> Scanf.sscanf l "%d %d" (fun x y -> (x, y)))
  |> Enum.fold solve (1, 1)
  |> fun (x, y) -> Int.print stdout (x + y)


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


Measured memory_bytes: 5596
#include<bits/stdc++.h>
typedef long long ll;
const int N = 2e5+1;
using namespace std;
int n;
struct ft{
    ll a[N];
    ll qry(int r){
        ll ret = 0;
        for(;r>=0;r=(r&(r+1))-1)ret=max(ret,a[r]);
        return ret;
    }
    void upd(int i,long long v){
        for(;i<=n;i=(i|(i+1)))a[i]=max(a[i],v);
    }
}f;
int main(){
    cin>>n;
    vector<int> h(n),a(n);
    for(int i=0;i<n;i++)cin>>h[i];
    for(int i=0;i<n;i++)cin>>a[i];
    //This is a O(nlogn) solution using a fenwick tree
    for(int i=0;i<n;i++){
        ll prefix_max = f.qry(h[i]-1);
        f.upd(h[i],prefix_max+a[i]);
    }
    ll ans=f.qry(n);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3328
S = input()
N = int(len(S))

S_inv = S[::-1]

S_mae = S[:int((N-1)/2)]
S_mae_inv = S_mae[::-1]

S_ushiro = S[int((N+1)/2):]
S_ushiro_inv = S_ushiro[::-1]

if (S == S_inv and S_mae == S_mae_inv and S_ushiro == S_ushiro_inv):
    print("Yes")

else:
    print("No")

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    string S; cin >> S;
    int cnt = 0;

    REP(i, S.size()) {
        if(i == 0) continue;

        if(S[i] != S[i - 1]) {
            continue;
        } else if(S[i] == S[i - 1]) {
            if(S[i] == '0') {
                S[i] = '1';
            } else {
                S[i] = '0';
            }
            cnt++;
        }
    }

    cout << cnt << endl;
}

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

using namespace std;

int main(){
  int i, n, m, k;
  vector<int> data;
  vector<int>::iterator iter;

  while(1){
    cin >> n >> k >> m;
    if(n == 0 && k == 0 && m == 0) break;

    for(i=0; i<n; ++i)
      data.push_back(i+1);

    data.erase(data.begin()+m-1);

    i = m-1;
    while(data.size() != 1){
      i += (k-1);
      if(i >= data.size()) i %= data.size();
      data.erase(data.begin()+i);
    }

    cout << data[0] << endl;
    data.clear();
  }

  return 0;
}

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

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

  ll r, c;
  cin >> r >> c;

  if (r == 1 || c == 1) {
    cout << 1 << '\n';
    return (0);
  }

  cout << (r * c + 1) / 2 << '\n';

  return (0);
}

Measured memory_bytes: 3512
//shara's here
//私は大きな男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
#include <bits/stdc++.h>
using namespace std;
//fold
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll> >
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
ll sumi(ll x){
	ll sum=0;
	while(x!=0){
	sum+=x%10;
	x/=10;
	}
	return sum;}
int main(){
	ll x;
	cin>>x;
	if((x%(sumi(x))==0))cout<<"Yes"<<endl;    
    else cout<<"No"<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int a;
	cin >> a;
	a = 3 * a * a;
	cout << a << endl;
}


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

  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(-100<=x&&x<=100 && 0<=W&&W<=100 && -100<=y&&y<=100 && 0<=H&&H<=100 &&0<=r&&r<=100 )
  {
    if(x+r>W || y+r>H || r>x || r>y)
      printf("No\n");
    else
      printf("Yes\n");
  }

}

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

int a,sum,ans,dx[6]={500,100,50,10,5,1};

int main (){
    while(1){
    cin >> a;
    if(a==0)break;
    a=1000-a;

    for(int i=0;i<6;i++){
    ans=a/dx[i];
    sum=sum+ans;
    a=a%dx[i];
    ans=0;
    }

    cout << sum << endl;
    sum=0;
    }
    return 0;
}

Measured memory_bytes: 1160
/**
 *    author:  tourist
 *    created: 13.06.2020 15:36:00       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  long long d = abs(a - b);
  if (v > w && d <= (v - w) * t) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}


Measured memory_bytes: 3688