akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define N 200005
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;





void solve()
{
	int n;
	cin>>n;
	
	vector<int>v(n);
	
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	
	sort(v.begin(),v.end(),greater<int>());
	
	int ans=0;
	
	for(int i=1;i<n;i++)
	ans+=v[i/2];
	
	cout<<ans<<endl;
	
	
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

Measured memory_bytes: 4784
#!/usr/bin/env python3
#ABC138 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,q = LI()
g = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = LI()
    g[a-1].append(b-1)
    g[b-1].append(a-1)

ans = [0]*n
for _ in range(q):
    p,x = LI()
    ans[p-1] += x

def dfs(start,par):
    for v in g[start]:
        if v != par:
            ans[v] += ans[start]
            dfs(v,start)
dfs(0,-1)
print(*ans)


Measured memory_bytes: 237684
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc  = new Scanner(System.in);
    boolean flag = false;
    int N = sc.nextInt();
    for(int i=0;i<N;i++){
      String s = sc.next();
      if(s.equals("Y")){
        flag = true;
      }
    }
    if(flag){
      System.out.println("Four");
    }else{
      System.out.println("Three");
    }

  }
}


Measured memory_bytes: 23124
import math
n,k=map(int,input().split())
"""
1～6で場合わけ
"""
log2k = math.log(k, 2)
ans = 0
for i in range(1, n+1):
	target = math.ceil(log2k - math.log(i, 2))
	if target >= 1:
		ans += 1/(2**target)
	else:
		ans += 1
print(ans/n)

Measured memory_bytes: 3060
#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>;

#include <atcoder/all>
using namespace atcoder;

int main() {
    string s;
    cin >> s;
    vector<int> sa = suffix_array(s);
    vector<int> lcp = lcp_array(s, sa);
    ll sum = s.size()*(s.size()+1) / 2;
    rep(i,lcp.size()) {
        sum -= lcp[i];
    }
    cout << sum << endl;
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> v;
    rep(i, n) v.push_back(s[i] - '1');

    vector<lint> c(n);
    c[0] = 0;
    rep(i, n - 1){
        int x = n-1-i, y = 1+i;
        c[i+1] = c[i];
        while(x % 2 == 0){
            c[i+1]++; x /= 2;
        }
        while(y % 2 == 0){
            c[i+1]--; y /= 2;
        }
    }
    rep(i, n){
        if(c[i] == 0) c[i] = 1;
        else c[i] = 0;
    }

    int r = 0;
    rep(i, n){
        r += v[i] * c[i];
        r %= 2;
    }

    if(r == 0){
        rep(i, n){
            if(v[i] == 1){
                out(0); return 0;
            }
            if(v[i] == 2){
                v[i] = 1;
            }
        }

        r = 0;
        rep(i, n){
            r += v[i] * c[i];
            r %= 2;
        }
        out(r * 2); return 0;
    }
    else{
        out(1); return 0;
    }
}

Measured memory_bytes: 13616
main(){
int a,b,c,x,y,z;
scanf("%d%d%d",&a,&b,&c);

if(a > b){ 
    x = a;
    a = b;
    b = x;
  }

  if(b > c){
    y = b;
    b = c;
    c = y;
  }   
  if(a > b){
    z = a;
    a = b;
    b = z;
  }   
  printf("%d %d %d\n",a,b,c);
   
  return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }

    Scanner kbd = new Scanner(System.in);

    void run(){
	// 高さと、対角線のセットを作成
	int[][] a = new int[23000][2];
	// ↑ 0:高さ、1:幅
	int k = 0;
	for(int i=1; i<=150; i++){  // 高さ
	    for(int j=i+1; j<=150; j++){ // 幅
		a[k][0] = i;
		a[k][1] = j;
		k++;
	    }
	}

	Arrays.sort(a, new Comparator<int[]>(){
		public int compare(int[]a, int[]b){
		    int x1 = a[0]*a[0]+a[1]*a[1];
		    int x2 = b[0]*b[0]+b[1]*b[1];
		    if(x1 != x2) return x1-x2;
		    else return a[0]-b[0];
		}
	    }
	    );


	while(kbd.hasNext()){
	    int h = kbd.nextInt();
	    int w = kbd.nextInt();
	    if(h!=0 && w!=0) solve(h, w, a);
	}
    }

    void solve(int h, int w, int[][] a){
	int t = h*h+w*w;
	int i=0;
	while((h!=a[i][0] || w!=a[i][1])) i++;
	System.out.println(a[i+1][0]+" "+a[i+1][1]);
    }
}
	    

Measured memory_bytes: 36600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    bool flag = false;
    const int inf = 1001001001;
    int mn = inf;
    ll sum = 0;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        sum += a;
        if (a > b) {
            flag = true;
            chmin(mn, b);
        }
    }
    if (!flag) cout << 0 << endl;
    else cout << sum - mn << endl;
}


Measured memory_bytes: 3640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    final double EPS = 1.0e-10;

    void run() {
        int MAX = 30001;
        boolean isPrime[] = new boolean[MAX];
        List<Integer> primes = new ArrayList<Integer>();
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i < MAX; i++) {
            if (isPrime[i]) {
                primes.add(i);
                for (int j = i + i; j < MAX; j += i) {
                    isPrime[j] = false;
                }
            }
        }
        Scanner sc = new Scanner(System.in);
        while (true) {
            int T = sc.nextInt();
            if (T == 0)
                break;
            int ans = 0;
            Set<String> set = new HashSet<String>();
            for (int i = 0; i < primes.size(); i++) {
                int a = primes.get(i);
                if (a >= T)
                    break;
                for (int j = i; j < primes.size(); j++) {
                    int b = primes.get(j);
                    int c = T - a - b;
                    if (c < 0 || c < b)
                        break;
                    if (a + b > c && c > Math.abs(b - a))
                        if (isPrime[c]) {
                            ans++;
                        }
                }
            }
            System.out.println(ans);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
using namespace std;
vector<char>s[10];
main()
{
	string t;
	t=".,!? ";for(int i=0;i<t.size();i++)s[1].push_back(t[i]);
	t="abc";for(int i=0;i<t.size();i++)s[2].push_back(t[i]);
	t="def";for(int i=0;i<t.size();i++)s[3].push_back(t[i]);
	t="ghi";for(int i=0;i<t.size();i++)s[4].push_back(t[i]);
	t="jkl";for(int i=0;i<t.size();i++)s[5].push_back(t[i]);
	t="mno";for(int i=0;i<t.size();i++)s[6].push_back(t[i]);
	t="pqrs";for(int i=0;i<t.size();i++)s[7].push_back(t[i]);
	t="tuv";for(int i=0;i<t.size();i++)s[8].push_back(t[i]);
	t="wxyz";for(int i=0;i<t.size();i++)s[9].push_back(t[i]);
	int n;cin>>n;
	for(;n--;)
	{
		cin>>t;
		string ans="";
		for(int i=0;i<t.size();i++)
		{
			int cnt=0,c=t[i]-'0';
			while(t[i]!='0')cnt++,i++;
			if(cnt)ans+=s[c][(cnt-1)%s[c].size()];
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3140
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
data = list(map(int,read().split()))

inf = 10**15
axis_p_max = -1 * inf
axis_p_min = inf
axis_m_max = -1 * inf
axis_m_min = inf

it = iter(data)
for x,y in zip(it,it):
    axis_p_max = max(axis_p_max, x+y)
    axis_p_min = min(axis_p_min, x+y)
    axis_m_max = max(axis_m_max, x-y)
    axis_m_min = min(axis_m_min, x-y)

ans = max(axis_p_max-axis_p_min, axis_m_max-axis_m_min)
print(ans)

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

    /*
    bool solve(string s) {
    if (s.length() == 0) {
        return true;
    }

    if (s.length() >= 7 && s.substr(s.length() - 7, 7) == "dreamer") {
        return solve(s.substr(0, s.length() - 7));
    } else if (s.length() >= 6 && s.substr(s.length() - 6, 6) == "eraser") {
        return solve(s.substr(0, s.length() - 6));
    } else if (s.length() >= 5 && s.substr(s.length() - 5, 5) == "dream") {
        return solve(s.substr(0, s.length() - 5));
    } else if (s.length() >= 5 && s.substr(s.length() - 5, 5) == "erase") {
        return solve(s.substr(0, s.length() - 5));
    } else {
        return false;
    }
    }
    */
    int main() {
    string s;
    
    cin >> s;

    while (1) {
        if (s.length() == 0) {
        cout << "YES" << endl;
        return 0;
        }

        if (s.length() >= 7 && s.substr(s.length() - 7, 7) == "dreamer") {
        s = s.substr(0, s.length() - 7);
        } else if (s.length() >= 6 && s.substr(s.length() - 6, 6) == "eraser") {
        s = s.substr(0, s.length() - 6);
        } else if (s.length() >= 5 && s.substr(s.length() - 5, 5) == "dream") {
        s = s.substr(0, s.length() - 5);
        } else if (s.length() >= 5 && s.substr(s.length() - 5, 5) == "erase") {
        s = s.substr(0, s.length() - 5);
        } else {
        cout << "NO" << endl;
        return 0;
        }
    }

    // cout << (solve(s) ? "YES" : "NO") << endl;
    return 0;
    }


Measured memory_bytes: 512
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

const string YES = "Yes";
const string NO = "No";

void solve(long long K, long long X) {
  cout << (K * 500 >= X ? YES : NO) << endl;
}

int main() {
  int a;
  long long K;
  scanf("%lld", &K);
  long long X;
  scanf("%lld", &X);
  solve(K, X);
  return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    
    int ans = 0, sum = 1;
    while (sum < b){
        sum += a - 1;
        ans += 1;
    }

    cout << ans << '\n';
    
    return 0;
}


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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    llong k;
    cin >> n >> m >> k;
    vector<llong> A(n + 1), B(m), cumB(m + 1);
    A[0] = 0;
    cumB[0] = 0;
    rep(i, n) cin >> A[i + 1];
    rep(i, m) {
        cin >> B[i];
        cumB[i + 1] = cumB[i] + B[i];
    }

    // rep(i, m + 1) cout << cumB[i] << ' ';
    // cout << endl;

    int ans = 0;
    llong t = 0;
    rep(i, n + 1) {
        t += A[i];
        // cout << A[i] << ' ' << k - t << ' ' << lower_bound(all(cumB), k - t) - cumB.begin() << endl;
        if (t > k) continue;
        ans = max(ans, static_cast<int>(upper_bound(all(cumB), k - t) - cumB.begin()) - 1 + i);
        // cout << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7880
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

const int mod=1e9+7;
const int inf=-1;
const int sz=2e5;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gap ' '
#define lb lower_bound
#define ub upper_bound
#define SIN(x) sin(x * pi / 180.0)
#define COS(x) cos(x * pi / 180.0)
#define clr(x) memset(x,0,sizeof(x))
#define all(x) sort(x.begin(),x.end())
#define rall(x) reverse(x.begin(),x.end())
#define dbg puts("finding wrong")
#define case(x,y) printf("Case %lld: %lld\n",++x,y)
#define fastio ios::sync_with_stdio(false);cin.tie(0)


ll coin[sz],way[sz];

int main()
{
  fastio;
  ll t, a, b, c, ans, i, n, j;
  
  cin>>n;
  if(n<=2)
  {
      cout<<0<<endl;
      return 0;
  }
  
  for(i=3; i<=n; i++)
  {
      coin[i-2]=i;
  }
  way[0]=1;
  for(i=1; i<=n; i++)
  {
      for(j=1; j<=n-2; j++)
      {
          if(i>=coin[j])
          {
              way[i]=(way[i]+way[i-coin[j]])%mod;
          }
      }
  }
  cout<<way[n]<<endl;
  
}


Measured memory_bytes: 3676
n = int(input())
card = {
    'S':[False for _ in range(13)],
    'H':[False for _ in range(13)],
    'C':[False for _ in range(13)],
    'D':[False for _ in range(13)]
}
for _ in range(n):
    mark, num = input().split()
    num = int(num)
    card[mark][num-1] = True

for mark in "SHCD":
    for num in range(13):
        if card[mark][num] is False:
            print(mark, num+1)



Measured memory_bytes: 5604
def main():
	n = int(input())
	arr =list(map(int , input().split()))
	ans = 0
	allseq = 1
	bad = 1
	# find the no of sequence which has product of all numbers odd
	# subtract the total no of sequence  
	for i in range(0 , n):
		if arr[i]%2==0:
			bad = bad*2# b can take value arr[i]-1 or arr[i]+1
		else:
			bad = bad*1# b can take value only arr[i]
		allseq = allseq*3# total no of elements
	print(allseq-bad)
if __name__=="__main__":
	main()

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

int main(void) {
  int a[100001] = {0};
  int n;
  int ans=0;
  cin>>n;
  for(int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a, a+n);
  int x=a[0];
  int c=1;
  for(int i=1; i<n; i++) {
    if(a[i]!=x) {
      if(x>c) ans+=c;
      else if(x<c) ans+=c-x;
      x=a[i];
      c=1;
    }
    else {
      c++;      
    }
  }
  if(x>c) ans+=c;
  else if(x<c) ans+=c-x;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

//gcdやり直す

void swap (int *x, int *y) {
  int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}




/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}




/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  long int n;
  scanf("%ld",&n);
  long int ans=0;
  for(int i=1;i<=n;i++){
    long int now=n/i;
    ans+=now*(now+1)/2*i;
  }

  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 1700
#include <stdio.h>

int gcd(int a, int b){
  if(a == 0 || b == 0) return (a == 0 ? b : a);
  int temp1, temp2;
  temp1 = (a > b ? a : b);
  temp2 = a + b - temp1;
  return gcd(temp2, temp1 % temp2);
}

int
main(int argc, char *argv[])
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if(c % gcd(a, b) == 0) printf("YES\n");
  else printf("NO\n");

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int a,i,j,sa[7];
		for(a=0;a<=6;a++){
			scanf("%d %d",&i,&j);
			sa[a]=i-j;
		}
		for(a=0;a<=6;a++){
			printf("%d\n",sa[a]);
		}
	return 0;
}


Measured memory_bytes: 2112
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    if (B - A) % 2 == 0:
        print((B - A) // 2)
    else:
        if B - 1 > N - A:
            print(N - B + 1 + ((B - A - 1) // 2))
        else:
            print(A - 1 + 1 + ((B - A - 1) // 2))
    return 0


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


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

int main(void){
	int x, y;

	while(1){
		cin >> x >> y;
		if(x == 0 && y == 0) break;

		if(x > y){
			printf("%d %d\n", y, x);
		}else{
			printf("%d %d\n", x, y);
		}
	}

	return 0;
}

Measured memory_bytes: 1144
#include <stdio.h>

#define MAX 45

int Fibonacci(int [],int);

int main(){
  int dp[MAX],n;
  int i;

  for (i = 0;i < MAX;i++){
    dp[i] = 0;
  }
  
  scanf("%d",&n);
  
  Fibonacci(dp,n);
  
  printf("%d\n",dp[n]);
  
  return 0;
}

int Fibonacci(int dp[],int n){
  if (n == 0 || n == 1)
    return dp[n] = 1;

  if (dp[n])
    return dp[n];

  return dp[n] = Fibonacci(dp,n - 2) + Fibonacci(dp,n - 1);
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
 
typedef long long   ll;
typedef long double ld;
const int N  = 5e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define iceil(n,x)      ((n)+(x)-1)/(x)
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll inv(ll n)       { ll ans=powm(n,mod-2); return ans; }
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }
ll choose2(ll n)   { ll ans=(n*(n-1))/2; return ans;  }
ll dist2(ll x1,ll y1,ll x2,ll y2){ ll ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); return ans;}

int main()
{
	fast
	ll n;
	cin>>n;
   
   ll a[n+1],b[n+1]={0};
   forn(i,1,n+1)
   cin>>a[i];
   
   forn(i,1,n+1)
   {
   	if(i%2)
   		b[1]+=a[i];
   	else
   		b[1]-=a[i];
   }

   forn(i,2,n+1)
   	b[i]=2*a[i-1]-b[i-1];

   forn(i,1,n+1)
   cout<<b[i]<<" ";	

	return 0;
}

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

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

    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> X(n), Y(m);
    REP(i, n) cin >> X[i];
    REP(i, m) cin >> Y[i];

    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    
    int x_max = X[n-1];
    int y_min = Y[0];

    if(y_min <= y and x < x_max and y_min - x_max > 0){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll n,d,ret=0; cin>>n>>d;
	for (int i=0; i<n; i++) {
		ll x,y; cin>>x>>y;
		if (x*x+y*y<=d*d) 
			ret++;
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 3688
n = int(input())
mnstr = list(map(int,input().split()))
yshabl = list(map(int,input().split()))

cnt = 0

for i in range(-1,-1*len(yshabl)-1,-1):
	y = yshabl[i]
	m = mnstr[i]+mnstr[i-1]
	if m >= y:
		cnt += y
		if mnstr[i] >= y:
			pass
		else:
			mnstr[i-1] -= y - mnstr[i]
	else:
		cnt += m
		mnstr[i-1] = 0

print(cnt)

Measured memory_bytes: 19156
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll c = min(C, D);
    ll d = max(C, D);
    ll CD = C*D;
    ll r = c % d;
    while(r != 0){
        c = d;
        d = r;
        r = c % d;
    }
    ll lcm = CD/d;

    ll minC, maxC, minD, maxD, minCD, maxCD;
    minC = (A-1)/C;
    maxC = B/C;
    minD = (A-1)/D;
    maxD = B/D;
    minCD = (A-1)/lcm;
    maxCD = B/lcm;
    

    cout << B-A+1-(maxC-minC)-(maxD-minD)+(maxCD-minCD) << endl;




    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    while(true){
       int i,j,k,n,x,tem=0;
       cin >> n >> x;
       if(n == 0 && x == 0)break;
       for(i=1;i<=n-2;i++){
           for(j=i+1;j<=n-1;j++){
               for(k=j+1;k<=n;k++){
                   if((i+j+k == x) && (i!=j || j!=k ||i!=k))tem = tem+1;
               }
           }
       }
       cout << tem << endl;
    }
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define fi(i,a,b) for (int i=a; i<=b; ++i)
#define fid(i,a,b) for (int i=a; i>=b; --i)
#define pp pair<int,int>
#define f first
#define s second
#define DAVu "Frog1"
#define maxn 100005
using namespace std;
int n, a[maxn] ;
long long l[maxn] ;
int main()
{
    ios_base::sync_with_stdio(0) ;
    cin.tie(NULL); cout.tie(NULL) ;
    //freopen(DAVu".inp", "r", stdin) ;
    //freopen(DAVu".out", "w", stdout) ;
    cin >> n ;
    fi(i,1,n) cin >> a[i] ;
    l[1] = 0 ;
    l[2] = abs(a[2] - a[1]) ;
    fi(i,3,n)
        l[i] = min(l[i-1]+abs(a[i] - a[i-1]), l[i-2]+abs(a[i] - a[i-2])) ;
    cout << l[n] ;
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll H, W, N;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
ll ans[11];

int main()
{
    cin >> H >> W >> N;
    set<pair<int, int>> st, br;
    ans[0] = (H - 2) * (W - 2);
    for (int i = 0; i < N; i++)
    {
        int y, x;
        cin >> y >> x;
        y--, x--;
        pair<int, int> p = make_pair(y, x);
        br.insert(p);
        st.insert(p);
        for (int i = 0; i < 8; i++)
        {
            ll ny = y + dy[i], nx = x + dx[i];
            if (ny < 1 || ny > H)
                continue;
            if (nx < 1 || nx > W)
                continue;
            pair<ll, ll> q = make_pair(ny, nx);
            st.insert(q);
        }
    }
    for (auto &p : st)
    {
        ll y = p.first, x = p.second, cnt = 0;
        if (br.find(p) != br.end())
            cnt++;
        for (int i = 0; i < 8; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W)
            {
                cnt = -1;
                break;
            }
            pair<int, int> q = make_pair(ny, nx);
            if (br.find(q) != br.end())
                cnt++;
        }
        if (cnt != -1)
            ans[cnt]++, ans[0]--;
    }
    for (int i = 0; i < 10; i++)
        cout << ans[i] << endl;
}

Measured memory_bytes: 47104
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
red = []
green = []
less = []
for i in range(x):
    red.append(p[-i-1])
for i in range(y):
    green.append(q[-i-1])
# print(red, green)
for i in range(c):
    if len(red) > 0 and len(green) > 0:
        if red[-1] < green[-1]:
            if red[-1] < r[-i-1]:
                del red[-1]
                less.append(r[-i-1])
        else:
            if green[-1] <= r[-i-1]:
                del green[-1]
                less.append(r[-i-1])
    elif len(red) > 0:
        if red[-1] < r[-i-1]:
            del red[-1]
            less.append(r[-i-1])
    elif len(green) > 0:
        if green[-1] <= r[-i-1]:
            del green[-1]
            less.append(r[-i-1])
ans = sum(red) + sum(green) + sum(less)
# print(red, green, less)
print(ans)

Measured memory_bytes: 106576
#include <iostream>

using namespace std;
int main(){
	long long i,n;
	cin >> n;
	if(n&1){
		cout << 0 << endl;
	}else{
		long long res = 0;
		for(i=10;i<=n;i*=5){
			res += n/i;
		}
		cout << res << endl;
	}
}

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

int prime(int n) {
	int i;

	if (n <= 1)/*1以下の場合は0を返す*/
	{
		return 0;/*素数ではない*/
	}
	/*nまでの数値を繰り返し、余りがあれば0を返す*/
	for (i = 2; i < n; i++) {
		if (n % i == 0) {
			return 0;/*素数ではない*/
		}
	}

	return 1;/*素数である*/
}

int main(){
  int x;
  cin>>x;
  int i=0;
  while(1){
    if (prime(x+i)==1){
      cout<<x+i<<endl;
      break;
    }
    else i++;
  }
}

Measured memory_bytes: 3140
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		
		while(true){
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}

			for(int i = 0; i < h; i++){
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 27584
using System;

class Atcoder115
{
    public static void Main()
    {
        string[] inputa = Console.ReadLine().Split(' ');
        int H = int.Parse(inputa[0]);
        int W = int.Parse(inputa[1]);

        string[] inputb = Console.ReadLine().Split(' ');
        int h = int.Parse(inputb[0]);
        int w = int.Parse(inputb[1]);

        Console.WriteLine((H - h) * (W - w));
    }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

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

  vector<int> A(N);
  rep(i,N) cin >> A.at(i);

  vector<int> bns(N);

  rep(i,N-1){
    if(A.at(i) < A.at(i+1)) bns.at(i) = 0;//buy
    else if(A.at(i) > A.at(i+1)) bns.at(i) = 2;//sell
    else bns.at(i) = 1;
  }


  bns.at(N-1) = 2;

//  rep(i,N) cout << bns.at(i) << endl;

  ll money = 1000, stock = 0;

  rep(i,N){
//    cout << money << endl;
    if(bns.at(i)==1) continue;
    if(bns.at(i)==0){
      stock += money/A.at(i); //ok
      if(money/A.at(i)==0) continue;
      money -= stock*A.at(i); //ok
    }
    if(bns.at(i)==2){
      money += stock*A.at(i);
      stock = 0;
    }
  }

  cout << money << endl;
}


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

int main(){
  int N;cin>>N;
  string S;cin>>S;
  for(int i=0;i<S.size();i++){
    if(S[i]+N<91){
      S[i]+=N;
    }else{
      S[i]=65+(N-(91-S[i]));
    }
  }
  cout<<S<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  string s;
  int K;
  while (cin >> s >> K) {
    set<string> S;
    for (int i = 0; i < s.size(); i++) {
      for (int len = 1; len <= K; len++) {
        S.insert(s.substr(i, len));
      }
    }
    auto it = S.begin();
    for (int i = 0; i < K - 1; i++) ++it;
    cout << *it << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h> 
using namespace std; 
void swap(int * num1, int * num2)
{
    int temp;
    temp = *num1;
    *num1= *num2;
    *num2= temp;
}
int main() 
{  int a,b,c;
   cin>>a>>b>>c;
   int sum;
   swap(a,b);
   swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<" ";
    return 0; 
} 

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	string S; cin >> S;
	ll K; cin >> K;
	REP(i,S.size()){
		if (26 - (S[i] - 'a') <= K) {
			K -= (26 - (S[i] - 'a'))%26;
			S[i] = 'a';
		}
	}
	K %= 26;
	S[S.size()- 1] = char('a' + ((S[S.size() - 1] - 'a') + K) % 26);
	cout << S << endl;
	return 0;
}



Measured memory_bytes: 512
#include <cstdio>
#include <complex>
using namespace std;
typedef complex<double> xy;
int main(){
    double x1,y1,x2,y2,px,py;
    while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&px,&py)){
        xy p = xy(px,py);
        xy ba=xy(x2-x1,y2-y1),bb=xy(px-x1,py-y1);
        double dp = (conj(ba)*bb).real();
        xy bc = ba*dp/norm(ba);
        xy pp = xy(bc.real()+x1,bc.imag()+y1);
        xy ans = p+(pp-p)+(pp-p);
        printf("%.6lf %.6lf\n",ans.real(),ans.imag());
    }
}

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

int main(){
  int n,t;cin>>n>>t;
  vector< vector<int> > ab(n,vector<int>(2,0));
  for(int i=0;i<n;i++)cin >> ab[i][0] >> ab[i][1];
  sort(ab.begin(),ab.end(),[](const vector<int>& a,const vector<int>& b){return a[0]<b[0];});
  int m= ab[n-1][0];
  vector<int> dp(t+m);

  for(int i=0;i<n;i++){
    vector<int> dp_sub(t+m);
    for(int j=0;j<t;j++){
      if(j==0){dp_sub[ab[i][0]]=ab[i][1];}
      else if(dp[j]!=0){dp_sub[j+ab[i][0]]=dp[j]+ab[i][1];}
    }
    for(int j=0;j<t+m;j++){
      dp[j]=max(dp[j],dp_sub[j]);
    }
  }
  cout << *max_element(dp.begin(),dp.end()) << endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cassert>
#include<algorithm>
using namespace std;

const int N = 2e5;
int a[N+3];
int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n+n; i++) scanf("%d",&a[i]);
	sort(a+1,a+n+n+1);
	int left = 0,right = n;
	while(left<right)
	{
		int mid = left+((right-left)>>1);
		bool ok = true;
		for(int i=mid*2+1; i<=n+n; i++)
		{
			if(a[i]+a[n+n+mid+mid+1-i]<m) {ok = false; break;}
		}
		if(ok==true) {right = mid;}
		else {left = mid+1;}
	}
	int pos = 2*right;
	int ans = 0;
	for(int i=1; i<=pos; i++) ans = max(ans,a[i]+a[pos+1-i]);
	for(int i=pos+1; i<=n+n; i++) ans = max(ans,(a[i]+a[n+n+pos+1-i])-m);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
struct stu{
	int numberr,rankk;
	bool operator < (const stu s)const
	{
		return rankk<s.rankk;
	}
};
stu ss[100010];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		ss[i].numberr=i;
		cin>>ss[i].rankk;
	}
	sort(ss+1,ss+n+1);
	for(int i=1;i<=n;i++)
	{
		cout<<ss[i].numberr;
		if(i!=n)
			cout<<" ";
	}
	cout<<endl;
 } 

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

int main() {
    int n, x;
    while (1) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;

        int num = 0;
        for (int i = 1; i <= n; i++){
            for (int j = i + 1; j <= n; j++){
                for (int k = j + 1; k <= n; k++){
                    if (i + j + k == x) num++;
                }
            }
        }
        cout << num << "\n";
    }

    return 0;
}

Measured memory_bytes: 3076
rev_s = ''.join(list(reversed(input())))
rev_w = ['maerd', 'remaerd', 'esare', 'resare', 'END']

while rev_s != '':
    for item1 in rev_w:
        if rev_s.find(item1) == 0:
            rev_s = rev_s[len(item1):]
            break
    if item1 == 'END':
        break

if rev_s == '':
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <set>
#define N 200005
using namespace std;

typedef long long ll;
ll n, a, l, r, ans, d[N];
set<ll> v;
int main()
{
	ll i;
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf ("%lld", &a);
		d[a] = i;
	}
	v.insert(0);
	v.insert(n + 1);
	for (i = 1; i <= n; i++) {
		l = *(--v.lower_bound(d[i]));
		r = *v.lower_bound(d[i]);
		ans += (d[i] - l) * (r - d[i]) * i;
		v.insert(d[i]);
	}
	cout << ans;
    return 0;
}

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

int main(){
  long long a,b,v,w,t;
  cin >> a >> v >> b >> w >> t;
  long long d = max(a-b,b-a);
  if(v < w) cout << "NO" << endl;
  else {
    v -= w;
    if(d <= v*t) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3624
#import sys
#input = sys.stdin.readline
S = list(input())
N = len(S)

def solver(n,m,idx):
    if (n-m)%2 == 0:
        ans[idx[0]] = (n+m)//2
        ans[idx[1]] = (n+m)//2
    else:
        if m%2 == 1:
            ans[idx[1]] = (n+m)//2 + 1
            ans[idx[0]] = (n+m)//2
        else:
            ans[idx[0]] = (n+m)//2 + 1
            ans[idx[1]] = (n+m)//2
    return    
    
    
        
        
ans = [0] * N
m = 0
n = 0
flagL = False
idx = []
for i,s in enumerate(S):
    if s == 'R':
        if flagL:
            solver(n,m,idx)
            n = 0
            m = 0
            flagL = False
        n += 1
    elif s == 'L':
        if not flagL:
            flagL = True
            idx = [i-1,i]
        m += 1 
solver(n,m,idx)
    
print(*ans,sep = ' ')

Measured memory_bytes: 7092
import java.util.Scanner;

public class Main {

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

		long n = scan.nextInt();
		long k = scan.nextInt();
		long i = 0;
		long a = 1;

		for (i = 0; i < n-1; i++) {

			a = a * (k - 1);

			//System.out.println(a);
		}

		if (n > 1) {
			System.out.println(k * a);

		} else if(n==1) {
			System.out.println(k);

		}

	}

}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		//		int h = sc.nextInt();
		//		int x = sc.nextInt();
		//		int y = sc.nextInt();

		for (int i = 0; i < s.length(); i += 2) {
			System.out.print(s.charAt(i));
		}

	}
}

Measured memory_bytes: 28756
#include <iostream>
#include <cstring>

#define DPRINT( val ) printf( "%d\n", val )
//#define DPRINT( val )

int main( void )
{
	char hoge[1201] = {};
	int initial[26] = {};
	while (scanf( "%s", hoge ) != EOF ) {
		size_t len = strlen( hoge );
		for ( int i = 0; i < len + 1; ++i ) {
			if ( 0x41 <= hoge[i] && hoge[i] <= 0x5A ) {
				initial[hoge[i] - 0x41] = initial[hoge[i] - 0x41] + 1;
			}
			else if ( 0x61 <= hoge[i] && hoge[i] <= 0x7A ) {
				initial[hoge[i] - 0x61] = initial[hoge[i] - 0x61] + 1;
			}
		}
	}
	printf( "a : %d\n", initial[0] );
	printf( "b : %d\n", initial[1] );
	printf( "c : %d\n", initial[2] );
	printf( "d : %d\n", initial[3] );
	printf( "e : %d\n", initial[4] );
	printf( "f : %d\n", initial[5] );
	printf( "g : %d\n", initial[6] );
	printf( "h : %d\n", initial[7] );
	printf( "i : %d\n", initial[8] );
	printf( "j : %d\n", initial[9] );
	printf( "k : %d\n", initial[10] );
	printf( "l : %d\n", initial[11] );
	printf( "m : %d\n", initial[12] );
	printf( "n : %d\n", initial[13] );
	printf( "o : %d\n", initial[14] );
	printf( "p : %d\n", initial[15] );
	printf( "q : %d\n", initial[16] );
	printf( "r : %d\n", initial[17] );
	printf( "s : %d\n", initial[18] );
	printf( "t : %d\n", initial[19] );
	printf( "u : %d\n", initial[20] );
	printf( "v : %d\n", initial[21] );
	printf( "w : %d\n", initial[22] );
	printf( "x : %d\n", initial[23] );
	printf( "y : %d\n", initial[24] );
	printf( "z : %d\n", initial[25] );

	return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T;
  cin >> S >> T;
  int A,B;
  cin >> A >> B;
  string U;
  cin >> U;
  if (U==S){
    A--;
  }
  else B--;
  cout << A << " " << B << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] length = new int[N];

		int total = 0;
		for (int i = 0; i < N; i++) {
			length[i] = sc.nextInt();
		}
		Arrays.sort(length);

		int a = N - K;
		for (int i = a; i < N; i++) {
			total += length[i];
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 35740
#include <algorithm>
#include<iostream>
#include<vector>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long n,ii,jj,kk,ll;
  vector<long> input,sumRes,xorRes;
  long rr,sum,xxor,cnt,len;
  cin >> n;

  input.resize(n);
  
  for(ii=0;ii<n;ii++){
	cin >> input[ii];
  }

  cnt = 0;
  sum = 0;
  xxor = 0;

  sum = 0;
  xxor = 0;
  jj=0;

  for(ii=0;ii<n;ii++){
	while(jj<n){
	  if((sum + input[jj]) != (xxor xor input[jj])){
		  break;
		}
	  sum = sum + input[jj];
	  xxor = xxor xor input[jj];
	  jj++;
	}
	cnt += jj - ii;
	sum = sum - input[ii];
	xxor = xxor xor input[ii];
  }


  

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#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 repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;
string multiple(string a,string b){
    if(a=="0"||b=="0") return "0";
    string t;bool bb=1;
    int la=a.size(),lb=b.size(),c,it1,it2,n1,n2,f;
    vector<int> v(la+lb);
    it1=0;
    Repp(i,la-1,0){
        it2=0;c=0;n1=a[i]-'0';
        Repp(j,lb-1,0){
            n2=b[j]-'0';
            f=v[it1+it2]+n1*n2+c;
            v[it1+it2]=f%10;
            c=f/10;
            it2++;
        }
        while(c>0) {
            f=v[it1+it2]+c;
            v[it1+it2]=f%10;
            c=f/10;
            it2++;
        }
        it1++;
    }
    Repp(i,la+lb-1,0){
        if(v[i]==0&&bb) ;
        else {bb=0;t+=char(v[i]+'0');}
    }

    return t;
}
bool cmp_bigger_or_equal(string a,string b){
    
    if(a.size()<b.size()) return 0;
    else if(a.size()==b.size()) {
        rep(i,a.size()) {
            if((a[i]-'0')>(b[i]-'0')) return 1;
            else if((a[i]-'0')<(b[i]-'0')) return 0;
        }
    }
    return 1;
}
int main() {
    cs
    string n="1",l="1000000000000000001",x;
    int q;cin>>q;bool b=1,bb=0;
    while(q--) {
        cin>>x;bb|=(x=="0");
        if(b) n=multiple(n,x);
        if(cmp_bigger_or_equal(n,l)) b=0;
    }
    if(b) cout<<n;
    else if(bb) cout<<0;
    else cout<<-1;
    
}

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

ll n,W;
ll a[N],b[N];

ll solve() {


    ll dp[n+1][W+1]={0};

    for (int i = 0; i <= n; i++)
{
	for (int w = 0; w <= W; w++)
	{
		if (i==0 || w==0)
			dp[i][w] = 0;
		else if (a[i-1] <= w)
				dp[i][w] = max(b[i-1] + dp[i-1][w-a[i-1]], dp[i-1][w]);
		else
				dp[i][w] = dp[i-1][w];
	}
}

    return dp[n][W];
}

int main() {


    cin>>n>>W;

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

    cout<<solve();




}


Measured memory_bytes: 79104
import java.util.*;
public class Main{
	public static class Node{
		ArrayList<Integer> to;
		int p_or_l;
		Node(){
			to = new ArrayList<Integer>();
		}
	}

	static Scanner sn = new Scanner(System.in);
	static int N = sn.nextInt();
	static int M = sn.nextInt();
	static Node[] peple = new Node[100002];
	static Node[] lang = new Node[100002];
	static boolean[] visit = new boolean[100002];
	static boolean[] visit_lang = new boolean[100002];
	public static void main(String[] args){		
		for(int i = 0; i < N; ++i){
			peple[i] = new Node();
			peple[i].p_or_l = 0;
			visit[i] = false;
		}
		for(int i = 0;i < M; ++i){
			lang[i] = new Node();
			lang[i].p_or_l = 1;
			visit_lang[i] = false;
		}
		for(int i = 0; i < N; ++i){
			int K = sn.nextInt();
			for(int j = 0; j < K; ++j){
				int l = sn.nextInt();
				peple[i].to.add(l-1);
				lang[l-1].to.add(i);
			}
		}
		visit[0] = true;
		solve(peple[0]);
		check();
	}

	public static void solve(Node p){
		if(p.to.isEmpty()) return;
		for(int i = 0; i < p.to.size(); ++i){		
			int next = p.to.get(i);			
			if(p.p_or_l == 0){
                                if(visit_lang[next]) continue;
				visit_lang[next] = true;
				solve(lang[next]);
			}
			else{
				if(visit[next]) continue;
				visit[next] = true;
				solve(peple[next]);
			}
		}
	}
	public static void check(){
		boolean flag = true;
		for(int i = 0; i < N; ++i){
			if(!visit[i]){
				flag = false;
				break;
			}  
		}
		if(flag) System.out.println("YES");
		else System.out.println("NO");
	}
}

Measured memory_bytes: 97384
#!ruby -narprime
A=$F.map &:to_i
d=A.tally
print Prime.each(1e6).all?{|b|((b..8**7)%b).sum{d[_1]||0}<2}?:pairwise:A.reduce(:gcd)<2?:setwise: :not,' coprime'if/ /

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

void SelectionSort(vector<int>&, const int);
void writeVector(const vector<int>&);
void readStdIn(int&, vector<int>&);

void SelectionSort(vector<int>& v, const int n_elem){
	int n_swp = 0;
	for(int i=0; i<n_elem; i++){
		int min_i = i;
		for(int j=i; j<n_elem; j++){
			if(v.at(j) < v.at(min_i)){
				min_i = j;
			}
		}

		if(i != min_i){
		    int tmp = v.at(i);
		    v.at(i) = v.at(min_i);
		    v.at(min_i) = tmp;
		    n_swp = n_swp + 1;
		}
	}
	writeVector(v);
	cout << n_swp << "\n";
}

void readStdIn(int& n_elem, vector<int>& v){
	cin >> n_elem;
	for(int i; i<n_elem; i++){
		int input;
		cin >> input;
		v.push_back(input);
	}
}

void writeVector(const vector<int>& v){
	for(int i=0; i<v.size(); i++){
		if(i==v.size()-1){
			cout << v.at(i);
			break;
		}
		cout << v.at(i) << " ";
	}
	cout << "\n";
}

int main() {
	int n_elem;
	vector<int> v;
	readStdIn(n_elem, v);

	SelectionSort(v, n_elem);

	return 0;
}



Measured memory_bytes: 3152