akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void) {
  int n,x;
  int ans = 0;
  scanf("%d %d",&n,&x);
  int a[n];
  int sum = x;
  int min = 0;
  for (int i = 0;i < n;++i) {
    scanf("%d",&a[i]);
  }
  for (int j = 0;j < n;++j) { //最小値計算
    if (a[j] < a[j + 1] && j == 0) {
      min = a[j];
    } else if(j == 0){
      min = a[j + 1];
    } else if(a[j] <= min){
      min = a[j];
    }
  }
  for (int y = 0;y < n;++y) {
    sum -= a[y];
  }
  ans += sum / min;
  printf("%d",ans + n);
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, x;

            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            if ((n * a) < b|| (n * a) == b)

                x = n * a;
            else 
            x = b;

            Console.WriteLine(x);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
first=input()
(A, B, C, D)=first.split()
A=int(A)
B=int(B)
C=int(C)
D=int(D)
answer1=A*B
answer2=C*D
if (A*B)>(C*D):
  print(answer1)
elif (A*B)<=(C*D):
  print(answer2)

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

int main(void) {
    int x,y;
    while(true) {
        cin >> x;
        cin >> y;
        if(x == 0 && y== 0){
            break;
        }
        if(x < y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
        
    }
}


Measured memory_bytes: 3084
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,m=0,p;
  cin>>n;
  
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(ALL(a));
  int x=a[1];
  
  int ans=1;
  for(int i=x;i>1;i--){
    int cnt=0;
    int j=0;
    while(cnt<2 && j<n){
      if(a[j]%i != 0) cnt++;
      j++;
    }
    if(cnt<2){
      ans=i;
      break;
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
}

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

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    vector<int> v(3, 0);
    for(int i = 0; i < 3; i++) {
        cin >> v[i];
    }
    int ans = 0;
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            if(i != j) {
                if(v[i] == v[j]) ans++;
            }
        }
    }

    // cout << ans << endl;
    if(ans == 2) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int counts = 0;
	rep(i,n){
		if(s[i] == s[i+1]) continue;
		counts++;
	}
	cout << counts << endl;
}

Measured memory_bytes: 3764
X,Y=map(int,input().split())
result=0
if X==1 :
  result+=300000
elif X==2:
  result+=200000
elif X==3:
  result+=100000
if Y==1 :
  result+=300000
elif Y==2:
  result+=200000
elif Y==3:
  result+=100000
if X==1 and Y==1:
  result+=400000
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, less<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 1'000'000;
const int LOGN = 18;

int n, m, k;

void solve(int test)
{
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 1; i < n - 1; ++i) {
    ans += a[i - 1] < a[i] && a[i] < a[i + 1]
      || a[i + 1] < a[i] && a[i] < a[i - 1];
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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


signed main(){
	
	ll a[5] = {},memo  = LINF,n,ans = 0;
	
	cin >> n;
	
	rep(i,0,5){
		cin >> a[i];
		memo = min(memo,a[i]);
	}
	
	if(n % memo != 0)ans = n / memo + 5;
	else ans = n / memo + 4;
	
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

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

int sum(vi &a) {
  int s = 0;
  for (auto i: a) s += i;

  return s;
}

int mincost_sort(vi &a, int k) {
  vector<pair<int, int>> b(a.size()), c(k + 1, make_pair(-1, 0));

  rep(i, a.size()) {
    // from, current index
    c[a[i]].first = i;
    // to
    c[a[i]].second++;
  }

  for (int i = 1; i <= k; i++) c[i].second += c[i - 1].second;

  for (int i = (int)a.size() - 1; i >= 0; i--) {
    auto &p = c[a[i]];
    b[p.second - 1] = make_pair(p.first, a[i]); // from, value
    // p.second--;
  }
  
  int total = 0;
  for (auto bp: b) {
    int cost = 0;
    auto &p = c[bp.second];

    int &x = p.first;
    vi cycle;
    cycle.push_back(a[x]);
    while (x != p.second - 1) {
      int y = b[x].first;
      cycle.push_back(a[y]);

      swap(a[x], a[y]);
      cost += a[x] + a[y];

      c[a[x]].first = x;
      x = y;
    }
    
    if (cycle.size() > 1) {
      int cost1 = sum(cycle) + ((int)cycle.size() - 2) * cycle[0], cost2 = INT_MAX;
      
      if (cycle[0] != b[0].second)
        cost2 = sum(cycle) + cycle[0] + ((int)cycle.size() + 1) * b[0].second;
      
      total += min(cost1, cost2);
    }
  }

  return total;
}

int main() {
  int n, k = 0;
  cin >> n;

  vi w(n);
  rep(i, n) {
    scanf("%d", &w[i]);
    k = max(k, w[i]);
  }
  
  int total = mincost_sort(w, k);

  cout << total << endl;
}



Measured memory_bytes: 3332
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;


signed main(){
	
	int a,b;
	cin>>a>>b;
	cout<<a*a-b<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


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

        int[][][] room = new int[4][3][10];
        for(int i=0;i<4;i++){
            for(int j=0;j<3;j++){
                Arrays.fill(room[i][j],0);
            }
        }

        int n = sc.nextInt();

        for(int i=0;i<n;i++){
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();
            room[b-1][f-1][r-1] += v;
        }

        for(int i=0;i<4;i++){
            for(int j=0;j<3;j++){
                for(int k=0;k<10;k++){
                    System.out.print(" "+room[i][j][k]);
                }
                System.out.println();
            }
            if(i!=3)    System.out.println("####################");
        }


        sc.close();
    }
}


Measured memory_bytes: 28964
#include<stdio.h>
 
typedef struct{
    int num;
    int depth;
}node;
 
int head=0;
int tail=0;
node queue[100];
 
int graph[100][100]={0};
 
int isEmpty(void){
    if(head==tail){
        return 1;
    }else{
        return 0;
    }
}
 
void enqueue(node n){
    queue[(head++)%100]=n;
}
 
node dequeue(void){
    return queue[(tail++)%100];
     
}
 
void init(int d[],int n){
    int i;
    d[0]=0;
    for(i=1;i<n;i++){
        d[i]=-1;
    }
}
 
int main(void){
    int n;
    int u,k,v;
    int i,j;
    int d[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d",&v);
            graph[u-1][v-1]=1;
        }
    }
    /*printf("qa\n");*/
    init(d,n);
    node tmp;
    node next;
    tmp.num=0;
    tmp.depth=0;
    enqueue(tmp);
    while(!isEmpty()){
        tmp=dequeue();
        for(i=0;i<n;i++){
            if(graph[tmp.num][i]&&d[i]==-1){
                d[i]=tmp.depth+1;
                next.num=i;
                next.depth=d[i];
                enqueue(next);
            }
        }
    }
    for(i=0;i<n;i++){
        printf("%d %d\n",i+1,d[i]);
    }
    return 0;
}

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

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

    
    int N, M, K;
    cin >> N >> M >> K;

    bool check = false;
    for(int i = 0; i <= N; ++i){
        for(int j = 0; j <= M; ++j){
            if(j * N + i * M - i * j * 2 == K){
                check = true;
            }
        }
    }

    cout << (check ? "Yes" : "No") << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

bool isPrime[MAX_N];

void seive(int n = MAX_N){
    fill(isPrime, isPrime+n, true);
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i*i<=n; ++i){
        for(int j = i*i; j<n; j+=i){
            isPrime[j] = false;
        }
    }
}

int Q, cum[MAX_N]{};

int main() {
    cin >> Q;
    seive();
    REP(i,int(1e5)+1){
        if(isPrime[i] && isPrime[(i+1)/2])cum[i+1]++;
        cum[i+1] += cum[i];
    }
    REP(i,Q){
        int l, r;
        cin >> l >> r;
        cout << cum[r+1] - cum[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b[]=new int[a];
	for(int i=0;i!=a;i++) {
		b[i]=scan.nextInt();
	}
	Arrays.sort(b);
	System.out.println(b[a-1]-b[0]);
}
}

Measured memory_bytes: 21716
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    int W,a,b;
    cin >> W >> a >> b;
    int ans;
    if(a+W<b){
        ans = b-a-W;
    }else if(b+W<a){
        ans = a-b-W;
    }else{
        ans = 0;
    }
    cout << ans;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;


int main(){
	int n,m;
	std::cin >> n>>m;
	std::vector<std::vector<int> > dist(n,std::vector<int>(n));
	rep(i,n)rep(j,n)dist[i][j]=INF;
	rep(i,n)dist[i][i]=0;
	rep(i,m){
		int a,b;
		std::cin >> a>>b;
		dist[a-1][b-1]=1;
		dist[b-1][a-1]=1;
	}
	  for (int i = 0; i < n; i++)      // 経由する頂点
    	for (int j = 0; j < n; j++)    // 開始頂点
    	 for (int k = 0; k < n; k++)  // 終端
    		 dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
	std::vector<int> v;
	for (int i = 1; i < n; i++) {
		/* code */
		v.pb(i);
	}
	int counter=0;
	do {
		int len=0;
		
		len+=dist[0][v[0]];

		rep(i,n-2){
			len+=dist[v[i]][v[i+1]];
			
		}
		
		if(len==n-1)counter++;
		

	 } while (std::next_permutation(v.begin(), v.end()));
	 std::cout << counter << std::endl;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

match = False
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        y = 10000*i + 5000*j + 1000*k
        if y == Y:
            match = True
            print(i, j, k)
            break
    if match:
        break

if not match:
    print(-1, -1, -1)

Measured memory_bytes: 3064
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8[:],i8)", cache=True)
def binary_search(a, key):
    """Meguru type binary search"""
    ng = -1
    ok = len(a)

    def is_ok(a, key, idx):
        if a[idx] > key:
            return True
        else:
            return False

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok


@nb.njit("i8(i8,i8[:],i8[:],i8[:])", cache=True)
def solve(N, A, B, C):
    A.sort()
    B.sort()
    C.sort()

    BC = np.zeros(shape=N + 1, dtype=np.int64)
    for i in range(N):
        BC[i] = N - binary_search(C, B[i])

    ans = 0
    for a in A:
        idx = binary_search(B, a)
        ans += np.sum(BC[idx:])

    return ans


def main():
    N = int(input())
    A = np.array(input().split(), dtype=np.int64)
    B = np.array(input().split(), dtype=np.int64)
    C = np.array(input().split(), dtype=np.int64)

    ans = solve(N, A, B, C)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 121748
char*p,E[200];l;M(r){for(r=T();*p==42|*p==47;)*p++-42?(r/=T()):(r*=T());return r;}A(r){for(r=M();*p==43|*p==45;)*p++-43?(r-=M()):(r+=M());return r;}T(r){*p-40?sscanf(p,"%d%n",&r,&l):(r=A(++p),l=1);p+=l;return r;}main(){for(;~scanf("%*d\n%[^=]=\n"+!!p*4,E);)printf("%d\n",A(p=E));}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception {
	    Scanner sc = new Scanner(System.in);   
	    
	    int[] map = new int[3];
	    for (int i = 0; i < 3; i++) {
	    	map[i] = sc.nextInt();
	    }
	    
	    Arrays.sort(map);
	    
	    System.out.println(map[0] + Integer.parseInt("" + map[2] + "" + map[1]));
	}    
}	

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

int main(){
  ll x,y;
  cin>>x>>y;
  ll ans=1e10;
  if(y>=x){
    ans=min(ans,y-x);
  }
  ll a,b;
  if(-y>=x){
    ans=min(ans,1-y-x);
  }
  if(y>=-x){
    ans=min(ans,1+y+x);
  }
  if(x>=y){
    ans=min(ans,2+x-y);
  }
  cout<<ans<<endl;
}

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

#include <bits/stdc++.h>


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;

class ARedOrNot {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a;
        in >> a;
        string s;
        in >> s;
        if (a < 3200) out << "red";
        else out << s;
    }
};


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


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

using namespace std;

const int INF = 1e9 + 7;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    
    // total cost  such that we did activity 'i' on the last considered day 
    vector<int> dp(3, 0);
    
    for (int day = 0; day < N; ++day)
    {
        vector<int> dp_new(3, 0), c(3);

        for (int i = 0; i < 3; ++i)
            cin >> c[i];

        for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 3; ++j)
            {
                if (i != j)
                    dp_new[i] = max(dp_new[i], dp[j] + c[i]);
            }
        }
        dp = dp_new;
    }
    cout << max({dp[0], dp[1], dp[2]});
    return 0;
}

Measured memory_bytes: 4564
#include<bits/stdc++.h>
#define ll unsigned long long int

using namespace std;

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

    ll sum=0;
    ll a=n/500;
    sum+=a*1000;
    ll b=n%500;
    b/=5;
    sum+=b*5;

    cout<<sum;




return 0;

}


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

int main() {
	int x, y, a, b, c; scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
	multiset<pair<int, int>> s;
	vector<int> r, g, cl;
	for (int i = 0; i < a; i++) {
		int d; scanf("%d", &d);
		r.push_back(d);
	}
	for (int i = 0; i < b; i++) {
		int d; scanf("%d", &d);
		g.push_back(d);
	}
	for (int i = 0; i < c; i++) {
		int d; scanf("%d", &d);
		cl.push_back(d);
	}
	sort(r.begin(), r.end());
	sort(g.begin(), g.end());
	sort(cl.begin(), cl.end());
	while (x--) {
		s.insert({r.back(), 0});
		r.pop_back();
	}
	while (y--) {
		s.insert({g.back(), 1});
		g.pop_back();
	}
	while (c--) {
		auto v = *s.begin();
		if (cl.back() > v.first) {
			s.erase(s.begin());
			s.insert({cl.back(), 2});
			cl.pop_back();
		} else break;
	}
	long long sum = 0;
	for (auto v: s) {
		sum += v.first;
	}
	printf("%lld\n", sum);
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a < b || d < b){
    cout << "No\n";
    return;
  }
  ll L = c + 1;
  ll R = b - 1;
  if(L > R){
    cout << "Yes\n";
    return ;
  }
  ll t = __gcd(b,d);
  a -= L;
  a = max(a, -a);
  ll sz = R - L;
  ll pv = a - a % t;
  if(a >= pv && a <= pv + sz)
    cout << "No\n";
  else
    cout << "Yes\n";
}

int main(){
  fastIO;
  int testc;
  cin >> testc;
  for(int i = 0 ; i < testc; i ++ ){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define N 1000005
#define MOD 1000000007
using namespace std;
namespace runzhe2000
{
	int n; long long ans, f[N], pre;
	void main()
	{
		scanf("%d",&n);
		f[0] = pre = 1;
		for(int i = 0; i <= n; i++)
		{
			if(i)
			{
				(f[i] += pre) %= MOD;
				if(i-2>=0)(f[i] -= f[i-2]) %= MOD;
				(pre += f[i]) %= MOD;
			}
			if(i<=n-2)(ans += f[i] * (n-1) % MOD * (n-1)) %= MOD;
			if(i<=n-2)(ans += f[i] * (i+1)) %= MOD;
			if(i==n-1)(ans += f[i] * i) %= MOD;
			if(i==n)(ans += f[i]) %= MOD;
		}
		printf("%lld\n",(ans+MOD)%MOD);
	}
}
int main()
{
	runzhe2000::main();
}

Measured memory_bytes: 7936
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

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, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int x;

signed main() {
	cin >> x;
	for (int i = -5000; i <= 5000; i++) {
		int mi = i, ma = 5000;
		while (ma - mi > 1) {
			int md = (ma + mi) / 2;
			int a = i * i*i*i*i;
			int b = md * md*md*md*md;
			if (b - a < x)mi = md;
			else ma = md;
		}
		if (ma * ma*ma*ma*ma- i * i*i*i*i == x) {
			cout << ma << " " << i << endl;
			return 0;
		}
	}
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int X[N];
    for(int i = 0; i < N; ++i) cin >> X[i];

    int res = 0;
    for(int i = 0; i < N; ++i) 
        res += min(2*X[i], 2*abs(K - X[i]));
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/** Seek God..Trust God..Praise God..**/

#include<bits/stdc++.h>
using namespace std;


#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////



/*
long long  Prime[3000000],nPrime;
long long  mark[10000002];

void seive(long long int n)
{
	long long int i,j,limit=sqrt(n*1.0)+2;
	mark[1]=1;
	for(i=4; i<=n ;i+=2)
	mark[i]=1;
	Prime[nPrime++]=2;
	for(i=3; i<=n; i+=2)
	{
		if(!mark[i])
		{
			Prime[nPrime++]=i;
			if(i<=limit)
			{
				for(j=i*i; j<=n ;j+=i*2)
				{
					mark[j]=1;
				}
			}
		}
	}
}
*/


int main()
{
    FASTIO;

    ll  n , x, t;

    cin >> n >> x >> t;

    ll ans = ceil(n*1.00/x);


    cout << (ll)(ans*t) << endl;














    return 0;
}


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

int main()
{
   int a;
   cin>>a;
   int b;
   cin>>b;
   int total=1;
   int count=0;
   while(total<b)
   {
       total+=(a-1);
       count++;
   } 
   cout<<count<<endl;

    return 0;
}

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

long long solve(int l, int r){
    if(l>=r) return 0;
    if(s[l]==s[r]){
        return solve(l+1, r-1);
    }
    if(s[l]=='x'){
        return (1+solve(l+1, r));
    }
    else if(s[r]=='x'){
        return (1+solve(l, r-1));
    }
    //return -1;
    cout << -1, exit(0);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    cout << solve(0, s.length()-1);
    return 0;
} 

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n 
#define pl(n) cout<<n<<" "
const int Nx=1e5+2;
const int mod=998244353;
const int inf=(int)(1e9+10LL);
const double pI=6.28318530717958623200;
void solve()
{
	int n,m;
	sl(n);sl(m);
	Vl arr(m);
	int sum=0;
	for(auto &it:arr){sl(it);sum+=it;}
	int ans=(n-sum)>=0?(n-sum):-1;
	cout<<ans<<endl;
}

signed main(){
  int test=1;
 // sl(test);
 while(test--){
 	solve();
 }
 
}

Measured memory_bytes: 3680
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2000+10;
int a,b,c[N];
bool judge(int x)
{
    int ans=0;
    while(x)
    {
        c[ans++]=x%10;
        x/=10;
    }
    int l=0,r=ans-1;
    bool flag=1;
    while(l<=r)
    {
        if(c[l]!=c[r]) {return 0;}
        l++;r--;
    }
    return 1;
}
int main(){
    scanf("%d%d",&a,&b);
    int sum=0;
    for(int i=a;i<=b;i++)
    {
        if(judge(i)) sum++;

    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  cout << (k==1 ? 0 : n-k) << endk;
  return 0;
}


Measured memory_bytes: 3604
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

int main()
{
    int N;
    cin >> N;
    vector<int> H;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        H.push_back(tmp);
        bool f = true;
        for (int j = 0; j < i; j++)
        {
            if (H[j] > H[i])
            {
                f = false;
                break;
            }
        }
        if (f)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll x,y;
  cin >> x >> y;
  ll a = (-1) * x, b = (-1) * y;
  ll ans = INF;
  if(y-x>=0){
    chmin(ans, y - x);
  }
  if(y-a>=0){
    chmin(ans, y - a + 1);
  }
  if(b-x>=0){
    chmin(ans, b - x + 1);
  }
  if(b-a>=0){
    chmin(ans, b - a + 2);
  }
  print(ans);
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
  string s;
  cin >> s;
  REP(i, s.length()) {
    if(s[i] == ',')
      s[i] = ' ';
  }
  cout << s << endl;
}


Measured memory_bytes: 256
package main

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

// Print test case
func main() {
	sc := bufio.NewScanner(os.Stdin)
	s := ""
	for i := 1; i <= 10000; i++ {
		sc.Scan()
		num, _ := strconv.Atoi(sc.Text())
		if num == 0 {
			break
		}
		s += fmt.Sprintf("Case %v: %v\n", i, num)
	}
	fmt.Print(s)
}



Measured memory_bytes: 8280
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS =1e-10;
double EQ(double a,double b){
	return abs(a-b)<EPS;
}

void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

void solve(){
	int n;
	while(cin>>n&&n){
		map<string,int> m;
		string s;
		getline(cin,s);
		for(int i=0;i<n;i++){
			getline(cin,s);
			stringstream ss(s);
			while(ss>>s){
				m[s]++;
			}
		}
		char ch;
		cin>>ch;
		vector<pair<int,string> >vs;
		for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
			if(it->first[0]==ch){
				vs.push_back(make_pair(-it->second,it->first));
			}
		}
		sort(vs.begin(),vs.end());
		if(vs.size()==0){
			cout<<"NA"<<endl;
		}
		else{
			for(int i=0;i<min(5,(int)vs.size());i++){
				cout<<vs[i].second;
				if(i!=vs.size()-1)cout<<" ";
				else cout<<endl;
			}
		}
	}
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 952
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

val = [0] * (N)
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    val[p] += x

used = [False]*N


def dfs(s):
    stack = []
    stack.append(s)
    while len(stack) > 0:
        now = stack[-1]
        used[now] = True
        stack.pop()
        for nxt in G[now]:
            if used[nxt]:
                continue
            val[nxt] += val[now]
            stack.append(nxt)


dfs(0)

answer = ' '.join(map(str, val[:]))
print(answer)


Measured memory_bytes: 66948
#include <iostream>
using namespace std;
int main()
{
  int n,m,l;
  cin>>n>>m>>l;
  long int ma1[n][m];
  long int ma2[m][l];
  long int ans[n][l];
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      cin>>ma1[i][j];
  for(int i=0;i<m;i++)
    for(int j=0;j<l;j++)
      cin>>ma2[i][j];

  for(int k=0;k<l;k++)
  {
    for(int i=0;i<n;i++)
    {
      long int sum=0;
      for(int j=0;j<m;j++)
      {
      sum+=ma1[i][j]*ma2[j][k];
      }
      ans[i][k]=sum;
    }
  }

  for(int i=0;i<n;i++)
    for(int j=0;j<l;j++)
      cout<<ans[i][j]<<(j==l-1?'\n':' ');
}

Measured memory_bytes: 3224
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
X, A, B = ri_()
print('delicious' if B - A <= 0 else 'safe' if B - A <= X else 'dangerous')

Measured memory_bytes: 63212
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<vector>
#include<cctype>
using namespace std;

int sum(int a[],int n){
	int s;
	for(int i=0;i<n;i++)s+=a[i];
	return s;
}

int main(){
int r,c;
int h[101][101];
vector<int> ts,ys;//縦の合計豊子の合計

cin>>r>>c;int a=0,b=0;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>h[i][j];
		}
	}
	
	for(int i=0;i<r;i++){
		int y=0;
		for(int j=0;j<c;j++){
		y+=h[i][j];
		}
		a+=y;
		ys.push_back(y);
	}
	for(int i=0;i<c;i++){
	int t=0;
		for(int j=0;j<r;j++){
			t+=h[j][i];
		}
		b+=t;
		ts.push_back(t);
	}
	for(int i=0;i<r;i++)h[i][c]=ys[i];
	for(int i=0;i<c;i++)h[r][i]=ts[i];
	
	h[r][c]=(a+b)/2;
	
	for(int i=0;i<=r;i++){
		for(int j=0;j<=c;j++){
			if(i==r&&j==c){cout<<h[r][c]<<endl;break;}
			else if(j==c){cout<<h[i][j]<<endl;}
			else cout<<h[i][j]<<" ";
		}
}

return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
const long long mx = 1e18;
int main()
{
    long long n, ans = 1, i, c = 0, p = 0;
    double y, s, x;
    cin >> n;
    long long a[n + 4];
    for (i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            c = 1;
        }
    }
    if (c == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    for (i = 1; i <= n; i++)
    {

        // if(ans<=(mx/a[i]));
        // {
        //     ans =ans * a[i];
        // }
        // else
        // {
        //     ans = -1;
        //     break;
        // }
        if(ans>(mx/a[i]))
        {
            ans=-1;
            break;
        }else
        {
            ans=ans*a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4428
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define SIZE 1010
#define MOD 998244353

using namespace std;

int n,m;
int ans;
char map[SIZE][SIZE];
int step[SIZE][SIZE];
bool vis[SIZE][SIZE];
struct point
{
    int x,y;
    int steps;
}tmp;
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
bool legal(int x,int y)
{
    if(x==0 || y==0)
        return false;
    if(x>n || y>m)
        return false;
    return !vis[x][y];
}
void bfs()
{
    int i,j;
    queue<point> que;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(map[i][j]=='#')
            {
                que.push({i,j,0});
                vis[i][j]=true;
            }
        }
    }
    while(!que.empty())
    {
        tmp=que.front();
        que.pop();
        ans=max(ans,tmp.steps);
        for(i=0;i<4;i++)
        {
            int tmpx=tmp.x+dir[i][0];
            int tmpy=tmp.y+dir[i][1];
            if(legal(tmpx,tmpy))
            {
                vis[tmpx][tmpy]=true;
                que.push({tmpx,tmpy,tmp.steps+1});
            }
        }
    }
    return ;
}
int main()
{
    int i,j;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        scanf("%s",map[i]+1);
    bfs();
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 14352
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int mod=1000000007;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  ll count=0;
  vlong sum(n+1,0);
  REP(i,1,n+1){
    sum[i]=sum[i-1]+i;
  }
  REP(i,k,n+1){
    count+=(sum[n]-sum[n-i])-sum[i-1]+1;
    count=count%mod;
  }
  cout<<count+1<<'\n';
  return(0);
}


Measured memory_bytes: 4756
#include <stdio.h>

int main(int argc, char const *argv[])
{
  unsigned long long X;
  scanf("%llu", &X);

  unsigned long long money = 100;
  unsigned int count = 0;
  while (money < X)
  {
    money += money / 100;
    count++;
  }
  printf("%d", count);

  return 0;
}

Measured memory_bytes: 1732
using System;
using System.Linq;

namespace codefestival_2016_qualC_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] y = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool[] decided = new bool[n];
            int last = -1;
            for (int i = 0; i < n; i++)
            {
                if (x[i] != last) decided[i] = true;
                last = x[i];
            }
            last = -1;
            long ret = 1;
            for (int i = n - 1; i >= 0; i--)
            {
                if (y[i] != last)
                {
                    if (decided[i])
                    { if (y[i] != x[i]) ret = 0; }
                    else
                    { if (y[i] > x[i]) ret = 0; }
                    decided[i] = true;
                }
                else if (decided[i])
                {
                    if (x[i] > y[i]) ret = 0;
                }
                else
                {
                    int min = Math.Min(x[i],y[i]);
                    ret *= min;
                }
                ret %= 1000000007;
                last = y[i];
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 37596
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main()
{
	char c[1000];
	gets(c);
	int i,j,t=0,a=0,b=0;
	int n=strlen(c);
	for(i=0;i<n;i++)
	{
		if(c[i]=='C')
		{
			t=1;
			a=1;
		}
		if(a==1&&c[i]=='F')
		{
			a=2;
		}
	}
	if(a==2)
		cout<<"Yes";
	else
		cout<<"No";	
	return 0;
}











Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cassert>
using namespace std;
#define MOD 1000003

long long bipow(long long n, long long m) {
    if (m == 0) return 1;
    if (m % 2 == 0) {
        n = (n * n) % MOD;
        return bipow(n, m / 2) % MOD;
    } else
        return (n * bipow(n, m - 1)) % MOD;
}

int main(){
    vector<long long> fac(MOD);
    fac[0] = 1;
    for(int i=1; i<MOD; i++)
        fac[i] = (fac[i-1] * i) % MOD;

    int Q;
    cin >> Q;
    for(int i=0; i<Q; i++){
        long long x, d, n;
        cin >> x >> d >> n;
        long long ans;
        if(d == 0) ans = bipow(x, n);
        else{
            long long y = (x * bipow(d, MOD-2)) % MOD;
            if(y == 0 || y + n - 1 >= MOD) ans = 0;
            else{
                long long tmp0 = bipow(d, n);
                long long tmp1 = fac[y+n-1];
                long long tmp2 = bipow(fac[y-1], MOD-2);
                ans = tmp0;
                ans = (ans * tmp1) % MOD;
                ans = (ans * tmp2) % MOD;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 8704
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

void rec (int i, int prev, int64_t& max_res,  vector<int64_t>& fixed, vector<int64_t>& C, vector<int64_t>& D, vector<pair<int,int>>& AB, int32_t& N, int32_t& M, int32_t& Q) {
  if (i == N) {
    int64_t cur_sum = 0;
    for (int k = 0; k < Q; k++) {
      int a = AB[k].first;
      int b = AB[k].second;
      if (fixed[b] - fixed[a] == C[k]) {
        cur_sum += D[k];
      }
    }
    max_res = max(max_res, cur_sum);
    return;
  }
  for (int j = prev; j <= M; j++) {
    fixed[i] = j;
    rec (i+1, j, max_res, fixed, C, D, AB, N, M, Q);
  }
  return;
}

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

  int32_t N, M, Q;
  cin >> N >> M >> Q;
  vector<int64_t> fixed(N, 0);
  fixed[0] = 1;
  vector<int64_t> D(Q);
  vector<int64_t> C(Q);
  vector<pair<int,int>> AB(Q);
  for (int i = 0; i < Q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    AB[i] = make_pair(a-1,b-1);
    C[i] = c;
    D[i] = d;
  }
  int64_t max_res = 0;
  rec(1, 1, max_res, fixed, C, D, AB, N, M, Q);
  cout << max_res << endl;
  return 0;
}


Measured memory_bytes: 3568
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n= sc.nextInt();
    //sc.nextLine();
    int[] array = new int[n];
    for(int i=0; i<n; i++){
      array[i] = sc.nextInt();
    }
    //処理部
    boolean judge =true;
    int a=0;
    int cnt=0;
    while(judge){
        for(int j=0; j<n; j++){
            if(array[j]%2==0){
                array[j]=array[j]/2;
                a++;
            }else{
                judge=false;
            }
            if(a==n){
                cnt++;
                 a=0;
            }
           
        }
    }
    System.out.println(cnt);
  }
}

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

int main(){
    int n,t;
    cin>>n>>t;
    vector<pair<int,int>>v;
    for(int i=0;i<n;i++){
        int c,ti;
        cin>>c>>ti;
        v.push_back(make_pair(c,ti));
    }
    sort(v.begin(),v.end());
    int f=0,c=1234567;
    for(int i=0;i<n;i++){
        if(v[i].first<c && v[i].second<=t){
            c=v[i].first;
            f=1;
        }
    }
    if(f==1)cout<<c;
    else cout<<"TLE";
}

Measured memory_bytes: 256
n = int(input())
lis = list(map(int,input().split()))
prod = 1
if 0 in lis:
    print(0)
    exit(0)
for i in lis:
    if(prod>1000000000000000000):
        print(-1)
        exit(0)
    prod=prod*i
print(prod) if(prod<=1000000000000000000) else print(-1)

Measured memory_bytes: 21644
/* Accepted. */
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
#define MAXN 200006
typedef long long ll;
char ch[MAXN];
int n;
int main() {
	cin >> ch;
	n = strlen( ch );
	ll curb = 0 , ans = 0;
	for( int i = 0 ; i < n ; ++ i ) 
		if( ch[i] == 'B' ) ++curb;
		else ans += curb;
	cout << ans;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    char s[6];
    int i=0;
    for(i=0;i<6;i++){
        cin>>s[i];    
    }
    if(s[2]==s[3] and s[4]==s[5]){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}


Measured memory_bytes: 256
/*
AizuOnline A2333
My friends are small
*/
#include <stdio.h>
int W,N;
int w[200];
int rs[200];
int us[200];
int  ALLWT;

#define MAXHASH 400000
struct {
  int x;
  int y;
  long long ways;} hash[MAXHASH];
int hashcnt;

int init_hash()
{
  int i;
  for(i=0;i<MAXHASH;i++)
    {
      hash[i].x = 0;
      hash[i].y = 0;
      hash[i].ways = -1LL;
    }
  hashcnt=0;
}
int hashfunc (int x,int y)
{
  return((x*31371 + y*2689) % MAXHASH);
}
int regist_hash(int x,int y,long long ways)
{
  int ptr,ptr1;

  if(hashcnt >= MAXHASH/2)
    return(-1);

  ptr = hashfunc(x,y);
  ptr1 = ptr;
  // printf("REGS0 %d %d:%lld (%d)\n",x,y,ways,ptr);
  for(;ptr<MAXHASH;ptr++)
    {
      if(hash[ptr].x == x && hash[ptr].y == y)
	return(-2);
      if(hash[ptr].ways == -1LL)
	goto REG;
      // printf("collision %d\n",ptr);
    }
  for(ptr=0;ptr<ptr1;ptr++)
    {
      if(hash[ptr].x == x && hash[ptr].y == y)
	return(-2);
      if(hash[ptr].ways == -1LL)
	goto REG;
      // printf("collision %d\n",ptr);
    }
 REG:
  // printf("REGS1 %d %d:%lld (%d)\n",x,y,ways,ptr);
  hash[ptr].x = x;
  hash[ptr].y = y;
  hash[ptr].ways = ways;
  hashcnt++;
  return(ptr);
}
long long find_hash(int x,int y)
{
  int ptr;

  ptr = hashfunc(x,y);
 
  while(1)
    {
      if(hash[ptr].x == x && hash[ptr].y == y)
	{
	  // printf("FIND %d %d:%lld\n",x,y,hash[ptr].ways);
	  return(hash[ptr].ways);      
	}
      if(hash[ptr].ways == -1)
	return(-1LL);
      ptr++;
    }
}
void init()
{
  int i;

  for(i=0;i<200;i++)
    us[i]=0;

  scanf("%d %d",&N,&W);

  for(i=0;i<N;i++)
    scanf("%d",&(w[i]));
}
int compare(const void *x , const void *y)
{
  return(*(int *)y - *(int *)x);
}
void sort()
{
  qsort(w,N,sizeof(int),compare);
}
runsum()
{
  int i,sum;
  sum = 0;
  for(i=0;i<N;i++)
    rs[i]=999999;

  for(i=N-1;i>=0 && sum <= W;i--)
    {
      sum += w[i];
      rs[i]=sum;
    }
  /*
  for(i=0;i<N;i++)
    printf("%d",rs[i]);
  */
}

// ryukku ni ireteinai tomodati de itiban karui
int lightest()
{
  int * p,ret,i;
  i=N-1;ret=w[N-1];
  while(us[i])
    {   
      ret=w[i];
      i--;
    }
  // printf("LTST=%d \n",ret);
  return(ret);
}

long long calc_combi_ways(int ptr,int total,int depth)
{ 
  long long result;

  // printf("%d %d %d\n",ptr,total,depth);

  result = find_hash(ptr,total);
  if(result != -1)
    return(result);
  if(total < lightest())
    {  // printf("*");
      return(1);}
  else if(ptr > N-1)
    return(0);
  else if(total >= rs[ptr] && total < rs[ptr-1])
    {  // printf("+");
      return(1);  }
  else
    {
      us[ptr]=0;
      result = calc_combi_ways(ptr+1,total,depth+1);
      us[ptr]=1; 
      if(total >= w[ptr])
	result += calc_combi_ways(ptr+1,total-w[ptr],depth+1);
      us[ptr]=0;
      result %= 1000000007LL;
      regist_hash(ptr,total,result);
      return(result);
    }
}

main()
{
  long long ret;
  init();
  init_hash();
  sort();
  runsum();

  ret=calc_combi_ways(0,W,0);
  printf("%lld\n",ret);
  // printf("%d\n",hashcnt);
return(0);
}

Measured memory_bytes: 6864
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<map>
 
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define f first
#define s second
 
using namespace std;
 
typedef long long ll;
 
int main(){
  int n;
  while(cin>>n, n){
    map<string,pair<int,ll> > m;
    vector<pair<int,string> > v;
    REP(i,n){
      string a;
      ll b,c;
      cin>>a>>b>>c;
      if(m.find(a) == m.end())
    m[a] = mp(m.size(),b*c);
      else
    m[a].s += b*c;
    }
    FOR(it,m) if(it->s.s >= (ll)1000000) v.push_back(mp(it->s.f,it->f));
    if(v.size() == 0) cout << "NA" << endl;
    else{
      sort(ALL(v));
      FOR(it,v) cout << it->s << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1364
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;

long long n,m;

inline long long read(){
	long long s=0,w=1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		if(ch == '-')w = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		s = s*10+ch-'0';
		ch = getchar();
	}
	return w*s;
}

ll GEt_ans(ll a)//求f([1,a])
{
    if(a <= 0)
        return 0;
    if(a%2==1){
        if(((a-1)/2)%2==1)//掐头
            return 0;
        else
            return 1;
    }
    else{
        if(((a-2)/2)%2==1)//掐头去尾
            return a;
        else
            return 1^a;
    }
}

int main(){
	n = read(),m = read();
	ll a = GEt_ans(m);
	ll b = GEt_ans(n-1);
	ll ans = 0;
	for(int i = 0;i <= 40;++i){
		if(a%2 != b%2){
			ans += (long long)1 << i;
		}
		a >>= 1;
		b >>= 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	wa := a + b

	var ans int
	if wa == 3 {
		ans = 3
	} else if wa == 4 {
		ans = 2
	} else {
		ans = 1
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512