akhauriyash/Code-Regression huggingface dataset:
N,X,M = map(int, input().split())

A = [X]
x = (X**2)%M

while x not in A:
  A.append(x)
  x = (x**2)%M

if len(A) >= N:
  answer = sum(A[:N])
else:
  index = 0
  while A[index] != x:
    index += 1
  len_loop = len(A) - index
  num_loop = (N-index)//len_loop
  num_last = N - index - len_loop*num_loop
  answer = sum(A[:index]) + num_loop*sum(A[index:]) + sum(A[index:index+num_last])

print(answer)

Measured memory_bytes: 68384
<?php
  $k = trim(fgets(STDIN));
  $ans = 0;
  $amari = 0;
  for($x=1; $x<=$k; $x++){
    for($y=1; $y<=$k; $y++){
      $s = gmp_gcd($x,$y);
      for($z=1; $z<=$k; $z++){
        $ans += gmp_gcd($s,$z);
      }
    }
  }

  echo $ans."\n";


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int H, W;
  cin >> H >> W;
  char v[H][W];
  int v1[H][W];
  int v2[H][W];
  int m = 0;
  rep(i, H) {
    rep(j, W) {
      cin >> v[i][j];
    }
  }
  rep(i, H) {
    int m1 = 0;
    int cnt = 0;
    rep(j, W) {
      if (v[i][j] == '.') {
        cnt++;
      }
      else {
        cnt = 0;
      }
      v1[i][j] = cnt;
    }
  }
  rep(i, H) {
    int m1 = 0;
    for (int j = W-1; j >= 0; j--) {
      if (v1[i][j] != 0) {
        if (j == W-1)
          m1 = v1[i][j];
        else if (v1[i][j+1] == 0)
          m1 = v1[i][j];
        else
          v1[i][j] = m1;
      }
    }
  }
  rep(i, W) {
    int m2 = 0;
    int cnt = 0;
    rep(j, H) {
      if (v[j][i] == '.') {
        cnt++;
      }
      else {
        cnt = 0;
      }
      v2[j][i] = cnt;
    }
  }
  rep(i, W) {
    int m1 = 0;
    for (int j = H-1; j >= 0; j--) {
      if (v2[j][i] != 0) {
        if (j == H-1)
          m1 = v2[j][i];
        else if (v2[j+1][i] == 0)
          m1 = v2[j][i];
        else
          v2[j][i] = m1;
      }
    }
  }
  rep(i, H) {
    rep(j, W) {
      m = max(v1[i][j] + v2[i][j], m);
    }
  }
  cout << m-1 << endl;
}


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



ll A, B, C, D;

ll gcd( ll a, ll b ){
	if ( a < b )
		return gcd( b, a );
	
	int k = a / b;
	if ( a - k * b == 0 )
		return b;
	return gcd( b, a - k * b );
}


// a <= x <= b となるx で dで割り切れる個数
ll f( ll a, ll b, ll d ){
	ll aa = (a+d-1)/d;
	ll bb = b/d;
	return bb-aa+1;
}

int main(){
	cin >> A >> B >> C >> D;
	
	
	
	cout << (B-A+1) - f(A,B,C) - f(A,B,D) + f(A,B,C*(D/gcd(C,D))) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

int main(){
  int long N, mult3, mult5, mult15, answer;
  std::cin >> N;
  
  mult3 = N / 3;
  mult5 = N / 5;
  mult15 = N / 15;
  
  answer = N * (N + 1) / 2 - (mult3 * 3 * (mult3 + 1) / 2 + mult5 * 5 * (mult5 + 1) / 2 - mult15 * 15 * (mult15 + 1) / 2);
  
  std::cout << answer;
  
  return 0;
}

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

using namespace std;

void SelectSort(int x[], int N);
void BubbleSort(int x[], int N);
void InsertSort(int x[], int N, int num);
void ShellSort(int x[], int N);
void Trace(int x[], int N);
void Trace2(int x[], int N);

int gCount = 0;

int main() {
    int N;

    cin >> N;

    int x[N];

    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    //SelectSort(x, N);
    //BubbleSort(x, N);
    //InsertSort(x, N, 1);
    ShellSort(x, N);
    cout << gCount << endl;
    Trace2(x, N);
    //Trace2(x, N);
    //cout << gCount << endl;

    return 0;
}


void SelectSort(int x[], int N) {
    int min;

    for (int i = 0; i < N - 1; i++) {
        min = i;
        for (int j = i; j < N; j++) {
            if (x[min] > x[j]) {
                min = j;
            }
        }
        if (i != min) {
            gCount++;
            swap(x[min], x[i]);
        }
    }
}

void BubbleSort(int x[], int N) {
    for (int i = 0; i < N - 1; i++) {
        for (int j = N - 1; j > i; j--) {
            if (x[j - 1] > x[j]) {
                swap(x[j - 1], x[j]);
                gCount++;
            }
        }
        //Trace(x, N);
    }
}

void ShellSort(int x[], int N) {
    vector<int> g;
    int s = 1;
    do {
        g.push_back(s);
        s = s * 3 + 1;
    } while(s < N);
    cout << g.size() << endl;
    int i;
    for(i = g.size() - 1; i > 0; i-- ) {
        cout << g[i] << " ";
        InsertSort(x, N, g[i]);
    }
    cout << g[i] << endl;
    InsertSort(x, N, g[i]);
}

void InsertSort(int x[], int N, int num) {
    for(int i = num; i < N; i++) {
        int v = x[i];
        int j = i - num;
        // Trace(x, N);
        while (j >= 0 && x[j] > v) {
            x[j + num] = x[j];
            j -= num;
            gCount++;
        }
        x[j + num] = v;
    }
}

void Trace (int x[], int N) {
    int i;
    for (i = 0; i < N - 1; i++) {
        cout << x[i] << " ";
    }
    cout << x[i] << endl;
}

void Trace2 (int x[], int N) {
    int i;
    for (i = 0; i < N; i++) {
        cout << x[i] << endl;
    }
}

Measured memory_bytes: 6988
N = int(input())
A = list(map(int, input().split()))
judge = 1
while 0 in A:
    A.remove(0)

A_ = list(set(A))
A_.sort()
for i in range(len(A_) - 1):
    if A_[i+1] == A_[i]+2:
        judge = 1
    else:
        judge = 0

if len(set(A)) == len(A)/2 and judge:
    print((2 ** (len(A) // 2)) % (10**9 +7))
else:
    print(0)

Measured memory_bytes: 14008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int a;
    cin>>a;
    int sum=0;
    int l[200000],r[200000];
    for(int i=0;i<a;i++){
        cin>>l[i]>>r[i];
        sum+=r[i]-l[i]+1;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
using namespace std;
long long n;
long long a[200000];
long long b[200000];
long long s, t, x, y, z;
long long ans;
priority_queue<long long>q;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		s += a[i];
	}
	for (int i = 0; i < n; i++) {
		scanf("%lld", b + i);
		t += b[i];
		q.push(b[i] * n + i);
	}
	while (t > s) {
		if (q.empty())break;
		x = q.top();
		x %= n;
		if (b[x] == a[x]) {
			q.pop();
			continue;
		}
		if (b[x] - b[(x + n - 1) % n] - b[(x + 1) % n] < a[x])break;
		q.pop();
		y = b[(x + n - 1) % n] + b[(x + 1) % n];
		z = (b[x] - a[x]) / y;
		b[x] -= z * y;
		t -= z * y;
		ans += z;
		q.push(b[x] * n + x);
	}
	y = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i])y = 0;
	}
	if (y)printf("%lld\n", ans);
	else printf("-1\n");
}

Measured memory_bytes: 5104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>

using namespace std;

typedef long long ll;
#define INF 1000000007

int main(){

    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if(e - a > k) cout << ":(\n";
    else cout << "Yay!\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    set<ll> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(ll(s.size())==2)
    cout<<"Yes";
    else
    cout<<"No";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    t=1;
    for(ll i=0;i<t;i++)
    solve();
}

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

using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
#define rep1(i,n) for (ll i=1; i<=(ll)(n); i++)
#define rep0(i,n) for (ll i=0; i<(ll)(n); i++)
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; }
#ifdef _DEBUG
string _format(string args) { string r = "", t; istringstream s(args); while (getline(s, t, ',')) r += t+":%ld "; return r + "\n"; }
#define debug(...) do { printf(_format(#__VA_ARGS__).c_str(), __VA_ARGS__); } while(0)
#define fast_ios() do {} while(0);
#else //_DEBUG
#define debug(...) do {} while(0)
#define fast_ios() do { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } while(0)
#endif //_DEBUG

int main() {
    fast_ios();

    int n;
    cin >> n;

    map<int,ll> count;
    int a[n];
    rep0(i,n) {
        cin >> a[i];
        count[a[i]]++;
    }

    int m = 200001;
    ll com[m];
    ll sum = 0;
    rep0(i,m) {
        if (count[i] > 1) {
            com[i] = (count[i]) * (count[i] - 1) / 2;
        } else {
            com[i] = 0;
        }
        sum += com[i];
        debug(sum, com[i]);
    }

    rep0(i,n) {
        ll ans = sum - com[a[i]];
        ll c = count[a[i]];
        if (c > 1) {
            ans += (c-1)*(c-2)/2;
        }
        cout << ans << endl;
    }
}


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

using namespace std;


int main() {
    int N; cin >> N;
    vector<int> B(N-1);
    for(auto& b : B) cin >> b;
    B.push_back(1e9);

    int ans = B[0];
    for(int i=1;i<N;i++) {
        ans += min(B[i], B[i-1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <stdio.h>
#include <math.h>
using namespace std;
 
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
 
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> PP;
 
struct edge {
	int to, cost;
	edge(int t, int c) :to(t), cost(c) {}
};
 
int dx[] = { 1,-1,0,0 }, dy[] = { 0,0,1,-1 };
int ddx[] = { 1,1,1,0,-1,-1,-1,0 }, ddy[] = { 1,0,-1,-1,-1,0,1,1 };
 
ll mypow(ll x, ll n, ll m) {	//xのn乗をmで割った余り
	if (n == 0) return 1;
	if (n % 2 == 0) return mypow(x*x%m, n / 2, m);
	else return x*mypow(x, n - 1, m) % m;
}
 
//-----------------------------------------------------------------------------

int n;
const int m=1e9+7;

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

	ll x=1;
	cin>>n;
	REP(i,n) (x*=(i+1))%=m;
	cout<<x<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] a = new int[N];
   for(int i=0;i<N;i++) a[i]=sc.nextInt();
   
   int ans=100*100*100;
   int tmp=0;
   for(int i=-100;i<=100;i++)
   {
     tmp=0;
     for(int k=0;k<N;k++)
     {
       tmp+= (a[k]-i)*(a[k]-i);
     }
     if(tmp<ans) ans=tmp;
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 25044
l = raw_input().split()
N = int(l[0])

S = []
P = []

for i in range(N):
    l = raw_input().split()
    S.append(l[0])
    P.append(int(l[1]))

S1 = []
for i in range(N):
    S1.append([i + 1, S[i], P[i]])
#print(N, S, P, S1)

S1.sort(key = lambda x: -x[2])
S1.sort(key = lambda x: x[1])
#print(S1)
for s in S1:
    print(s[0])


Measured memory_bytes: 2568
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let n: usize = read!();
    let m: usize = read!();
    let mut zz = Vec::new();
    let mut mm = m;
    let mut sum = 0;
    for _ in 0..n {
        let a: usize = read!();
        let b: usize = read!();
        zz.push((a, b));
    }
    zz.sort();
    for (cost, lim) in zz {
        if lim <= mm {
            mm -= lim;
            sum += cost * lim;
        } else {
            sum += cost * mm;
            break;
        }
    }
    println!("{}", sum);
}

Measured memory_bytes: 4280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
char ch[2005];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	ll a=read(),v=read(),b=read(),w=read(),T=read();
	if(a>b)swap(a,b);
	if(a+T*v>=b+T*w){
		puts("YES");
	}else puts("NO");
}


Measured memory_bytes: 3640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    if(d==22){
      System.out.println("Christmas Eve Eve Eve");
    }else if(d==23){
      System.out.println("Christmas Eve Eve");
    }else if(d==24){
      System.out.println("Christmas Eve");
    }else if(d==25){
      System.out.println("Christmas");
    }else{
      return;
    }
  }
  

  
}

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    
    vector<int> arr;

    string s;
    cin>>s;

    for(int i=0;i<s.length();i++) {
        arr.push_back(int(s[i]-'0'));
    }

    int total=0;
    for(int i=0;i<s.length();i++) {
        total+=arr[i];
    }

    if(total%9==0) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }

}




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

int x[17], y[100][2], z[100], p[100], s;

int main() {
	for (int i = 0; i < 17; i++) {
		x[i] = 10000;
	}
	for (int i = 0; i < 100; i++) {
		z[i] = 10000;
	}
	for (int i = 0; i < 100; i++){
		y[i][0] = i * 5;
		y[i][1] = 17 * (i % 2) + 3 * (i % 3) + 19;
	}
	for (int i = 0; i < 1000; i++) {
		//Simulation.
		for (int j = 0; j < 100; j++) {
			if (z[j] < 100) {
				z[j]--;
			}
			if (z[j] == 0) {
				for (int k = 0; k < 17; k++) {
					if (x[k] == j) { x[k] = 10000; }
				}
				z[j] = 10000;
			}
		}
		if (i % 5 == 0 && i < 500) {
			z[i / 5] = 100000;
		}
		for (int j = 0; j <= s; j++) {
			if (z[j] == 100000) {
				if (j % 5 != 1) {
					for (int k = 0; k < 16; k++) {
						if (x[k] + x[k + 1] == 20000) {
							x[k] = j;
							x[k + 1] = j;
							z[j] = y[j][1];
							p[j] = i - y[j][0];
							s++;
							goto E;
						}
					}
				}
				else {
					for (int k = 0; k < 13; k++) {
						if (x[k] + x[k + 1] + x[k + 2] + x[k + 3] + x[k + 4] == 50000) {
							x[k] = j;
							x[k + 1] = j;
							x[k + 2] = j;
							x[k + 3] = j;
							x[k + 4] = j;
							z[j] = y[j][1];
							p[j] = i - y[j][0];
							s++;
							goto E;
						}
					}
				}
			E:;
			}
		}
	}
	int n;
	while (cin >> n) {
		cout << p[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int m,d;
long long int cnt=0;
cin>>m>>d;

for(int i=1;i<=m;i++){
  for(int j=10;j<=d;j++){
if(i==(j/10)*(j%10)&&(j/10)>=2&&(j%10)>=2){ cnt++;
}
  }
}
cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	static int N, Ma, Mb;
	static int[] a, b, c;
	static int[][][] dp;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		Ma = sc.nextInt();
		Mb = sc.nextInt();
		a = new int[N];
		b = new int[N];
		c = new int[N];
		for (int i = 0; i < N; ++i) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		dp = new int[N][401][401];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j <= 400; ++j) {
				for (int k = 0; k <= 400; ++k) {
					dp[i][j][k] = Integer.MAX_VALUE / 16;
				}
			}
		}
		dp[0][0][0] = 0;
		dp[0][a[0]][b[0]] = c[0];
		for (int i = 1; i < N; ++i) {
			for (int j = 0; j <= 400; ++j) {
				for (int k = 0; k <= 400; ++k) {
					dp[i][j][k] = Math.min(dp[i][j][k], dp[i - 1][j][k]);
					if (j + a[i] > 400 || k + b[i] > 400 || dp[i - 1][j][k] >= Integer.MAX_VALUE / 16)
						continue;
					dp[i][j + a[i]][k + b[i]] = Math.min(dp[i][j + a[i]][k + b[i]], dp[i - 1][j][k] + c[i]);
				}
			}
		}
		long ans = Integer.MAX_VALUE / 16;
		for (int i = 1; i <= 400; ++i) {
			for (int j = 1; j <= 400; ++j) {
				if (dp[N - 1][i][j] >= Integer.MAX_VALUE / 16)
					continue;
				if (i * Mb == j * Ma) {
					ans = Math.min(ans, dp[N - 1][i][j]);
				}
			}
		}
		System.out.println((ans < Integer.MAX_VALUE / 16) ? ans : -1);
	}
}

Measured memory_bytes: 41216
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String S=sc.next();
    int Len=S.length();
    String model="abcdefghijklmnopqrstuvwxyz";
    
    if(S.charAt(0)=='A'){
    }else{
      System.out.println("WA");
      return;
    }
    
    int Count=0;
    int index=-1;
    for(int i=2;i<Len-1;i++){
      if(S.charAt(i)=='C'){
        Count++;
        index=i;
      }
      if(Count>=2){
        System.out.println("WA");
        return;
      }
    }
    
    if(Count==0){
      System.out.println("WA");
      return;
    }
    
    
    
    for(int i=1;i<Len;i++){
      if(i==index){
      }else{
        for(int j=0;j<26;j++){
          if(S.charAt(i)==model.charAt(j)){
            j=26;
          }
          if(j==25){
            System.out.println("WA");
            return;
          }
        }
      }
    }
    
    System.out.println("AC");
   
  }
}

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

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

  vector<int> l;
  for (int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    l.push_back(tmp);
  }

  sort(l.begin(), l.end(), greater<int>());

  int sum=0;
  for (int i=0; i<k; i++) {
    sum += l[i];
  }

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


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    double R;
    cin >> R;
    cout << R * M_PI * 2 << '\n';

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
// #define f first
// #define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};
void solve(){
  string s;
  cin>>s;
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
  vector<string> v1={"+--","---","--+","-+-","++-","-++","+-+","+++"};
  rep(i,0,8){
    int rem=7-a;
    if(v1[i][0]=='+') rem-=b;
    else rem+=b;
    if(v1[i][1]=='+') rem-=c;
    else rem+=c;
    if(v1[i][2]=='+') rem-=d;
    else rem+=d;
    if(rem==0){
      cout<<a<<v1[i][0]<<b<<v1[i][1]<<c<<v1[i][2]<<d<<"=7"<<endl;
      return;
    }
  }
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 6980
N=int(input())
ans=[]
n = 55555
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
#print(len(primes),primes[:10])
for i in primes:
    if (i%5)==1:
        ans.append(i)
#print(len(ans),ans[:10])
print(*ans[:N])




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

void trace(int A[], int N)
{
    for(int i=0; i<N-1; i++)cout<<A[i]<<' ';
    cout<<A[N-1]<<endl;
}

void insertionSort(int A[], int N)
{
    for(int i=1; i<N; i++)
    {
        int j = i-1;
        int k = A[i];
        while(j>=0 && A[j]>k)
        {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = k;
        trace(A,N);
    }
}

int main()
{
    int N,A[110];

    cin>>N;
    for(int i=0; i<N; i++)cin>>A[i];

    trace(A,N);
    insertionSort(A,N);

    return 0;
}



Measured memory_bytes: 3104
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

void solve(){

	int n;
	cin>>n;
	int a[n];
	int b[n];

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

	sort(a ,a + n);
	sort(b , b + n);
	int ans = 0;
	if(n&1)
		ans = b[n/2] - a[n/2] + 1;
	else ans = (b[(n-1)/2] + b[n/2] - a[(n-1)/2] - a[n/2]) + 1;


	cout<<ans<<endl;
}

signed main(){

	int t = 1;
	//cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 6640
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			int sum=0;
			for(int i=0; i<n; i++){
				int size=sc.nextInt()+sc.nextInt()+sc.nextInt();
				int w=sc.nextInt();
				int[] sizes={60, 80, 100, 120, 140, 160};
				int[] ws={2, 5, 10, 15, 20, 25};
				for(int k=0; k<6; k++){
					if(size<=sizes[k]&&w<=ws[k]){
						sum+=600+k*200;
						break;
					}
				}
			}
			println(""+sum);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k, s = map(int, input().split())

    res = 0
    for x in range(k + 1):
        for y in range(k + 1):
            z = s - x - y
            if x + y + z == s and k >= z >= 0:
                res += 1

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 40940
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
//        int tc = scan.nextInt();
//        for (int i = 0; i < tc; i++) {
        solve();
//        }
        out.close();
    }

    private static void solve() {
        long x = scan.nextLong();
        int year = 0;
        long curr = 100;
        while (curr < x) {
            year++;
            curr *= 1.01;
        }
        out.println(year);
    }


    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

    public static MyScanner scan = new MyScanner();

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
//--------------------------------------------------------

}

Measured memory_bytes: 32908
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    for Cx in range(101):
        for Cy in range(101):
            H = INF
            for i in range(N):
                if h[i] > 0:
                    H = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)

            flg = True
            for i in range(N):
                if max(H - abs(x[i]-Cx) - abs(y[i]-Cy), 0) != h[i]:
                    flg = False
                    break
            if flg:
                print(" ".join([str(Cx), str(Cy), str(H)]))
                return


if __name__ == '__main__':
    main()


Measured memory_bytes: 67948
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

const int MOD = 1e9 + 7;

struct Matrix {
  vector<vector<long long>>mat;
  Matrix(int n) {
    mat.resize(n, vector<long long>(n, 0));
  }
  Matrix operator *(const Matrix& other) const {
    const int n = mat.size();
    Matrix mul(n);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < n; k++) {
          mul.mat[i][j] = (mul.mat[i][j] + (mat[i][k] * other.mat[k][j])) % MOD;
        }
      }
    }
    return mul;
  }
};

int main() {
  int n;
  long long k;
  cin >> n >> k;
  vector<vector<long long>>graph(n, vector<long long>(n, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> graph[i][j];
    }
  }
  // fast
  Matrix ans(n);
  for (int i = 0; i < n; i++) {
    ans.mat[i][i] = 1; // identity matrix;
  }
  Matrix acc(n);
  acc.mat = graph;
  while (k) {
    if (k%2 == 1) {
      ans = ans * acc;
    }
    acc = acc * acc;
    k /= 2;
  }
  long long answer = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      answer = (answer + ans.mat[i][j]) % MOD;
    }
  }
  cout << answer << "\n";
  // // slow
  // // dp[i][j] = number ways to walk into vertex i using j steps.
  // vector<vector<long long>>dp(n, vector<long long>(k + 1, 0));
  // for (int i = 0; i < n; i++) {
  //   dp[i][0] = 1; // 1 way to get to vertex i with 0 steps
  // }
  // for (int step = 1; step <= k; ++step) {
  //   for (int i = 0; i < n; ++i) {
  //     for (int j = 0; j < n; ++j) {
  //       if (graph[i][j]) {
  //         dp[j][step] = (dp[j][step] + dp[i][step - 1]) % MOD;
  //       }
  //     }
  //   }
  // }
  // long long ans = 0;
  // for (int i = 0; i < n; i++) {
  //   ans = (ans + dp[i][k])%MOD;
  // }
  // cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int par[100001];
int size[100001];
int group=100000;

int find(int x){           //親探し
	if(par[x]==x){
		return x;
	}else {
		int z= find(par[x]);
		par[x]=z;
		return z;
	}
}

bool  unit(int x, int y){
	
	int xpar=find(x);
	int ypar=find(y);
	
	if(xpar==ypar){return false;}   //すでに結合済み
	group--;
	par[ypar]=xpar;
	size[xpar]+=size[ypar];
	return true;
}

int main() {

int N,M;
cin>>N>>M;
group=N;
fx(N){
	par[x+1]=x+1;
	size[x+1]=1;
}

fx(M){
	int a,b,c;
	cin>>a>>b>>c;
	unit(a,b);
}
ce(group)

}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    int i; //カウント用
    int x; //置き換え用
    int up; //上面
    int front; //前面
    int side; //側面
    int question; //質問の数
    int dice[6]={0}; //サイコロの配列

    for(i=0;i<=5;i++){    
        scanf("%d",&dice[i]);
    }

    scanf("%d",&question);

    for(i=0;i<question;i++)
    {
        scanf("%d %d",&up,&front);
        if(up==dice[0])
        {
            if(front==dice[1])
            {
                side=dice[2];
            }
            if(front==dice[2])
            {
                side=dice[4];
            }
            if(front==dice[3])
            {
                side=dice[1];
            }
            if(front==dice[4])
            {
                side=dice[3];
            }
        }
        if(up==dice[1])
        {
            if(front==dice[0])
            {
                side=dice[3];
            }
            if(front==dice[2])
            {
                side=dice[0];
            }
            if(front==dice[3])
            {
                side=dice[5];
            }
            if(front==dice[5])
            {
                side=dice[2];
            }
        }
        if(up==dice[2])
        {
            if(front==dice[0])
            {
                side=dice[1];
            }
            if(front==dice[1])
            {
                side=dice[5];
            }
            if(front==dice[4])
            {
                side=dice[0];
            }
            if(front==dice[5])
            {
                side=dice[4];
            }
        }
        if(up==dice[3])
        {
            if(front==dice[0])
            {
            side=dice[4];
            }
            if(front==dice[1])
            {
            side=dice[0];
            }
            if(front==dice[4])
            {
            side=dice[5];
            }
            if(front==dice[5])
            {
            side=dice[1];
            }
        }
        if(up==dice[4])
        {
            if(front==dice[0])
            {
            side=dice[2];
            }
            if(front==dice[2])
            {
            side=dice[5];
            }
            if(front==dice[3])
            {
            side=dice[0];
            }
            if(front==dice[5])
            {
            side=dice[3];
            }
        }
        if(up==dice[5])
        {
            if(front==dice[1])
            {
            side=dice[3];
            }
            if(front==dice[2])
            {
            side=dice[1];
            }
            if(front==dice[3])
            {
            side=dice[4];
            }
            if(front==dice[4])
            {
            side=dice[2];
            }

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




Measured memory_bytes: 2036
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	a := sint64()
	printf("%d\n", a + a*a + a*a*a)
}


Measured memory_bytes: 1836
#include <iostream>

using namespace std;
string s;
char st[200005];
int u,i;
int main()
{
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(u&&st[u]=='S'&&s[i]=='T') u--;
        else st[++u]=s[i];
    }
    cout<<u;
    return 0;
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    cout << n/2 + n%2 << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  REP(i, SZ(s)) {
	if (s[i] != t[i]) {
		ans++;
	  }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*988244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
void input() { cin >> x >> y; }
void solve() {
    if(y % 2 == 1) {
        cout << "No" << endl;
        return;
    }
    if(x * 2 > y) {
        cout << "No" << endl;
        return;
    }
    if(x * 4 < y) {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 3656
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
def gcd(a,b):
  c = a%b
  if c == 0:
    return b
  else:
    return gcd(b,c)
c = 0
for i in a[1:]:
  c_ = gcd(i,a[0])
  if c_ == 1:
    c = 1
    break
  else:
    if c_ < c or c == 0:
      c = c_
print(c)


Measured memory_bytes: 14252
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(even, odd) = sc.nextInt  match{
      case i if i % 2 == 0 => Array(i/2, i/2)
      case i => Array(i/2, i/2 + 1)
    }
    println(even * odd)
  }

}


Measured memory_bytes: 27072
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	long long int n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	long long int minnumber = min(min(a, b), min(c, min(d, e)));
	cout << 4 + (n+minnumber-1) / minnumber;
}

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

long pow_and_mod(int x, int N)
{
    if (N == 0)
    {
        return 1;
    }
    else
    {
        return (x * pow_and_mod(x, N - 1)) % MOD;
    }
}

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;

    long a[N];
    // S = 作る三角形の辺の合計の長さ
    long S = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        S += a[i];
    }

    // DP1[j] : 辺Rの長さがjとなる選び方の個数
    // DP2[j] : 辺Rの長さがj、辺Bの長さS-jがとなる選び方の個数
    long DP1[S + 1];
    long DP2[S + 1];
    // 初期化
    for (int s = 0; s < S + 1; s++)
    {
        DP1[s] = DP2[s] = 0;
    }
    DP1[0] = 1; // TODO: ここ１なのなんなんだ
    DP2[0] = 1; // TODO: ここ１なのなんなんだ

    for (int i = 0; i < N; i++)
    {
        for (long j = S; j >= 0; j--)
        {
            if (j >= a[i])
            {
                DP1[j] = (DP1[j] * 2 + DP1[j - a[i]]) % MOD;
                DP2[j] = (DP2[j] + DP2[j - a[i]]) % MOD;
            }
            else
            {
                DP1[j] = (DP1[j] * 2) % MOD;
                DP2[j] = DP2[j];
            }
        }
    }

    /*
    cout << endl;
    for (int s = 0; s < S + 1; s++)
    {
        cout << DP1[s] << endl;
    }
    cout << endl;
    */

    // R_is_bigger_than_half_of_S : 辺RがS/2より長い選び方の数
    long R_is_bigger_than_half_of_S = 0;
    if (S % 2 == 0)
    {
        for (long j = S / 2; j <= S; j++)
        {
            R_is_bigger_than_half_of_S += DP1[j];
        }
    }
    else
    {
        for (long j = S; j > S / 2; j--)
        {
            R_is_bigger_than_half_of_S += DP1[j];
        }
    }

    R_is_bigger_than_half_of_S %= MOD;

    // R_and_B_is_half_of_S: 辺R、Bの長さが共にS/2となる選び方の数
    long R_and_B_is_half_of_S = 0;
    if (S % 2 == 0)
    {
        R_and_B_is_half_of_S = DP2[S / 2] % MOD;
    }

    //cout << R_is_bigger_than_half_of_S << endl;
    cout << ((pow_and_mod(3, N) - (R_is_bigger_than_half_of_S * 3) % MOD + MOD) % MOD + (R_and_B_is_half_of_S * 3)) % MOD << endl;

    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

int n, A[20 + 1];

int solve(i, m){
    if(m == 0) return 1;
    if(i > n || m <0) return 0;
    return solve(i+1, m) || solve(i+1, m-A[i]);
}

int main(){
    int q, m;
    int i;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &A[i]);
    }

    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d", &m);
        if(solve(0, m)){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }

    return 0;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N=int(input())

A=[]
for i in range(N):
    A.append(int(input()))

if N==1:
    print(A[0])
    exit(0)
k=lcm(A[0],A[1])
for i in range(2,N):
    k=lcm(k,A[i])
print(k)


Measured memory_bytes: 5432
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a[1001],b[1001],c,d;
  char tmp[100];
  for(int i=0;i<1001;i++){
    a[i]=0;b[i]=0;
  }
  while(strcmp(fgets(tmp,99,stdin),"\n")!=0){
    sscanf(tmp,"%d,%d",&c,&d);
    a[c]++;
  }
  while(scanf("%d,%d",&c,&d)!=EOF){
    b[c]++;
  }
  for(int i=1;i<1001;i++){
    if(a[i]>0 && b[i]>0){
      printf("%d %d\n",i,a[i] + b[i]);
    }
  }
}

Measured memory_bytes: 1208