akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c;
	cin>>a>>b>>c;
	ll ans=0;
	ans+=min(c,(a+b)+1)+b;
	cout<<ans<<endl;
}


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

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

    for (int i = 0; i < n; i++)
    {   
        cout << s[i] << t[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i=1; i*i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    auto res = divisor(n);
    int s = (int)res.size();
    ll ans = LINF;
    REP(i,s){
        REP(j,s){
            if(res[i]*res[j] == n){
                ll tmp = res[i] - 1 + res[j] -1;
                chmin(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		while(x%2==0){
			ans++;
			x/=2;
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 384
def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    A = sorted(A)
    xor_a = 0
    
    if max(A) == 0:
        return 1
    if N % 3 == 0:
        if A[0] == 0:
            for i in range(N//3):
                if A[i] != 0:
                    return 0
            for i in range(N//3, N):
                if A[i] != A[N//3]:
                    return 0
            return 1
        else:
            for i in range(N//3):
                if A[i] != A[0]:
                    return 0
            for i in range(N // 3, 2 * N // 3):
                if A[i] != A[N // 3]:
                    return 0
            for i in range(2 * N // 3, N):
                if A[i] != A[2 * N // 3]:
                    return 0
            for i in range(N):
                xor_a ^= A[i]
            return 1 if xor_a == 0 else 0
    else:
        return 0


if __name__ == '__main__':
    inputs = read()
    print('Yes' if solve(*inputs) else 'No')


Measured memory_bytes: 60912
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(v_info):
    for v_detail in v_info:
        v_adj_list = v_detail[2:]
        assert len(v_adj_list) == int(v_detail[1])
        for each in v_adj_list:
            init_adj_matrix[int(v_detail[0]) - 1][int(each) - 1] = 1
    return init_adj_matrix


def graph_dfs(v_init):
    global time

    # init the first node of overall graph iterations(times >= 1)
    vertex_visit_stack.append(v_init)
    vertex_status_list[v_init] = VISITED_IN_STACK
    vertex_d_time[v_init] += time
    # init end

    while len(vertex_visit_stack) > 1:
        current_vertex = vertex_visit_stack[-1]
        next_vertex = get_adj_vertices(_vertex=current_vertex)

        if next_vertex:
            if vertex_status_list[next_vertex] is UNVISITED:
                vertex_status_list[next_vertex] = VISITED_IN_STACK
                time += 1
                vertex_d_time[next_vertex] += time
                vertex_visit_stack.append(next_vertex)
        else:
            vertex_visit_stack.pop()
            vertex_status_list[current_vertex] = POPPED_OUT
            time += 1
            vertex_f_time[current_vertex] += time

    return None


def get_adj_vertices(_vertex):
    for j in range(vertex_num):
        if adj_matrix[int(_vertex) - 1][j]:
            adj_matrix[int(_vertex) - 1][j] = 0
            return j + 1
    return None


def dfs_start():
    global time
    for i in range(vertex_num):
        if vertex_status_list[i + 1] == UNVISITED:
            # print('round', i + 1)
            graph_dfs(v_init=i + 1)
            time += 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertex_num = int(_input[0])
    vertex_info = list(map(lambda x: x.split(), _input[1:]))
    init_adj_matrix = [[0] * vertex_num for _ in range(vertex_num)]
    # assert len(vertex_info) == vertex_num

    # config length = (vertex_num + 1)
    vertex_visit_stack = [-1]
    vertex_status_list = [UNVISITED] * vertex_num
    vertex_status_list.insert(0, -1)
    vertex_d_time, vertex_f_time = ([0] * (vertex_num + 1) for _ in range(2))

    adj_matrix = generate_adj_matrix(vertex_info)
    time = 1
    dfs_start()
    for k in range(vertex_num):
        print(k + 1, vertex_d_time[k + 1], vertex_f_time[k + 1])

Measured memory_bytes: 7852
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const int INF = 1e+9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

const int MAX_N = 110000;

int dp[MAX_N];

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

  vi C_LW(N), C_RE(N);
  C_LW[0] = 0;
  C_RE[N-1] = 0;
  for (int i = 0; i < N-1; i++) {
    if (S[i] == 'W') {
      C_LW[i+1] = C_LW[i]+1;
    }
    else {
      C_LW[i+1] = C_LW[i];
    }
  }
  for (int i = N-1; i > 0; i--) {
    if (S[i] == 'E') {
      C_RE[i-1] = C_RE[i]+1;
    }
    else {
      C_RE[i-1] = C_RE[i];
    }
  }

  int ans = INF;
  rep(i,N) {
    ans = min(ans, C_LW[i]+C_RE[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[][] w = new int[n][2];
		for(int i = 0; i < n; i++){
		    w[i][0] = sc.nextInt();
		    w[i][1] = sc.nextInt();
		}
		Arrays.sort(w, (a, b) -> Integer.compare(a[1], b[1]));
		
		// 計算
		String result = "Yes";
		int t = 0;
		for(int i = 0; i < n; i++){
		    t += w[i][0];
		    if(t > w[i][1]) result = "No";
		}

		// 出力
		System.out.println(result);
		
	}
}


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

using namespace std;

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;
const int MAX_N = 1e5+100;
int n,m;
typedef pair<int, int> P;
#define c first
#define b second
P p[MAX_N];
LL a[MAX_N];
LL b[MAX_N];

bool cmp(int x, int y){
    return x > y;
}

int main(){
	//freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    sort(a+1, a+n+1);
    memset(b, 0, sizeof b);
    for(int i = 1; i <= m; ++i){
        cin >> p[i].b >> p[i].c;
    }
    // 按照c排序
    sort(p+1, p+1+m);
    int idx = 0;
    for(int i = m; i >= 1 && idx <= n; --i){
        for(int j = 1; j <= p[i].b; ++j){
            b[++idx] = p[i].c;
            if(idx > n) break;
        }
    }
    sort(b+1, b+1+n, cmp);
    LL ans = 0;
    for(int i = 1; i <= n; ++i){
        ans += max(a[i], b[i]);
    }
    cout << ans << endl;
	return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 999999
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*--------------------------------------------*/

int main(){
    int N,W;cin>>N>>W;
    const int MAX_V=100001;
    const int MAX_N=110;
    V w(N),v(N);rep(i,N)cin>>w[i]>>v[i];
    vector<vector<ll>>dp(MAX_N,vector<ll>(MAX_V));//INFで初期化
    rep(j,MAX_V)dp[0][j]=INF+100;
    //dp[i][sum_v]はi-1番目までの商品を使ってvalueがsum_v以上になるように選んだ時の重量の最小
    dp[0][0]=0;//初期条件
    REP(i,N){
        rep(sum_v,MAX_V){
            dp[i][sum_v]=dp[i-1][sum_v];
            if(sum_v-v[i-1]>=0)dp[i][sum_v]=min(dp[i-1][sum_v],dp[i-1][sum_v-v[i-1]]+w[i-1]);
            
        }
    }
    int ans=0;
    for(int i=MAX_V-1;i>=0;i--){//dpの値がW以下のうちでsum_vの最大を保存
        if(dp[N][i]<=W){ans=i;break;}
    }
    cout<<ans<<endl;
}






Measured memory_bytes: 87296
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int n,x=0,c=0,i=0;
    string s;
    scanf("%d",&n);
    cin>>s;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='I')
        {
            x+=1;
            if(x>c)
            c=x;
        }
        else if(s[i]=='D')
            x-=1;
        else
            continue;
    }
    printf("%d",c);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   lli A,B,C,L,R,N,M,K,X=0,Y=0,W,H,sum=0,num=0,flag=0;string S,T,O;
   cin >> W >> H >> N;
   DV(P,int,W,H,1);
   Vec(Q,int,N,0);
   Vec(U,int,N,0);
   Vec(G,int,N,0);
   rep(i,0,N)cin >> U[i] >> G[i] >> Q[i];
   rep(i,0,N){
      if(Q[i]==1)rep(j,0,U[i])rep(k,0,H)P[j][k]=0;
      if(Q[i]==2)rep(j,U[i],W)rep(k,0,H)P[j][k]=0;
      if(Q[i]==3)rep(j,0,W)rep(k,0,G[i])P[j][k]=0;
      if(Q[i]==4)rep(j,0,W)rep(k,G[i],H)P[j][k]=0;
   }
   rep(i,0,W)rep(j,0,H)if(P[i][j])sum++;
   Out(sum);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,temp;
  scanf("%d %d",&a,&b);
  if(a<=0 && 0<=b){
    printf("Zero\n");
  }else if(a>0 && b>0){
    printf("Positive\n");
  }else{
    temp=-a-b;
    if(temp%2==0)
      printf("Negative\n");
    else
      printf("Positive\n");
  }
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;

int main() {
	int N;
	int cnt;
	int sumi;

	while (cin >> N && N) {
		cnt=0;
		REP(i,1,N+1) {
			sumi=0;
			REP(ii,i,N+1) {
				if (sumi>=N) {
					if (sumi == N) { 
						cnt++; 
					}
					break;
				}
				sumi+=ii;
			}
		}
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
var n: array[1..3] of char;
    i : integer;
begin
  for i := 1 to 3 do read(n[i]);
  for i := 1 to 3 do begin
    if n[i] = '1' then n[i] := '9'
    else if n[i] = '9' then n[i] := '1';
  end;
  for i := 1 to 3 do write(n[i]);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl w(n);
  ll sum=0;
  rep(i,n){
    cin >> w[i];
    sum +=w[i];
  }
  ll ans=INF;
  ll sum2=0;
  rep(i,n){
    sum2+=w[i];
    ans=min(ans,abs(sum-2*sum2));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
main = do
 [a,b,x] <- map read . words <$> getLine :: IO [Integer]
 print (between a b x)

between a b x
 | ra == 0 && rb == 0 = qb - qa + 1
 | ra == 0 = qb - qa + 1
 | otherwise = qb - qa
 where
  (qa,ra) = divMod a x
  (qb,rb) = divMod b x

Measured memory_bytes: 508
#include <stdio.h>
#include <math.h>

int main(void) {
	int n, l, r;
	int ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d %d", &l, &r);
		ans += r - l + 1;
	}
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = Integer.parseInt(scan.next());
        scan.close();

        int sum = 0;
        for (int a = 1; a <= k; a++) {
            for (int b = 1; b <= k; b++) {
                for (int c = 1; c <= k; c++) {
                    int gcd = gcd(a, gcd(b, c));
                    sum += gcd;
                }
            }
        }

        System.out.println(sum);
    }

    private static int gcd(int a, int b) {
        if (a < b) {
            int memory = a;
            a = b;
            b = memory;
        }

        int q = a % b;
        while (q != 0) {
            a = b;
            b = q;
            q = a % b;
        }
        return b;
    }

}


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

string henkan(string str)//?°????????????§??????????????§??????????°????????????????
{
	int len = str.length();
	
	for(int i = 0; i < len; i++){
		if('A' <= str[i] && str[i] <= 'Z'){
			str[i] += 32;
		}
		else if('a' <= str[i] && str[i] <= 'z'){
			str[i] -= 32;
		}
	}
	return str;
}

int main(void)
{
	//char str[1200];
	string str;
	
	//fgets(str, 1200, stdin);
	getline(cin, str);//??????????????????
	
	cout << henkan(str) <<endl;
	
	return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

using Weight = int;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
    g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

int n, m;
Graph g;
int q;

pair<int,int> time_color[11][100010]; // dist, vertex -> time, color

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

    while(cin >> n >> m && n){
        g.assign(n, {});
        rep(i, m){
            int a, b;
            cin >> a >> b;
            --a; --b;
            add_edge(g, a, b);
        }
        rep(i, n) {
            add_edge(g, i, i);
        }

        rep(i, 11) rep(j, n) time_color[i][j] = {0, 0};
        cin >> q;
        rep(t, q){
            int v, d, c;
            cin >> v >> d >> c;
            --v;
            time_color[d][v] = make_pair(t + 1, c);
        }

        rrep1(d, 10) {
            rep(v, n) {
                for (auto &e : g[v]) {
                    int w = e.dst;
                    if (time_color[d-1][w] < time_color[d][v]) {
                        time_color[d-1][w] = time_color[d][v];
                    }
                }
            }
        }
        rep(i, n){
            auto res = make_pair(0, 0);
            rep(j, 11){
                res = max(res, time_color[j][i]);
            }
            cout << res.second << '\n';
        }
    }
}


Measured memory_bytes: 21760
<?php
$num = trim(fgets(STDIN));
fscanf(STDIN,"%s %s",$a,$b);
$ans = "";
for ($i = 0;$i < $num;++$i) {
    $ans .= substr($a,$i,1);
    $ans .= substr($b,$i,1);
}
echo $ans.PHP_EOL;
?>


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acos(-1);

vector<int> dp;
int dfs(int v, int p, Graph<int> &G) {
    for (auto nv : G[v]) {
        if (nv == p)
            continue;
        dp[v] ^= dfs(nv, v, G) + 1;
    }
    return dp[v];
}

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

    int N;
    cin >> N;
    Graph<int> G(N);
    for (int i = 1; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    dp.resize(N);
    dfs(0, -1, G);

    cout << (dp[0] ? "Alice" : "Bob") << endl;
    return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>


using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

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

    // v[i]: i日かかるバイトのリスト
    const int M_MAX = 100001;
    vector< vector<ll> > bites(M_MAX);
    for(int i = 0; i < N; i++){
        ll a, b;
        cin >> a >> b;
        bites[a].push_back(b);  
    } 

    priority_queue<ll> que;

    ll ans = 0;
    for(int i = 1; i <= M; i++){
        for(int j = 0; j < bites[i].size(); j++){
            que.push( bites[i][j] );
        }
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main() {
  int X;
  cin >> X;
  int res = 1;
  for (int i = 1; i * i <= X; ++i) {
    int pow = i;
    for (int j = 0; j < 9; ++j) {
      pow *= i;
      if (pow <= X) res = max(res, pow);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
# initialize maze
maze = []

for r in range(H):
  maze.append(list(input()))
maxVisit = 0
for row in maze:
  for road in row:
    if (road == "."):
      maxVisit += 1
# do bfs for each point and record maximum steps...
def findMaxBFS(start):
  #check start point is valid
  if (maze[start[0]][start[1]] == "#"):
    return 0
  # initialize BFS
  visitedCount = 1
  visitedPoints = []
  for r in range(H):
    visitedPoints.append([])
    for c in range(W):
      if (r == start[0]) and (c == start[1]):
        visitedPoints[r].append("Y")
      else:
        visitedPoints[r].append("N")
  points = [start]
  directions = [[0,1], [0,-1], [1,0], [-1,0]]
  steps = 0
  # BFS starts
  while (visitedCount < maxVisit):
    steps += 1
    nextPoints = []
    for p in points:
      for d in directions:
        nextP = [p[0]+d[0], p[1]+d[1]]
        #check nextP is inside the maze
        if (0<=nextP[0] and nextP[0]<H) and (0<=nextP[1] and nextP[1]<W):
          road = maze[nextP[0]][nextP[1]]
          #check nextP is walkable = stone
          if (road == "."):
            # check if nextP is already visisted
            if (visitedPoints[nextP[0]][nextP[1]] == "N"):
              nextPoints.append(nextP)
              visitedCount += 1
              visitedPoints[nextP[0]][nextP[1]] = "Y" 
    points = nextPoints
  # BFS ended
  # return max step
  return steps

max_steps = []
for r in range(H):
  for c in range(W):
    max_steps.append(findMaxBFS([r,c]))
print(max(max_steps))
    

Measured memory_bytes: 75328
#!/usr/bin/env python3

import numpy as np
from numba import njit

def main():
    k = int(input())
    print(getresult(k))

@njit("i4(i4, i4)", cache=True)
def gcd(x, y):
    if x < y:
        x, y = y, x  # x >= y
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

@njit("i8(i4)", cache=True)
def getresult(k):
    res = np.array([0], dtype=np.int64)
    for a in range(1, k + 1):
        for b in range(1, k + 1):
            for c in range(1, k + 1):
                res += gcd(gcd(a, b), c)
    return res[0]

if __name__ == "__main__":
    main()


Measured memory_bytes: 106360
#include<iostream>
#define ll long long int
using namespace std;
ll knapSack(ll W[],ll val[],ll n,ll s){
	ll dp[n+1][s+1];
	for(ll i=0;i<=n;i++)
	{
		for(ll w=0;w<=s;w++)
		{
			if(i==0 || w==0)
			dp[i][w]=0;
			else if(W[i-1]<=w)
			dp[i][w]=max(val[i-1]+dp[i-1][w-W[i-1]],dp[i-1][w]);
			else
			dp[i][w]=dp[i-1][w];
		}
	}
	return dp[n][s];
}
int main(){
	ll n,s,W[10000],val[10000];
	cin>>n>>s;
	for(ll i=0;i<n;i++){
    	cin>>W[i]>>val[i];
    }
	ll ans =  knapSack(W,val,n,s);
	cout<<ans;	
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int L, R, d; cin>>L>>R>>d;

    int count = 0;
    for(int i=L;i<=R;i++){
        if(i%d==0)count++;
    }

    cout<<count<<endl;

    return 0;
}

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

const long long N = 3e6 + 17;
ll a[N], b[N], cnt = 1, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m;
    r1 = n + m;
    r0 = n + n - 1;
    l1 = m + m - 1;
    cout << max(r1,max(r0, l1));
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    
    bool a=false;
    
    string s, t;
    
    cin>>s;
    cin>>t;
    
    string str=s;
    
    for(int i=0; i<s.size(); i++){
        str.insert(str.begin(), str[str.size()-1]);
        str.pop_back();
        
        if(str==t){
            a=true;
            break;
        }
    }
    
    if(a){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var n = int.Parse(ReadLine());
    var s = ReadLine();
    var t = ReadLine();

    var machCnt = 0;
    for(var i = 0; i < n; i++)
    {
      var ss = s.Substring(i);
      var st = t.Substring(0, n - i);
      if(ss == st)
      {
        machCnt = n - i;
        break;
      }
    }

    var ans = n * 2 - machCnt;
    WriteLine(ans);
  }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  ll n;cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)cin >> a[i];
  
  ll ans = 0;
  bool f = true;
  while(f){
    for(int i = 0; i < n; ++i){
      ll d = a[i]/n;
      ll r = a[i]%n;
      a[i]= r;
      ans += d;
      for(int j = 0; j < n; ++j){
        if(i!=j) a[j] += d;
      }
    }
    f = false;
    for(int i = 0; i < n; ++i){
      if(a[i]>n-1)f = true;
    }
  }
  cout << ans << endl;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    unordered_map<string,bool> user;
    string str;
    REP(i,n){
        cin >> str;
        user[str]=false;
    }
    int m;
    bool flg=false;
    cin >> m;
    REP(i,m){
        cin >> str;
        if(user.find(str)!=user.end()){
            flg=!flg;
            if(flg)cout << "Opened by "<<str << endl;
            else cout << "Closed by "<<str << endl;
        }else{
            cout << "Unknown "<<str<<endl;
        }
    }
}



Measured memory_bytes: 3228
H,W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))

ans = [[-1]*W for _ in range(H)]
now = rem = 0
for i in range(H):
    r = range(W)
    if i%2: r = reversed(r)
    for j in r:
        if rem:
            ans[i][j] = now
            rem -= 1
        else:
            now += 1
            ans[i][j] = now
            rem = A[now-1] - 1
for row in ans:
    print(*row)

Measured memory_bytes: 9500
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  string s,t;cin>>s>>t;
  int cnt=0;
  rep(i,s.size()){
    if(s[i]!=t[i])cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3896
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(void) {
  char S[10];
  scanf("%s", S);
  if (S[0] == 'S') {
    printf("Cloudy");
  }
  else if (S[0] == 'C') {
    printf("Rainy");
  }
  else {
    printf("Sunny");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<string> blue(n);
    map<string, int> fruit;

    for (int i = 0; i < n; i++){
        cin >> blue[i];
        if (fruit.find(blue[i]) == fruit.end()){
            fruit[blue[i]] = 0;
        }
    }

    int m;
    cin >> m;

    vector<string> red(m);

    for (int i = 0; i < m; i++){
        cin >> red[i];
        if (fruit.find(red[i]) == fruit.end()){
            fruit[red[i]] = 0;
        }
    }

    for (int i = 0; i < n; i++){
        fruit[blue[i]]++;
    }

    for (int i = 0; i < m; i++){
        fruit[red[i]]--;
    }

    map<string, int>::iterator it;

    int ans = 0;

    for ( it = fruit.begin(); it != fruit.end(); it++ )
    {
        ans = max(ans, it->second);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long i = x; i < (N); i++)
using namespace std;

int main()
{
    string S;
    cin >> S;
    rep(i, 0, S.size())
    {
        cout << 'x';
    }
    cout << endl;
}


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

int main() {
  int N;
  cin >> N;
  int x[N], y[N], h[N];

  for(int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i]; 
  }
  int si = -1;
  for(int i = 0; i < N; i++) {
    if(h[i] > 0) si = i;
  }
  
  int ansx, ansy, ansh;
  for(int X = 0; X <= 100; X++) {
    for(int Y = 0; Y <= 100; Y++) {
      bool ok = true;
      ll H = h[si] + abs(x[si] - X) + abs(y[si] - Y);
      for(int i = 0; i < N; i++) {
        if(h[i] > 0 && H - abs(x[i] - X) - abs(y[i] - Y) != h[i]) {
          ok = false;
        }
        if(h[i] == 0 && H > abs(x[i] - X) + abs(y[i] - Y)) {
          ok = false;
        }
  
      }
        if(ok) { ansx = X; ansy = Y; ansh = H; break; }
    }
  }
  cout << ansx << " " << ansy << " " << ansh;
    return 0;
}


Measured memory_bytes: 256
/******
	~site:    atcoder.jp
	~user:    Turkhuu
	~problem: AtCoder Beginner Contest 177 - C (abc177_c)
** **/

#include<bits/stdc++.h>

#define FFOR(i,s,e,k) for(int i=s;(k==1?i<=e:i>=e);i+=k)
#define FOR(i,n) FFOR(i,0,n-1,1)
#define FORR(i,s,e) FFOR(i,s,e,1)
#define ll long long
#define PQ priority_queue
#define pb push_back
#define ppb pop_back()
#define pp push
#define MIN(v) *min_element(v.begin(),v.end())
#define MAX(v) *max_element(v.begin(),v.end())
#define SORT(v) sort(v.begin(),v.end())
#define TROS(v) sort(v.rbegin(),v.rend())
#define CNT(v,x) count(v.begin(),v.end(),x)

using namespace std;

const ll MOD=1000000007;

ll a[200001],s[200001];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin>>n;
	s[0]=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		s[i]=s[i-1]+a[i];
	}
	ll sum=0;
	for(int i=n;i>=2;i--){
		sum+=(a[i]*(s[i-1]%MOD))%MOD;
		sum%=MOD;
	}
	cout<<sum;
}

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

int main(){
	int N;
	cin >> N;
	long long A[N];
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	long long MAX = A[0];
	long long ans = 0;
	for(int i=1;i<N;i++){
		if(A[i] < MAX){
			ans += MAX - A[i];
		}
		MAX = max(MAX, A[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 int INF = 1e9;
const LL LLINF = 1e16;

LL dp[2][101010][3];

int main(){
    fastcin();

    int n, k;
    cin >> n >> k;
    int s[3];
    rep(i, 3) cin >> s[i];
    string t;
    cin >> t;
    rep(i, n){
        rep(my, 3){
            rep(prv, 3){
                if(i/k >= 1 && my == prv) continue;
                LL score = 0;
                if(t[i]=='r'&&my==2) score = s[2];
                if(t[i]=='s'&&my==0) score = s[0];
                if(t[i]=='p'&&my==1) score = s[1];
                chmax(dp[((i/k)+1)%2][i%k][my], dp[(i/k)%2][i%k][prv]+score);
                // cout << dp[((i/k)+1)%2][i%k][my] << " " << my << " " << prv << " " << score << endl;
            }
        }
    }
    n--;
    LL ans = 0;
    REP(i, n-k+1, n+1){
        LL tmp = 0;
        rep(j, 3){
            // cout << dp[(i/k+1)%2][i%k][j] << endl;
            chmax(tmp, dp[(i/k+1)%2][i%k][j]);
        }
        // cout << tmp << endl;
        ans += tmp;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3584
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    string s;
    cin >> n >> s;

    UNIQUE(s);
    cout << SZ(s) << endl;

    return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<int,pi>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n;
ll f[20][20];
pi g(int x)
{
    pi a;
    a.S=x%10;
    while(x)
    {
        a.F=x%10;
        x/=10;
    }
    return a;
}
int main()
{
    go;
    cin>>n;
    for(int i=1;i<=n;i++)
        f[g(i).F][g(i).S]++;
    ll ans=0;
    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
           ans+=f[i][j]*f[j][i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] strs = Console.ReadLine().Split(' ');
        int[] num = new int[strs.Length];
        for (int i = 0; i < num.Length; i++)
        {
            num[i] = int.Parse(strs[i]);
        }

        int k = int.Parse(Console.ReadLine());

        for(int i = 0; i < k; i++) 
        {


            if (num[2] <= num[1] || num[2] <= num[0])
            {
                num[2] *= 2;
                continue;
            }
            else if (num[1] <= num[0])
            {
                num[1] *= 2;
                continue;
            }
        }

        if (num[0] < num[1] && num[1] < num[2])
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");







    }

}




Measured memory_bytes: 27388
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

void Calc(int A, double theta, double &x, double &y) {
  x = A * cos(theta);
  y = A * sin(theta);
}

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double theta1 = 2.0 * M_PI * (double(H) + double(M) / 60.0) / 12.0;
  double theta2 = 2.0 * M_PI * double(M) / 60.0;
  double x1, y1, x2, y2;
  Calc(A, theta1, x1, y1);
  Calc(B, theta2, x2, y2);
  double dx = x1 - x2;
  double dy = y1 - y2;
  double dist = sqrt(dx * dx + dy * dy);
  cout << setprecision(20);
  cout << dist << endl;
  return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int X, N;
	cin >> X >> N;
	vector<int> p;
	p.resize(N);
	for (int i = 0; i < N; i++)
		cin >> p[i];

	int min = 0;
	int distance = 100;
	for (int i = 0; i <= 101; i++) {
		bool isSame = false;
		for (int j = 0; j < p.size(); j++) {
			if (i == p[j]) {
				isSame = true;
				break;
			}
		}
		if (!isSame) {
			int tmp = abs(X - i);
			if (distance > tmp) {
				distance = tmp;
				min = i;
			}
		}
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    string s;
    cin >> s;
    ll c = 0;
    rep(i,s.size()-1) {
        if(s[i] != s[i+1]) {
        c += 1;
        }
    }
    cout << c;
}



Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		String s = sc.next();
		int b = sc.nextInt();
		
		// 計算
		int result = a - b;
		if(s.equals("+")) result = a + b;
		
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

int main() {
	int i; //x*y???x??¨?????¨
	int k; //x*y???y??¨?????¨
	int seki = 0; //?????¨?????¨
	
	for(i=1;i<=9;i++){
		for(k=1;k<=9;k++){
			seki = i * k; 
			std::cout << i;
			std::cout << "x";
			std::cout << k;
			std::cout << "=";
			std::cout << seki;
			std::cout << "\n";
		}
	}
	
	return 0;
}

Measured memory_bytes: 1112
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string a[1100]={};
  string s;
  cin>>n>>s;
  int c=0;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        a[c]+=to_string(i);
        a[c]+=to_string(j);
        a[c]+=to_string(k);
        c++;
      }
    }
  }
  int ans=0;
   for(int i=0;i<1000;i++){
     int k=0;
     for(int j=0;j<n;j++){
       if(s[j]==a[i][k]) k++;
       if(k==3) { ans++; break; }
     }
   }
   cout<<ans;



}


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

const int MAXS = 1e5+10;
const int MAXN = 222;
const ll M = 1e9+7;
int n, x;

ll mem[MAXN][MAXS], s[MAXN];

ll dp(int tot, int x) { // total number chosen nodes , last x
  ll & ans = mem[tot][x];
  if (ans!=-1) return ans;
//cerr << tot << " " << x <<endl;
  if (tot==n) return x;
  ans = 0;
  int i;
  for(i=0;s[i]<=x && i<n;i++) {
//cerr << x << " is  x and can sub " << s[i] << " " << tot << " " << x%s[i] << endl;
    ans = (ans+dp(tot+1, x%s[i]))%M;
  }
  if (n-i>tot) {
//cerr << (n-i-tot) << " " << dp(tot+1,x) <<endl;
    ans = (ans+(n-i-tot)*dp(tot+1,x))%M;
  }
  return ans;
}

int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> n >> x;
  memset(mem,-1, sizeof mem);
  for(int i=0;i<n;i++) cin >> s[i];
  sort(s, s+n);
  cout << dp(0, x) <<endl;
}

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

int main()
{
	string n;
	cin>>n;
	
	long long sum=0;
	
	for( auto x : n)
	sum= sum + x-'0';
	
	if( sum % 9 ==0)
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

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

    ll a[n];
    ll count = 0;
    ll sum = 0;
    ll mi = 10000000000;
    rep(i, n){
        cin >> a[i];
        if(a[i] != abs(a[i]))
            count++;

        mi = min(mi, abs(a[i]));
        sum += abs(a[i]);
    }

    if(count % 2 == 0){
        cout << sum << endl;
    }else{
        cout << sum - 2 * mi << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int D; cin >> D; 
	int C[30] = {}; 
	for(int i = 1; i <= 26; i++) cin >> C[i]; 
	int S[370][30] = {}; 
	for(int i = 1; i <= D; i++){
		for(int j = 1; j <= 26; j++){
			cin >> S[i][j]; 
		}
	}
	int ans[370] = {}; 
	int L[30] = {}; 
	for(int i = 1; i < D; i+= 2){
		int E[700] = {}; 
		for(int j = 1; j <= 676; j++){
			int p = (j - 1) % 26 + 1; // i日目
			int q = (j - 1) / 26 + 1; // i+1日目
			int M[30] = {}; 
			for(int k = 1; k <= 26; k++){
				M[k] = L[k]; 
			}
			E[j] += S[i][p] + C[p] * (i - M[p]) * min(D-i, 6); 
			M[p] = i; 
			E[j] += S[i+1][q] + C[q] * (i + 1 - M[q]) * min(D-i, 6);
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 676; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = (a-1) % 26 + 1; ans[i+1] = (a-1) / 26 + 1; 
		L[(a-1) % 26 + 1] = i; L[(a-1) / 26 + 1] = i + 1; 
	}
	for(int i = D; i <= D; i++){
		int E[30] = {}; 
		for(int j = 1; j <= 26; j++){
			E[j] = S[i][j] + C[j] * (i - L[j]); 
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 26; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = a; L[a] = i; 
	}
	for(int i = 1; i <= D; i++) cout << ans[i] << endl; 
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
const ll MOD = 1000000007;
void Main(){
    ll n;cin>>n;
    vector<ll> c(n);
    For(i,0,n) cin>>c[i];
    sort(ALL(c));
    reverse(ALL(c));
    ll N4=1;
    For(i,0,n-1) N4=N4*4%MOD;
    For(i,0,n){
         ans+=(i+2)*c[i]%MOD;
         ans%=MOD;
    }
    ans*=N4;
    ans%=MOD;
    cout<<ans<<endl;
}
int main(){
     Main();
     return 0;
}

Measured memory_bytes: 1792
Imports System

Module Program
    Sub Main(args As String())
        Dim N As Integer = CInt(Console.ReadLine())
        Dim Str As String = Console.ReadLine()

        Dim s1 As String = Str.Substring(0, N)
        Dim s2 As String = Str.Substring(N + 1, N)

        Dim i As Integer
        Dim StrResult As String = ""
        For i = 0 To N - 1
            StrResult = StrResult + s1(i) + s2(i)
        Next

        Console.WriteLine(StrResult)

    End Sub
End Module


Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
using namespace std;
const int MAXN=1<<13;
const int inf=0x7fffffff/3;
int f[MAXN+50];
int w[1011],num[1010];
int main()
{
	int n,m,b,now=0,c;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>w[i]>>b;
		now=0;
		for(int j=1;j<=b;j++)
		{
			cin>>c;
			now+=(1<<c-1);
		}
		num[i]=now;
	}
	int k=(1<<n)-1;
	for(int i=0;i<=k;i++)  f[i]=inf;
	f[0]=0;
	
	for(int i=0;i<=k;i++)
	{
		for(int j=1;j<=m;j++)
		{
			f[i|num[j]]=min(f[i|num[j]],f[i]+w[j]);
		}
	}
	if(f[k]==inf)  f[k]=-1;
	cout<<f[k]<<endl;
	return 0;
}

Measured memory_bytes: 3592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int[] num = new int[3];
        for (int i = 0; i < 3; i++)
        {
            num[i] = cin.nextInt();
        }
        Console.WriteLine(num.Sum() - num.Max());
    }




}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

using namespace std;

int main(){

    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    long long ans(0);

    ans += min(a,k);
    k -= min(a,k);

    k -= min(b,k);

    ans -= min(c,k);

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N,K;
  int sum = 1;
  int i = 0;
  cin>>N>>K;
  while(i<N){
    if(sum < K)
      sum *= 2;
    else
      sum += K;
  i++;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256