akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   string s,t;
   cin>>s>>t;
   bool flag1=false;
   bool flag2=true;
   for(int i=0;i<s.size();i++){
      for(int j=0;j<t.size();j++){
         if(s[i]<t[j])flag1=true;
      }
   }
   for(int i=0;i<s.size()-1;i++){
      if(s[i]!=s[i+1])flag2=false;
   }
   for(int i=0;i<t.size()-1;i++){
      if(t[i]!=t[i+1])flag2=false;
   }
   if(flag1){
      cout<<"Yes"<<endl;
      return 0;
   }
   if(flag2 && s.size()<t.size()){
      cout<<"Yes"<<endl;
      return 0;
   }
   cout<<"No"<<endl;

}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






long long int gcd(long long int a,long long int b)
{
 
  long long int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,ans=0,count=0,c[5];
  cin>>n;
  rep(i,5) c[i]=0;
  rep(i,n){
    string s;
    cin>>s;
    if(s[0]=='M'){
      c[0]++;
    }else if(s[0]=='A'){
      c[1]++;
    }else if(s[0]=='R'){
      c[2]++;
    }else if(s[0]=='C'){
      c[3]++;
    }else if(s[0]=='H'){
      c[4]++;
    }
  }
  rep(i,5) if(c[i]>0) count++;
  if(count<=2){
    cout<<0<<endl;
    return 0;
  }
  for(int p=0;p<3;p++){
    for(int q=p+1;q<4;q++){
      for(int r=q+1;r<5;r++){
        ans+=c[p]*c[q]*c[r];
      }
    }
  }
  cout<<ans<<endl;
}
///////////////////////////



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <complex>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <fstream>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

void myprint(vector<int> a){
  REP(i,a.size()){
      cout << a[i];
      if(i != a.size()-1) cout << " ";
  }

    cout << endl;
    
}

int main (){
  int N;
  while (cin >> N){
    vector<int> a;
    REP(i,N){
      int ia;
      cin >> ia;
      a.push_back(ia);
    }
    myprint(a);
    
    FOR(i,1,N){
      int v = a[i];
      int j = i-1;
      for(; j>=0 && v < a[j]; j--){
	a[j+1] = a[j];
      }
      a[j+1] = v;
      myprint(a);
    }
    
    a.clear();
  }
  return 0;
}



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

int main(){
    int a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    int x=v-w;
    if(abs(a-b)<=(ll)x*t)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<climits>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
ll n,m;
pair<ll,ll> p[100010];
int main(){
  scan(n);scan(m);
  rep(i,n){
    scan(p[i].first);scan(p[i].second);
  }
  sort(p,p+n);
  ll ans=0;
  rep(i,n){
    ll a=p[i].first;
    ll b=p[i].second;
    if(m<=b){
      ans+=a*m;
      break;
    }
    else{
      ans+=a*b;
      m-=b;
    }
  }
  prin(ans);
  
  
  

  

  return 0;
}


Measured memory_bytes: 1792
import java.util.*;

//sort
public class Main {
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		String[] input = sc.nextLine().split(" ");
		int [] abc = new int[input.length];
		for(int i = 0;i<abc.length;i++)
		{
			abc[i] = Integer.parseInt(input[i]);
		}
		for(int i=0;i<abc.length - 1;i++)
		{
			for(int t = i +1;t<abc.length;t++)
			{
				int temp = 0;
				if(abc[i] > abc[t])
				{
					temp = abc[i];
					abc[i] = abc[t];
					abc[t] = temp;
				}
			}
		}
		System.out.println(abc[0] + " " + abc[1] + " " + abc[2]);
		sc.close();
	}
}


Measured memory_bytes: 26180
#include <iostream>
#include <cstdio>
#include <string.h>
#include <queue>
#define L 40050
#define ll long long
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int n,h=1;
    ll a[100005];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    int m=0;
    for(int i=0;i<n;i+=h)
    {
        h=1;
        while(a[i]==a[i+h])
            h++;
        if(h%2==1)
            m++;
    }
    printf("%d\n",m);
    return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	int p=0,w=0,g=0,y=0;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s=="P")p=1;
		if(s=="W")w=1;
		if(s=="G")g=1;
		if(s=="Y")y=1;
	}
	int sum=p+w+g+y;
	if(sum==3)
		cout<<"Three";
	else
		cout<<"Four";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;
typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;

int ar[MV];
ll arr[MV];
ll G[301][301], GX[301][301];

void solve(int T)
{
	int n,m,l;
	cin>>n>>m>>l;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i != j)
			{
				G[i][j] = INF;
				G[j][i] = INF;
				GX[i][j] = INF;
				GX[j][i] = INF;
			}	
		}	
	}
	for(int i=0;i<m;i++)
	{
		int s,d;
		ll w;
		cin>>s>>d>>w;
		G[s][d] = w;
		G[d][s] = w;
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(G[i][k] != INF || G[k][j] != INF)
				G[i][j] = min(G[i][j], G[i][k] + G[k][j]);	
			}
		}	
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i != j)
			{
				if(G[i][j] <= l)
				GX[i][j] = 1;
			}	
		}	
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(GX[i][k] != INF || GX[k][j] != INF)
				GX[i][j] = min(GX[i][j], GX[i][k] + GX[k][j]);	
			}	
		}	
	}
	int q;
	cin>>q;
	while(q--)
	{
		int st,dt;
		cin>>st>>dt;
		if(GX[st][dt] == INF)
		cout<<"-1\n";	
		else cout<<GX[st][dt]-1<<"\n";
	}	
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

/*#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif*/

	while(T--)
	solve(T);

/*#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif*/

	return 0;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL MOD = (LL)1e9 + 7;
LL mul(LL a, LL b) {
    return (a * b) % MOD;
}

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    if (abs(N - M) > 1) return !printf("0\n");
    if (M > N) swap(N, M);
    LL ans = 1;
    for (int i = 1; i <= N; i++)
        ans = mul(ans, i);
    for (int i = 1; i <= M; i++)
        ans = mul(ans, i);
    if (N == M) ans = mul(ans, 2);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for upper_bit_bound in range(41,-2,-1):
    if (upper_bit_bound != -1 and not (K & 1 << upper_bit_bound)):
        continue
    fx = 0
    for bit_index in range(41,-1,-1):
        mask = 1 << bit_index
        hit_num = 0
        for a in A:
            if(a & mask):
                hit_num += 1
        nohit_num = N - hit_num
        if (bit_index > upper_bit_bound):
            if(K & mask):
                fx += mask * nohit_num
            else:
                fx += mask * hit_num
        elif(bit_index == upper_bit_bound):
            fx += mask * hit_num
        else:
            fx += mask * max(hit_num, nohit_num)
    ans = max(ans, fx)
print(ans)

Measured memory_bytes: 64748
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int count = 0;
  int a_index = 725098740;
  int z_index = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      a_index = (a_index > i) ? i : a_index;
    }
    if (s[i] == 'Z') {
      z_index = (z_index < i) ? i : z_index;
    }
  }
  cout << z_index - a_index + 1 << endl;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll to, cost;
	bool operator<(const edge& right) const {
		return cost == right.cost ? to < right.to : cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

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



int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << s1[0] << s2[1] << s3[2] << endl;
	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=5e4+10,MAXM=1e6+10;
const int INF=~(1<<31),MOD=1e9+7;

char s[MAXN];

int main()
{
    scanf("%s",s+1);
    for(int i=1;i<=strlen(s+1);i++)
    {
        if(i%2==1&&s[i]=='L')
        {
            puts("No");
            return 0;
        }
        if(i%2==0&&s[i]=='R')
        {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
	return 0;
}



Measured memory_bytes: 256
def main():
  n = list(map(int,input().split()))
  x_ans=[0,n[0]]
  y_ans=[0,n[1]] 
  x = [0] * n[2]
  y = [0] * n[2]
  t = [0] * n[2]
  for i in range(n[2]):
    x[i], y[i],t[i] = map(int, input().split())
  for i in range(0,n[2]):
    if t[i]==1 and x_ans[0]<x[i]:
      x_ans[0]=x[i]
    elif t[i]==2 and x[i]<x_ans[1]:
      x_ans[1]=x[i]
    elif t[i]==3 and y_ans[0]<y[i]:
      y_ans[0]=y[i]
    elif t[i]==4 and y[i]<y_ans[1]:
      y_ans[1]=y[i]
  if x_ans[0]>x_ans[1] or y_ans[0]>y_ans[1]:
    print(0)
  else:
    print((x_ans[1]-x_ans[0])*(y_ans[1]-y_ans[0]))
     
main()

Measured memory_bytes: 3192
#include <iostream>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define li long long int //defineしたなら使おう．li* でlong long int*にもなるよ

//C[]に入れてからcountに足さなくても，
//countに直接足せばいいと思う(たぶん)
//void city(li* A,li* B,int i,int j) で宣言して，(li *Cをなくすってこと)
//以下のコメントぽく書き換えるとよさげ
//もちろんli count はグローバル宣言しないといけない
void city(long long int* C,long long int* A,long long int* B,int i,int j){
  if(A[i]>=B[j]){
    C[i]+=B[j]; //count += B[j];
    A[i]-=B[j];
    B[j]=0;
  }else{
    C[i]+=A[i]; //count += A[i];
    B[j]-=A[i];
    A[i] = 0; //
  }
 
 
}
 
int main (){
  int N;
  cin >>N;
  long long int A[N+1],B[N],C[N+1]={0};
  for(int i=0;i<N+1;i++)// rep使える
    cin >>A[i];
  rep(i,N)
    cin >>B[i];
  for(int i=N;i>0;i--){
    city(C,A,B,i,i-1);
    city(C,A,B,i-1,i-1);
  }

  long long int count=0;
  for(int i=0;i<N+1;i++){ // rep使える
    count+=C[i];
  
  }
 
  cout << count << endl;
 
 
 
 
 
 
  return 0;
}


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

using namespace std;

bool c(int x,int n,int k,vector<int> &w){
    int t;
    for(int i = 0 ; i < n ; i++,k--){
        t = 0;
        if(w[i] > x) return false;
        while(i < n && t + w[i] <= x){
            t += w[i++];
        }
        i--;
    }
    return (k >= 0);
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> w(n);
    for(int i = 0 ; i < n ; i++){
        cin >> w[i];
    }
    int l = 0, r = 1e9;
    while(r-l > 0){
        int mid = (l + r) / 2;
        if(c(mid,n,k,w)){
            r = mid;
        }else{
            l = mid + 1;
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1532
# D - Maze Master
# https://atcoder.jp/contests/abc151/tasks/abc151_d
from collections import deque


def main():
    height, width = [int(num) for num in input().split()]
    maze = [input() for _ in range(height)]

    ans = 0
    next_to = ((0, 1), (1, 0), (0, -1), (-1, 0))

    for start_x in range(height):
        for start_y in range(width):
            if maze[start_x][start_y] == '#':
                continue
            queue = deque()
            queue.append((start_x, start_y))
            reached = [[-1] * width for _ in range(height)]
            reached[start_x][start_y] = 0

            while queue:
                now_x, now_y = queue.popleft()
                for move_x, move_y in next_to:
                    adj_x, adj_y = now_x + move_x, now_y + move_y
                    # Python は index = -1 が通ってしまうことに注意。
                    # except IndexError では回避できない。
                    if (not 0 <= adj_x < height
                            or not 0 <= adj_y < width
                            or maze[adj_x][adj_y] == '#'
                            or reached[adj_x][adj_y] != -1):
                        continue
                    queue.append((adj_x, adj_y))
                    reached[adj_x][adj_y] = reached[now_x][now_y] + 1
            most_distant = max(max(row) for row in reached)
            ans = max(most_distant, ans)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9464
n = int(input())

sp = []
for i in range(1,n+1):
    s,p = input().split()
    sp.append([s,int(p),i])

sp.sort(reverse = True,key = lambda x:x[1])
sp.sort(key = lambda x:x[0])

for i in range(n):
    print(sp[i][2])

Measured memory_bytes: 9012
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
	
int main(){
	int n;
	cin >> n;
	auto d = set<int>();
	for(int i =0;i<n;i++){
		int t;
		cin >>t;
		d.insert(t);
	}

	cout << d.size();
}


Measured memory_bytes: 256
use proconio::input;
fn main() {
    input!(n: i32, p: [i32; n]);
    let mut min = i32::max_value();
    let mut count = 0;
    for item in p.iter() {
        if *item <= min {
            count += 1;
            min = *item;
        } 
    }
    println!("{}", count);
}

Measured memory_bytes: 3908
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cmath>
#include<iomanip>

using namespace std;
typedef long long ll;
const double PI = 3.14159265358979323846;

int main() {
    long double a, b, x;
    cin >> a >> b >> x;

    long double y = 2.0 * x / (a * a) - b;
    long double z = a * y / (b - y);
    long double theta = atan(y / z) / PI * 180;

    if (z == 0) {
        cout << std::setprecision(12) << 45.0 << endl;
    } else if (y < 0) {
        y = 2.0 * x / (a * b);
        theta = atan(b / y) / PI * 180;
        cout << std::setprecision(12) << theta << endl;
    } else {
        cout << std::setprecision(12) << theta << endl;
    }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import math
time = int(raw_input())

def check (a,b):
    num = a*b 
    count = 0
    r = math.sqrt(num)
    r = int(r)
    if num == r**2:
        count = r
    else:
        count = r+1
    if a == b:
        return count*2-2
    elif a*b == count**2:
        return count*2-3
    elif a*b > count*(count-1):
        return count*2-3
    else:
        return count*2-4
for i in range (time):
    a,b = list(map(int,raw_input().split()))
    print check(a,b)
    


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


int main()
{
    long long x,y,i,t,s,j;
    char a[4][4];
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    cout<<a[0][0]<<a[1][1]<<a[2][2];
    return 0;
}


Measured memory_bytes: 3524
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<vector>
#include<numeric>
#include<random>
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

bool isprime(int x) {
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;
	int i = 3;
	while (i <= sqrt(x)) {
		if (x%i == 0)return false;
		i = i + 2;
	}
	return true;
}
int main(){
	int n;
	int a;
	int cnt=0;
	int sq;
	cin >> n;
	rep(i, n) {
		cin >> a;
		if (isprime(a)) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3076
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            Console.WriteLine(r * 2 * Math.PI);
        }
    }
}

Measured memory_bytes: 27604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0075
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "";
            List<Student> studentList = new List<Student>();
            int i = 0;
            while (!((str = Console.ReadLine()) == null))
            {
                studentList.Add(new Student());
                string[] str1 =  str.Split(',');
                studentList[i].studentnumber =int.Parse( str1[0]);
                studentList[i].weight = double.Parse(str1[1]);
                studentList[i].height = double.Parse(str1[2]);
                ++i;
            }
            foreach(var item in studentList)
            {
                if (item.weight / (item.height * item.height) >= 25)
                {
                    Console.WriteLine(item.studentnumber);
                }
            }
        }
    }
    class Student
    {
        public int studentnumber;
        public double weight;
        public double height;
        public Student()
        {
            studentnumber = 0;
            weight = 0;
            height = 0;
        }
    }
}



Measured memory_bytes: 15816
#include <stdio.h>

int main(){
  int n,A[100],i,j,temp,c=0;

  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }

  for(i=0 ; i<n ; i++){
    for(j=n-1; j>i ;j--){
      if(A[j] < A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	c++;
      }
    }
  }

  for(i=0 ; i<n ; i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }

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

Measured memory_bytes: 604
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    ll m=min(k,a),s=0;
    s+=m;
    k-=m;
     m=min(k,b);
    k-=m;
     m=min(k,c);
    s-=m;
    k-=m;
    cout<<s;
}


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

int main() {
    int K, A, B, i;
    cin >> K;
    cin >> A >> B;
    for (i=A; i<=B; ++i) {
        if (i % K == 0) {
            cout << "OK" << endl;
            break;
        }
    }
    if (i == B+1 && B % K != 0) {
        cout << "NG" << endl;
    }
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

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


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int f[1005];

int main () {
	
	int n,k; scanf ("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf ("%d",&f[i]);
	sort (f+1,f+n+1);
	int ans=0;
	for (int i=1;i<=k;i++) {
		ans+=f[i];
	}
	printf ("%d\n",ans);

	return 0;
}



Measured memory_bytes: 1696
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
long long Pow(long long base,long long x){
    if (x == 0) return 1;
    if (x%2 == 1) return (base*Pow(base,x-1))%MOD;
    long long y = Pow(base, x/2);
    return y*y%MOD;
}

int main(){
    long long n,q; cin >> n;
    vector<long long> a(0);
    for(int i = 0; i < n; i++){
        long long num;
        cin >> num;
        a.push_back(num);
    }
    cin >> q;
    for(int i = 0; i < q; i++){
        long long k; cin >> k;
        cout << lower_bound(a.begin(), a.end(), k) - a.begin() << endl;
    }
}
  




Measured memory_bytes: 3920
#include <iostream>
using namespace std;
int main(){
  int n;
  std::cin >> n;
  int t = n%10;
  switch(t){
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl; break;
    case 3:
      cout << "bon" << endl; break;
    default:
      cout << "hon" << endl; break;
  }
}

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

int main() {
	int n,i,k=0,p,s;
	cin>>n;
	for(i=1;i<=n;i++)
	{
	 s=0;
	 p=i;
	 while(p)
	 {
	     p=p/10;
	     s++;
	 }
	 if(s%2!=0)
	 k++;
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Maybe as Maybe

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

remain a b
	| a == 1 && b == 2 = 3
	| a == 1 && b == 3 = 2
	| a == 2 && b == 1 = 3
	| a == 2 && b == 3 = 1
	| a == 3 && b == 1 = 2
	| a == 3 && b == 2 = 1

main :: IO ()
main = do
	a <- readLn
	b <- readLn
	print $ remain a b


Measured memory_bytes: 508
while True:
    try:
        m = str(input());
        if m == "EOF":
            break;
    except EOFError:
        break;
    j = "JOI";
    i = "IOI";
    J = 0;
    I = 0;
    l = "";

    for a in range(0,len(m)-2):
        l = m[a:a+3]

        if l == j:
            J += 1;
        if l == i:
            I += 1;

    print(J);
    print(I);


Measured memory_bytes: 5572
#include <iostream>

using namespace std;

int gcd(int a, int b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}


int main() {
  int p, q;
  cin >> p >> q;

  while (true) {
    int g = gcd(p, q);
    if (g == 1) {
      break;
    }
    p /= g;
    q /= g;
  }


  int t = q;
  int ans = 1;
  for (int i = 2; i * i <= q; i++) {
    if (t % i == 0) {
      ans *= i;
      while (t % i == 0) {
        t /= i;
      }
    }
  }
  ans *= t;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3068
from functools import reduce
import math
K = int(input())


def gcd(*num):
    return reduce(math.gcd, num)


ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd(i, j, k)

print(ans)


Measured memory_bytes: 74836
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;
typedef long long int ll;


int main() {
    ll ans;
    ll N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // 全ての帽子の排他的論理和が0、3種類の数が1/3ずつか、2種類以下か
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> cnt;
  rep(i, N) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  if (cnt[0] == N) {
    puts("Yes");
    return 0;
  }
  if (N % 3 != 0) {
    puts("No");
    return 0;
  }
  vector<int> all;
  for (auto& p : cnt) {
    for (int i = 0; i < p.second / (N/3); i++) {
      all.push_back(p.first);
    }
  }
  //show(all);
  if (all.size() == 3 && (all[0] ^ all[1] ^ all[2]) == 0) puts("Yes");
  else puts("No");
  return 0;
}


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

using namespace std;

int sgn(int x) {
    if (x > 0) {
        return 1;
    }

    if (x < 0) {
        return -1;
    }

    return 0;
}

int x, y, ans;

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

    cin >> x >> y;

    ans = abs(abs(x) - abs(y));

    if ((sgn(x) * sgn(y)) == 1) {
        if (x > y) {
            ans += 2;
        }
    }

    if ((sgn(x) * sgn(y)) == 0) {
        if (x > y) {
            ans += 1;
        }
    }

    if ((sgn(x) * sgn(y)) == -1) {
        ans += 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let ans = n * (n - 1) / 2 + m * (m - 1) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
n = gets.to_i
a = Array.new
max_candies = 0

2.times{a.push(gets.split.map(&:to_i))}

for i in 0..n
    col = 0
    row = 0
    temp_candies = 0
    
    for col in 0..n
        temp_candies += a[row][col].to_i
        #print "(#{row},#{col}):#{a[row][col].to_i} "
        if i == col
            i -= 1
            row = 1
            redo
        end
        if max_candies < temp_candies
            max_candies = temp_candies
        end
    end
end

puts max_candies

Measured memory_bytes: 3836
#include<stdio.h>

int main(){
    long long int A,B,C,K;
    scanf("%lld",&A);
    scanf("%lld",&B);
    scanf("%lld",&C);
    scanf("%lld",&K);

    if(K%2==0){
        printf("%lld",A-B);
    }

    if(K%2 == 1){
        printf("%lld",B-A);
    }

return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;


int main()
{    
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i,j,k,n,m;
     ll t;
     cin>>i>>j>>n>>k;
     ll sum=0;
     if(k<=i)
     {
         cout<<k;
         return 0;
     }
     if(k<=i+j)
     {
         cout<<i;
         return 0;
     }
     cout<<i-min(n,(k-(i+j)));
}

Measured memory_bytes: 3652
/**
 * author:    Ziel
 * created:   12.04.2020 18:07:18
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin, x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int k;
	cin >> k;
	
	ll ans = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int n = 1; n <= k; n++) {
				ans += __gcd(__gcd(i, j), n);
			}
		}
	}

	cout << ans;
	return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define ll long long
const int MOD = 1e9+7;
int main(){
    int n; cin >> n;
    vector<vector<int> > c(10,vector<int>(10,0));
    for(int i=1;i<=n;++i){
        string s = to_string(i);
        c[s[0]-'0'][s[s.size()-1]-'0']++;
    }
    ll ans=0;
    rep(i,10){
        rep(j,10){
            ans += c[i][j]*c[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

string S;
int K;

int main()
{
    cin >> K >> S;

    int N = S.size();

    for(int i = 0; i < min(K, N); ++i)
        cout << S[i];

    if(N > K)
        cout << "...";

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define S second 
#define F first 
using namespace std;

int n ; 
vector < int > a , b , c ;
int dp[100001][4] ; // 1 -> a , 2 -> b , 3 -> c , 0 -> none 

int cal ( int idx , int prv ){
    
    if ( idx == n ){
        return 0 ; 
    }
    else if ( dp[idx][prv] ){
        return dp[idx][prv] ; 
    }
    else {
        
        if ( prv == 1 ){
            return dp[idx][prv] = max ( cal ( idx + 1 , 2 ) + b[idx+1] , cal ( idx + 1 , 3 ) + c[idx+1] ) ; 
        }
        else if ( prv == 2 ){
            return dp[idx][prv] = max ( cal ( idx + 1 , 1 ) + a[idx+1] , cal ( idx + 1 , 3 ) + c[idx+1] ) ; 
        }
        else if ( prv == 3 ){
            return dp[idx][prv] = max ( cal ( idx + 1 , 1 ) + a[idx+1] , cal ( idx + 1 , 2 ) + b[idx+1] ) ; 
        }
        else if ( prv == 0 ){
            return dp[idx][prv] = max ({ cal ( idx + 1 , 1 ) + a[idx+1] , cal ( idx + 1 , 2 ) + b[idx+1] , cal ( idx + 1 , 3 ) + c[idx+1] }) ; 
        }
    }
}

int main(){
    
  cin >> n ; 
  a.resize(n+1);
  b.resize(n+1);
  c.resize(n+1);
  
  for ( int i = 1 ; i <= n ; ++i ){
        cin >> a[i] >> b[i] >> c[i] ;  
  }
  
  cout << cal ( 0 , 0 )  ; 

return 0;
}

Measured memory_bytes: 7680
N = int(input())
C = []
S = []
F = []
T = [0 for i in range(N)]

for i in range(N-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(1,N):
    time = 0
    if i == 1:
        #print(S[-i])
        time = S[-i] + C[-i]
    else:
        time = S[-i] + C[-i]
        for j in range(1,i):
            if time < S[-(i-j)]:
                time = S[-(i-j)] + C[-(i-j)]
            else:
                dev = (time - S[-(i-j)]) % F[-(i-j)]
                if(dev != 0):
                    time = (time + (F[-(i-j)] - dev) + C[-(i-j)])
                else:
                    time = time + C[-(i-j)]
    T[-(i+1)] = time

for t in T:
    print(t)

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

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

	sort(a, a + N, greater<int>());
	int Alice = 0;
	int Bob = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) Alice += a[i];
		else Bob += a[i];
	}
	cout << Alice - Bob << endl;
}

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

int main(void)
{
  int input, count = 0, num, prenum = 10, preprenum = 11;
  cin >> input;
  for (int i = 0; i < 4; i++)
  {
    num = input % 10;
    input = input / 10;
    if (preprenum == num)
    {
      count += 1;
    }
    if (prenum == num)
    {
      count += 1;
    }
    preprenum = prenum;
    prenum = num;
  }
  if (count >=3)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

pair<int, int> i_to_pair(int x)
{
	int sentou = to_string(x)[0] - '0';
	int matubi = to_string(x)[to_string(x).size() - 1] - '0';
	return make_pair(sentou, matubi);
}

int main()
{
	int n;
	cin >> n;
	vector<int> s(n);
	for (int i = 0; i < n; i++) cin >> s[i];
	int sum = accumulate(s.begin(), s.end(), 0);
	sort(s.begin(), s.end());
	bool flag = false;
	if (sum % 10 == 0) {
		for (int i = 0; i < n; i++) {
			if (s[i] % 10 != 0) {
				cout << sum - s[i] << endl;
				flag = true;
				break;
			}
		}
		if (!flag) cout << 0 << endl;
	}
	else cout << sum << endl;
}

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

int main(){
int W,H,x,y,r;
cin >> W>>H>>x>>y>>r;

if ((x<=0)||(y<=0)){
cout << "No" << endl;
}
else if (((W-x)>=r)&&((H-y)>=r)){
cout << "Yes" << endl;
}
else{
cout << "No" << endl;
}



}


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

using namespace std;


int main()
{
  int N, M, E[200000];
  bool used[200001] = {};

  scanf("%d %d", &N, &M);
  for(int i = 0; i < M; i++) {
    scanf("%d", E + i);
  }
  for(int i = M - 1; i >= 0; i--) {
    if(used[E[i]]++) continue;
    printf("%d\n", E[i]);
  }
  for(int i = 1; i <= N; i++) {
    if(used[i]++) continue;
    printf("%d\n", i);
  }
}

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

int main() {
	int N;
	long long M;
	cin >> N >>M;
	vector<int> A(N);
	for (int n = 0;n < N;++n) {
		cin >> A[n];
	}
	sort(A.begin(), A.end());
	int l = 0;
	int r = 200005;
	vector<long long>S(N + 1);
	for (int n = 0;n<N;++n) {
		S[n + 1] = (long long)A[n] + S[n];
	}

	while (l + 1 < r) {
		long long num = 0;
		int c = (l+r) / 2;
		for (int n = 0;n < N;++n) {
			int j = lower_bound(A.begin(), A.end(), c - A[n]) - A.begin(); 
			num += (long long)(N - j);
		}
		if (num >= M) {
			l = c;
		}
		else {
			r = c;
		}
	}
	long long ans = 0;
	long long num = 0; 
	for (int n = 0; n < N; ++n) {
		int j = lower_bound(A.begin(), A.end(), l - A[n]) - A.begin();
		num += (long long)(N - j);
		ans += (long long)(S[N] - S[j]);
		ans += (long long)(A[n]) * (long long)(N - j);
	}

	ans -= ((num-M)*(long long)l);
	cout << ans <<endl;
	return 0;
}	

Measured memory_bytes: 4584
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 1000000007
#define endl "\n" 
#define int long long // remove when constraints are tight.
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	int ar[n];
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>ar[i];
		sum+=ar[i];
	}
	int avg=sum/n;
	int mi=inf;
	int cur=0;
	for(int i=0;i<n;i++)
	{
		cur+=(ar[i]-avg)*(ar[i]-avg);
	}
	mi=min(mi,cur);
	avg++;
	cur=0;
	for(int i=0;i<n;i++)
	{
		cur+=(ar[i]-avg)*(ar[i]-avg);
	}
	mi=min(mi,cur);
	cout<<mi<<endl;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = Integer.parseInt(sc.nextLine());
			String firstRowValue = sc.nextLine();
			String secondRowValue = sc.nextLine();
			List<Integer> firstRow = Arrays.asList(firstRowValue.split(" ")).stream().map(Integer::parseInt).collect(Collectors.toList());
			List<Integer> secondRow = Arrays.asList(secondRowValue.split(" ")).stream().map(Integer::parseInt).collect(Collectors.toList());

			ArrayList<Integer> resultList = new ArrayList<>();
			for(int i = 0 ; i < n ; i++) {
				int sum = 0;
				for(int j=0 ; j < n ; j++) {
					if(i > j) {
						sum += firstRow.get(j);
					} else if (i == j) {
						sum += firstRow.get(j);
						sum += secondRow.get(j);
					} else {
						sum += secondRow.get(j);
					}
				}
				resultList.add(sum);
			}

			Optional<Integer> maxOpt = resultList.stream().max(Comparator.naturalOrder());
			System.out.println(maxOpt.get());

		}
	}
}

Measured memory_bytes: 28116
ar = Array.new(4) { Array.new(3) { Array.new(10) {0}}}

gets
while line=gets
  b, f, r, v = *line.split(/\s+/).map(&:to_i)

  ar[b - 1][f - 1][r - 1] += v
end

puts ar.map {|b| b.map {|f| " " + f.join(" ")}.join "\n"}.join("\n" + "#" * 20 + "\n") 


Measured memory_bytes: 6948
import fractions
na = lambda: list(map(int, input().split()))
A,B,C,D = na()
ee = (C * D)//fractions.gcd(C, D)
A = A-1
cc = B//C
dd = B//D
ansb = cc+dd-B//ee
ansa = A//C+A//D-A//ee
print(B-A-(ansb-ansa))

Measured memory_bytes: 5588
import java.io.IOException;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

class Solve{
	final Scanner in = new Scanner(System.in);
	final static int[] dx = {-1, 0, 1, 0};
	final static int[] dy = {0, 1, 0, -1};
	boolean solve(){
		int[][] map = new int[500][500];
		int n = in.nextInt();
		if(n == 0) return false;
		if(n == 1){
			System.out.println("1 1");
			return true;
		}
		int[][] table = new int[n][2];
		table[0][0] = 250;
		table[0][1] = 250;
		map[250][250] = 1;
		int lx = 250;
		int ly = 250;
		int rx = 250;
		int ry = 250;
		for(int i=1; i<n; i++){
			int id = in.nextInt();
			int dir = in.nextInt();
			int x = table[id][0] + dx[dir];
			int y = table[id][1] + dy[dir];
			map[y][x] = 1;
			lx = Math.min(x, lx);
			rx = Math.max(x, rx);
			ly = Math.min(y, ly);
			ry = Math.max(y, ry);
			table[i][0] = x;
			table[i][1] = y;
		}
		System.out.println((rx-lx+1)+" "+(ry-ly+1));
		return true;
	}
}

public class Main{
	public static void main(String[] args) throws IOException{
		Solve solve = new Solve();
		while(solve.solve());
	}
}

Measured memory_bytes: 60468
# -*- coding: utf-8 -*-

TT, TA, AT, AA = map(int, input().split())

while True:
    AT = AT - TA # T attack
    if (AT <= 0):
        print("Yes")
        break

    TT = TT - AA #A attack
    if (TT <= 0):
        print("No")
        break

Measured memory_bytes: 9172
#include <algorithm>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

namespace atcoder {

namespace {

} // namespace
} // namespace atcoder

int main()
{
  using namespace atcoder;
  int P, Q, R;
  cin >> P >> Q >> R;
  cout << min(min(P + Q, P + R), Q + R);
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x, y = map(int, input().split())
    for i in range(200):
        for j in range(200):
            if i + j == x and i * 2 + j * 4 == y:
                print("Yes")
                exit()
    else:
        print("No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9116