akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define en "\n"
#define INF (int) 9e15
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int n, m, x;
const int maxN = 12;
int costs[maxN];
int mat[maxN][maxN];
int curr[maxN];

int getBest(int i) {
	if (i == n) {
		for (int j = 0; j < m; j++) {
			if (curr[j] < x) {
				return INF;
			}
		}
		return 0;
	}
	int ans = getBest(i + 1);
	for (int j = 0; j < m; j++) {
		curr[j] += mat[i][j];
	}
	ans = min(ans, costs[i] + getBest(i + 1));
	for (int j = 0; j < m; j++) {
		curr[j] -= mat[i][j];
	}
	return ans;
}

int32_t main() { fastio;
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++) {
		cin >> costs[i];
		for (int j = 0; j < m; j++) {
			cin >> mat[i][j];
		}
	}
	int val = getBest(0);
	if (val >= 9e15) {
		cout << -1 << endl;
	} else {
		cout << val << endl;
	}
	return 0;
}


Measured memory_bytes: 3656
N, M = map(int, input().split(" "))
S = input()
T = input()

def gcd(n, m):
	if m < n:
		n, m = m, n
	while n:
		n, m = m%n, n
	return m

gcd_NM = gcd(N, M)
if S[::N//gcd_NM] == T[::M//gcd_NM]:
	print(N*M//gcd_NM)
else:
	print(-1)

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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 1e5 + 5;


int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    char c; cin >> c;

    if (c >= 'a') cout << "a" << endl;
    else cout << "A" << endl;

    return 0;
%>


Measured memory_bytes: 3584
X, Y, A, B, C = map(int, input().split())
Ps = list(map(int, input().split()))
Qs = list(map(int, input().split()))
Rs = list(map(int, input().split()))

Ps.sort(reverse=True)
Qs.sort(reverse=True)

Al = Ps[:X] + Qs[:Y] +Rs
Al.sort(reverse=True)

print(sum(Al[:X+Y]))

Measured memory_bytes: 106712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h+2);
    rep(i, h) {
        cin >> s[i+1];
        s[i+1] = "#" + s[i+1] + "#";
    }
    rep(i, w+2) s[0] = s[0] + "#";
    s[h+1] = s[0];
    rep(i, h+2) {
        cout << s[i] << endl;
    }
}


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

int N,A;
ll ans = 0;
vector<int> x;

int main() {
  cin >> N >> A;
  x.resize(N);
  for(int i=0;i<N;i++)
		  cin >> x[i];

  //探索した要素数(0~N-1),取った要素数,合計
  vector<vector<vector<ll> > > dp(N+3, vector<vector<ll>>(N+3, vector<ll>(2600, 0)));

  ll ans = 0;
  for(int i=0;i<=N;i++)
		  dp[i][0][0] = 1;
  
  for(int j=1;j<=N;j++){
		  for(int k=1;k<=N;k++){
				  for(int s=0;s<=2500;s++){
						if(s>=x[j-1]){
								dp[j][k][s] += dp[j-1][k-1][s-x[j-1]];
						}
						dp[j][k][s] += dp[j-1][k][s];
				  }
		  }
  }

  for(int k=1;k<=N;k++){
		  for(int s=1;s<=2500;s++){
				  if(k*A==s){
				  		ans += dp[N][k][s];
				  }
		  }
  }
  cout << ans << endl;
}


Measured memory_bytes: 58496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn for(int i=0;i<n;i++)
#define pb push_back
#define pob pop.back()
int main()
{
   string s;
   cin>>s;
   sort(s.begin(),s.end());
   if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[3]) cout<<"Yes";
   else cout<<"No";
   return 0;
  
  
    
}

Measured memory_bytes: 256
N = int(raw_input())
A = []
for i in range(0, N):
	A.append(int(raw_input()))
A.sort()
i = 0
while i < len(A)-1:
	if A[i] == A[i+1]:
		A.pop(i)
		A.pop(i)
	else:
		i = i + 1

print len(A)

Measured memory_bytes: 10612
#include <iostream>

using namespace std;

int main(){
    long int X;
    cin>>X;

    long int x_500,x_5;
    x_500=0;
    x_5=0;
    long int result=0;
    x_500=X/500;
    X-=x_500*500;
    x_5=X/5;
    
    result=x_500*1000+x_5*5;
    cout<<result;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll ans=0;
	cin >>n;
	VI a(n), b(n), c(n-1);
	rep(i, n) cin >>a[i];
	rep(i, n) cin >>b[i];
	rep(i, n-1) cin >>c[i];
	
	ans = accumulate(all(b), 0LL);
	//dbg(ans);
	rep(i, n){
		if(i>0 && a[i-1] +1 == a[i]){ ans += c[a[i]-2];}
	}
	
	cout << ans <<"\n";
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

using Weight = int;
using Flow = int;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
    g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

bool solve(int n, int rank, vi &leaf)
{
    return false;
}

void dfs(Graph &g, int p, vi &used)
{
    for (auto i : g[p]) {
        if (!used[i.d]) {
            used[i.d] = used[p] + 1;
            dfs(g, i.d, used);
        }
    }
}

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

    Int(n);
    Graph g(n);
    for (int i = 0; i < n-1; i++) {
        int2(tmpx, tmpy);
        tmpx--; tmpy--;
        addEdge(g, tmpx, tmpy );
    }

    vi used(n, 0);
    used[0] = 1;
    dfs(g, 0, used);

    int p = 0;
    rep(i, n) {
        if (used[p] < used[i]) p = i;
    }

    used.assign(n, 0);
    used[p] = 1;
    dfs(g, p, used);

    int ans = 0;
    rep(i, n) ans = max(ans, used[i]);

    if (ans % 3 == 2) {
        std::cout << "Second" << std::endl;
    } else {
        std::cout << "First" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 31488
#include<stdio.h>
int N,K,W[200005],i,j,r,l,m;
int bs(int p)
{
	int i,t=0,c=1;
	for(i=0;i<N;i++)
	{
		if(W[i]>p)return 0;
		if(t+W[i]>p)
		{
			c++;
			t=0;
		}
		t+=W[i];
	}
	return c<=K;
}
int main()
{
	scanf("%d%d",&N,&K);
	for(i=0;i<N;i++)
		scanf("%d",&W[i]);
	for(l=0,r=2147483647;r-l>1;)
	{
		m=(l+r)/2;
		if(bs(m))
			r=m;
		else
			l=m;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 988
/*
*	User: Isanchez_Aguilar
*	Problem: CodeForces
*/
#include <bits/stdc++.h>

using namespace std;
using Long = long long;

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

	Long n, m;
	cin >> n >> m;

	cout << min(n, m / 2ll) + (m - 2ll * min(n, m / 2ll)) / 4ll << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        String[] S = new String[N];
        for (int i=0; i<N; i++) {
            S[i] = sc.next();
        }

        System.out.println(solve(N, S));
    }

    private static int solve(int N, String[] S) {
        Set<String> set = new HashSet();

        for (int i=0; i<N; i++) {
            set.add(S[i]);
        }

        return set.size();
    }
}

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

typedef long long int ll;

int main(){
    ll n,r=0,b=0,g=0,tc=0,c=0;
    string s;
    cin >> n;
    cin >> s;

    for (int i = 0; i < n; ++i){
        if(s[i] == 'R') r++;
        if(s[i] == 'G') g++;
        if(s[i] == 'B') b++;
    }
    tc = r*b*g;
    for (int i = 0; i < n; ++i){
        for (int j = i+1; j < n; ++j){
            if(j+(j-i) < n && j > i ){
                if (s[i] != s[j] && s[i] != s[j+(j-i)] && s[j] != s[j+(j-i)])
                    c++;
            }
        }
    }
    cout << tc-c << endl;
    return 0;
}


Measured memory_bytes: 3620
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
MOD = 10 ** 9 + 7

ans = 0

for i in range(60):
    one = np.count_nonzero(a >> i & 1)
    zero = n - one
    ans += one * zero * 2 ** i
    ans %= MOD

print(ans)

Measured memory_bytes: 48824
#include <iostream>
#include <fstream>

#include <iostream>

class abc081a {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int s;
	    in >> s;
	    int ans = 0;
	    ans = (s / 100) + ((s % 100) / 10) + (s % 10);
	    out << ans;

	}
};


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


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int K, A, B;
	long long ans;
	cin>>K>>A>>B;
	if(A+1<B) {
		if(K<=A) cout<<K+1<<'\n';
		else {
			K-=A-1;
			ans=(K&1);
			cout<<ans+1LL*(K/2)*B-1LL*(K/2-1)*A<<'\n';
		}
	}
	else cout<<K+1<<'\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] argas){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int count = 0;
    if(a / 100 == 1) count++;
    if(a / 10  % 2  == 1) count++;
    if ( a % 2 == 1) count++;
    System.out.println(count);
  }
}

Measured memory_bytes: 22996
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        string[] strer = new string[2];
        strer = str.Split(' ');

        int r = int.Parse(strer[0]);
        int c = int.Parse(strer[1]);
        int[,] data = new int[r, c];
        string[] strer2 = new string[c];

     
        for (int i = 0; i < r; i++)
        {
            str = Console.ReadLine();
            strer2 = str.Split(' ');

            for (int j = 0; j < c; j++)
            {
                data[i, j] = int.Parse(strer2[j]);
            }
        }

        int[,] result = new int[r + 1, c + 1];
        int rsum = 0;
        int csum = 0;

        
        for (int i = 0; i < r; i++)
        {
            
                for (int j = 0; j < c + 1; j++)
                {
                    if (j == c)
                    {
                        result[i, j] = csum;
                    }
                    else
                    {
                        csum += data[i, j];
                        result[i, j] = data[i, j];
                    }

                }
            csum = 0;
        }

                 
        for (int j = 0; j < c + 1; j++)
        {
            for (int i = 0; i < r; i++)
            {
                rsum += result[i, j];
               
            }
            result[r, j] = rsum;
            rsum = 0;
        }

    
        for (int i = 0; i < r + 1; i++)
        {
            for (int j = 0; j < c + 1; j++)
            {
                if (j == c)
                {
                    Console.Write(result[i, j]);
                }
                else
                {
                    Console.Write(result[i, j] + " ");
                }
               
            }
            Console.WriteLine();
        }


    }
}


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

int main() {
    int f;
    cin >> f;
    cout << (f-30)/2 << endl;

    return 0;
}


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

using namespace std;

#define long long long
long c[55][55];
int main()
{
	for (int y = 0; y < 51; y++) {
		c[0][y] = y ? -1 : 0;
		for (int x = 1; x < 51; x++) {
			if (x == y) {
				c[x][y] = 0;
				continue;
			}
			int i = 1;
			for (; i <= x; i++)
				if (c[x%i][y] >= 0)
					break;
			c[x][y] = i <= x ? c[x%i][y] | 1ll << i : -1;
		}
	}
	int n;
	cin >> n;
	int a[55], b[55];
	int aa[55][55] = {};
	for (int i = 0; i < n; i++)
		cin >> a[i], aa[i][a[i]] = 1;
	for (int i = 0; i < n; i++)
		cin >> b[i];
	for (int i = 0; i < n; i++) {
		if (c[a[i]][b[i]] < 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	long r = 0;
	for (;;) {
		long k = 0;
		for (int i = 0; i < n; i++) {
			long m = 1ll << 55;
			for (int j = 0; j < 51; j++)
				if (aa[i][j]) m = min(m, c[j][b[i]]);
			k = max(k, m);
		}
		if (!k) break;
		int l = 0;
		while (k >>= 1) l++;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 51; j++)
				if (aa[i][j] && c[j%l][b[i]] >= 0)
					aa[i][j%l] = 1;
		r |= 1ll << l;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static boolean search(long a[], int k){
        int start = 0;
        int end = a.length-1;
        while(true){
            if(a[start] == k || a[end] == k)
                return true;
            else{
                int mid = (start + end)/2;
                if(a[mid] == k)
                    return true;
                else if(a[mid] > k)
                    end = mid;
                else
                    start = mid;
            }
            if(start+1 >= end)
                return false;
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a[] = new long[n];
        for(int i = 0 ; i < n ; i++)
            a[i] = sc.nextLong();
        int q = sc.nextInt();
        for(int i = 0 ; i < q ; i++){
            int k = sc.nextInt();
            if(search(a,k))
                System.out.println(1);
            else
                System.out.println(0);
        }
    }
}


Measured memory_bytes: 128460
k = int(input())
s = input()

# nCr(n, r, m)
mod = 1000000007
n = len(s) + k

fac = [1,1] # 階乗 n!
inv = [0,1] # 逆元 1/n
finv = [1,1] # 逆元の階乗 (n^-1)! = (1/n)!

for i in range(2, n+1):
    fac.append( (fac[-1] * i ) % mod )
    inv.append( (-inv[mod%i] * (mod//i)) % mod )
    finv.append( (finv[-1] * inv[-1]) % mod )

def nCr(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m

# a^n mod m
def modpow(a, n, m):
    x = 1
    while n > 0:
        if n & 1: x = x * a % m
        a = a * a % m
        n >>= 1
    return x

n = len(s)
ans = 0
for i in range(k+1):
    ans += modpow(25, i, mod) * modpow(26, k-i, mod) * nCr(i+n-1, n-1, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 226844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    itn n; cin>>n;
    int r=0,b=0,g=0;
    int ans = 1;
    vector <int> a(n);
    rep(i,n) cin>>a[i]; 
    rep(i,n){
        int cnt = 0;
        if(a[i] == r) cnt++;
        if(a[i] == b) cnt++;
        if(a[i] == g) cnt++;
        ans *= cnt;
        ans %= MOD;
        if(a[i] == r) {r++; continue;}
        if(a[i] == b) {b++; continue;}
        if(a[i] == g) {g++; continue;}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+10;
const int INF=1e9+10;
int n,k;
int a[MAX],dp[MAX];
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	dp[0]=0;
	for(int i=1;i<n;i++) dp[i]=INF;
	for(int i=1;i<n;i++){
		for(int j=i-1;j>=max(i-k,0);j--){
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
		}
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1024
n, k = [int(i) for i in input().split()]
mod = 10 ** 9 + 7

a = [[int(i) for i in input().split()]for _ in range(n)]
b = [[0] * n for _ in range(n)]
for i in range(n):
    b[i][i] = 1


def mul(a, b):
    c = [[0] * n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            s = 0
            for k in range(n):
                s += a[i][k] * b[k][j]
                s %= mod
            c[i][j] = s
    return c


while k != 0:
    if k & 1 == 1:
        b = mul(b, a)
    a = mul(a, a)
    k //= 2

ans = sum(map(sum, b)) % mod

print(ans)


Measured memory_bytes: 42732
#include <string>
#include <iostream>
using namespace std;
int main(){
    string s, verdict = "No\n";
    cin >> s;
  for (int s_num = 0; s_num < s.length(); s_num++){
        if (s.c_str()[s_num] == '7'){
            verdict = "Yes\n";
        }
    }
    cout << verdict;
    return 0;
}

Measured memory_bytes: 3072
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxm=1e5;
ll n;
int x,m,s,id;
ll a[maxm+5],pres[maxm+5],ss[maxm+5],tots;
int used[maxm+5];
int main(){
	scanf("%lld",&n);
	scanf("%d %d",&x,&m);
	a[1]=x;
	for(s=1;!used[a[s]];s++){
		used[a[s]]=s;
		a[s+1]=a[s]*a[s]%m;
		pres[s]=pres[s-1]+a[s];
	}
	tots+=pres[used[a[s]]-1];
	for(int i=used[a[s]];i<s;i++)
		ss[i-used[a[s]]+1]=ss[i-used[a[s]]]+a[i];
	n=n-used[a[s]]+1; s-=used[a[s]];
	//printf("%lld %d\n",n,s);
	if(a[s]==0) printf("%lld\n",pres[s-1]);
	else printf("%lld\n",ss[s]*(n/s)+tots+ss[n%s]);
	return 0;
}


Measured memory_bytes: 3296
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

long long N;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N;
	string ans;
	while (true)
	{
		N--;
		if (N < 0) break;
		ans += 'a' + N % 26;
		N /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#define FI(i) (puts((i) ? "Yes" : "No"), exit(0))
const int maxn = 1e6+2;
int n;
pair<int,int> a[maxn];
bool solve(vector<pair<int,int>> &v) {
	int now = 0;
	reverse(v.begin(), v.end());
	for (auto [low, c] : v) {
		if (now + low < 0) return false;
		now += c;
	}
	return true;
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	int sum = 0;
	vector<pair<int,int>> pos, neg;
	for (int i = 0;i < n;++i) {
		string w;
		cin >> w;
		int c = 0, low = 0;
		for (char j : w) {
			c += (j == '(' ? 1 : -1);
			low = min(low, c);
		}
		sum += c;
		if (c >= 0) pos.pb(low, c);
		else {
			c = 0, low = 0;
			while (w.size()) {
				c += (w.back() == ')' ? 1 : -1);
				low = min(low, c);
				w.pop_back();
			}
			neg.pb(low, c);
		}
	}
	if (sum != 0) 
		FI(0);
	sort(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	FI(solve(pos) && solve(neg));
}



Measured memory_bytes: 11596
/*
 * 17-1-22_AGC009_A.cpp
 *
 *  Created on: 2017/01/22
 *      Author: ryoma
 */

#include<iostream>

using namespace std;

typedef long long ll;

int N;
ll A[100010],B[100010];
ll add;
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i] >> B[i];
	}
	for(int i=N-1;i>=0;i--){
		A[i] += add;
		ll a=(A[i]>0ll?((A[i]-1)/B[i]+1)* B[i] - A[i]:0);
		add +=a ;
		//cout << a << endl;
	}
	cout << add << endl;
	return 0;
}




Measured memory_bytes: 1792
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    l <- sort . map strToInt . words <$> getLine
    -- 出力
    putStrLn $ if l!!0 + l!!1 == l!!2 then "Yes" else "No"


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int k;
double r, l;
double p, e, t;

double solve(int now, double r, double l, double pp) {
  // cout << now << ":" << r << ":" << l << endl;
  double mid = (r + l) / 2;
  if(now == k) {
    if(abs(t - mid) < e + eps) {
      return pp;
    } else {
      return 0;
    }
  }

  if(r - t > e || t - l > e) {
    // cout << now << ":" << r << ":" << l << endl;
    return 0;
  }

  if(mid >= t) {
    return solve(now+1, r, mid, pp * (1-p)) + solve(now+1, mid, l, pp * p);
  } else {
    return solve(now+1, r, mid, pp * p) + solve(now+1, mid, l, pp * (1-p));
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  cin >> k;
  cin >> r >> l;
  cin >> p >> e >> t;

  
  cout << solve(0, r, l, 1) << endl;
}



Measured memory_bytes: 3276
import math
A,B = input().split()
Num = int(A+B)
SqN = math.sqrt(Num)
Flag = False
for T in range(math.floor(SqN),math.ceil(SqN)+1):
    if T*T==Num:
        Flag = True
        break
if Flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9044
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
long long int MOD = 1000000007;
using namespace std;

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

#define MAX_N 200000

using namespace std;

int par[MAX_N];
int rnk[MAX_N];

// 初期化
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

// x の親を返す
int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

// x と y を併合する
void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		par[x_par] = y_par;
	}else{
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

// x, y が同じグループか判定
bool same(int x, int y){
	return (find(x) == find(y));
}

int main(){
	
	int n, q;
	cin >> n >> q;
	
	init(20000);
	
	for(int i = 0; i < q; i++){
		int num, a, b;
		cin >> num >> a >> b;
		if(num == 0){
			unite(a, b);
		}else{
			cout << same(a, b) << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define OP_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i = a; i < b; i++)
#define foi(i,a,b) for(int i = a; i>=b; i--)
#define fi first
#define si second
#define pb push_back
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const ll INF = 1e18L + 5;
const int MAXN = 3005;
const ll modn = 1e9+7;

ll dp[MAXN][MAXN];

ll solve(vll &a, int low, int high){
  if(low == high){
    return dp[low][high] = a[low];
  }
  if(dp[low][high] != -1){
    return dp[low][high];
  }
  dp[low][high] = max(a[low] - solve(a, low+1, high), a[high] - solve(a, low, high-1));
  return dp[low][high];
}

ll solve(vll &a){
  int n = a.size();
  fo(i, 0, n){
    fo(j, 0, n){
      dp[i][j] = -1;
    }
  }
  solve(a, 0, n-1);
  return dp[0][n-1];
}

void printval(int n){
  fo(i,0,n){
    fo(j,0,n){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
}

ll solve1(vll &a){
  int n = a.size();
  ll dp1[n][n];
  fo(i,0,n){
    fo(j,0,n){
      dp1[i][j] = -1;
    }
  }
  foi(i, n-1, 0){
    fo(j, i, n){
      if(i == j){
	dp1[i][j] = a[i];
      }else{
	dp1[i][j] = max(a[i] - dp1[i+1][j], a[j] - dp1[i][j-1]);
      }
			
    }
  }
  return dp1[0][n-1];
}

int main(){
  OP_IO;
  int n;
  cin>>n;
  vll a(n);
  fo(i,0,n){
    cin>>a[i];
  }
  //cout<<solve(a)<<endl;
  cout<<solve1(a)<<endl;
  //printval(n);
  return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

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


int main() {


	string S;
	cin >> S;
	if (S[0] == '7' || S[1] == '7' || S[2] == '7')cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}


Measured memory_bytes: 3628
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var Q = Number(lines[0]); lines.shift();
    var lr = lines.map(i => i.split(" ").map(i => Number(i)));

    var x = lr.concat().sort((a, b) => b[1] - a[1])
    var max = x[0][1];

    var sum = Array(max + 1).fill(0);

    sum[0] = 0; sum[1] = 0; sum[2] = 0; sum[3] = 1; sum[4] = 1;

    for (var i = 5; i <= max; i++) {
        for (var j = 2; j <= Math.sqrt(i); j++) {

            if (i % j === 0) { break; }
            if ((i + 1) / 2 !== Math.floor((i + 1) / 2)) { break; }
            if (((i + 1) / 2) % j === 0) { break; }
            if (j === Math.floor(Math.sqrt(i))) { sum[i]++; }
        }
        sum[i] += sum[i - 1];
    }



    for (var i = 0; i < Q; i++) {
        console.log(sum[lr[i][1]] - sum[lr[i][0] - 1]);
    }

});

Measured memory_bytes: 54908
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    for(int i = 0;i < n;i++)
    {
        if(s[i] == s[i + 1])
        {
            count++;
        }
    }
    cout << s.size() - count;

    return 0;
}

Measured memory_bytes: 512
n = int(input())
nums = list(map(int, input().split()))

frag = True
count = 0
while frag:
    frag = False
    for i in reversed(range(1, n)):
        if nums[i] < nums[i-1]:
            nums[i], nums[i-1] = nums[i-1], nums[i]
            count += 1
            frag = True
print(' '.join(map(str, nums)))
print(count)


Measured memory_bytes: 5600
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<vector<int>> a(n, vector<int>(n));
  vector<int> cnt(n, 0);
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++){
      a[i][j] = abs(i - j);
      //cout << a[i][j] << " ";
    }
    //cout << endl;
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      a[i][j] = min({a[i][j], a[i][x] + 1 + a[y][j], a[i][y] + 1 + a[x][j]});
    }
  }
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++){
      //cout << a[i][j] << " ";
      cnt[a[i][j]]++;
    }
    //cout << endl;
  }
  for(int i = 1; i < n; i++){
    cout << cnt[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 16000
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String s = sc.next();
			boolean flag = true;
			if(s.length()%2==1){
				System.out.println("NA");
				flag = false;
			}
			char[] t = new char[s.length()/2];
			int a = 0;
			int b = 0;
			
			if(flag==true){
				for(int i=0;i<s.length()/2;i++){
					a = s.codePointAt(2*i)-48;
					b = s.codePointAt(2*i+1)-48;
					if(a<1 || a>6 || b<1 || b>5 || flag==false){
						System.out.println("NA");
						flag = false;
						break;
					}
					
					if(a==6){
						if(b==1) t[i] = 'z';
						else if(b==2) t[i] = '.';
						else if(b==3) t[i] = '?';
						else if(b==4) t[i] = '!';
						else if(b==5) t[i] = ' ';
					}else{
						t[i] = (char)(91+5*a+b);
					}
				}
			}
			if(flag==true){
				for(int i=0;i<t.length;i++) System.out.print(t[i]);
				System.out.println();
			}
			
		}
	}	
}

Measured memory_bytes: 17256
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int t;
    int n=s.size();
    cin >> t;
    vector <char> F;
    vector <char> L;
    int rev=0;
    while(t--){
        int x;
        cin >> x;
        if(x==1){
            rev++;
            //reverse(all(s));
        }
        else{
            n++;
            int f;
            cin >> f;
            char c;
            cin >> c;
            if((rev+f)%2==0){
                F.push_back(c);
            }
            else L.push_back(c);
            // if(f==1){
            //     s=c+s;
            // }
            // else s=s+c;
        }
    }
    if(rev%2==1){
        for(int i=0;i<F.size();i++){
            cout << F[F.size()-i-1];
        }
        reverse(all(s));
        cout << s;
        for(int i=0;i<L.size();i++){
            cout << L[i];
        }
    }
    else{
        for(int i=0;i<L.size();i++){
            cout << L[L.size()-i-1];
        }
        cout << s;
        for(int i=0;i<F.size();i++){
            cout << F[i];
        }
    }
    //cout << s;
    
}

Measured memory_bytes: 976
def abc154d_dice_in_line():
    n, k = map(int, input().split())
    p = list(map(lambda x: (int(x)+1)*(int(x)/2)/int(x), input().split()))
    ans = sum(p[0:k])
    val = ans
    for i in range(k, len(p)):
        val = val - p[i-k] + p[i]
        ans = max(ans, val)
    print(ans)
abc154d_dice_in_line()

Measured memory_bytes: 97408
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int A, B, K;

void solve() {
    REP(j, K) {
        if ((B - A) / 2 >= j) cout << A + j << endl;
    }
    REPR(j, K) {
        if ((B - A) % 2 != 0 && (B - A) / 2 >= j) cout << B - j << endl;
        if ((B - A) % 2 == 0 && (B - A) / 2 > j) cout << B - j << endl;
    }
}

int main() {
    cin >> A >> B >> K;
    solve();
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  vector<int> d(26);

  for (int i = 0; i < s.size(); i++) {
    d.at(s.at(i) - 'a')++;
  }

  for (int i = 0; i < d.size(); i++) {
    if (d.at(i)%2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int N;
  scanf("%d", &N);
  int amin, amax;
  amin = 10000;
  amax = -1;
  for (int i = 0; i < N; ++i) {
    int a;
    scanf("%d", &a);
    if (a < amin) amin = a;
    if (a > amax) amax = a;
  }
  printf("%d\n", amax-amin);
  return 0;
}

Measured memory_bytes: 128
import sys
from io import StringIO
import unittest

def kaiseki(nums,res=[],s=""):
    for i in range(len(nums)):
        tmp = nums[:]
        a = str(tmp.pop(i))
        if len(tmp) > 0:
            kaiseki(tmp,res,s+a)
        else:
            res.append(int(s+a))

def resolve():
    readline=sys.stdin.readline

    n=int(readline().strip())
    p = list(map(str,readline().strip().split()))
    q = list(map(str,readline().strip().split()))

    p = int("".join(p))
    q = int("".join(q))

    nums=list(range(1,n+1))
    res=[]
    kaiseki(nums,res,"")
    res.sort()

    i=0
    for r in res:
        if r==p:
            p=i
        if r==q:
            q=i
        i+=1

    diff=p-q
    if diff < 0:
        diff *= -1
    
    print(diff)

    return

resolve()

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

bool c(P p1, P p2){
  if(p1.second == p2.second) return p1.first > p2.first;
  return p1.second < p2.second;
}

int main(){
  int n, m;
  cin >> n >> m;
  P p[m];
  REP(i, m) cin >> p[i].first >> p[i].second;
  sort(p, p+m, c);
  vector<P> v;
  v.pb(p[0]);
  REP(i, m-1){
    if(p[i+1].first >= p[i].first) v.pb(p[i+1]);
  }
  int ans = 1, cur = p[0].second;
  REP(i, v.size()-1){
    if(cur <= v[i+1].first){
      ans++;
      cur = v[i+1].second;
    }
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int x, y;
    cin >> x >> y;
    if (y % 2 == 0 && y >= 2*x && y <= 4*x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	int arr[n], b[n]; for(int i=0; i<n; i++) {cin>>arr[i]; b[i]=arr[i];}
	sort(b, b+n);
	int count=0;
	for(int i=0; i<n; i++){
		if(arr[i]!=b[i]) count++;
	}
	if(count<=2) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, X, x[100000];

int main() {
	cin >> n >> X;
	inc(i, n) { cin >> x[i]; }
	
	int ans = abs(X - x[0]);
	inc(i, n) {
		ans = gcd(ans, abs(X - x[i]));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int a[n];
	map<int, int>m1, m2;
	set< int>s;
	zip(i, 0, n)
	{
		cin >> a[i];
		s.insert(a[i]);

		m2[a[i]]++;
		m1[a[i]]++;
	}
	int ans = 0;
	sort(a, a + n);
	//int ans = 0;
	for (int x : s)
	{

		//cout << x << " " << m1[x] << en;
		if (m1[x] >= 3)
		{
			if (m1[x] % 2 == 1)
				ans += m1[x] - 1, m1[x] = 1;
			else
				ans += m1[x] - 2, m1[x] = 2;
		}
	}
	int cnt = 0;
	for (int x : s)
	{
		if (m1[x] == 2)
		{
			cnt++;
		}
	}
	//int cnt = 0;
	if (cnt % 2 == 0)
	{
		ans += cnt;
	}
	else
	{
		ans += cnt + 1;
	}
	cout << n - ans << en;
	// for(int x:s)
	// {
	// 	ans+=m1[x]-1;
	// }
	//cout << ans << en;








	return 0;
}



Measured memory_bytes: 21492
def factorial(n):
    ans = 1
    for i in range(n,1,-1):
        ans*=i
        ans%=10**9+7
    return(ans)
        
N,M=list(map(int,input().split()))
ans=0
if N==M:
    ans=2*factorial(N)*factorial(M)%(10**9+7)
elif N+1==M or N==M+1:
    ans=factorial(N)*factorial(M)%(10**9+7)
print(ans)

Measured memory_bytes: 3060
<?php
  
fscanf(STDIN,"%s",$s);
$a_li = str_split($s);
$sum=0;
$op = ['+','-'];
$one=0;
for($i=0;$i<2;$i++){
  if($i%2 == 0){
    $one += $a_li[0];
  }else{
    $one -= $a_li[0];
  }
  for($j=0;$j<2;$j++){
    if($j%2 == 0){
      $two = $one+$a_li[1];
    }else{
    $two = $one-$a_li[1];
    }
    for($k=0;$k<2;$k++){
       if($k%2 == 0){
         $three = $two+$a_li[2];
       }else{
         $three = $two-$a_li[2];
       }
     // echo "two ".$two." a ".$a_li[2]."\n";
     // echo $three."\n";
       for($t=0;$t<2;$t++){
        if($t%2 == 0){
         $four = $three+$a_li[3];
        }else{
         $four = $three-$a_li[3];
        }
         
         if($four==7){
          echo $a_li[0].$op[$j].$a_li[1].$op[$k].
           $a_li[2].$op[$t].$a_li[3]."=".$four."\n";
           exit;
         }
       }
    }
  }
}

 


Measured memory_bytes: 4604
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    vector<int>v(3);
    rep(i,3)cin>>v[i];
    sort(all(v),greater<int>());
    ll maxi=0;
    ll mini=0;
    maxi=v[0]/2+v[0]%2;
    mini=v[0]/2;
    cout<<(maxi-mini)*v[1]*v[2]<<endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0, a, b; cin >> a >> b; i++) {
    G.at(--a).push_back(--b);
    G.at(b).push_back(a);
  }
  for (auto g : G) cout << g.size() << "\n";
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(3*n);
    rep(i,3*n){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<ll>());
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=a[2*i+1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] arr = new String[3];
        arr[0] = scanner.nextLine();
        arr[1] = scanner.nextLine();
        arr[2] = scanner.nextLine();

        char turn = 'a';
        while (arr[turn - 'a'].length() > 0) {
            String s = arr[turn - 'a'];
            char nextTurn = s.charAt(0);
            arr[turn - 'a'] = s.substring(1, s.length());
            turn = nextTurn;
        }
        System.out.printf("%c\n", 'A' + turn - 'a');
    }
}


Measured memory_bytes: 23636
import java.util.Scanner;

/**
 * Finding Missing Cards
 */
public class Main {
    private static Scanner scan;

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

        int n = scan.nextInt();
        // 絵柄:スペード、ハート、クラブ、ダイヤ
        // ランク:1-13
        int[][] card = new int[4][13];
        String mark = "";
        int lank = 0;
        for (int i = 0; i < n; i++) {
            mark = scan.next();
            lank = scan.nextInt();
            lank --;
            if (mark.equals("S")) {
                card[0][lank] = 1;
            } else if (mark.equals("H")) {
                card[1][lank] = 1;
            } else if (mark.equals("C")) {
                card[2][lank] = 1;
            } else if (mark.equals("D")) {
                card[3][lank] = 1;
            }
        }
        for (int i = 0; i < 4; i++) {
            for (int p = 0; p < 13; p++) {
                if (card[i][p] == 0) {
                    if (i == 0) {
                        mark = "S";
                    } else if (i == 1) {
                        mark = "H";
                    } else if (i == 2) {
                        mark = "C";
                    } else if (i == 3) {
                        mark = "D";
                    }
                    lank = p + 1;
                    System.out.println(mark + " " + lank);
                }
            }
        }
    }
}

Measured memory_bytes: 18208
M=10**9+7;*I=r=j=1;eval"N,*Z="+`dd`.split*?,;Z.map{|k|$*[k]&&X=$*[k]+N-$.;$*[k]=$.+=1}.map{|i|I<<s=i<2?1:M/i*-I[M%i];p (-j+r=r*(N+2-i)*s%M)%M;j=j*(X-i)*s%M}

Measured memory_bytes: 46424
// AtCoder Beginner Contest 125 - Problem B: Resale (https://atcoder.jp/contests/abc125/tasks/abc125_b)
#include <bits/stdc++.h>

using namespace std;

int solve(int N, const vector<int>& vs, const vector<int>& cs)
{
    int ans = 0;

    for (int i = 0; i < N; ++i)
        if (vs[i] > cs[i])
            ans += (vs[i] - cs[i]);

    return ans;
}

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

    int N;
    cin >> N;

    vector<int> vs(N), cs(N);

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

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

    auto ans = solve(N, vs, cs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.StringBuilder
import java.util.*


fun main(args: Array<String>) {
    val inputReader = InputReaderb(System.`in`)

    val n = inputReader.nextInt()
    val s = inputReader.nextLine().split(" ")

    val output = StringBuilder()
    for (i in 0 until n) {
        output.append(s[0][i]).append(s[1][i])
    }

    print(output)
}

class InputReaderb(stream: InputStream) {
    private var reader: BufferedReader = BufferedReader(InputStreamReader(stream))
    private var tokenizer: StringTokenizer? = null

    init {
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }

    fun nextLine(): String {
        var str = ""
        try {
            str = reader.readLine()
        } catch (e: IOException) {
            e.printStackTrace()
        }

        return str
    }
}


Measured memory_bytes: 33988