akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
ll n,a,b;
cin >>n>>a>>b;
ll x[n];
for(ll i=0;i<n;i++){
cin >>x[i];
}
ll sum=0;
for(ll i=0;i<n-1;i++){
if((x[i+1]-x[i])*a<b){
sum+=(x[i+1]-x[i])*a;
}
else
sum +=b;
}
cout <<sum;

return 0;
}


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

typedef long long ll;

int main(){
    int n;
    char a[100] = {0};

    scanf("%d", &n);

    int j;
    for(int i = 1; i <= n; ++i){
        j = i;
        for(;;){
            if((j % 2) == 0){
                a[i]++;
                j = j / 2;
            }else break;
            //printf("%d\n", j);
            if(j == 0) break;
        }
    }

    int max = a[1];
    int ans = 1;
    for(int i = 1; i <= n; ++i){
        //printf("%d\n", a[i]);
        if(max < a[i]){
            max = a[i];
            ans = i;
        }
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1732
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

    vector<pair<int,int>> P;
    for (int i = 0; i < n; ++i) {
        int l = 0;
        int r = 0;
        cin >> l >> r;
        P.emplace_back(l, r);
    }
    sort(P.begin(), P.end());

    int res = 0;

    for (int i = 0; i < P.size(); ++i) {
        int l = P[i].first;
        int r = P[i].second;
        while (i + 1 < P.size() && r >= P[i + 1].first) {
            r = max(r, P[++i].second);
        }

        res += r - l + 1;
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3572
import java.io.*;
import java.util.*;
public class Main{

     public static void main(String []args){
    Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      long a[]=new long[n];
      for(int i=0;i<n;i++)
      a[i]=s.nextLong();
      HashSet<Long>hs=new HashSet<>();
      boolean flag=false;
      for(int i=0;i<n;i++)
      {if(hs.contains(a[i]))
      {flag=true;
      break;}
      else
      hs.add(a[i]);}
      if(flag)
      System.out.println("NO");
      else
      System.out.println("YES");
     }
}

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

int main() {
  int N,M;cin>>N>>M;
  dsu d(N);
  for(int i=0;i<M;i++){
    int A,B;cin>>A>>B;
    d.merge(A-1,B-1);
  }
  vector<bool>a(1001000,false);
  for(int i=0;i<N;i++)a[d.leader(i)]=true;
  int c=0;
  for(int i=0;i<N;i++)if(a[i])c++;
  cout<<c-1<<endl;
}

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

#define whole(xs) (xs).begin(),(xs).end()

typedef long long Long;

template<class T>
istream& operator>>(istream& is, vector<T>& xs) {
    for (int i = 0; i < xs.size(); i++) is >> xs[i];
    return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& xs) {
    if (xs.empty()) return os << "[]";
    os << "[" << xs[0];
    for (int i = 1; i < xs.size(); i++) os << " " << xs[i];
    return os << "]";
}

Long N, P, Q;
vector<Long> C;
int main() {
    cin >> N >> P >> Q;
    C.clear(); C.resize(N);
    cin >> C;

    for (int i = 0; i < N; i++) {
        C[i] += P * i;
    }

    sort(whole(C), greater<Long>());
    Long A = 2 * P * N * (N - 1) / 2 + P * Q * N;
    Long Ans = A;
    for (int i = 0; i < N; i++) {
        A += C[i] - P * (Q + 2 * (N - 1 - i));
        Ans = max(Ans, A);
    }
    cout << Ans - P * N * (N - 1) / 2 << endl;

}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n,k;
    cin>>n>>k;
    if (k==1) out(0);
    int extra = n-k;
    int hi = extra+1;
    int lo = 1;
    cout<<hi-lo<<endl;    
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
const int maxn=50+10;
long long dp[maxn][2];
int main()
{
	int n,p;
	cin>>n>>p;
	int a[60];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
//		dp[i][0]=0;
//		dp[i][1]=0;
	}
	dp[0][0]=1;
//	dp[0][1]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=1;j++)
		{
			if(dp[i-1][j]!=0) dp[i][(j+a[i])%2]+=dp[i-1][j];
			dp[i][j]+=dp[i-1][j];
		}
	}
//	for(int j=0;j<=1;j++)
//	{
//		for(int i=0;i<=n;i++)
//		{
//			cout<<dp[i][j]<<' ';
//		}
//		cout<<endl;
//	}
	cout<<dp[n][p];
	return 0;
}

Measured memory_bytes: 256
while line = gets
  n = line.chomp.to_i
  break if n == -1

  x, y, r = 0.0, 0.0, 0.0

  n.times do
    x += Math.cos(r)
    y += Math.sin(r)
    r = Math.atan2(y, x) + Math::PI / 2
  end

  puts sprintf('%0.2f', x), sprintf('%0.2f', y)
end

Measured memory_bytes: 9028
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  int i,n,a,b,lim1,lim2,j,tmp,ll,rr;
  vector<int> ans;
  scanf("%d%d%d",&n,&a,&b);
  lim1=(n/a);
  if (n%a!=0) lim1++;
  lim2=n+1-a;
  if ((lim1<=b)&&(b<=lim2))
  {
    for (i=0;i<=n;i++)
    {
      tmp=i;
      tmp+=((n-i)/a);
      if ((n-i)%a!=0) tmp++;
      if (tmp==b)
      {
        ans.clear();
        for (j=0;j<n;j++)
        {
          ans.push_back(n-j);
        }
        for (j=0;j<n-i;j+=a)
        {
          ll=j;rr=j+a-1;
          if (rr>n-i-1) rr=n-i-1;
          //cout<<ll<<" "<<rr<<endl;
          reverse(ans.begin()+ll,ans.begin()+rr+1);
        }
        for (j=0;j<n;j++)
        {
          if (j!=0) printf(" ");
          printf("%d",ans[j]);
        }
        printf("\n");
        //cout<<i<<endl;
        return 0;
      }
    }
  }
  else printf("-1\n");
  return 0;
}

Measured memory_bytes: 3440
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

bool is_prime[1<<16];
vector<int> primes;
int n;
void init() {
    rep(i,1<<16) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<1<<16;i++) {
        if(is_prime[i]) {
            for(int j=i+i;j<1<<16;j+=i) is_prime[j]=false;
        }

    }
    rep(i,1<<16) if(is_prime[i]) primes.pb(i);
}

void solve() {
    set<P> s;
    rep(i,primes.size()) rep(j,primes.size()) {
        if(n==primes[i]+primes[j]) {
            if(primes[j]<primes[i]) swap(primes[i],primes[j]);
            s.insert(P(primes[i],primes[j]));
        }
    }
    cout<<s.size()<<endl;


}

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

        if(n==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  
  if(N%111==0){
    cout<<N<<endl;
  }
  else{
    while(true){
      N++;
      if(N%111==0){
        cout<<N<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>

using namespace std;

static void print(const vector<int> &nums) {
  for (auto itr = nums.begin(); itr != nums.end(); itr++) {
    if (itr != nums.begin()) {
      cout << " ";
    }
    cout << *itr;
  }

  cout << endl;
}

static void insertion_sort(vector<int> &nums) {
  print(nums);

  for (size_t i = 1; i < nums.size(); i++) {
    int key = nums[i];
    size_t j = i;
    while (j > 0 && nums[j - 1] > key) {
      nums[j] = nums[j - 1];
      j--;
    }
    nums[j] = key;

    print(nums);
  }
}

int main(int argc, char *argv[]) {
  // Read input
  istream_iterator<int> eos;
  istream_iterator<int> iit(cin);

  vector<int> nums;
  if (iit != eos) {
    iit++;  // skip first line
  }

  for (; iit != eos; iit++) {
    nums.push_back(*iit);
  }

  insertion_sort(nums);

  return 0;
}

Measured memory_bytes: 3116
N = int(input())
B = [int(i) for i in input().split()]

A = [0 for i in range(N)]
A[0] = B[0]
for i in range(N-1):
    A[i] = min(A[i], B[i])
    A[i+1] = B[i]

print(sum(A))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define lim 1000000
using namespace std;
typedef pair<int, int> ii;
vector <vector<int> > Adj;
int check[100001]={0};
ll res=0;

void dfs(ll i) {
	check[i]=1;
	for(int x=0; x<(int)Adj[i].size(); x++) {
		if(check[Adj[i][x]]==0) dfs(Adj[i][x]);
	}
}

signed main() {
	ll n, m;
	cin >> n >> m;
	ll x[m], y[m], z[m];
	Adj.assign(n+1, vector<int>());
	for(int i=0; i<m; i++) {
		cin >> x[i] >> y[i] >> z[i];
		Adj[y[i]].push_back(x[i]);
		Adj[x[i]].push_back(y[i]);
	}
	
//	for(int i=1; i<=Adj.size(); i++) {
//		for(int j=0; j<Adj[i].size(); j++) {
//			cout << Adj[i][j] << " ";
//		}
//		cout << endl;
//	}

	for(int i=1; i<=n; i++) {
		if(check[i]==0) {
			dfs(i);
			res++;
		}
	}
	cout << res;
}

Measured memory_bytes: 11520
#include <stdio.h>
 
int myabs(int n)
{
	return n>0?n:-n;
}
 
int main()
{
	int n, i;
	scanf("%d", &n);
	int flag = 1;
	int t0 = 0, x0 = 0, y0 = 0;
	for(i=0;i<n;i++)
	{
		int t, x, y;
		scanf("%d%d%d", &t, &x, &y);
		int dt = myabs(t-t0);
		int dx = myabs(x-x0);
		int dy = myabs(y-y0);
		if((dx+dy)%2!=dt%2)
			flag = 0;
		else if((dx+dy)>dt)
			flag = 0;
		t0 = t;
		x0 = x;
		y0 = y;
	} 
	if(flag)
		printf("Yes\n");
	else
		printf("No\n");
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(long[]);
    auto cs = new long[](N);
    foreach (i; 0..N) {
        if (i != 0) cs[i] = cs[i-1];
        cs[i] += as[i];
    }

    auto DP = new long[][](N, N);
    long solve(int l, int r) {
        if (l == r) return 0;
        if (DP[l][r] == 0) {
            long x = long.max;
            foreach (m; l..r) {
                x = min(x, solve(l, m) + solve(m+1, r));
            }
            x += cs[r];
            if (l != 0) x -= cs[l-1];
            DP[l][r] = x;
        }
        return DP[l][r];
    }
    writeln(solve(0, N-1));
}

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


Measured memory_bytes: 256
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();
        if(K==1){
            System.out.println(0);
        }else{
            System.out.println(N-K);
        }
    }

}


Measured memory_bytes: 23124
def exchange(p, q)
  p = p.odd? ? p - 1 : p
  [p / 2, q + p / 2] 
end
a, b, k = gets.split.map(&:to_i)
turn = 0
k.times do
  if turn == 0
    a, b = exchange(a, b)
  else
    b, a = exchange(b, a)
  end
  turn = 1 - turn
end
puts [a, b].join(' ')


Measured memory_bytes: 1788
#include<stdio.h>
//int cmp(const void*a,const void*b){
// return *(int*)a-*(int*)b;}
int main(){
  int i,n;
  scanf("%d",&n);
  int a[n],b[n];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<n;i++)
    b[a[i]-1]=i+1;
  for(i=0;i<n;i++)
    printf("%d\n",b[i]);
  return 0;}


Measured memory_bytes: 1536
<?php
define('MOD', 10 ** 9 + 7);
list($n) = ints();
list($s1) = strs();
list($s2) = strs();
if ($s1[0] === $s2[0]) $ans = 3;
else $ans = 3 * 2;
for ($i = 1; $i < $n; ++$i) {
    if ($s1[$i - 1] === $s1[$i] && $s2[$i - 1] === $s2[$i]) continue;

    if ($s1[$i] === $s2[$i]) {
        if ($s1[$i - 1] === $s2[$i - 1]) $ans = ($ans * 2) % MOD;
    } else {
        if ($s1[$i - 1] === $s2[$i - 1]) $ans = ($ans * 2) % MOD;
        else $ans = ($ans * 3) % MOD;
    }
}
echo $ans;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

using namespace std;

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

int l = s.size();
if(l % 2 == 1){
	l--;
}

s = s.substr(0,l-1);

while(true){
	if(s.substr(0,l/2) == s.substr(l/2,l/2)){
		cout << l <<endl;
		return 0;
	}
	else{
		s = s.substr(0,l-2);
		l -= 2;
	}
}
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;

public class Main{

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			boolean [] in = new boolean[31];
			for(int i  = 0; i < 28; i++){
				int now = sc.nextInt();
				in[now] = true;
			}
			for(int i = 1; i < 31; i++){
				if(! in[i]){
					System.out.println(i);
				}
			}
		}
	}

	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 17184
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
//#include<regex>
using namespace std;

int main(){
    int a = 0;
    int b = 0;
    int c = 0;
    string s;
    cin>>s;
    if(s[0] == 'A'){
        a++;
    }
    if(65 <= s[1] && s[1] <= 90){
        b++;
    }
    if(65 <= s[s.length()-1] && s[s.length()-1] <= 90){
        b++;
    }
//    cout<<s[2]<<s[s.length()-2]<<endl;a
    for(int i = 2; i < s.length()-1; i++){
        if(s[i] == 67){
            c++;
        }else if(65 <= s[i] && s[i] <= 90){
            b++;
        }
    }
    if(a == 1 && b == 0 && c == 1){
        cout<<"AC"<<endl;
    }else{
        cout<<"WA"<<endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
LL N,K;
LL a[MAXN],f[MAXN],b[MAXN];
LL sum;

bool is_judge(LL  mid){
//    printf("---\n");
    for(int i=1;i<=N;i++){
        b[i]=mid/f[N+1-i];
    }
//    printf("---\n");
//    for(int i=1;i<=N;i++) printf("%lld ",b[i]);
//    printf("\n");
//    printf("---\n");
    LL tmp=0LL;
    for(int i=1;i<=N;i++){
        if(a[i]>b[i]) tmp+=a[i]-b[i];
    }
    return tmp<=K;
}

void work(){
    scanf("%lld%lld",&N,&K);
    for(int i=1;i<=N;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=N;i++){
        scanf("%lld",&f[i]);
    }
    sort(f+1,f+1+N);
    sort(a+1,a+1+N);
    LL L=0LL,R=(LL)N*f[N]*a[N];
//    printf("R = %lld\n",R);
    LL ans=R;
    while(L<=R){
//        printf("---\n");
        LL mid=(L+R)>>1;
        if(is_judge(mid)){
            ans=mid;
            R=mid-1;
        }
        else L=mid+1;
    }
    printf("%lld\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}






Measured memory_bytes: 4992
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ret = min(a * n, b);
    cout << ret << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<string> S(N);
    rep(i,N){
        cin >> S[i];
    }
    map<string,ll> mp;
    rep(i,N){
        mp[S[i]]++;
    }
    cout << "AC x "<< mp["AC"] << endl;
    cout << "WA x "<< mp["WA"] << endl;
    cout << "TLE x "<< mp["TLE"] << endl;
    cout << "RE x "<< mp["RE"] << endl;
}


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



int main() {
    
    int n,x;
    while(1){
        cin>>n>>x;
        if(n==0) break;
        int sum=0;
        for(int i=1; i<n-1; i++){
            for(int j=i+1; j<n; j++){
                for(int k=j+1; k<=n;k++ ){
                    if(i+j+k==x) sum++;
                }
            }
        }
        cout<<sum<<endl;
    }
  
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int A[3];
    rep(i,3)cin>>A[i];
    int K;cin>>K;
    sort(A,A+3);
    rep(i,K)A[2]<<=1;
    cout<<accumulate(A,A+3,0ll)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long int sum = 0;
  int k;
  cin >> k;
  int i, j, m;
  for (i = 1; i <= k; i++)
    for (j = 1; j <= k; j++)
      for (m = 1; m <= k; m++)
        sum += __gcd(__gcd(i, j), m);
  cout << sum << endl;
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N, K;
  cin >> N >> K;
  ll A[N], B[N];
  rep(i, N) cin >> A[i];

  ll sum = 0;
  rep(i, N) sum += A[i];
  vll cand;
  for(ll i = 1; i * i <= sum; i++){
    if(sum % i == 0){
      cand.push_back(i);
      if(i * i != sum) cand.push_back(sum / i);
    }
  }
  sort(cand.begin(), cand.end(), greater<ll>());
  ll ans = 1;
  for(ll n: cand){
    rep(i, N) B[i] = A[i] % n;
    sort(B, B+N);
    ll l = 0, r = N-1;
    ll suml = B[0], sumr = n - B[N-1];
    while(r - l > 1){
      if(suml <= sumr) suml += B[++l];
      else sumr += n - B[--r];
    }
    if(suml == sumr && suml <= K){
      ans = n;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    int x;
    cin >> x;
    cout << (x ^ 1) << endl;
    return 0;
}


Measured memory_bytes: 3552
from heapq import*
X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];p=[];q=[];L=[0];R=[0]
for _ in[0]*N:A.append([int(e)for e in input().split()])
A.sort(key=lambda a:a[0]-a[1])
for i in range(N):
	L+=[L[i]+A[i][1]];heappush(p,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q,A[~i][0]-A[~i][2])
	if i>=Y:L[i+1]-=heappop(p)
	if i>=X:R[i+1]-=heappop(q)
print(max(L[i]+R[~i]for i in range(Y,N-X+1)))

Measured memory_bytes: 39200
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  string s;
  cin>>s;
  m--;
  if(s[m]=='A') s[m]='a';
  if(s[m]=='B') s[m]='b';
  if(s[m]=='C') s[m]='c';
  cout<<s<<endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    int c[3], n;
    cin >> c[0] >> c[1] >> c[2] >> n;
    int count = 0;

    vector<int> rgb;
    rgb.push_back(c[0]);
    rgb.push_back(c[1]);
    rgb.push_back(c[2]);
    sort(rgb.begin(),rgb.end());

    for(int i=0; i <= ((n-(n%rgb.at(2)))/rgb.at(2)); ++i){
        static int a;
        a = n - rgb.at(2) * i;
        for(int j=0; j <= ((a-(a%rgb.at(1)))/rgb.at(1)); ++j){
            static int b;
            // cout << j << endl;
            b = a - rgb.at(1) * j;
            // cout << a << endl;a
            if(b%rgb.at(0)==0) ++count;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
 #pragma GCC target("avx", "avx2")
#include<bits/stdc++.h>

using namespace std;

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

#define int long long
// #define double ld
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}


signed main() {
    accell();
    int n;
    cin >> n;
    vector<int>a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(all(a));
    int x = a.size();
    a.erase(unique(all(a)), a.end());
    if (x == a.size())
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int sum,a,am,b,bm,x,y;
  cin>>sum;
  cin>>a>>am;
  cin>>b>>bm;
  if(sum%a==0){
    x=sum/a*am;
  }
  else{
    x=(sum/a+1)*am;
  }
  

  if(sum%b==0){
      y=sum/b*bm;
  }
  else{
    y=(sum/b+1)*bm;
  }
if(x>=y){
  cout<<y<<endl;
 }
 else{
   cout<<x<<endl;
 }


}



Measured memory_bytes: 3120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int x = Integer.parseInt(str[0]);
		int y = Integer.parseInt(str[1]);

		int max = Math.max(x + y, x - y);
		max = Math.max(max, x * y);

		System.out.println(max);
	}
}

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

int main() {
	char s;
	cin >> s;
	if (97 <= int(s)) {
		cout << "a" << endl;
	}
	else {
		cout << "A" << endl;
	}

	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
int main() {
	int a;
	string s;
	cin >> a;
	cin >> s;
	if (a  < 3200) {
		cout << "red";
	}
	else {
		cout << s;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])){
		cout << "Yes" << endl;
		
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int a[100010]; 
int main() {
  int n;
  cin >> n;
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n) {
    int cnt = 0;
    while (a[i] % 2 == 0)
    {
      a[i] /= 2;
      cnt++;
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3664
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int INF = 1e9+7;

int should_pirnt(int x) {
	int i;
	if (x % 3 == 0) return 1;
	else for (i = x; x > 0; x /= 10) {
		if (x % 10 == 3) return 1;
	}
	return 0;
}

void call(int n) {
	int i;
	for (i = 1; i <= n; i++) {
		if (should_pirnt(i)) printf(" %d", i);
	}
	putchar('\n');
}

int main(int argc, char **argv)
{
	int n;
	scanf("%d", &n);
	call(n);
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n= scan.nextInt();
      	int k = scan.nextInt();
      	int[] h = new int[n];
     	for(int i = 0; i < n; i++){
        	h[i] = scan.nextInt();
        }
      	Arrays.sort(h);
      	int ans = Integer.MAX_VALUE;
      	for(int j = 0; j < n - k + 1; j++){
        	ans = Math.min(ans, h[j + k - 1] - h[j]);
        }
      	System.out.print(ans);
    }
 
}

Measured memory_bytes: 52192
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);

const myMin = (a: number, b: number) => a < b ? a : b;

let args: number[] = input.map(mp => +mp);
let min = myMin(args[0], args[1]);
let ans: number[] = [];

for(let i=0; i <= min; i++ ) {
  if( args[0] % (i+1) === 0 && args[1] % (i+1) === 0 ) {
    ans.push(i+1);
  }
}

console.log( ans[ans.length - args[2]] );


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin >> n;
	long long sn = n*(n+1)/2;
	long long arr[n];
	long long sum = 0;
	for(long long i = 0; i < n; i++){
		cin >> arr[i];
		sum += arr[i];
	}
	if(sum % sn != 0){
		cout << "NO" <<endl;
		return 0;
	}
	long long ans = 1;
	long long cnt = sum/sn;
	long long awal = cnt;
	for(long long i = 0; i < n; i++){
		long long z = awal;
		while(arr[i]+z != arr[(i+1)%n]){
			cnt--;
			z-=n;
			if(arr[i]+z <  arr[(i+1)%n]){
				ans = 0;
				break;
			}
		}
		if(ans == 0)break;
	}
	if(cnt != 0 || ans == 0)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	
	
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int a[5];
int b;
int main()
{
	rep(i,5)cin>>a[i];
	cin>>b;
	sort(a,a+5);
	if(a[4]-a[0]<=b)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);

	FOR(i, 0, n) {
		cin >> a[i];
	}

	a.push_back(0);

	long long cnt = 0;
	long long temp = 0;

	FOR(i, 0, n + 1) {
		if (a[i] > 0)
			temp += a[i];
		else {
			cnt += temp / 2;
			temp = 0;
		}
	}
	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 1152
#ifndef COMPETITIVE_HEADER
    #pragma GCC optimize ("Ofast")
    #ifdef ONLINE_JUDGE
        #pragma GCC target ("avx512f")
    #else
        #pragma GCC target ("avx")
    #endif
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%d", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;
#endif

inline unsigned long long rdtsc()
{
#ifdef __amd64
  unsigned long long a, d;
  __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
  return (d << 32) | a;
#else
  unsigned long long x;
  __asm__ volatile ("rdtsc" : "=A" (x));
  return x;
#endif
}

inline double gettime(){return rdtsc()/2993344000.0;}
inline double elapsed(double st){return gettime()-st;}
uint32_t xor128() { 
    static uint64_t x = 88172645463325252ULL;
    x = x ^ (x << 13); x = x ^ (x >> 7);
    return x = x ^ (x << 17);
}

const int D = 365;
int c[26], s[365][26], t[365];
int lst[26];
int satisfy;

void input(){
    I(c[0]);
    REP(i,26) I(c[i]);
    REP(i,D) REP(j,26) I(s[i][j]);
}

void exec(){
    double st = gettime();



    while(elapsed(st) < 1.95){
        REP(_,50){
            double prob;
            bool do_exch = prob * UINT32_MAX > xor128();
            if(do_exch){

            }
        }
    }
    
}

void judge(){
    input();
    exec();


}

void test(){
    REP(i,26) c[i] = xor128() % 101;
    REP(i,D) REP(j,26) s[i][j] = xor128() % 20001;
    exec();


}

int score(){
    satisfy = 0;
    REP(i,26) lst[i] = 0;
    REP(i,D){
        lst[t[i]] = i+1;
        satisfy += s[i][t[i]];
        REP(j,26) satisfy -= c[j] * (i - lst[j] + 1);
        cout << satisfy << endl;
    }
    return satisfy;
}

int main(){
    // #ifdef ONLINE_JUDGE
    //     judge();
    // #else 
    //     test();
    // #endif
    input();
    REP(i,D) {I(t[i]); t[i]--;}
    score();
}

Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
	int n,m,l;
	long long cell1[101][101];
	long long cell2[101][101];
	long long ans[101][101];
	memset(ans,0,sizeof(ans));
	cin >> n >> m >> l;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> cell1[i][j];
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<l;j++){
			cin >> cell2[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			for(int k=0;k<m;k++){
				ans[i][j] += cell1[i][k] * cell2[k][j];
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			cout << ans[i][j];
			if(j != l-1) cout << " ";
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

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


typedef long long ll;

typedef pair<ll,ll> Point;
#define x first
#define y second

bool cmp(Point & A, Point & B)
{
    return A.x * B.y - A.y * B.x < 0;
}

void show(vector<Point> & p)
{
    /*
    for (Point & pt : p)
        printf("%lld %lld\n", pt.x, pt.y);
    printf("\n");
    */
}


int main()
{
    int n;
    scanf("%d", &n);
    vector<Point> x0, l, r;
    for (int i = 0; i < n; ++i)
    {
        static Point p;
        scanf("%lld%lld", &p.x, &p.y);
        if (p.x == 0)
            x0.push_back(p);
        else if (p.x > 0)
            r.push_back(p);
        else
            l.push_back(p);
    }


    show(l);
    show(r);
    show(x0);

    /*
    8
    3 2
    -1 2
    0 -1
    0 -2
    -2 0
    0 3
    2 -1
    3 -2
    */


    sort(all(x0));
    reverse(all(x0));
    sort(all(l), cmp);
    sort(all(r), cmp);

    show(l);
    show(r);
    show(x0);

    vector<Point> p;

    int pos = 0;
    while(pos < (int)x0.size() && x0[pos].y > 0)
    {
        p.push_back(x0[pos]);
        ++pos;
    }
    for (Point pt : r)
        p.push_back(pt);
    while(pos < (int)x0.size())
    {
        p.push_back(x0[pos]);
        ++pos;
    }
    for (Point pt : l)
        p.push_back(pt);


    show(p);

    ll ans = 0;
    for (int l = 0; l < n; ++l)
    {
        for (int r = 0; r < n; ++r)
        {
            static Point A;
            A = {0, 0};
            if (l <= r)
            {
                for (int i = l; i <= r; ++i)
                {
                    A.x += p[i].x;
                    A.y += p[i].y;
                }
            }
            else
            {
                for (int i = l; i < n; ++i)
                {
                    A.x += p[i].x;
                    A.y += p[i].y;
                }
                for (int i = 0; i <= r; ++i)
                {
                    A.x += p[i].x;
                    A.y += p[i].y;
                }
            }

            ans = max(ans, A.x * 1LL * A.x + A.y * 1LL * A.y);
        }
    }

    printf("%.15f", sqrt(ans));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
ll n,m;
vector<vector<ll>> dp(2020,vector<ll>(2020,0));
int main(){
    cin>>n>>m;
    vector<ll> s(n),t(m);
    rep(i,n)    cin>>s[i];
    rep(i,m)    cin>>t[i];
    rep(i,n){
        rep(j,m){
            if(s[i]==t[j]){
                dp[i+1][j+1]=(dp[i][j+1] + dp[i+1][j] + 1)%mod;
            }
            else{
                dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j];
                if(dp[i+1][j+1]<0)  dp[i+1][j+1]+=mod;
                else    dp[i+1][j+1]%=mod;
            }
        }
    }
    cout<<(dp[n][m]+1)%mod<<endl;
    return 0;
}


Measured memory_bytes: 32256
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val c1 = next().toList()
    val c2 = next().toList()
    val c3 = next().toList()
    println("${c1[0]}${c2[1]}${c3[2]}")
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33784
from collections import deque

n, q = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(n-1)]
px = [[int(i) for i in input().split()] for _ in range(q)]

tree = [[] for _ in range(n+1)]
for a, b in ab:
    tree[a].append(b)
    tree[b].append(a)

counter = [0] * (n+1)
for p, x in px:
    counter[p] += x

# pop, appendまたはQueueライブラリだと間に合わない
queue = deque([[0,1]])
while queue:
    parent, node = queue.popleft()
    for leaf in tree[node]:
        if leaf == parent:
            continue
        counter[leaf] += counter[node]
        queue.append([node, leaf])

print(*counter[1:])


Measured memory_bytes: 123180
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
long long n,i,array[10000],sum1=0,sum2=0,average,ch1=0,ch2=0;
scanf("%lld",&n);
for(i=0;i<n;++i){
    scanf("%lld",&array[i]);
}
for(i=0;i<n;++i){
     sum1+=array[i];
     sum2+=array[i]*array[i];
}
average=sum1/n;
for(i=0;i<n;++i){
    ch1+=(array[i]-average)*(array[i]-average);
    ch2+=(array[i]-average-1)*(array[i]-average-1);
}
printf("%lld",min(sum2,min(ch1,ch2)));


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void) {
	
	int a,b;
     scanf("%d%d",&a,&b);
     if(a%3==0 || b%3==0 ||(a+b)%3==0)
           printf("Possible");
  
     else
        printf("Impossible");
	          
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//素因数分解
map<int,int> prime_factor(int n){
    map<int,int> res; //res[2] = 4は、素因数2が4個あることを表す
    for(int i = 2;i*i <= n;i++){//小さい素因数から順に割っていく
        while(n % i == 0){//i = 2が素因数だとすると、割り切れる限り2で割る
            res[i]++;//割り切れる回数をres[i]に格納
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;//ループ処理の結果、nが素数の場合、res[n] = 1とする。
    return res;
}

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
 
  int count = 0;
 // cout << (int)S[2] - 48 << endl;
  for(int j = 0; j < 1000;j++){
      int a = j/100;
      int b = (j/10)%10;
      int c = j%10;
      bool flag0 = false;//Sにaがあるか
      bool flag1 = false;
      bool flag2 = false;
      int i = 0;
      while(i<N){
          if((int)S[i] - 48 == a){
            flag0 = true;
            i++;
            while(i<N){
                if((int)S[i] - 48  == b){
                    flag1 = true;
                    i++;
                    while(i<N){
                        if((int)S[i] - 48 == c){
                            flag2 = true;
                            i++;
                        }
                        i++;
                    }
                }
                i++;
            }
          }
          i++;
      }
      if(flag0 && flag1 && flag2) count++;
  }
  cout << count << endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
using namespace std;

int main() {
    int a,m,n;
    cin >> a >> m >> n;
    vector<int> d(m);
    int y = m;
    for (int i = 0; i < m; i++) {
        cin >> d.at(i);
        if (d.at(i) > n) {
            y = i;
            break;
        }
    }
    cout << min(y, m - y) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }
template<typename V> void printVec(V v) {ll i=0;for(auto x : v){std::cout << " [" << i++ << "] " << x;} print();}

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

  ll N;
  std::cin >> N;
  std::vector< ll > vh(N, 0LL);

  for (ll i = 0; i < N; i++) {
    std::cin >> vh[i];
  }

  ll ans = 0LL;
  ll max_val = vh[0];
  for (ll i = 0; i < N; i++) {
    ans = vh[i] >= max_val ? ans + 1 : ans;
    max_val = std::max(max_val, vh[i]);
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
void insertionSort(int A[], int N);

int main(){
    int height[10];
	for(int i=0;i<10;i++){
        cin >> height[i];
        }
	insertionSort(height, 10);
	for(int i=9;i>6;i--){
	cout << height[i] << endl;
}
	return 0;
}

void insertionSort(int A[], int N){
    int j, i, v;
    for(i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
    while(j >= 0 && A[j] > v){
        A[j+1] = A[j];
        j--;
    }
    A[j+1] = v;
    }
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S; cin >> S;
	int Q; cin >> Q;
	int inv = 0;
	string t;
	while (Q--) {
		int T;
		cin >> T;
		if (T == 1) inv = 1-inv;
		else {
			int F; char C; cin >> F >> C; --F;
			if (inv == F) t += C;
			else S += C;
		}
	}
	reverse(begin(t), end(t));
	S = t + S;
	if (inv) reverse(begin(S), end(S));
	cout << S << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 1196