akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
const double pi = acos(-1);
const int BUF_SIZE = (int)1e6 + 10;
template <typename T> inline bool chkmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}
template <typename T> inline bool chkmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
struct fastIO {
	char buf[BUF_SIZE], buf1[BUF_SIZE];
	int cur, cur1; FILE *in, *out;
	fastIO() { cur = BUF_SIZE, in = stdin, out = stdout; cur1 = 0; }
	inline char getchar() { if(cur == BUF_SIZE) fread(buf, BUF_SIZE, 1, in), cur = 0; return *(buf + (cur++)); }
	inline void putchar(char ch) { *(buf1 + (cur1++)) = ch; if (cur1 == BUF_SIZE) fwrite(buf1, BUF_SIZE, 1, out), cur1 = 0; } 
	inline int flush() { if (cur1 > 0) fwrite(buf1, cur1, 1, out); return cur1 = 0; }
}IO;
#define getchar IO.getchar
#define putchar IO.putchar
LL read() {
	char ch = getchar();
	LL x = 0, flag = 1;
	for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
	for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
	return x * flag;
}
void write(LL x) {
	if (x < 0) putchar('-'), x = -x;
	if (x >= 10) write(x / 10);
	putchar(x % 10 + 48);
}

const int Maxn = 1e5 + 9;
set <int> G[Maxn];
map<pair<int, int>, int> buc;
queue <pair<int, int> > que;
int fa[Maxn], n;
int find(int u) { return (fa[u] ^ u) ? (fa[u] = find(fa[u])) : u; }
void add(int u, int v) { G[u].insert(v); }

void link(int u, int v) {
	add(u, v), add(v, u);
	if (u > v) swap(u, v);
	if (++buc[make_pair(u, v)] == 2) que.push(make_pair(u, v));
}

void Init() {
	n = read();
	rep (i, 1, n) fa[i] = i;
	rep (i, 1, n - 1) link(read(), read());
	rep (i, 1, n - 1) link(read(), read());
}

void Solve() {
	int cnt = 0;
	while (!que.empty()) {
		pair<int, int> p = que.front(); que.pop(); 
		p.first = find(p.first), p.second = find(p.second);
		if (p.first == p.second) continue;

		int u = p.first, v = p.second;
		
		if (G[u].size() > G[v].size()) swap(u, v);
		++cnt, fa[u] = v;

		for (set <int> :: iterator IT = G[u].begin(); IT != G[u].end(); ++IT) {
			int q = find(*IT);
			if (q != v) link(q, v);
		}
	}
	printf("%s\n", cnt == n - 1 ? "YES" : "NO");
}

int main() {
	//freopen("bosky.in", "r", stdin);
	//freopen("bosky.out", "w", stdout);

	Init();
	Solve();

#ifdef Qrsikno
	debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
	return IO.flush();
}



Measured memory_bytes: 55040
n = int(input())
l = {}
for i in range(0,n):
    #print (i)
    line = input()
    l[i] = line.strip().split()
x = str(input())
time = 0

for i in range(0,n):
    if l[i][0] == x:
        l.pop(i)
        break
    l.pop(i)

for i in l:
    time += int((l[i][1]))

print (time)

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

#define ll long long int
#define ld long double
#define pb push_back

ll mod = 1000000007;

using namespace std;

int main()
{
	
	 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	 int n,k;
	 cin>>n>>k;
	 int nn = n-2;
	 ll temp = (nn*(nn+1))/2;
	 if(temp < k)
	 {
		cout<<"-1\n";
		return 0;
	 }	

	 std::vector<pair<int,int>> v;

	 for (int i = 2; i <= n; ++i)
	 {
	 	v.push_back(make_pair(1,i));
	 }

	 int s = n;
	 int c = n-2;

	 while(temp != k)
	 {
	 	if(temp - c >=  k)
	 	{
	 		temp -= c;
	 		for (int i = s-1; i > 1; --i)
	 		{
	 			v.push_back(make_pair(s,i));
	 		}

	 		s--;
	 		c--;
	 	}
	 	else
	 	{
	 		for (int i = s-1; i > 1; --i)
	 		{
	 			v.push_back(make_pair(s,i));
	 			temp--;
	 			if(temp == k)
	 				break;
	 		}
	 	}
	 }

	 cout<<v.size()<<"\n";

	 for (int i = 0; i < v.size(); ++i)
	 {
	 	cout<<v[i].first<<" "<<v[i].second<<"\n";
	 }
	 
	
	return 0;
}

Measured memory_bytes: 384
import math
list1=list(map(int,input().strip().split()))[:4]
a,b,h,m=list1[0],list1[1],list1[2],list1[3]
angle=(0.5*(h*60+m))-(6*m)
an=(math.pi/180)*angle
c=math.sqrt((a**2)+(b**2)-(2*a*b*math.cos(an)))
print(c)

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

int main() {
  int N,A;
  cin >> N >>A;

  if (A >= 499) {
    cout << "Yes" << endl;
  }
  else if(N % 500 <= A) {
    cout << "Yes" <<endl;
  }
  else 
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
    int n,d;
    cin >>n>>d;
    vector<vector<int>>x(n,vector<int>(d));
    rep(i,n){
        rep(j,d) cin>>x[i][j];
    }
int ans=0;
rep(i,n)rep(j,i){
    int sq=0;
    rep(k,d){
        int s=x[i][k]-x[j][k];
        sq+=s*s;

    }
    int s=sqrt(sq)+0.5;
    if(s*s==sq)ans++;
}
cout<<ans<<endl;
return 0;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

long long n;
int num_digits;
int num_nine;
int first_digit;

int main(){
	scanf("%lld", &n);
	while(n >= 10){
		num_digits++;
		num_nine += (n % 10 == 9);
		n /= 10;
	}
	first_digit = n;
	if(num_nine == num_digits){
		printf("%d\n", first_digit + 9 * num_digits);
	}else{
		printf("%d\n", first_digit - 1 + 9 * num_digits);
	}
	return 0;
}

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

using namespace std;

int main() {
	Int N, M;
	cin >> N >> M;
	vector<Int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	sort(a.begin(), a.end());
	Int low = 0, high = 1e15;
	while (high - low > 1) {
		Int mid = (high + low) / 2;
		Int m = 0;
		for (int i = 0; i < N; ++i) {
			m += a.end() - lower_bound(a.begin(), a.end(), mid - a[i]);
		}
		if (m >= M) { low = mid; }
		else { high = mid; }
	}

	vector<Int> d(N + 1, 0);
	for (int i = N - 1; i >= 0; --i) {
		d[i] = d[i + 1] + a[i];
	}
	
	Int ans = 0;
	Int cnt = 0;
	for (int i = 0; i < N; ++i) {
		Int x = upper_bound(a.begin(), a.end(), low - a[i]) - a.begin();
		ans += (N - x) * a[i] + d[x];
		cnt += N - x;
	}
	ans += low * (M - cnt);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a[ohara], b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n;
    rep(i, n)
    {
        cin >> a[i];
        sum += a[i];
        cnt += i + 1;
    }
    ll sousa = sum / cnt;
    if (sum % cnt != 0)
        Cout("NO");
    else
    {
        ll kagen, zyou;
        kagen = sousa;
        zyou = n * sousa;
        rep(i, n)
        {
            if (kagen <= a[i] && a[i] <= zyou)
                continue;
            Cout("NO");
            return 0;
        }
        a[n] = a[0];
        rrep(i, 1, n + 1)
        {
            tmp += a[i] - a[i - 1];
        }
        if (tmp != 0)
            Cout("NO");
        else
        {
            rrep(i, 1, n)
            {
                tmp = (a[i] - a[i - 1]);
                if (tmp >= 0)
                {
                    if (tmp != sousa)
                    {
                        Cout("NO");
                        return 0;
                    }
                }
                else
                {
                    tmp *= -1;
                    ll herakai;
                    herakai = tmp / (n - 1);
                    if (tmp % (n - 1) != 0)
                        herakai++;
                    tmp -= herakai * (n - 1);
                    herakai += abs(tmp);
                    if (herakai != sousa)
                    {
                        Cout("NO");
                        return 0;
                    }
                }
            }
            Cout("YES");
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
//#include <fstream>

using namespace std;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    int S;
    cin >> S;
    
    int upper = S / 100;
    int rower = S - upper * 100;
    
    if (1<=upper && upper<=12 && 1<=rower && rower<=12)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (1<=rower && rower<=12)
    {
        cout << "YYMM" << endl;
    }
    else if (1<=upper && upper<=12)
    {
        cout << "MMYY" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }
    
    
    
    return 0;
}

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

int main(void) {
	int n, x, y, m, i;
	char d;
	while (true)
	{
		int cnt = 0;
		int fx = 10;
		int fy = 10;
		int fld[21][21] = { 0 };

		cin >> n;
		if (n == 0) break;
		for (int j = 0; j < n; j++) {
			cin >> x >> y;
			fld[x][y] = 1;
		}
		cin >> m;
		for (int j = 0; j < m; j++) {
			cin >> d >> i;
			for (int k = 0; k < i; k++) {
				switch (d) {
				case 'N':
					if (fld[fx][++fy] == 1) cnt++;
					break;
				case 'E':
					if (fld[++fx][fy] == 1) cnt++;
					break;
				case 'S':
					if (fld[fx][--fy] == 1) cnt++;
					break;
				case 'W':
					if (fld[--fx][fy] == 1) cnt++;
					break;
				default:
					break;
				}
				fld[fx][fy] = 0;
			}
		}
		if (cnt == n) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
 
using namespace std;
typedef long long ll;
 
int main(void) {
  ll a, b, c;
  cin >> a >> b >> c;
  ll x = a*a;
  ll y = b*b;
  ll z = c*c;
  ll d = a*b;
  ll e = b*c;
  ll f = a*c;
  ll g = c-a;
  if((x + y + z) > 2*d + 2*e + 2*f  && g-b > 0){
    cout << "Yes" << endl;   
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
s=math.ceil((n**0.5))
a=set([])
if n==2:print(1);exit()
a.add(n)
a.add(n-1)
for i in range(2,int((n-1)**0.5)+1):
    if (n-1)%i==0:
        a.add(i)
        a.add((n-1)//i)
def check(dived,diving):
    while dived>=2:
        if dived<diving:return False
        if dived%diving==0:
            dived//=diving
        else:
            dived%=diving
    return True
for j in range(2,int(n**0.5)+1):
    if n%j==0:
        if check(n,j):a.add(j)
print(len(a))

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	string n;
	cin>>n;
	for(int i=0;i<3;i++){
		if(n[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
ll a[430];
ll dp[430][430];
ll sum[430];
bool flag[430][430];

ll cost(ll l,ll r){
  if(flag[l][r])return dp[l][r];
  flag[l][r]=true;
  if(l==r)return dp[l][r]=0;
  ll mn=INF;
  for(int i=l;i<=r-1;i++){
   chmin(mn,cost(l,i)+cost(i+1,r));
  }
  if(l==r-1)mn=0;
  //mn+=a[l]+a[l+1]+...+a[r]
  mn+=sum[r];
  if(l-1>=0)mn-=sum[l-1];
  //cout<<l<<" "<<r<<" "<<mn<<endl;
  return dp[l][r]=mn;
}
int main(){
  int n;
  cin>>n;
  rep(i,0,n)cin>>a[i];
  rep(i,0,n){
   sum[i]=a[i];
    if(i-1>=0)sum[i]+=sum[i-1];
    //cout<<sum[i]<<endl;
  }
  cout<<cost(0,n-1)<<endl;
}

Measured memory_bytes: 5128
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
int main()
{
    int x;
    cin>>x;
    int k=gcd(x,360);
    cout<<360/k;
    return 0;
}


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

int main(){
    int p,q,r;
    scanf("%d",&p);scanf("%d",&q);scanf("%d",&r);
    if (p <= r && q <= r){
        cout << p + q;
    }else if(p <= q && r <= q){
        cout << p + r;
    }else if(q <= p && r <= p){
        cout << q + r;
    }

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int count = 0;
        int count2 = 0;
        int[] b = new int[a];
        for(int i = 0;i<a;i++){
            b[i] = sc.nextInt();
        }
        int flag = 0;
        while(flag == 0){
            for(int j = 0;j<a;j++){
                if(b[j] % 2 == 0){
                    b[j] = b[j]/2;
                    count2++;
                }
                if(count2 == a){
                    count++;
                    count2 = 0;
                }
            }
            for(int j = 0;j<1;j++){
                if(b[j] % 2 != 0){
                    flag++;
                }
            }
            if(flag != 0){
                break;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl
int n,m;
int ans = 0;

int main(){
  string s;
  int a[26];
  cin >> s;
  clr(a,0);
  rep(i,0,s.sz){
    a[s[i]-'a'] = 1;
  }
  rep(i,0,26){
    if(a[i] == 0){
      print(char('a'+i));
      return 0;
    }
  }
  print("None");
  return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 * Created 2017/06/01.
 */
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    ArrayList<Integer> ary = new ArrayList<>();

    while (true) {
      int a = sc.nextInt();
      ary.add(a);
      if (ary.size() == n) break;
    }

    int max_a = Collections.max(ary);
    int min_a = Collections.min(ary);
    long sum_a = 0;
    for (int sum : ary) {
      sum_a += sum;
    }
    System.out.println(min_a + " " + max_a + " " + sum_a);
  }
}

Measured memory_bytes: 41616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  string S; cin >> S;
  int x = 0, ans = x;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'I') {
      x++;
      ans = max(ans, x);
    } else if (S[i] == 'D') {
      x--;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	string s;
	cin >> s;
	
	rep(i,s.size()){
		s[i] = 'x';
	}
	
	
	cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
k = gets.chomp.to_i
a, b = gets.chomp.split(" ").map(&:to_i)
 

count = 0
(a..b).each do |i|
    if i % k == 0
        count += 1
    end
end

if count >= 1
    puts "OK"
else
    puts "NG"
end

Measured memory_bytes: 14288
res=(1 4 16 61 230 865 3247 12185 45719 171531 643550 2414454 9058467 33985227 127504505 478366600 794717734 733354121 261943303 776803305 580025381 51688048 44657419 737209731 604119499 159693437 858533109 639056669 549054109 996291083 531294469 23314687 783022045 855462856 649970414 68697295 409213624 604356692 88638656 978442997 534833116 763737161 785892908 123883652 639213333 181836645 998121103 124885216 501575626 39816123 113468411 799008836 775465589 256852905 664630886 971550783 751629411 51018086 702530485 725438992 696683714 792638194 221791721 149602322 414054379 986519078 981760191 305799096 515140586 406959393 975058685 245601370 324759692 673385295 191483611 570246669 427196161 781042769 569725155 842176273 25328739 847501730 206282374 353770801 323137024 371653459 940737264 123820509 915711339 847205021 252858375 718889563 866398347 738390145 133009077 333099663 170591295 329869205 616680192 597534442 388130742)
read n
echo ${res[$n]}


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

int main() {
    string s, t;
    cin >> s;
    cin >> t;

    int ans = 1000000000;
    for (size_t i = 0; i <= s.length() - t.length(); i++) {
        int sum = 0;
        for (size_t j = 0; j < t.length(); j++) {
            // tがsの部分文字列となるためには，sを何回書き換えれば良いか
            if (t.at(j) != s.at(i + j)) ++sum;
        }
        ans = min(ans, sum);
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){ cout << name << " : " << arg1 << std::endl; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
#define endl '\n'

ll power(ll a, ll b, ll mod){ ll c = 1; while(b>0){ if(b%2) c*=a, c%=mod; b/=2; a*=a; a%=mod; } return c; }
 
const ll N = (6e3) + 10;
const ll M = 320;
const ll Mod = 998244353LL;

ll ncr[N][N], n;
void pre(){
    ncr[0][0]=1;
    for(ll i=0;i<N;i++) ncr[i][0] = 1;
    for(ll i=1;i<N;i++)
        for(ll j=1;j<=i;j++)
    (ncr[i][j] = ncr[i-1][j] + ncr[i-1][j-1])%=Mod;
}
ll fun(ll p, ll q, ll n){
    ll ans = 0;
    ll tw = 1;
    // cout<<p<<' '<<q<<' '<<n<<endl;
    for(ll i=0;i<=p;i++){
        ll tmp = tw; tmp %= Mod;
        tmp *= (ncr[p][i]); tmp %= Mod;
        ll r = q + i;
        ll n1 = n - i;
        tw = (tw*2)%Mod;
        if(r-1 < 0) continue;
        (tmp *= ncr[n1+r-1][r-1]) %= Mod;
        (ans += tmp) %= Mod;
        
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    pre();
    ll k;
    cin>>k>>n;
    for(ll i=2;i<=2*k;i++){
        ll p,q,r; p =0;
        for(ll j=1;j<=k;j++){
            if(i-j >= 1 && i-j <= k) p++;
        }
        q = k-p;
        r = p%2;
        p /= 2;
        ll ans =  fun(p,q,n);
        if(r) (ans += fun(p,q,n-1))%=Mod;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 280576
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	string sa;
	cin>>n;
	cin>>sa;
	if(sa.size()>n){
		sa=sa.substr(0,n);
		sa+="...";
	}
	cout<<sa<<endl;
}

Measured memory_bytes: 3608
n = int(input())
a = list(map(int,input().split()))


a2 = [0]
a2.extend(a)
a2.append(0)

max_length = 0

for i in range(len(a2) - 1):
    max_length += abs(a2[i] - a2[i+1])

def checker(a2,j):
    n1,n2,n3 = a2[j-1], a2[j], a2[j+1]
    if n1 > n2 and n2 > n3:
        ans = 0
    elif n1 < n2 and n2 < n3:
        ans = 0
    else :
        ans = 2 * min(abs(n1 - n2), abs(n2 - n3))
        
    return ans

for i in range(len(a2)-2):
    j = i+1
    i_ans = max_length - checker(a2,j)
    print(i_ans)

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

int main(){
    int N, temp;
    cin >> N;
    
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    
    cout << A[0];
    for(int i = 1; i < N; i++) cout << " " << A[i];
    cout << endl;
    
    for(int i = 1; i < N; i++){
        temp = A[i];
        int j = i - 1;
        
        while(j >= 0 && A[j] > temp){
            A[j+1] = A[j];
            j--;
        }
        
        A[j+1] = temp;
        
        cout << A[0];
        for(int i = 1; i < N; i++) cout << " " << A[i];
        cout << endl;
    }
}


Measured memory_bytes: 3092
#!/usr/bin/env python3
#ABC123 D

X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()
A.reverse()
B = list(map(int,input().split()))
B.sort()
B.reverse()
C = list(map(int,input().split()))
C.sort()
C.reverse()
S = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K:
                S.append(A[i]+B[j]+C[k])
            else:
                break
S.sort()
S.reverse()
for i in range(K):
    print(S[i])

Measured memory_bytes: 47584
#include <iostream>
using namespace std;
int main() {
	int n,i;
	cin>>n;
	int a[n],b[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++)
	{
	    if(i==0)
	    b[i]=0;
	    else if(i==1)
	    {
	        b[i]=b[i-1]+abs(a[i]-a[i-1]);
	    }
	    else
	    {
	        b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
	    }
	}
	cout<<b[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
n=input()
f = 0
if len(n)==2 :
    if n[0]==n[1]:
        print(1,2)
        f = 1
for i in range(len(n)-2) :
    vis = {}
    t = 0 
    for j in range(i , i+3) :
        
        if n[j] in vis :
            vis[n[j]]+=1

        else:
            vis[n[j]] = 1
    for j in vis :
        if vis[j]>=2:
            print(i+1 , i+3)
            f = 1
            break
    if f==1:break
if not f :
    print(-1 , -1)
    


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

int main() {
  int n,k;

  cin >> n >> k;

  int d,a;
  int sum = 0;

  vector<int> flag(n,0);

  rep(i,k){
    cin >> d;
    rep(i,d){
      cin >> a;
      flag.at(a-1) = 1; 
    }
  }

  rep(i,n){
    //cout << flag.at(i);
    if(flag.at(i) == 0)
    sum += 1;
  }

  cout << sum;

  
}

Measured memory_bytes: 3616
w, h, n = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(n)]
x1, x2 = 0, w
y1, y2 = 0, h
for i in range(n):
    if L[i][2] == 1:
        x1 = max(x1, L[i][0])
    elif L[i][2] == 2:
        x2 = min(x2, L[i][0])
    elif L[i][2] == 3:
        y1 = max(y1, L[i][1])
    elif L[i][2] == 4:
        y2 = min(y2, L[i][1])
S = max(0, x2 - x1) * max(0, y2 - y1)
print(S)


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

int N;
int dp [4001] [4001];
int memo [4001] [4001];
const int init_pos = 2000;
const int MOD = 1e9 + 7;

int comb(int x,int y)
{
	if(x == 0 && y == 0) return 1;
	if(memo [x] [y]) return memo [x] [y];

	int res = 0;
	if(x - 1 >= 0) res += comb(x - 1,y);
	if(y - 1 >= 0) res += comb(x,y - 1);
	res %= MOD;
	return memo [x] [y] = res;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	vector< pair<int,int> > coor(N);
	FOR(i,0,N){
		cin >> coor [i].first >> coor [i].second;
		dp [init_pos - coor [i].first] [init_pos - coor [i].second]++;
	}
	
	for(int i = 0;i <= 4000;i++){
		for(int j = 0;j <= 4000;j++){
			if(i - 1 >= 0){
				dp [i] [j] += dp [i - 1] [j];
			}
			if(j - 1 >= 0){
				dp [i] [j] += dp [i] [j - 1];
			}
			dp [i] [j] %= MOD;
		}
	}
	int ans = 0;
	FOR(i,0,N){
		(ans += dp [init_pos + coor [i].first] [init_pos + coor [i].second]) %= MOD;
	}

	FOR(i,0,coor.size()){
		(ans -= comb(coor [i].first * 2,coor [i].second * 2)) %= MOD;
	}
	(ans += MOD) %= MOD;
	if(ans & 1){
		ans += MOD;
	}
	ans /= 2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 127104
#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++)
typedef int64_t Int;


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

    int ans = 0;
    rep(i,N){
        int A; cin >> A;
        while(A % 2 == 0){
            A /= 2; ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e6 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;



int main() {
    fast;

    ll n; cin >> n;
    cout << ((n%1000)?(1000 - n % 1000):(0)) << "\n";
}

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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

#define F first
#define S second

int main() {
	fastio();
	
	LL h, w, ch, cw, dh, dw;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	ch--, cw--, dh--, dw--;
	vector<vector<char>> g(h, vector<char>(w));

	for (auto &e : g) {
		for (auto &f : e) {
			cin >> f;
		}
	}

	auto valid = [&h, &w](int x, int y) -> bool {
		return (x < h && y < w && x >= 0 && y >= 0);
	};

	vector<vector<pair<LL, LL>>> adj(h*w);

	for (int i = 0; i < h; ++i) {
		for (int j= 0; j < w; ++j) {
			for (int k = i-2; k <= i+2; ++k) {
				for (int l = j-2; l <= j+2; ++l) {
					int x = k, y = l;
					if (valid(x, y) && g[x][y] == '.') {
						LL wt = 0;
						if (abs(x-i) + abs(y-j) != 1) {
							wt = 1;
						}
						adj[i*w + j].push_back({x*w + y, wt});
					}
				}
			}
		}
	}

	// 0-1 bfs
	vector<LL> dis(h*w, INF), vis(h*w, 0);
	deque<LL> q;
	q.push_back(ch*w+cw);
	dis[ch*w+cw] = 0;

	while (!q.empty()) {
		LL u = q.front();
		q.pop_front();
		if (!vis[u]) {
			vis[u] = 1;
			for (auto ed : adj[u]) {
				LL v = ed.F, wt = ed.S;
				dis[v] = min({dis[v], dis[u]+wt});

				if (wt == 0) {
					q.push_front(v);
				}
				else {
					q.push_back(v);
				}
			}
			
		}
	}

	if (dis[dh*w+dw] == INF ) {
		cout << "-1\n";
	}
	else {
		cout << dis[dh*w+dw] << "\n";
	}





}

Measured memory_bytes: 316220
import sys
from random import randint
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def count_v(last_d, C, S, t, d):
    ret = S[t - 1]
    last_d[t - 1] = d
    for i in range(len(last_d)):
        ret -= C[i] * (d - last_d[i])
    return ret


def count_v_virtual(last_d, C, S, t, d):
    ret = S[t]
    tmp = last_d[t]
    last_d[t] = d
    for i in range(len(last_d)):
        ret -= C[i] * (d - last_d[i])
    last_d[t] = tmp
    return ret


def get_diff_score(T, d, q, C, D, Ss):
    diff = 0
    original_t = T[d - 1]
    last_d_q = 0
    last_d_ori = 0
    for i in range(d):
        if T[i] == q:
            last_d_q = i + 1
        if T[i] == original_t and i < d - 1:
            last_d_ori = i + 1
    # print(d, q, original_t, last_d_q, last_d_ori)
    for i in range(d - 1, D):
        if T[i] == q:
            break
        diff += C[q - 1] * (d - last_d_q)
    # print(diff, C[q - 1])
    T[d - 1] = q
    for i in range(d - 1, D):
        if T[i] == original_t:
            break
        diff -= C[original_t - 1] * (d - last_d_ori)
    # print(C[original_t - 1], diff)
    diff += Ss[d - 1][q - 1] - Ss[d - 1][original_t - 1]
    return diff


def main():
    D = int(input())
    C = inpl()
    Ss = [inpl() for _ in range(D)]
    T = []
    last_d = [-1] * len(C)
    Contest = 26

    for d in range(D):
        tmp_t, tmp_v = -1, -float('inf')
        for i in range(Contest):
            tmp_score = count_v_virtual(last_d, C, Ss[d], i, d)
            if tmp_score > tmp_v:
                tmp_v = tmp_score
                tmp_t = i
        last_d[tmp_t] = d
        T.append(tmp_t + 1)

    Cs = [i + 1 for i, c in enumerate(C)]
    Cs.sort(key=lambda x: C[x - 1])

    for _ in range(10000):
        d, q = randint(1, D), randint(1, Contest)
        ori_q = T[d - 1]
        diff = get_diff_score(T, d, q, C, D, Ss)
        if diff < 0:
            T[d - 1] = ori_q

    for t in T:
        print(t)

    return


if __name__ == '__main__':
    main()


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int K;string s;cin>>K>>s;
	if(s.size()<=K){
		cout<<s<<endl;
	}
	else{
		cout<<s.substr(0,K)+"..."<<endl;
	}
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int s,i,j,n,a[500],b[500],c[500];
	scanf("%d",&n);
	for(i=0;i<n-1;i++)
  	{
    	scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	for(i=0;i<n;i++)
	{
	    s=0;
	    if(i==n-1)
	    {
			printf("0");
			return 0;
		}
		for(j=i;j<n-1;j++)
		{
    		if(s<b[j])
			{
		   	 	s=b[j];
    			s+=a[j];
    		}
			else if(s%c[j]==0)
			{
				s+=a[j];
			}
			else
			{
				s=s+c[j]-s%c[j];
				s+=a[j];
			}
    	}
		printf("%d\n",s);
	}
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <array>
#include <stdlib.h>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main() {
	int n;
	cin >> n;
	if ((n % 10 == 9) || (n / 10 == 9)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n){
    ans+=min(a[i]*2,abs(a[i]-k)*2);
  }
  cout<<ans<<endl;
}

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

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

    vector<string> s;
    string k;
    for(int i = 0; i < n; i++){
        cin >> k;
        s.push_back(k);
    }

    int m;
    cin >> m;

    vector<string> t;
    for(int i = 0; i < m; i++){
        cin >> k;
        t.push_back(k);
    }

    vector<int> cou;
    int coun = 0;
    string ken;

    while(1){

        if(s.size() == 0 && t.size() == 0){
            break;
        }

        coun = 0;

        if(s.size() != 0){
            ken = s[0];
            s.erase(s.begin());
            coun++;
            n--;

            if(n != 0){
                for(int i = 0; i < n; i++){
                    if(ken == s[i]){
                        coun++;
                        s.erase(s.begin() + i);
                        i--;
                        n--;
                    }
                }
            }
        }  

        if(t.size() != 0 && s.size() != 0){
            for(int i = 0; i < m; i++){
                if(ken == t[i]){
                    coun--;
                    t.erase(t.begin() + i);
                    i--;
                    m--;
                }
            }
        }else if(t.size() != 0){
            ken = t[0];
            t.erase(t.begin());
            m--;
            coun--;
            if(m != 0){
                for(int i = 0; i < m; i++){
                    if(ken == t[i]){
                        coun--;
                        t.erase(t.begin() + i);
                        i--;
                        m--;
                    }
                }   
            }
        }

        cou.push_back(coun);

    }

    int ans = *max_element(cou.begin(), cou.end());

    if(ans < 0){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	xs := make([]int, n)
	for i := range xs {
		fmt.Scan(&xs[i])
	}

	min := int(1e9)
	for i := 1; i <= 100; i++ {
		var sum int
		for j := range xs {
			d := (xs[j] - i)
			sum += d * d
		}
		if sum < min {
			min = sum
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 512
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n;cin>>n;
	string str;cin>>str;
	int ans=0,gen=0;
	for(auto it:str){
		if(it=='.'){ans++;mineq(ans,gen);}
		else{gen++;}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <cstring>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <ctype.h>

using namespace std;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pli;
typedef pair<lli,lli> pll;

int _abs_int(int a) {return a<0 ? -a : a;}
lli _abs_lli(lli a) {return a<0 ? -a : a;}

map<lli,int> tr;
int n;
lli arr[2000001];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%lld",arr+i);
		arr[i]+=arr[i-1];
		tr[arr[i]]+=1;
	}
	tr[0]+=1;

	lli ans=0;
	for(int i=0;i<n;i++) {
		ans+=tr[arr[i]]-1;
		tr[arr[i]]-=1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 14336
#include <stdio.h>
#include <string.h>

int main (){
    char a[12];
    char b[12];
    char c[12];
    
    scanf("%s %s %s", &a, &b, &c);
    int k = strlen (a); 
    int t = strlen (b); 
    int f = strlen (c);
    if (a[k-1] == b[0] && b[t-1] == c[0]) {
        printf("YES\n");
    } 
	else {
        printf("NO\n");
    }
    
    return 0;
}

Measured memory_bytes: 1656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] input = br.readLine().split(" ");
    double n = Double.parseDouble(input[0]);
    double k = Double.parseDouble(input[1]);
    
    double result = 0;
    
    for(int i=1; i<=n; i++){
      int coin = k<=i ? 0 : BigDecimal.valueOf(Math.log(k/i)/Math.log(2)).setScale(0, RoundingMode.UP).intValue();
      result += Math.pow(0.5, coin)/n;
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 24900
n = int(input())
a = [int(x) for x in input().split()]

base = max(a)
tmp = 10**9
tmp_i = 0
for x in a:
    if x == base:
        pass
    elif abs(base - 2*x) < tmp:
        tmp = abs(base - 2*x)
        tmp_i = x

print(base, tmp_i)

Measured memory_bytes: 14052
#include<cstdio>
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
int main(){
	int a,b,w;
	cin >> w >> a >> b;
	if(b < a){
		int temp = a;
		a = b;
		b = temp;
		}
	if(a+w>=b)puts("0");
	else
	cout << b - w - a <<endl;
	return 0;
	}


Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint n;
llint memo[15][15][105];

llint calc(int n1, int n2, int x)
{
	if(x == 0){
		if(n1 != 10 && n2 != 10) return 1;
		else return 0;
	}
	
	if(memo[n1][n2][x] != -1) return memo[n1][n2][x];
	llint ret = 0;
	int N1, N2;
	for(int i = 0; i < 10; i++){
		if(n1 == 10 && i == 0) continue;
		if(n1 != 10 && n2 != 10 && n1 != i && n2 != i) continue;
		N1 = n1, N2 = n2;
		if(N1 == 10) N1 = i;
		else if(N2 == 10 && N1 != i) N2 = i;
		ret += calc(N1, N2, x - 1);
	}
	return memo[n1][n2][x] = ret;
}

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		
		for(int i = 0; i <= 10; i++){
			for(int j = 0; j <= 10; j++){
				for(int k = 0; k < 100; k++){
					memo[i][j][k] = -1;
				}
			}
		}
		
		llint keta, num = 0;
		for(int i = 1; ; i++){
			num += 81*((1LL<<(i-1)) - 1);
			if(n <= num){
				keta = i;
				break;
			}
		}
		
		n -= num - 81*((1LL<<(keta-1)) - 1);
		int n1 = 10, n2 = 10, N1, N2;
		llint sum = 0;
		for(int i = 1; i <= keta; i++){
			llint s = 0;
			for(int j = 0; j < 10; j++){
				if(n1 == 10 && j == 0) continue;
				if(n1 != 10 && n2 != 10 && n1 != j && n2 != j) continue;
				
				N1 = n1, N2 = n2;
				if(N1 == 10) N1 = j;
				else if(N2 == 10 && N1 != j) N2 = j;
				s = calc(N1, N2, keta-i);
				
				if(sum + s >= n){
					cout << j;
					if(n1 == 10) n1 = j;
					else if(n2 == 10 && n1 != j) n2 = j;
					break;
				}
				sum += s;
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false);


    int v,e,r;
    cin >> v >> e >> r;
    vector<vector<P>> g(v);
    rep(i,e) {
        int s,t,d;
        cin >> s >> t >> d;
        g[s].push_back(make_pair(t,d));
    }
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push(make_pair(0,r));
    vector<int> cost(v,-1);
    cost[r]=0;
    while (!pq.empty()) {
        P p=pq.top();
        int now=p.second,c=p.first;
        pq.pop();
        rep(j,g[p.second].size()) {
            int next=g[now][j].first;
            if (cost[next]==-1 || cost[next]>cost[now]+g[now][j].second) {
                cost[next]=cost[now]+g[now][j].second;
                pq.push(make_pair(cost[next],next));
            }
        }
    }
    rep(i,v) {
        if (cost[i]>=0) cout << cost[i] << endl;
        else cout << "INF" << endl;
    }
    

    return 0;   
}



Measured memory_bytes: 12992
#include<cstdio>
#include<cstring>
int f[2][16005];
int x[8005],y[8005];
char s[8005];

void getReach(int n,int a[],int start){
    int offset = 8000;
    for(int i = -8000; i <= 8000; i++) f[0][i+offset] = 0;
    f[0][start+offset] = 1;
    for(int i = 1; i <= n; i++){
        int v = i%2; int u = !v;
        int step = a[i];
        for(int j = -8000; j <= 8000; j++){
            f[v][j+offset] = 0;
            int last = j-step;
            if(last>=-8000) f[v][j+offset] |= f[u][last+offset];
            last = j+step;
            if(last<=8000) f[v][j+offset] |= f[u][last+offset];
        }
    }
}

int main(){
    int tx,ty;
    scanf("%s%d%d",s+1,&tx,&ty);
    int n = strlen(s+1);
    int p = 1, baseX = 0;
    while(p<=n && s[p]=='F') p++, baseX++;
    int sizeX = 0, sizeY = 0; int direct = 0; // 0 for x
    while(p<=n){
        if(s[p]!='F'){
            direct = !direct;
            p++;
        }
        else{
            int np = p;
            while(np+1<=n && s[np+1]=='F') np++;
            int step = np-p+1;
            if(!direct) x[++sizeX] = step;
            else y[++sizeY] = step;
            p = np+1;
        }
    }
    int ok = 1;
    getReach(sizeX,x,baseX);
    int offset = 8000;
    if(f[sizeX%2][tx+offset]==0) ok = 0;
    getReach(sizeY,y,0);
    if(f[sizeY%2][ty+offset]==0) ok = 0;
    if(ok) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 1780
import java.io.*;
import java.util.regex.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str;
		String op;
		int a, b, result = 0;
		
		LOOP : do {	
			str = br.readLine().split("\\s+");
			if (str.length == 3 && chkStrToInt(str[0]) && chkStrToInt(str[2])) {

				a	= Integer.parseInt(str[0]);
				b	= Integer.parseInt(str[2]);
				op	= str[1];
				
				switch (op) {
				case "+":	result = a + b; break;
				case "-":	result = a - b; break;
				case "*":	result = a * b; break;
				case "/":	result = a / b; break;
				case "?":	break LOOP;
				default :	continue LOOP;
				}
				System.out.println(result);
			}
		} while (true);
	}
	
	public static boolean chkStrToInt(String str) {
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(str);
		
		return m.find();
	}
}

Measured memory_bytes: 24656
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
if n%2==0:
    print(n)
else:
    print(2*n)
        

Measured memory_bytes: 65472