akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <math.h>
#include <algorithm>
#include<queue>
#include<map>
// #include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)

typedef long long ll;

main(){
    int N;
    bool bol = true;
    ll now = 0;
    ll Ai, Bi;
    vector<ll> a;
    vector<pair<ll,ll>> b;

    cin >> N;
    FOR(i,0,N){
        cin >> Ai >> Bi;
        a.push_back(Ai);
        b.push_back(make_pair(Bi,i));
    }
    sort(b.begin(),b.end());

    FOR(j,0,N){ 
        now += a[b[j].second];
        if(now > b[j].first){
            bol = false;
            break;
        }
    }

    bol ? cout << "Yes" << endl : cout << "No"  << endl; 
}


Measured memory_bytes: 7524
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	arr := make([]int, n)
	sortedArr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
		sortedArr[i] = i + 1
	}

	diffCount := 0
	for i, e := range arr {
		if e != sortedArr[i] {
			diffCount++
		}
	}

	if diffCount > 2 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


Measured memory_bytes: 512
H,W=map(int,input().split())
g=''
g2=''
h_removed=0
w_removed=0
for i in range(H):
    ip=input()
    if ip=='.'*W:
        h_removed+=1
    else:
        g+=ip
        
for i in range(W):
    col=''
    for j in range(H-h_removed):
        col+=g[i+j*W]
    if col=='.'*(H-h_removed):
        w_removed+=1
    else:
        g2+=col
        
for i in range(H-h_removed):
    p=''
    for j in range(W-w_removed):
        p+=g2[i+j*(H-h_removed)]
    print(p)

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

int a,b,c;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>a>>b>>c;
    cout<<c<<' '<<a<<' '<<b<<endl;

    return 0;
}

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

using namespace std;

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

ll gcd(ll x, ll y) {
    return y ? gcd(y, x%y) : x ;
}

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i*i <= n; i++) {
        if (n%i) continue;
        res.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; ll k;
    cin >> n >> k;
    vl a(n);
    rep(i,n)cin >> a[i], a[i]--;
    ll logK = 1;
    while((1LL << logK) < k)logK++;
    vvl doubling(logK,vl(n));
    rep(i,n)doubling[0][i] = a[i];
    rep(i,logK-1)rep(j,n)doubling[i+1][j] = doubling[i][doubling[i][j]];

    int now = 0; //最初は0地点
    rep(i,logK){
        if((k >> i) & 1) now = doubling[i][now];
    }
    out(now + 1);
}


Measured memory_bytes: 100076
// Single_Sorce_Shotest_Path_1


#include <stdio.h>
#include <stdlib.h>


typedef struct{
	int distance;
	int vertex_n;
	int *box;
	int *omomi;
} DATA_T;


void Bfs(DATA_T *box, int n)
{
	int vertex, sub_vertex;
	int omomi;
	int ring_queue[10000];
	int front, rear;
	int i;

	box[0].distance = 0;
	front = rear = 0;
	ring_queue[rear++] = 0;
	while(front != rear){
		vertex = ring_queue[(front++) % 10000];

		for(i = 0; i < box[vertex].vertex_n; i++){
			sub_vertex = box[vertex].box[i];
			omomi = box[vertex].omomi[i];
			if(box[sub_vertex].distance == -1 ||  box[vertex].distance + omomi < box[sub_vertex].distance){
				box[sub_vertex].distance = box[vertex].distance + omomi;
				ring_queue[(rear++) % 10000] = sub_vertex;
			}
		}
	}
}


int main()
{
	DATA_T *box;
	int n, vertex, k;
	int sub_vertex, omomi;
	int i, j;

	scanf("%d", &n);

	box = (DATA_T *)malloc(sizeof(DATA_T) * n);

	for(i = 0; i < n; i++){
		scanf("%d %d", &vertex, &k);
		box[vertex].distance = -1;
		box[vertex].vertex_n = k;

		if(k){
			box[vertex].box = (int *)malloc(sizeof(int) * k);
			box[vertex].omomi = (int *)malloc(sizeof(int) * k);
			for(j = 0; j < k; j++){
				scanf("%d %d", &sub_vertex, &omomi);
				box[vertex].box[j] = sub_vertex;
				box[vertex].omomi[j] = omomi;
			}
		}
	}


	// 幅優先探索で最短経路を求める
	Bfs(box, n);


	// 表示
	for(i = 0; i < n; i++)
		printf("%d %d\n", i, box[i].distance);

	return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;

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

  // trueの時，文字列は順方向
  bool state = true;
  // a:先頭に付加する文字列，b:末尾に付加する文字列
  string a,b;

  rep(i,q){
    int t;
    cin >> t;
    if (t == 1) {
      state = !state;
      continue;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f==1) {
        // 先頭に文字を追加
        if (state) a.push_back(c);
        else b.push_back(c);
      } else {
        // 末尾に文字を追加
        if (state) b.push_back(c);
        else a.push_back(c);
      }
    }
  }

  reverse(a.begin(),a.end());
  string ans = a + s + b;
  if (!state) reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4256
import numpy as np

s=input()
isContinue=0
part=[0]

for i in range(len(s)):
    if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
        isContinue+=1
        if i==len(s)-1:
            part.append(isContinue)
    else:
        part.append(isContinue)
        isContinue=0

print(max(part))


Measured memory_bytes: 21412
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans1=[]
ans2=[]
ans1+=a
ans2+=a
for i in range(min(k,50)):
  now=0
  ans2=[]
  ans2+=ans1
  kans=[0]*n
  for j in range(n):
    if j+ans2[j]+1<=n-1:
      kans[j+ans2[j]+1]-=1
    now+=1+kans[j]
    #基本kans[j]は0だが終点は-1
    ans1[j]=now
  if ans1==list(range(1,n+1)):
    ans1=[n]*n
    break
  now=0
  kans=[0]*n
  for j in range(1,n+1):
    if n-j-ans2[n-j]>=0:
      kans[n-j-ans2[n-j]-1]-=1
    now+=1+kans[n-j]
    #基本kans[j]は0だが終点は-1
    ans1[n-j]+=now-1



print(*ans1) 


Measured memory_bytes: 209636
fun main(){
    val N = readLine()!!.toInt()

    var ans: Long = 0
    for(i in 1..N){
        if (i % 15 == 0) continue;
        if (i % 3 == 0 || i % 5 == 0) continue;

        ans += i
    }

    println(ans)
}

Measured memory_bytes: 34552
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define PI 3.14159265358979
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using P = pair<string , int>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll n;
    cin >> n;
    vl b(n-1);
    rep(i,n-1) cin >> b.at(i);

    vl ans_layer(n);
    rep(i,n) {
        if (i == 0) ans_layer.at(i) = b.at(0);
        else if (i == ans_layer.size()-1) ans_layer.at(i) = b.at(i-1);
        else ans_layer.at(i) = min(b.at(i-1), b.at(i));

    }

    ll ans = 0;
    rep(i, n) ans += ans_layer.at(i);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
#define se second
#define fi first
#define prout(x) cout.precision(x)
using namespace std;
ll a[100010];
int main(){
    ll n;
    cin>>n;
    ll  mn=1000000000000, sm=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sm+=a[i];
        mn=min(mn, a[i]);
    }
    ll x=(n*(n+1))/2;
    if(sm%x!=0){
        cout<<"NO"<<endl; return 0;
    }
    ll k=sm/x;
    ll t=a[1];
    for(int i=1;i<n;i++)a[i]=a[i+1]-a[i];
    a[n]=t-a[n];
    for(int i=1;i<=n;i++){
        a[i]-=k;
        if(a[i]>0 || a[i]%n!=0){
            cout<<"NO"<<endl; return 0;
        }
    }
    cout<<"YES"<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  string s;
  cin>>s;
  int cnt,mx=0;
  for(int i=0;i<3;i++)
  {
    cnt=0;
    if(s[i]=='R')
     {
       while(s[i]=='R')
       {
         cnt++;
         i++;
       }
     }
      mx=max(mx,cnt);
  }
  cout<<mx<<nl;
}

int main()
{
    su;
    ///tt
    f();
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#define OVERLOAD3(_1,_2,_3,name,...) name
#define REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main () {
  int n; cin >> n;
  cout << 1-n << endl;
}

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());

        int x[] = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = scan.nextInt();
        }

        int res = 0;
        while (true) {
            boolean flag = false;

            for (int y = 0; y < n; y++) {
                if (x[y] % 2 != 0)
                    flag = true;
            }
            if (flag)
                break;

            for (int i = 0; i < n; i++) {
                x[i] = x[i] / 2;
            }
            res++;

        }
        System.out.print(res);

    }
}


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

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

	double sum = 0;
	for (int i = 0; i < n; i++) {
		sum += (double)1 / a[i];
	}
	double ans = (double)1 / sum;


	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  for(ll i=1;i<=n;i++){
    if(i%5!=0&&i%3!=0){
      ans += i;
    }
  }
  cout << ans << endl;
}


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

int top = 0, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<P> ab;
    int n;cin>>n;
    ab.resize(n);
    rep(i,n){
        int a,b;cin>>a>>b;
        ab[i]=make_pair(b,a);
    }
    sort(all(ab));
    int now = 0;
    bool isok = true;
    for(auto a : ab){
        now += a.second;
        if(now > a.first){
            isok = false;
            break;
        }
    }
    if(isok){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 1792
using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
typedef pair<double,int> p;
int y;
double func(int r,int t){
	if(t==1){
		return (double)1+y*r/(double)100;
	}else{
		double x=1+r/(double)100,res=1;
		for(int i=0;i<y;i++){
			res*=x;
		}
		return (double)res;
	}
}
int main()
{
	int n;
	while(cin>>n&&n){
		cin>>y;
		p ans[50];//first:ganri second:num
		for(int i=0;i<n;i++){
			cin>>ans[i].second;
			int r,t;cin>>r>>t;
			ans[i].first=func(r,t);
			//printf("*%.6f\n",func(r,t));
		}
		sort(ans,ans+50,greater<p>());
		printf("%d\n",ans[0].second);
	}
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
const int N=3005;
int n,P,Ans;
int f0[N],f1[N],C[N][N],S[N][N];
int Mod(int x){return x>=P?x-P:x;}
int ksm(int x,int k){
	int res=1;
	while(k){
		if(k&1)res=1ll*res*x%P;
		x=1ll*x*x%P,k>>=1;
	}return res;
}
void Pre(int n){
	f0[0]=1;for(int i=1;i<=n;i++)f0[i]=2ll*f0[i-1]%P;
	f1[0]=1;for(int i=1;i<=n;i++)f1[i]=2ll*f1[i-1]%(P-1);
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)C[i][j]=Mod(C[i-1][j-1]+C[i-1][j]);
	}S[0][0]=1;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=i;j++)S[i][j]=Mod(S[i-1][j-1]+1ll*S[i-1][j]*j%P);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),P=read(),Pre(n+1);
	for(int i=0;i<=n;i++){
		int res=0;
		for(int j=0;j<=i;j++)res=Mod(res+1ll*S[i+1][j+1]*ksm(f0[n-i],j)%P);
		Ans=Mod(Ans+1ll*res*(i&1?P-1:1)%P*C[n][i]%P*ksm(2,f1[n-i])%P);
	}printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 58900
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    A solver = new A();
    solver.solve(1, in, out);
    out.close();
  }

  static class A {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
      String N = in.next();
      if (N.endsWith("2") || N.endsWith("4") || N.endsWith("5") || N.endsWith("7") || N.endsWith("9")) {
        out.print("hon");
      } else if (N.endsWith("0") || N.endsWith("1") || N.endsWith("6") || N.endsWith("8")) {
        out.print("pon");
      } else {
        out.print("bon");
      }
    }

  }
}



Measured memory_bytes: 35792
require 'prime'

q = gets.to_i
l, r = [], []
q.times do |i|
  l[i], r[i] = gets.split.map(&:to_i)
end

s = [0]
(1..r.max).each do |n|
  s << ((n.prime? && ((n + 1) / 2).prime?) ? s[-1] + 1 : s[-1])
end

q.times do |i|
  puts s[r[i]] - s[l[i] - 1]
end

Measured memory_bytes: 5532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n;cin>>n;
  int ans=1,cnt1=0;
  for(int i=1;i<=n;i++){
    int cnt=0,a=i;
    while(1){
      if(a%2==1)break;
      a/=2;
      cnt++;
    }
    if(cnt1<cnt){
      cnt1=cnt;
      ans=i;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    string s;cin>>s;
    int mae = stoi(s.substr(0, 2)), ato = stoi(s.substr(2, 2));
    if(mae>0&&mae<13&&ato>0&&ato<13)co("AMBIGUOUS");
    else if(mae>0&&mae<13)co("MMYY");
    else if(ato>0&&ato<13)co("YYMM");
    else co("NA");
    
}


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

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

    long long int money = 100;

    long long int ans = 0;

    while(true) {
        money += money / 100;
        ans++;
        if(X <= money){
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int n, a, b = 1, c = 1;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &a);
		b *= 3;
		if(a%2 == 0) c *= 2;
	}
	printf("%d\n", b-c);
}

Measured memory_bytes: 256
import math
ii = lambda: int(input())
mis = lambda: map(float,input().split())
lmis = lambda: list(mis())

n = lmis()
a = n[0]
b = n[1]
x = n[2]

m = 2*x/(a**2)-b

if m >= 0:
    print(90-math.degrees(math.atan2(a,b-m)))
else:
    c = a - 2*x/a/b
    print(90-math.degrees(math.atan2(a-c,b)))

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int a[10000],r,c,b,d=0,e,f=0;
    scanf("%d%d",&r,&c);
    for(b=0;b<r*c;b++){
        scanf("%d",&a[b]);
    }
    for(b=0;b<r*c;b++){
        printf("%d ",a[b]);
        d+=a[b];
        if((b+1)%c==0){
            printf("%d\n",d);
            f+=d;
            d=0;
        }
    }
    for(b=0;b<c;b++){
        for(e=b;e<r*c;e=e+=c){
            d+=a[e];
        }
        printf("%d ",d);
        d=0;
    }
    printf("%d\n",f);
    return 0;
}


Measured memory_bytes: 2112
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt(); 
		int[] nums = new int[count];
		for(int i=0;i<count;i++){
			nums[i] = sc.nextInt();
		}
		int swap = selectionSort(nums);
		printArray(nums);
		System.out.println(swap);
		
	}
	public static int  selectionSort(int[] nums){
		int swap = 0;
		for(int i=0;i<nums.length;i++){
			int min = i;
			for(int j=i+1;j<nums.length;j++){
				if(nums[j]<nums[min]) min=j;
			}
			if(min!=i){
				int tmp = nums[i];
				nums[i] = nums[min];
				nums[min] = tmp;
				swap++;
			}
		}		
		return swap; 
		
		
	}
	public static void printArray(int[] nums){
		for(int i=0;i<nums.length;i++){
			if(i!=0)System.out.print(" "+nums[i]);
			else System.out.print(nums[i]);
		}
		System.out.println();
	}

}

Measured memory_bytes: 26236
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

const ll MXN=100005;
vector<edge> G[MXN];
vector<bool> B(MXN,false);
vl ans(MXN);

void bfs(ll x,ll d){
  B[x]=true;
  ans[x]=d;
  ll k=G[x].size();
  rep(i,k){
    if(B[G[x][i].to]==false){
      bfs(G[x][i].to,G[x][i].cost+d);
    }
  }
}

  
int main() {
  ll N;
  cin >> N;
  rep(i,N-1){
    ll a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
  }
  ll Q,K;
  cin >> Q >> K;
  K--;
  bfs(K,0);
  rep(i,Q){
    ll x,y;
    cin >> x >> y;
    x--;y--;
    cout << ans[x]+ans[y] << endl;
  }
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int a;
    string s;
    cin>>a>>s;

    if (a >= 3200) cout<<s<<endl;
    else cout<<"red"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


SINT32 main() {
    SINT32 a,b,c;
    scanf("%d%d%d",&a,&b,&c);


    SINT32 ans = 0;

    ans = a - b - c;

    if (ans > 0 ) {
        ans = 0;
    } else {
        ans = ABS(ans);
    }


    printf("%d %d\n",MIN(b,c),ans);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n, m;
    cin >> n >> m;
    li q;
    cin >> q;
    vector<li> qs(q);
    for (int i = 0; i < q; ++i) {
        cin >> qs[i];
        qs[i]--;
    }

    reverse(qs.begin(), qs.end());
    bool ok = true;

    map<li, li> positions;
    map<li, li> length_count;
    length_count[0] = n;
    for (int i = 0; i < q; ++i) {
        bool first_time = positions.count(qs[i]) == 0;
        if (first_time) {
            const li next_index = positions.size();
            positions[qs[i]] = next_index;
        }

        const li next_index = positions[qs[i]];
        if (length_count[next_index] > 0) {
            length_count[next_index]--;
            length_count[next_index + 1]++;
        } else if (first_time) {
            ok = false;
            break;
        }
    }

    if (ok) {
        li shortest = m;
        for (int i = 0; i < m; ++i) {
            if (length_count[i] > 0) {
                shortest = min(shortest, (li)i);
            }
        }
        vector<li> order(positions.size());
        for (auto &position  : positions) {
            order[position.second] = position.first;
        }
        set<li> unseen;
        for (int i = 0; i < m; ++i) {
            unseen.insert(i);
        }
        for (int i = 0; i < positions.size(); ++i) {
            if (i < shortest) {
                unseen.erase(order[i]);
            } else {
                ok &= unseen.lower_bound(order[i]) == unseen.begin();
                unseen.erase(order[i]);
            }
        }
    }

    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 2
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

int n;
bool f(vector<int> v){
    int ret=0;
    rep(i,n)if(((n-1)&i)==i) ret+=v[i];
    return ret%2;
}

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

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

    rep(i,s.size()){
        if(s[i]=='1') s[i]='0';
        else if(s[i]=='2') s[i]='1';
        else if(s[i]=='3') s[i]='2';
    }
    int cnt[3]={};
    rep(i,s.size()){
        cnt[s[i]-'0']++;
    }
    int cntcnt=0;rep(i,3)if(cnt[i]>0) cntcnt++;
    if(cntcnt==1){
        cout<<0<<endl;
        return 0;
    }
    if(cnt[1]==0){
        vector<int> v(n);
        rep(i,n){
            if(s[i]=='0')   v[i]=0;
            else            v[i]=1;
        }
        if(f(v)) cout<<2<<endl;
        else     cout<<0<<endl;
        return 0;
    }

    vector<int> v(n);
    rep(i,n){
        if(s[i]=='1') v[i]=1;
        else          v[i]=0;
    }
    if(f(v))    cout<<1<<endl;
    else        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 9116
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を2と3以上の奇数で順次割っていくする（下から計算したら、素数判定は不要）
# 3. 2.の結果に含まれる数の種類の数＋１が答え

def main():
  a, b = map(int, input().split())
  while b != 0: a, b = b, a % b #最大公約数を求める
  print(num_facto(a) + 1)  
  
def num_facto(n):
  ans = 0
  max_n = int(n ** 0.5) + 1
  if n == 1: return ans
  two_and_odds = [2] + [x for x in range(3, max_n, 2) if x ** 2 <= n]
  for cursor in two_and_odds:
    if n == 1: break
    if n % cursor == 0: ans += 1
    while n % cursor == 0: n = n // cursor
  if n != 1: ans += 1
  return ans

if __name__ == "__main__":
  main()


Measured memory_bytes: 79472
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(n);
  rep(i, m) cin >> a[i];

  int low = 0;
  int up = 0;

  rep(i, m) {
    if (a[i] > x) {
      low++;
    } else {
      up++;
    }
  }

  cout << (low >= up ? up : low);
  return 0;
}


Measured memory_bytes: 3600
n, m = map(int, input().split())
ac_lst = []
for i in range(m):
    a, b = map(int, input().split())
    lst = list(map(int, input().split()))
    ac_lst.append((a, lst))
    
dp = [[10**10] * (2**n) for _ in range(m+1) ]
for i in range(m+1):
    dp[i][0] = 0

for i in range(1, m+1):
    a, c_lst = ac_lst[i-1]
    d = 0
    for k in c_lst:
        d = d | (2**(k-1))
    for j in range(2**n):
        k = j | d
        dp[i][j] = min(dp[i][j], dp[i-1][j])
        dp[i][k] = min(dp[i][k], dp[i-1][k], dp[i-1][j] + a)
        
print(dp[-1][-1]) if dp[-1][-1] != 10**10 else print(-1)

Measured memory_bytes: 78952
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
using namespace std;

#define INF 100

int main() {
    int N;
    cin >> N;
    vector<string>S(N);
    vector<vector<int>>count(N+1, vector<int>(26,0));
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    for (int i = 0; i < 26; i++) {
        count[N][i] = INF;
    }

    //文字の個数を数える
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < S[i].size(); j++) {
            count[i][S[i][j] - 'a']++;
        }
    }
    //全ての文書に存在していた文字の種類と個数を数える
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 26; j++) {
            count[N][j] = min(count[N][j], count[i][j]);
        }
    }

    string ans;

    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < count[N][i]; j++) {
            ans.push_back('a' + i);
        }
    }

    cout << ans;
    

    return 0;
}

Measured memory_bytes: 764
#!/usr/bin/env python3
# %%
from functools import reduce

# %%
stdin = open(0)

# %%
N, A, B = map(int, stdin.read().split())
MOD = 10 ** 9 + 7

# %%


def f(A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD


# %%
answer = pow(2, N, MOD) - f(A) - f(B) - 1
answer %= MOD
print(answer)

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

int main() {
    long long N;
    long long answer = 1;
    cin >> N;
    vector<long long> x(N);

    for(long long i = 0; i < N; i++) {
      cin >> x.at(i);
      if(x.at(i) == 0) {
        cout << 0 << endl;
        return 0;
      }
    }

    for(long long i = 0; i < N; i++) {
      if(x.at(i) > 1000000000000000000/answer) {
        answer = -1;
        break;
      }
      answer *= x.at(i);
    }

    cout << answer << endl;
}


Measured memory_bytes: 4048
/*
  AtCoder Regular Contest 097
  D - Equals
*/

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

class DisjointSet {
public:
  DisjointSet(int size): size(size) {
    id.resize(size, -1);
  }

  void unite(int x, int y) {
    x = getId(x);
    y = getId(y);

    if (x != y) {
      if (id[x] > id[y]) swap(x,y);
      id[x] += id[y];
      id[y] = x;
      --size;
    }
  }

  int getId(int x) {
    return id[x] < 0 ? x : id[x] = getId(id[x]);
  }

  void show() {
    printf("\n");
    for (int i = 0; i < id.size(); ++i) printf("%d ", id[i]);
    printf("\n");
  }

private:
  vector<int> id;
  int size;
};

int N, M;
int p[100000];

int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &p[i]);
    --p[i];
  }

  DisjointSet ds(N);
  int x, y;
  for (int i = 0; i < M; ++i) {
    scanf("%d%d", &x, &y);
    --x, --y;
    ds.unite(x,y);
    //ds.show();
  }

  int count = 0;
  for (int i = 0; i < N; ++i) if (ds.getId(i) == ds.getId(p[i])) ++count;

  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1024
# encoding:utf-8
def calc(n, m, b_n, b_m):
	return m * b_n + n * b_m - b_n * b_m * 2

def sub():
	n, m, k = list(map(int, input().split()))
	for i1 in range(n + 1):
		for i2 in range(m + 1):
			if calc(n, m, i1, i2) == k:
				return "Yes"
	return "No"

def main():
	print(sub())

if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
L,R = map(int,input().split())
if R-L >= 2019: print(0)
else:
    if L % 2019 > R % 2019: print(0)
    else:
        s,t = L % 2019, R % 2019 + 1
        ans = 2019
        for i in range(s,t):
            for j in range(i+1,t):
                temp = (i*j) % 2019
                if temp < ans:  ans = temp
        print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        String [] charac = {"P", "W", "G", "Y"};
        boolean [] state = new boolean[4];
        String h;
        for (int i = 0; i < n; i++) {
            h = tokenizer.nextToken();
            for (int j = 0; j < 4; j++) {
                if (h.equals(charac[j])) {
                    state[j] = true;
                    break;
                }
            }
        }
        System.out.println(state[3]? "Four": "Three");
    }
}


Measured memory_bytes: 21844
A, B, N = map(int, input().split())  # 入力

ans = None
a_max = None

for _x in range(1):
    x = min((B - 1), N) * (_x+1)
    if x > N:
        break
    # print(x)
    a = x/B-int(x / B)
    # print(int(a * A))
    sa = int(a*A)
    # s = int((A * x) / B) - A * int(x / B)
    if a_max == None:
        a_max = sa
    elif sa > a_max:
        a_max = sa

print(a_max)


Measured memory_bytes: 9192
#include <cstdio>
// using namespace std;

int main() {
    int a, b;
    char op;
    while (1) {
    	scanf("%d %c %d", &a, &op, &b);
    	if (op == '?')
    		break;
    	else if (op == '+') {
    		printf("%d\n", a + b);
    	}
    	else if (op == '-') {
    		printf("%d\n", a - b);
    	}
    	else if (op == '*') {
    		printf("%d\n", a * b);
    	}
    	else if (op == '/') {
    		int c = a / b;
    		printf("%d\n", c);
    	}
    }
    return 0;
}


Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;

void solve()
{
	int ans=0;
	string s;
	cin>>s;
	s+='B';
	int cur=0;
	for(auto i:s)
	{
		if(i!='R')
		{
			ans=max(ans,cur);
			cur=0;
		}
		else
		{
			cur++;
		}
	}
	cout<<ans<<endl;
	
}

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
	solve();
    return 0;
}


Measured memory_bytes: 3652
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> Int -> BC.ByteString -> Int
solve n k p = let
    initialScore =
         foldl' (\acc (a, b) -> if a == b then acc + 1 else acc) 0 (BC.zip p $ BC.tail p)
    in
        min (n - 1) (initialScore + k * 2)

main = do
    (n, k) <- readTuple2
    p <- BC.getLine
    print $ solve n k p


Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
typedef pair<int, int> PII;
typedef long long int ll;

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

  int ans = H / A;

  if((H % A) != 0) ans++;
  
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e6+5;
const int MOD=1e9+7;
typedef long long LL; 
typedef long double LD;

LL fac[MAX];
LL ifac[MAX];
LL val[MAX];

int add(int a, int b, int c) {
    int res = a + b;
    return (res >= c ? res - c : res);
}

int mod_neg(int a, int b, int c) {
    int res; if(abs(a-b) < c) res = a - b;
    else res = (a-b) % c;
    return (res < 0 ? res + c : res);
}

int mul(int a, int b, int c) {
    LL res = (LL)a * b;
    return (res >= c ? res % c : res);
}

template <typename T>T power(T e, T n, T m) {
    T x = 1, p = e;
    while(n) {
        if(n & 1) x = mul(x, p, m);
        p = mul(p, p, m);
        n >>= 1;
    }
    return x;
}

template<typename T> T extended_euclid(T a, T b, T &x, T &y) {
    T xx = 0, yy = 1; y = 0; x = 1;
    while(b) {
        T q = a / b, t = b;
        b = a % b; a = t;
        t = xx; xx = x - q * xx;
        x = t; t = yy;
        yy = y - q * yy; y = t;
    }
    return a;
}

template<typename T> T mod_inverse(T a, T n) {
    T x, y, z = 0; 
    T d = extended_euclid(a, n, x, y);
    return (d > 1 ? -1 : mod_neg(x, z, n));
}

LL ncr(int n,int r)
{
    if(n<0||r<0||r>n)
    {
        return 0ll;
    }
    return ((((fac[n]*ifac[r])%MOD)*ifac[n-r])%MOD);
}

int main()
{
    int n;
    scanf("%d",&n);
    fac[0]=1;
    ifac[0]=1;
    for(int i=1;i<=n;i++)
    {
        fac[i]=(fac[i-1]*i)%MOD;
        ifac[i]=mod_inverse(fac[i],1ll*MOD);
    }
    LL ans=0;
    for(int i=(n+1)/2;i<n;i++)
    {
        LL cur=(ncr(i-1,n-i-1)*fac[i])%MOD;
        cur*=fac[n-i-1];
        cur%=MOD;
        val[i]=cur;
        cur-=val[i-1];
        cur+=MOD;
        cur%=MOD;
        cur*=i;
        cur%=MOD;
       // printf("%lld\n",cur);
        ans+=cur;
        ans%=MOD;
    }
    printf("%lld\n",ans);
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> t(n);
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    ll ans = t[0];
    for(int i = 1; i < n; i++){
        ans = ans / __gcd(ans, t[i]) * t[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static boolean isPrimenum(int i) {
		int max = (int) Math.sqrt(new Double(i));
		for (int j=max;j >1 ;j--){
			if(i%j==0) {
				return false;
			}
		}
		return true;
	}

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

		int nx = stdIn.nextInt();
        int [] x = new int[nx];

        for(int i = 0; i < nx; i++){
        	x[i] = stdIn.nextInt();
        }
        stdIn.close();
		int ans=0;
		for (int i = 0; i < nx; i++) {
			if ((0==x[i]%2) && (2 !=x[i])) {
			} else if ((0==x[i]%3) && (3 !=x[i])) {
			} else if (isPrimenum(x[i])){
				ans +=1;
			};
		}

    	System.out.println(ans);
	}
}



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

int main()
{
    int n, h[101];
    int ans;
    while(cin>>n, n) {
        for(int i=0; i<=n; i++) cin>>h[i];
        for(int i=0; i<=n; i++) {
            int dif;
            bool ok = true;
            if(i==0 || i==1) dif = h[n] - h[n-1];
            else dif = h[1] - h[0];
            for(int j=0; j<n; j++) {
                int dif2;
                if(j==i) continue;
                if(j+1==i && j+1==n) continue;
                if(j+1==i) dif2 = h[j+2] - h[j];
                else dif2 = h[j+1] - h[j];
                if(dif2 == dif) continue;
                ok = false;
                break;
            }
            if(ok) {
                ans = h[i];
                break;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		
		int max = Math.max(b-a, c-a);
		max = Math.max(max, d-a);
		max = Math.max(max, e-a);
		max = Math.max(max, c-b);
		max = Math.max(max, d-b);
		max = Math.max(max, e-b);
		max = Math.max(max, d-c);
		max = Math.max(max, e-c);
		max = Math.max(max, e-d);
		
		if (max<=k)
			System.out.println("Yay!");
		else
			
			System.out.println(":(");
	}

}

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

int main(){long N;
           cin >> N;
vector<string> w(N + 1);

string ans = "Yes";
erep(i, N) cin >> w.at(i);
erep(i, N - 1){
    for(long j = i + 1; j <= N; j++){
        if(w.at(i) == w.at(j)){
            ans = "No";
        }
    }
}
erep(i, N - 1){
  int s = w.at(i).size() - 1;
    if(w.at(i).at(s) != w.at(i + 1).at(0)){
        ans = "No";
    }
}
//int t = w.at(2).length();
//cout << w.at(2).size() << endl;
cout << ans << endl;
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,m;
signed main(){
    cin>>n>>m;
    if(n==m)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct node{
	int x,id;
}a[N];

int main()
{
	ios::sync_with_stdio(false);
	int n;cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i].x,a[i].id=i;
	sort(a+1,a+1+n,[](node aa,node bb){return aa.x<bb.x;});
	for(int i=1;i<=n;i++){
		cout<<a[i].id<<(i==n?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++)
      a[i] = sc.nextInt();
    sc.close();

    boolean[] dp = new boolean[K + 1];
    for (int i = 0; i < K + 1; i++)
      for (int j = 0; j < N; j++)
        if (0 <= i - a[j] && !dp[i - a[j]]) dp[i] = true;

    String ans = dp[K] ? "First" : "Second";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include <cstdio>
#include <cmath>

using namespace std;

double sum = 0, average = 0;

int main()
{
    int price, num, cnt = 0;
    while( scanf( "%d,%d\n", &price, &num ) != EOF )
    {
        cnt++;
        sum += price * num;
        average += num;
    }

    average = round( average / cnt );
    printf( "%.0lf\n%.0lf\n", sum, average );
}


Measured memory_bytes: 2620
#include<iostream>
using namespace std;
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int findGCD(int arr[], int n) 
{ 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
    { 
        result = gcd(arr[i], result); 
  
        if(result == 1) 
        { 
           return 1; 
        } 
    } 
    return result; 
} 
int main()
{
  int n,i,j,k;
  long int sum=0;
  cin>>n;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=n;j++)
    {
      for(k=1;k<=n;k++)
      {
        int arr[3];
        arr[0]=i;
        arr[1]=j;
        arr[2]=k;
        int t=findGCD(arr, 3);
        sum+=t;
      }
    }
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3624
using System;

namespace ABC167
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();
            var r = Console.ReadLine().ToCharArray();

            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] == r[i]) continue;
                Console.WriteLine("No");
                return;
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 25836
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 2e3 + 5;
ll i,j,n,ans,lo,hg,p,mid;
ll a[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,1,n + 1) cin>>a[i];
    sort(a + 1,a + n + 1);
    rep(i,1,n + 1) rep(j,i + 1,n + 1){
        lo = j + 1; hg = n;
        p = -1;
        while(lo <= hg){
            mid = (lo + hg) / 2;
            if(a[mid] < a[i] + a[j]){
                p = mid;
                lo = mid + 1;
            }
            else
                hg = mid - 1;
        }
        if(p != -1)
            ans += p - j;
    }
    cout<<ans;
    return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int calc(ll x){
  ll tmp = x;
  int res = 0;
  while(tmp){
    res += tmp % 10;
    tmp /= 10;
  }
  return res;
}

int main(int argc, char const* argv[])
{
  ll n;
  cin >> n;
  int res = calc(n);
  for(ll curr = 1; curr <= n; curr *= 10){
    res = max(res, calc((n / curr - 1) * curr + curr - 1));
  }

  cout << res << endl;
	return 0;
}


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

int main(){
    int k;
    cin >> k;
    int a,b;
    cin >> a >> b;
    if(a/k != b/k || a%k == 0 || b%k == 0) cout << "OK" << endl;
    else cout << "NG" << endl;
}

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

string a, b;
int k, n;

int ans = 0;

void dfs(string val, int pos, int cnt, int bor){
    if(pos == n){
        ans = max(ans, stoi(val));
        return;
    }

    if(cnt == k || a[n-1-pos]-bor >= b[n-1-pos]){
        string tmp{(char)('0'+a[n-1-pos]-bor-b[n-1-pos])};
        dfs(tmp+val, pos+1, cnt, 0);
    }else{
        string tmp{(char)('0'+a[n-1-pos]-bor+10-b[n-1-pos])};
        dfs(tmp+val, pos+1, cnt, 1);
        dfs(tmp+val, pos+1, cnt+1, 0);
    }
}


int main(){
    cin >> a >> b >> k;
    n = a.size();
    while(b.length() != n)  b = "0" + b;
    dfs("", 0, 0, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3208