akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
typedef long long ll;
const int N = 205;
ll n;
int a[55], len, cnt, length, lx[N], rx[N], nl, nr;
void solve(ll x) {
	while (x) a[++len] = x & 1, x >>= 1;
	nl = nr = 0;
	for (int i = len - 1; i; --i) {
		lx[++nl] = ++cnt;
		if (a[i]) rx[++nr] = ++cnt;
	}
		
	printf("%d\n", cnt << 1);
	for (int i = cnt; i; --i) printf("%d ", i);
	for (int i = nl; i; --i) printf("%d ", lx[i]);
	for (int i = 1; i <= nr; ++i) printf("%d ", rx[i]);
}
int main() {
	scanf("%lld", &n);
	solve(n + 1);
}

Measured memory_bytes: 128
# include <bits/stdc++.h>
using namespace std;
int main(){  
  int n;
  cin>>n;
  int res =0;
  int flag = 1;
  for(int i =0;i<n;i++)
  {   int x,y;
      cin>>x>>y;
      if(x==y)
      {  flag =1;
         res++;
      }
      else
      {
       flag=0;
       if(res<3)
       {  res =0;
       }
      }
  }
if(res>=3)
{  cout<<"Yes"<<endl;
}
else
{ cout<<"No"<<endl;
}
 return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
 	int W,H,x,y,r;
 	
 	scanf( "%d %d %d %d %d", &W,&H,&x,&y,&r);
 	
 	int rotate[3];
 	int i;

 	rotate[0]=r;
 	rotate[1]=r*(-1);
 	
 	int res=0;
 	for( i=0; i<2; i++) {
 		res = x+rotate[i];
 		if( res < 0 || W < res  ) {
 			printf( "No\n");
 			break;
 		}
 		res = y+rotate[i];
 		if( res < 0 || H < res  ) {
 			printf( "No\n");
 			break;
 		}
 	}
 	if( 2 == i) {
		printf( "Yes\n");
	}

	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

int n;
char s[6005];
int a[3005], b[3005];
int cnt1 = 0, cnt2 = 0;
int bel[6005];
string dp[3005];

int main() {
	n = read();
	scanf("%s", s);
	rep(i, 2 * n) {
		if (s[i] == 'a') bel[i] = cnt1, a[cnt1 ++] = i;
		else bel[i] = cnt2, b[cnt2 ++] = i;
	}
	for (int i = n - 1; ~i; -- i) {
		if (a[i] < b[i]) {
			int nex = i;
			for (int j = a[i]; j <= b[i]; ++ j) {
				nex = max(nex, bel[j] + 1);
			}
			dp[i] = "ab" + dp[nex];
		} else {
			int x = i;
			while (x + 1 < n && b[x + 1] <= a[x]) ++ x;
			rep(j, 2 * n) {
				if (bel[j] >= i && bel[j] <= x) dp[i] += s[j];
			}
			dp[i] += dp[x + 1];
		}
		dp[i] = max(dp[i], dp[i + 1]);
	}
	printf("%s\n", dp[0].c_str());
	return 0;
}


Measured memory_bytes: 14592
while True:
    m,f,r = map(int, input().split())
    if m == f == r ==-1:
        break
    elif (m+f) >= 80:
        print("A")
    elif (m+f) < 80 and (m+f) >= 65:
        print("B")
    elif ((m+f) < 65 and (m+f) >= 50) or (((m+f) < 50 and (m+f) >= 30 and (m != -1 and f != -1)) and r >= 50):
        print("C")
    elif (m+f) < 50 and (m+f) >= 30 and (m != -1 and f != -1):
        print("D")
    else:
        print("F")


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

int main()
{
	int i, N;
	long long A[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));

	long long ans = 0;
	for (i = 1; i < N; i++) {
		ans += A[i] / 2;
		if (A[i+1] > 1 && A[i] % 2 == 1) {
			A[i+1]--;
			ans++;
		}
	}
	ans += A[N] / 2;

	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
const int maxn=3005;
int dp[maxn][maxn];
pair<int,int> pre[maxn][maxn];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin>>s;
  cin>>t;

  int n=(int)s.length();

  int m=(int)t.length();
  
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        if( dp[i+1][j] < dp[i][j] ){
                dp[i+1][j] = dp[i][j]; 
                pre[i+1][j] = {i,j};
            }
            if( dp[i][j+1] < dp[i][j] ){
                dp[i][j+1] = dp[i][j]; 
                pre[i][j+1] = {i,j};
            }
            if( s[i]==t[j] && dp[i+1][j+1] < dp[i][j]+1 ){
                dp[i+1][j+1] = dp[i][j]+1;
                pre[i+1][j+1] = {i,j};
            }        
    }
  }
  int ans=0;
  pair<int,int>cur;

 for(int i=0;i<=n;i++){
   for(int j=0;j<=m;j++){
     if(dp[i][j]>ans){
       ans=dp[i][j];
       cur={i,j};
     }
   }
 }

int i=cur.first,j=cur.second;
string res;

 while(cur.first>0 && cur.second>0){

       i=cur.first;
       j=cur.second;
       pair<int,int>previous=pre[i][j]; 
        if(previous==(make_pair(i-1,j-1))){
            assert(s[i-1]==t[j-1]);
            res.push_back(s[i-1]);      
        }
       cur=previous; 

 }

 reverse(res.begin(),res.end());

 cout<<res<<endl;
 

  
  




     
  return 0;
}


Measured memory_bytes: 105984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1000000000+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

string s,t;

int calc(int l){
	int ans=0;
	for(int i=0,j=l;i<(int)t.size();++i,++j){
		if(s[j]!=t[i]) ++ans;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>s>>t;
	int ans=INF;
	for(int i=0;i<(int)s.size()-(int)t.size()+1;++i){
		ans=min(ans,calc(i));
	}
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3652
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()

if k == 1:
    print(0)
else:
    print(n-k)

Measured memory_bytes: 3064
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}]

int main(){
	ll a ; cin >> a ; yorn(a>=30) ;
}


Measured memory_bytes: 3600
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

vector<pair<ll, int>> factorize(ll n){
    vector<pair<ll, int>> ans;
    if(n == 1) return ans;
    for(ll i = 2; i*i <= n; i++){
        int cnt = 0;
        while(n%i == 0){
            cnt++;
            n /= i;
        }
        if(cnt) ans.eb(i, cnt);
    }
    if(n != 1) ans.eb(n, 1);
    return ans;
}

/*** MOD CALCULATION ***/

const int MOD = 1e9+7;
const int MAX = 1'000'005;

ll addM(ll a, ll b){
	return ((a % MOD) + (b % MOD)) % MOD;
}

ll mulM(ll a, ll b){
	return ((a % MOD) * (b % MOD)) % MOD;
}

ll powM(ll a, ll b){
	if(b == 0) return 1;
  	else if(b == 1) return a % MOD;
  	else if(b%2==0) return mulM(powM(a, b/2), powM(a, b/2));
  	else return mulM(a, mulM(powM(a, (b-1)/2), powM(a, (b-1)/2)));
}

// b^{-1} = b^{p-2} (mod p)
// a/b = a*b^{p-2} (mod p)
ll divM(ll a, ll b){ 
  	return mulM(a, powM(b, MOD-2));
}

// n!, (n!)^{-1} のテーブル作成
ll fac[MAX], finv[MAX], inv[MAX];
void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep3(i,2,MAX-1){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COMB(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;
}

/*** MOD CALCULATION ここまで ***/

void Main() {
    int n, m; cin >> n >> m;
    
    COMBinit();
    int ans = 1;
    for(auto [p, e] : factorize(m)){
        ans = mulM(ans, COMB(e+n-1, n-1));
    }

    cout << ans << endl;
    return;
}

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

Measured memory_bytes: 27068
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
#define LL long long
int n,a[100001],l;
LL ans = 1;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	  scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	l = 0;
	for(int i = n;i >= 0; i--){
	    if(l == 2)  {printf("%lld", ans);return 0;}
	  	if(a[i] == a[i - 1]){
	  		 i--;
	  		 ans *= a[i];
	  		 l++;
	  	}
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 640
import sys
lines = sys.stdin.readlines()
n = lines.pop(0)
e = lines.pop(-1).strip()
r = 0
s = False
for l in lines:
    l = l.strip()
    n, t = l.split(' ')
    if s:
        r += int(t)
    elif n == e:
        s = True
print(r)


Measured memory_bytes: 3060
import sys
readline = sys.stdin.readline

N, K = map(int, readline().split())

D = []
A = []
for i in range(K):
    D.append(int(readline()))
    A.append(list(map(int, readline().split())))

import itertools

a = set(itertools.chain.from_iterable(A))
print(N - len(a))

Measured memory_bytes: 9188
n,k=map(int,input().split())
lst=[list(map(int,input().split())) for i in range(k)]
mod=998244353


dp=[1]
imos=[0]*(2*n+10)
imos[0]=1
imos[1]=-1
for i in range(n):
    for l,r in lst:
        imos[i+l]+=dp[-1]
        imos[i+r+1]-=dp[-1]
    dp.append((dp[-1]+imos[i+1])%mod)


print(dp[n-1])

Measured memory_bytes: 84844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int A[400], B[400];
ll sum[401][401];
ll dp[401][401];
ll mod_pow(ll a, ll b) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll x = mod_pow(a, b / 2);
		return (x*x) % MOD;
	}
	return (a*mod_pow(a, b - 1)) % MOD;
}
int main() {
	int N, C;
	cin >> N >> C;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i <= 400; i++) {
		for (int j = 0; j <= 400; j++) sum[i][j] = mod_pow(j, i);
		for (int j = 1; j <= 400; j++) (sum[i][j] += sum[i][j - 1]) %= MOD;
	}
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= C; j++) {
			for (int k = 0; j + k <= C; k++) {
				ll x = sum[k][B[i]];
				(x += MOD - sum[k][A[i] - 1]) %= MOD;
				ll t = (dp[i][j] * x) % MOD;
				(dp[i + 1][j + k] += t) %= MOD;
			}
		}
	}
	cout << dp[N][C] << endl;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using std::string;
using std::vector;
using std::pair;
using pii = pair<int, int>;
using lint = long long;

bool c[100];
int main() {
	string str;
	std::cin >> str;
	for (int i = 0; i < str.size(); i++)
		c[str[i] - 'a'] = true;

	for (int i = 0; i <= 'z' - 'a'; i++) {
		if (c[i] == false) {
			printf("%c", i + 'a'); return 0;
		}
	}
	printf("None");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	
	ll lucas[102] = {2, 1,
3,
4,
7,
11,
18,
29,
47,
76,
123,
199,
322,
521,
843,
1364,
2207,
3571,
5778,
9349,
15127,
24476,
39603,
64079,
103682,
167761,
271443,
439204,
710647,
1149851,
1860498,
3010349,
4870847,
7881196,
12752043,
20633239,
33385282,
54018521,
87403803,
141422324,
228826127,
370248451,
599074578,
969323029,
1568397607,
2537720636,
4106118243,
6643838879,
10749957122,
17393796001,
28143753123,
45537549124,
73681302247,
119218851371,
192900153618,
312119004989,
505019158607,
817138163596,
1322157322203,
2139295485799,
3461452808002,
5600748293801,
9062201101803,
14662949395604,
23725150497407,
38388099893011,
62113250390418,
100501350283429,
162614600673847,
263115950957276,
425730551631123,
688846502588399,
1114577054219522,
1803423556807921,
2918000611027443,
4721424167835364,
7639424778862807,
12360848946698171,
20000273725560978,
32361122672259149,
52361396397820127,
84722519070079276,
137083915467899403,
221806434537978679,
358890350005878082,
580696784543856761,
939587134549734843
};
	int n;
	cin >> n;
	cout << lucas[n] << endl;
	
	return 0;
}

Measured memory_bytes: 256
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,t_limit=gsmi
ct=n.times.map{gsmi}.sort

ct.each do |c,t|
  next if t>t_limit
  putsend c
end
puts 'TLE'

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
struct fastio { fastio () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io;
template<class T, class U> bool chmax(T& a, const U &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmin(T& a, const U &b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long INF = (1LL << 60);

int main() {
	int n;
	std::cin >> n;
	const int ALL = (1 << n) - 1;
	std::vector<long long> x(n, 0), y(n, 0), p(n, 0);
	for (int i = 0; i < n; i++) {
		std::cin >> x[i] >> y[i] >> p[i];
	}
	
	std::vector<long long> ans(n + 1, INF), base(n, INF);
	for (int i = 0; i < n; i++) base[i] = std::min(std::abs(x[i]), std::abs(y[i]));
	std::vector<std::vector<long long>> mx((1 << n) + 10), my((1 << n) + 10);
	
	for (int s = 0; s < (1 << n); s++) {
		int se = (ALL ^ s);
		for (int t = se; t > 0; t = (t - 1) & se) {
			std::vector<long long> cost = base;
			if (mx[s].size()) {
				for (int i = 0; i < n; i++) chmin(cost[i], mx[s][i]);
			} else {
				mx[s].resize(n, INF);
				for (int i = 0; i < n; i++) if (s >> i & 1) {
					for (int j = 0; j < n; j++) {
						chmin(cost[j], std::abs(x[j] - x[i]));
						chmin(mx[s][j], std::abs(x[j] - x[i]));
					}
				}
			}
			if (my[t].size()) {
				for (int i = 0; i < n; i++) chmin(cost[i], my[t][i]);
			} else {
				my[t].resize(n, INF);
				for (int i = 0; i < n; i++) if (t >> i & 1) {
					for (int j = 0; j < n; j++) {
						chmin(cost[j], std::abs(y[j] - y[i]));
						chmin(my[t][j], std::abs(y[j] - y[i]));
					}
				}
			}
			int id = __builtin_popcount(s) + __builtin_popcount(t);
			long long value = 0;
			for (int i = 0; i < n; i++) value += cost[i] * p[i];
			chmin(ans[id], value);
		}
		std::vector<long long> cost = base;
		if (mx[s].size()) {
			for (int i = 0; i < n; i++) chmin(cost[i], mx[s][i]);
		} else {
			mx[s].resize(n, INF);
			for (int i = 0; i < n; i++) if (s >> i & 1) {
				for (int j = 0; j < n; j++) {
					chmin(cost[j], std::abs(x[j] - x[i]));
					chmin(mx[s][j], std::abs(x[j] - x[i]));
				}
			}
		}
		int id = __builtin_popcount(s);
		long long value = 0;
		for (int i = 0; i < n; i++) value += cost[i] * p[i];
		chmin(ans[id], value);
	}
	
	for (int i = 0; i <= n; i++) {
		std::cout << ans[i] << '\n';
	}
	
	return 0;
}
	

Measured memory_bytes: 12928
use proconio::input;

struct SeqIterator {
  stack : Vec<(usize, usize)>,
  n : usize,
  m : usize,
  seq : [usize; 11],
}

impl SeqIterator {
  fn new(n: usize, m : usize) -> SeqIterator {
    SeqIterator{ n, m, seq: [0; 11], stack : vec![(0,1)] }
  } 
}

impl Iterator for SeqIterator {
  type Item = Vec<usize>;
  fn next(&mut self) -> Option<Self::Item> {
    let n = self.n;
    let m = self.m;
    let stack = &mut self.stack;
    let seq = &mut self.seq;
    
    loop {
      let (i,j) = stack.pop()?;
      seq[i] = j;
      
      if i == n {
        break Some(seq[0 ..= n].to_vec());
      }
      
      for k in j ..= m {
        stack.push((i + 1, k));
      }
    }
  }
}

fn main() {
  input!{
      n: usize,
      m: usize,
      q: usize,
      qu: [(usize, usize, usize, i32); q]
  };
  let ans : i32 = SeqIterator::new(n, m)
  	.map(|seq| qu.iter().map(|&(a,b,c,d)| if seq[b] - seq[a] == c { d } else { 0 } ).sum())
  	.max()
  	.unwrap();
  println!("{}", ans);
}


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

/*define*/
char N[3];
int flg_7 = 0;

int main(){
/*inputs*/
    std::cin >> N;
    for(int i =0 ; i< 3; i++){
        if(N[i] == '7'){
            std::cout << "Yes";
            flg_7 = 1;
            break;
        }
    
    }
    if(flg_7 == 0){
        std::cout << "No";
    }
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <cmath>
#define REP(i,N) for(int i = 0; i < (N); i++)
using namespace std;

string s;
bool ck[26];

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

    cin >> s;

    REP(i,26) ck[i] = true;

    REP(i,s.length()){
        int index = (int)s[i] % 26;

        if(ck[index]){
            ck[index] = false;
        }
        else{
            cout << "no" << "\n";
            return 0;
        }
        
    }

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

Measured memory_bytes: 256
#include<stdio.h>

main(){
  int a, b, rest;
  scanf("%d%d", &a, &b);

  printf("%d\n", gcd(a, b));
  return 0;
}

int gcd(int x, int y){
  int rest;
  rest = x % y;
  while(rest != 0) {
    x = y;
    y = rest;
    rest = x % y;
  }
  return y;
}

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

const int MOD = 1000000007;

// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

//最小公倍数
int lcm(int number1,int number2){
	return number1 * number2 / gcd(number1,number2);	
}

int main(){
     int N;
     cin >> N;
     if(N % 2 == 0){
         cout << N << endl;
     }else{
         cout << N * 2 << endl;
     }
}

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

int main(void) {
    int a, b, c, d;
    int flag = 1;
    cin >> a >> b >> c >> d;
    while (true) {
        if (flag == 1) flag = 0;
        else flag = 1;
        if (flag == 0) c -= b;
        else a -= d;
        if (a <= 0) {
            cout << "No";
            return 0;
        }
        if (c <= 0) {
            cout << "Yes";
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <fstream>
#include <iostream>

using namespace std;

const int DIV = 1000000007;

#define MAX(a, b) (a < b ? b : a)
#define MIN(a, b) (b < a ? b : a)

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
	ifstream f("in.txt");
#else
	istream &f = cin;
#endif
	int n;
	f >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++)
		f >> s[i];
	vector<int> b(n), bmin(n), bmin2(n);
	priority_queue<pair<int, int>> pos, neg;
	for (int i = 0; i < n; i++) {
		int cur = 0, cur2 = 0;
		bmin[i] = 0;
		bmin2[i] = 0;
		for (int j = 0; j < s[i].size(); j++) {
			if (s[i][j] == '(')
				cur++;
			else
				cur--;
			if (s[i][s[i].size() - j - 1] == ')')
				cur2++;
			else
				cur2--;
			bmin[i] = std::min(bmin[i], cur);
			bmin2[i] = std::min(bmin2[i], cur2);
		}
		b[i] = cur;
		if (b[i] >= 0)
			pos.emplace(bmin[i], i);
		else
			neg.emplace(bmin2[i], i);
	}
	bool yes = true;
	int sumPos = 0;
	while (pos.size()) {
		if (pos.top().first + sumPos < 0)
			yes = false;
		sumPos += b[pos.top().second];
		pos.pop();
	}
	int sumNeg = 0;
	while (neg.size()) {
		if (neg.top().first + sumNeg < 0)
			yes = false;
		sumNeg -= b[neg.top().second];
		neg.pop();
	}
	yes = yes && (sumPos - sumNeg == 0);
	printf("%s\n", yes ? "Yes" : "No");

	return 0;
}



Measured memory_bytes: 54196
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
ans = [[None]*(n-i-1) for i in range(n-1)]
vs = [list(range(n))]
level = 1
def sub(l):
    if len(l)==1:
        return []
    v = len(l)//2
    for i in l[:v]:
        for j in l[v:]:
#             print(i,j)
            ans[i][j-i-1] = level
    return [l[:v], l[v:]]
while True:
    nvs = []
    for l in vs:
        nvs.extend(sub(l))
    if not nvs:
        break
    vs = nvs
    level += 1
write("\n".join(" ".join(map(str, ans[i])) for i in range(n-1)))

Measured memory_bytes: 81516
import java.util.*;
import java.io.PrintWriter;

public class Main{
	static int[] c=new int[26];
	static int[] lastD=new int[26];
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int d=sc.nextInt();
		for(int i=0; i<26; i++){
			c[i]=sc.nextInt();
		}
		int[][] s=new int[d][26];
		for(int i=0; i<d; i++){
			for(int j=0; j<26; j++){
				s[i][j]=sc.nextInt();
			}
		}
		int maxScore=-1;
		int maxInd=-1;
		//j:何日目
		for(int j=0; j<d; j++){
			//i:どの大会をやるか
			for(int i=1; i<=26; i++){
				int sati=0;
				lastD[i-1]=j+1;
				sati+=s[j][i-1];
				sati-=subSati(j+1);
				sati=Math.max(sati+1000000,0);
				lastD[i-1]=0;
				if(maxScore<sati){
					maxScore=sati;
					maxInd=i;
				}
			}
			System.out.println(maxInd);
			lastD[maxInd-1]=j+1;
			maxScore=-1;
			maxInd=-1;
		}
	}
	static int subSati(int d){
		int ret=0;
		for(int i=0; i<26; i++){
			ret+=c[i]*(d-lastD[i]);
		}
		return ret;
	}
}


Measured memory_bytes: 46516
#include <iostream>

int main(void) {
  int k, x;
  std::cin >> k;
  std::cin >> x;
  int min, max;
  min = x - k + 1;
  max = x + k - 1;
  for (int i = min; i <= max; i++) {
    std::cout << i;
    if (i != max) {
      std::cout << " ";
    }
  }
  std::cout << std::endl;
  return 0;
}


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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n, m;
  cin >> n >> m;
  vt<int> cnt(n + 1, 0);
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    cnt[a]++; cnt[b]++;
  }

  rep(i, 1, n + 1) {
    if(cnt[i] % 2 == 1) return cout << "NO\n", 0;
  }
  cout << "YES\n";
}

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

int main()
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> v(s.size(), 0);
    for (int i = 1; i < s.size(); i++) {
        if (s[i - 1] == 'A' && s[i] == 'C') {
            v[i] = v[i - 1] + 1;
        } else {
            v[i] = v[i - 1];
        }
    }
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << v[r - 1] - v[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int,null_type, less<int>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e6+10, mod=1e9+7;


int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int a; string s;
	cin>>a>>s;
	if(a<3200)cout<<"red";
	else cout<<s;
}
// check for any potential overflow before submitting

	


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;



public class Main {
	public static void init(int[] arr, int[] init) {
		for(int i = 0; i < arr.length; i++) {
			arr[i] = init[i];
		}
	}
	public static int insertionSort(int[] arr, int n, int g) {
		int count = 0;
		for(int i = g; i < n; i++) {
			int key = arr[i];
			int j = i - g;
			while(j >= 0 && arr[j] > key) {
				arr[j + g] = arr[j];
				j -= g;
				count++;
			}
			arr[j + g] = key;
		}
		return count;

	}
	public static int shellSort(int[] arr, int n, List<Integer> list) {
		int count = 0;
		for(int i = 0; i < list.size(); i++) {
			count += insertionSort(arr, n, list.get(i));
		}
		return count;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] init = new int[n];
		int count = 0;
		List<Integer> g = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			init[i] = sc.nextInt();
			arr[i] = init[i];
		}
		int index = 1;
		g.add(index);
		if(n > 4) {
			index = 4;
			g.add(0, index);
		}
		while(index <= n / 9) {
			if(index == 4) {
				index = index * 3 + 1;
				continue;
			}
			g.add(0, index);
			index = index * 3 + 1;
		}
		while (true) {
			count = shellSort(arr, n, g);
			if(count < Math.ceil(Math.pow(n, 1.5))) {
				break;
			} else {
				init(arr, init);
				count = 0;
				index = 3 * index + 1;
				g.add(0, index);
			}
		}
		System.out.println(g.size());
		for(int i = 0; i < g.size(); i++) {
			if(i == g.size() - 1) {
				System.out.println(g.get(i));
			} else {
				System.out.print(g.get(i) + " ");
			}
		}
		System.out.println(count);
		for (int i = 0; i < arr.length; i++) {
			System.out.println(arr[i]);

		}
		sc.close();
	}
}



Measured memory_bytes: 303704
s = int(input())
a = [s]
i = 1
while True:
    if a[i - 1] % 2 == 0:
        a.append(a[i - 1] // 2)
    else:
        a.append(a[i - 1] * 3 + 1)
    if a.count(a[i]) == 2:
        print(i + 1)
        break
    i += 1


Measured memory_bytes: 9088
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}


void warshall_floyd(ll n, vvi &d) {
	trep(k, n, i, n, j, n) {
		d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
}

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

	vvi S(N, vi(N));
	vvi d(N, vi(N));
	ll inf = LLMAX / 3;

	vvi graph(N, vi());

	drep(i, N, j, N) {
		char a; cin >> a;
		S[i][j] = a - '0';
		d[i][j] = (i == j) ? 0 :
			S[i][j] ? 1 : inf;

		if (S[i][j]) {
			graph[i].pb(j);
		}
	}

	warshall_floyd(N, d);

	ll maxi = 0, maxj = 0, max = 0;

	drep(i, N, j, N) {
		if (d[i][j] > max) {
			maxi = i; maxj = j;
			max = d[i][j];
		}
	}

	vvi group(max + 1, vi());

	rep(i, N) {
		ll id = d[maxi][i];
		group[id].pb(i);
	}


	/*
	for (auto i : d) {
		for (auto j : i) {
			cout << j << " ";
		}
		cout << endl;
	}

	for (auto i : group) {
		for (auto j : i) {
			cout << j << " ";
		}
		cout << endl;
	}
	*/



	rep(i, max + 1) {
		ll size = group[i].size();
		// cout << "group " << i << endl;
		for (ll j = 0; j < size - 1; j++) {
			for (ll k = j + 1; k < size; k++) {
				// cout << "(j, K) : " << j << ", " << k << endl;

				if (S[group[i][j]][group[i][k]] == 1) {
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}

	cout << max + 1 << endl;
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>

int main(void)
{
	char data[7][7] = {0};
	char input[402] = {0};
	int i, j, k, p, len, a, b;
	k = 0;
	p = 0;
	for (i = 0; i < 6; i++)
	{
		for (j = 0; j < 5; j++)
		{
			if ( j == 1 && i == 5)
			{
				data[j][i] = '.';
				k++;
				continue;
			}
			if (j == 2 && i == 5)
			{
				data[j][i] = '?';
				k++;
				continue;
			}
			if (j == 3 && i == 5)
			{
				data[j][i] = '!';
				k++;
				continue;
			}
			if (j == 4 && i == 5)
			{
				data[j][i] = ' ';
				k++;
				continue;
			}
			data[j][i] = 'a' + k;
			k++;
		}
	}
	while (scanf("%c", &input[0]) != EOF)
	{    
		if(input[0] == '\n')
			continue;
		for (i = 1; i < 400; i++)
		{
			scanf("%c", &input[i]);
			if (input[i] == '\n')
			{
				len = i;
				break;
			}
		}
		p = 0;
		if ((len % 2) != 0)
		{
			printf("NA\n");
			continue;
		}
		for (i = 0; i < len; i += 2)
		{
			if (input[i] < '1' || input[i] > '6' || input[i+1] < '1' || input[i+1] > '5')
			{
				p = 1;
				break;
			}
		}
		if (p == 1)
		{
			printf("NA\n");
			continue;
		}
		for (i = 0; ; i += 2)
		{
			if (i == len || i + 1 == len)
				break;
			a = input[i+1] - '0';
			b = input[i] - '0';
			printf("%c", data[a-1][b-1]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(){
    int N;
    scanf("%d", &N);
    int a[100];

    int sum = 0;

    for (int n = 0; n < 100; n++)
    {
        a[n] = 0;

    }

    for (int n = 0; n < N; n++){
        scanf("%d", &a[n]);
    }

    for (int i = 0; i < N; i++){
        int k = a[i];
        for (int l = i; l < N; l++){
            if(a[l] > a[i]){
                a[i] = a[l];
                a[l] = k;
                k = a[i];
            }
        }
    }

    for (int m = 0; (N > 2 * (m - 1)) && (N > 2 * (m - 1) + 1); m++)
    {
        sum = sum + (a[2 * m] - a[2 * m + 1]);
    }
    printf("%d", sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = -INF;

int main()
{
ll n,k;
cin >> n>>k;
ll v[n] = {};
rep(i, n)
{
    cin >> v[i];
}
ll maxa=k;
if(k>n)maxa=n;

for(ll i=0;i<=maxa;i++){
    rep(j,i+1){
        vector<ll> vv;
        rep(l,j){
            vv.push_back(v[l]);
           // cout << v[l] << " ";
        }
        rep(l,i-j){
            vv.push_back(v[n-l-1]);
            //cout << v[n-l-1] << " ";
        }
        sort(vv.rbegin(), vv.rend());
        rep(l,k-i){
            if(vv.size()>0&&vv[vv.size()-1]<0)vv.pop_back();
            else break;
        }
        ll sum=0;
        rep(l,vv.size()){
            sum+=vv[l];
        }
        ans=max(sum,ans);
        vv.clear();

    }
}

cout << ans << endl;
return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
    int n, p;
    string s;
    cin >> n >> p >> s;
    if (p == 2 || p == 5) {
        ll ans = 0;
        REP(i, n)
        {
            if ((s[i] - '0') % p == 0) {
                ans += (i + 1);
            }
        }
        cout << ans << endl;
        return 0;
    }
    vector<ll> amari(p, 0);
    amari[0] = 1;
    ll a = 0;
    ll ten = 1;
    REP(i, n)
    {
        a += (s[n - 1 - i] - '0') * ten;
        a %= p;
        amari[a]++;
        ten = (ten * 10) % p;
    }
    ll ans = 0;
    REP(i, p)
    {
        ans += amari[i] * (amari[i] - 1) / 2;
    }
    cout << ans << endl;
}

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

ll a, b, k;

int main(){
    cin >> a >> b >> k;
    
    if(k >= a + b){
        cout << 0 << ' ' << 0;    
    } else if(a >= k){
        cout << a - k << ' ' << b;
    } else {
        cout << 0 << ' ' << b + a - k;
    }
    
    
}


Measured memory_bytes: 256
import java.util.*;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static HashMap<String,String> map = new HashMap<>();

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a[] = new int[5];
		for(int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
		}
		int time = (Math.abs(Math.min(0, a[0])) * a[2]) + (a[0]<=0?a[3]:0) + ((a[1] - Math.max(a[0], 0)) * a[4]);
		System.out.println(time);
	}
}

Measured memory_bytes: 26040
import numpy as np

#take input
n = int(input())

#Filter only the even number
list_a = [int(a) for a in input().split() if not int(a)%2 ]

numOps = 0

#iterate each element and divide by two over and over
for el in list_a:
    #1. check iteratively if divisible by two, then divide by two and count up
    while(el%2 == 0):
        el = el / 2
        numOps += 1

print(numOps)


Measured memory_bytes: 13236
/* You lost the game. */

#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cfloat>
#include <numeric>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <vector>

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000009

#define si(n) scanf("%d", &n)
#define sii(n,m) scanf("%d %d", &n, &m)
#define siii(n,m,k) scanf("%d %d %d", &n, &m, &k)
#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define ss(s) scanf("%s", s)
#define sai(t,n) fin(i,n) { scanf("%d", &t[i]); }
#define sal(t,n) fin(i,n) { scanf("%lld", &t[i]); }

#define pi(n) printf("%d\n", n)
#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s);
#define pii(n,m) printf("%d %d\n", n, m)
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define pai(t,n) fin(i,n) { printf("%d ", t[i]); } printf("\n"); 
#define pal(t,n) fin(i,n) { printf("%lld ", t[i]); } printf("\n"); 

#define L long long int
#define D double
#define PII pair<int, int>
#define VPII vector<PII>
#define VL vector<L>
#define VI vector<int>
#define VVI vector<VI>

using namespace std;

char tm[60][60], tn[60][60];
int n, m;
int verif(int x, int y) {
    fin2(i, x, x+m) {
        fin2(j, y, y+m) {
            if (tm[i-x][j-y] != tn[i][j]) { return 0; }
        }
    }
    return 1;
}

int main() {
    sii(n, m);
    fin(i, n) { ss(tn[i]); }
    fin(i, m) { ss(tm[i]); }
    fin(i, n-m+1) {
        fin(j, n-m+1) {
            if (verif(i, j) == 1) { printf("Yes\n"); return 0; }
        }
    }
    printf("No\n"); return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main()
{
   int N;
   cin>>N; 
   int a[N];
   for(int i=0; i<N; i++){
       cin>>a[i];
   }
   
   sort(a,a+N);
   
   cout<<a[N-1]-a[0]<<endl;
   return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            bool isStart = true;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                if (!isStart) sb.Append("\n");
                else isStart = false;

                int n = input.Length;

                int[] memo = new int[5];

                for (int i = n - 1, j = 4; i >= 0; i--, j--)
                {
                    memo[j] = int.Parse(input[i].ToString());
                }

                bool[,] isSpaceT = new bool[2, 5];
                bool[,] isSpaceU = new bool[5, 5];

                for (int i = 0; i < 5; i++)
                {
                    if (memo[i] >= 5)
                    {
                        isSpaceT[0, i] = true;
                        memo[i] -= 5;
                    }
                    else
                    {
                        isSpaceT[1, i] = true;
                    }

                    isSpaceU[memo[i], i] = true;
                }

                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        sb.Append(isSpaceT[i, j] ? " " : "*");
                    }
                    sb.Append("\n");
                }

                for (int i = 0; i < 5; i++) sb.Append("=");
                sb.Append("\n");

                for (int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        sb.Append(isSpaceU[i, j] ? " " : "*");
                    }
                    sb.Append("\n");
                }
            }
            Console.Write(sb);
        }
    }
}

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

#define p 1000000007

long long int power(long long int a, long long int b) {
	if(b == 0)
		return 1;
	long long int temp = power(a, b/2);
	temp *= temp;
	temp %= p;
	if(b%2 == 0)
		return temp;
	return (temp*a)%p;
}

long long int factorial(long long int n) {
	long long int answer = 1;
	if(n == 0)
		return answer;
	for(int i=1; i<n+1; i++) {
		answer *= i;
		answer %= p;
	}
	return answer;
}

long long int choose(long long int n, long long int k)  {
	// cout<<n<<"  "<<k<<"  "<<n-k<<endl;

	long long int answer = 1;
	answer *= factorial(n);
	answer %= p;
	answer *= power(factorial(k), p-2);
	answer %= p;
	answer *= power(factorial(n-k), p-2);
	answer %= p;
	return answer;
}

int main() {
	int x,y;
	cin>>x>>y;

	if((x+y)%3 != 0) {
		cout<<"0";
		return 0;
	}

	if(y > x) {
		swap(x,y);
	}
	if(x > 2 * y){
		cout<<"0";
		return 0;
	}

	int steps = (x + y)/3;
	int x_max = 2 * steps;

	// cout<<steps<<"  "<<x_max<<"  "<<x_max-x<<endl;
	cout<<choose(steps, x_max-x);

	return 0;
}

Measured memory_bytes: 256
#include<stack>
#include<queue>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  stack<char> q3;
  char c;
  string s;
  int x=0,i,a,b,q;
  queue<char> q1,q2;
  cin >> s;
  scanf("%d\n",&q);
  for(i=0;i<q;i++){
    scanf("%d",&a);
    if(a==1){
      if(x==0){
        x=1;
      }
      else{
        x=0;
      }
    }
    else{
      scanf("%d %c\n",&b,&c);
      if(x==0 && b==1){
        q1.push(c);
      }
      else if(x==0 && b==2){
        q2.push(c);
      }
      else if(x==1 && b==1){
        q2.push(c);
      }
      else{
        q1.push(c);
      }
    }
  }
  if(x==0){
    while(!q1.empty()){
      c=q1.front();
      q1.pop();
      q3.push(c);
    }
    while(!q3.empty()){
      c=q3.top();
      q3.pop();
      printf("%c",c);
    }
    cout << s;
    while(!q2.empty()){
      c=q2.front();
      q2.pop();
      printf("%c",c);
    }
  }
  else{
    while(!q2.empty()){
      c=q2.front();
      q2.pop();
      q3.push(c);
    }
    while(!q3.empty()){
      c=q3.top();
      q3.pop();
      printf("%c",c);
    }
    reverse(s.begin(),s.end());
    cout << s;
    while(!q1.empty()){
      c=q1.front();
      q1.pop();
      printf("%c",c);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int S = sc.nextInt();
		int h = S/3600;
		int m = (S%3600)/60;
		int s = S%60;
		
		System.out.println(h+":"+m+":"+s);
		

		
	}

}


Measured memory_bytes: 26292
#include <stdio.h>
#include <stdlib.h>
#define N 10000000

int MCO(int *p, int n){
  int i, l, k, j, m[101][101], q;

  for(i = 1; i <= n; i++){
    m[i][i] = 0;
  }
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n -l +1; i++){
      j = i +l -1;
      m[i][j] = N;
      for(k = i; k
      < j; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if(m[i][j] > q){
	  m[i][j] = q;
	}
      }
    }
  }

  return m[i-1][j];
}

int main(){
  int i, n, p[100];

  scanf("%d", &n);

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

  return 0;
}



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

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

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

int main(){

  string str;
  cin >> str;
  int n = str.size();
  int flag = 1;

  for(int i = 0; i < n; i++){
    for(int j = i+1; j <= n; j++){
      if(str[i] == str[j]){
        flag = 0;
        break;
      }
    }
    if(flag == 0) break;
  }
  if(flag == 1){
    cout << "yes" << endl;
  }else{
    cout << "no" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>d(n), h(n);
	ll maxh = 0;
	rep(i, n) {
		cin >> d[i];
		if (d[0] != 0) {
			cout << 0 << endl;
			return 0;
		}
		if (i != 0 && d[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
		h[d[i]]++;
		maxh = max(maxh, d[i]);
	}
	ll ans = 1;
	rep(i, maxh) {
		rep(j, h[i + 1]) {
			ans *= h[i];
			ans %= 998244353;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4820
x, k, d = map(int, input().split())

x = abs(x)
if x == 0:
    if k % 2 == 0:
        print(0)
        exit(0)
    else:
        print(d)
        exit(0)

else:
    cent = x % d
    num = x // d

if d / 2 > cent and cent != 0:
    cent = d - cent
    num += 1

if num >= k:
    print(abs(x) - k * d)
    exit(0)

rem = k - num

if rem % 2 == 0:
    print(cent)
    exit(0)
else:
    print(d - cent)

Measured memory_bytes: 9112
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B;
	cin>>A>>B;
	double x1=(A*100.0)/8.0;
	double x2=B*10;
	bool bA=false;
	bool bB=false;
	if ((int)(x1*0.08)==A && (int)(x1*0.1)==B){
		bA=true;
	}
	if ((int)(x2*0.08)==A && (int)(x2*0.1)==B){
		bB=true;
	}
	int x=min(x1,x2);
	while (true){
		if ((int)(x*0.08)==A && (int)(x*0.1)==B){
			cout<<x<<endl;
			return 0;
		}
		if ((int)(x*0.08)>A || (int)(x*0.1)>B){
			cout<<-1<<endl;
			return 0;
		}
		x++;
	}
	/*
	if (bA && bB){
		cout<<min((int)x1,(int)x2)<<endl;
		return 0;
	}
	if (bA){
		cout<<(int)x1<<endl;
		return 0;
	}
	if (bB){
		cout<<(int)x2<<endl;
		return 0;
	}
	cout<<-1<<endl;
	*/
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#define k first
#define v second
using namespace std;

const int N = 200005;
int n, T;

long long score(vector<pair<int, int>> &x)
{
  	if(x.empty()) return 0;
	long long res = 0;
	sort(x.begin(), x.end());
	priority_queue<int> q;
	int idx = x.size() - 1;
	for(int i = x[idx].k; i; --i)
	{
		while(idx >= 0 && x[idx].k == i) q.push(x[idx--].v);
		if(!q.empty())
		{
			res += q.top();
			q.pop();
		}
	}
	return res;
}

int main(){
	cin >> T;
	while(T--)
	{
		cin >> n;
		long long ans = 0;
		vector<pair<int, int>> L, R;
		for(int i = 0, k, l, r; i < n; ++i)
		{
			cin >> k >> l >> r;
			if(l <= r) {
				ans += l;
				R.push_back({n-k, r-l});
			}
			else
			{
				ans += r;
				L.push_back({k, l-r});
			}
		}
		ans += score(L);
		ans += score(R);
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 5176
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define pb push_back
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;

struct mode
{
	int a,b,w;
};

vector<mode> v;

int main()
{jizz
	int L,x,t,s;
	cin >> L,x=__lg(L);
	for(int i=0;i<x;++i)
		v.pb(mode{x-i,x-i+1,1<<i}),v.pb(mode{x-i,x-i+1,0});
	for(L-=1<<x,s+=1<<x;L;)
	{
		t=__lg(L);
		v.pb(mode{1,x-t+1,s});
		L-=1<<t,s+=1<<t;
	}
	cout << x+1 << " " << v.size() << "\n";
	for(auto i:v)
		cout << i.a << " " << i.b << " " << i.w << "\n";
} 

Measured memory_bytes: 256
N = int(input())
L = [0]*201

for i in range (1, 201):
	for j in range (i, 201):
		if j%i==0:
			L[j]+=1
            
count = 0

for i in range (1, N+1):
	if i%2 == 1 and L[i] == 8:
		count+=1

print(count)

Measured memory_bytes: 64068
#include <stdio.h>

int main(){
    int N, X, i, cnt;
    int L[110] = {};
    int D[110] = {};
    scanf("%d%d", &N, &X);
    for(i=0; i<N; i++){
        scanf("%d", &L[i]);
    }
    D[0] = 0;
    for(i=0; i<N; i++){
        D[i+1] = D[i] + L[i];
    }
    for(i=0; i<=N; i++){
        if(X>=D[i]) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int num1 = sc.nextInt();
    	  int num2 = sc.nextInt();
    		if(num2 % num1 == 0) {
              System.out.println(num1 + num2);
            } else {
              System.out.println(num2 - num1);
            }
        }
      }

Measured memory_bytes: 21844