akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define inf (1LL<<61)
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define int long long
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >  
#define mod 1000000007
#define ll long long

const int mm = (1<<19);
int bit[mm+1];

void update(int s,int valuse)
{
    while(s<=mm)
    {
        bit[s] = max(bit[s],valuse);
        s+=(s&-s);
    }
}
int query(int s)
{
    int ans = 0;
    while(s)
    {
        ans = max(ans,bit[s]);
        s -= (s&-s);
    }
    return ans;
}
int32_t main()
{
    IOS;
    
    memset(bit,0,sizeof(bit));
    int n;
    cin>>n;
    int ans = 0;
    int h[n+1];
    int val[n+1];
    for(int i = 1; i <= n;i++)
    {
        cin>>h[i];
        
    }
    for(int i = 1;i <= n;i++)
    {
        cin>>val[i];
    }
    for(int i = 1;i <= n;i++)
    {
        int f = query(h[i]);
        update(h[i],f+val[i]);
        ans = max(ans,f+val[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 7424
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn exec() {
    let mut sc = Scanner::new();
    let mut a: Vec<i64> = (0..3).map(|_| sc.ne()).collect();
    for i in 0..1000000 {
        for &x in &a {
            if x % 2 == 1 {
                println!("{}", i);
                std::process::exit(0);
            }
        }
        let mut na = vec![0;3];
        for j in 0..3 {
            for k in 0..3 {
                if k != j {
                    na[j] += a[k] / 2;
                }
            }
        }
        a = na;
    }
    println!("-1");
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r])
                  .ok()
                  .unwrap()
                  .parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 8572
#include <stdio.h>
int main (void){
int H[300],W[300],i=0,j,n=0,l,k;
H[0]=1;
W[0]=1;
while(H[i]!=0 && W[i]!=0){
	i++;
	n++;
	scanf("%d %d",&H[i],&W[i]);
}
for(j=1;j<n;j++){
	for(l=1;l<=H[j];l++){
		for(k=1;k<=W[j];k++){
			printf("#");
		}
	printf("\n");
	}	
	printf("\n");
}




return 0;	
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 

typedef unsigned long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

const int DIM = 1e5 + 17;

bool used[DIM];
vii v[DIM];
int pos[DIM];

bool DFS(int nod)
{
	used[nod] = true;
    
	for(auto i : v[nod])
	{
		if(used[i.F])
		{
			if(pos[i.F] != pos[nod] + i.S)
				return false;
			continue;
		}
		else
		{
			pos[i.F] = pos[nod] + i.S;
			if(!DFS(i.F))
				return false;
		}
	}
	
	return true;
}

main()
{
	IOS
	
	int n, m;
	cin >> n >> m;
	
	while(m--)
	{
		int x, y, d;
		cin >> x >> y >> d;
        
		v[x].pb({y, d });
		v[y].pb({x, -d});
	}

	for(int i = 1; i <= n; i++)
		if(!used[i])
		{
			if(!DFS(i))
			{
				cout << "No";
				return 0;
			}
		}
	
	cout << "Yes";
}

Measured memory_bytes: 11136
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	string s = readln.chomp;
	
	bool[char] flag;
	foreach(c; s) flag[c] = 1;
	
	string ans = "Yes";
	if('N' in flag && !('S' in flag)) ans = "No";
	if('S' in flag && !('N' in flag)) ans = "No";
	if('E' in flag && !('W' in flag)) ans = "No";
	if('W' in flag && !('E' in flag)) ans = "No";
	
	ans.writeln;
	
	}

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

using namespace std;

int main()

{
	
	int n, i, j, k;
	cin >> n;
	
	int arr[n];
	
	
	int ans[2*n];
	
	for (i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	
	sort(arr, arr+n);
	int ii = 0;
	i = n-1;
	j = 0;
	while ((i > 0) && (arr[i-1] > 0))
	{
		//cout << arr[j] << " " <<  arr[i] << '\n';
		ans[ii++] = arr[j];
		ans[ii++] = arr[i];
		arr[j] = arr[j] - arr[i];
		--i;
	}
	while (j < i)
	{
		//cout << arr[i] << " " << arr[j] << '\n';
		ans[ii++] = arr[i];
		ans[ii++] = arr[j];
		arr[i] = arr[i] - arr[j];
		++j;
	}
	
	cout << arr[i] << endl;
	
	for(i = 0; i < ii; i+=2)
	{
		cout << ans[i] << " " << ans[i+1] << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <cmath>
#include <iomanip>

#define NUM_S 6

class Dice {
public:
	Dice(const int n[NUM_S]);
	int roll(char);
	void show();

private:
	int top, south, east, west, north, bottom;
};
using namespace std;


int main(void){
	int surface[NUM_S];
	char ch;
	
	for (int i = 0; i < NUM_S; i++) {
		cin >> surface[i];
	}

	Dice dice(surface);
	while (cin >> ch) {
		dice.roll(ch);
	}
	dice.show();

	return 0;
}


Dice::Dice(const int n[NUM_S]) {
	top = n[0];
	south = n[1];
	east = n[2];
	west = n[3];
	north = n[4];
	bottom = n[5];
}

int Dice::roll(char c) {
	int buf;
	if (c == 'S') {
		buf = top;
		top = north;
		north = bottom;
		bottom = south;
		south = buf;
		return top;
	}
	else if (c == 'E') {
		buf = top;
		top = west;
		west = bottom;
		bottom = east;
		east = buf;
		return top;
	}
	else if (c == 'W') {
		buf = top;
		top = east;
		east = bottom;
		bottom = west;
		west = buf;
		return top;
	}
	else if (c == 'N') {
		buf = top;
		top = south;
		south = bottom;
		bottom = north;
		north = buf;
		return top;
	}
}

void Dice::show() {
	cout << top << "\n";
}

Measured memory_bytes: 3104
import itertools
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
nums = list(range(1,n+1))
d= [ list(i) for i in itertools.permutations(nums)]
a=0
b=0
for i in range(len(d)):
  if p==d[i]:
    a=i
  if q==d[i]:
    b=i
print(abs(a-b))

Measured memory_bytes: 10228
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
vector<pair<int, int>>v[100010];//年度、市名
pair<int, int>P[100010];//県名、順番
int main(){
	int n, m;
	int p[100010], y[100010];
	cin >> n >> m;
	rep(i, m) {
		cin >> p[i] >> y[i];
		v[p[i]].push_back({ y[i],i });
	}
	rep(i, n + 1) {
		sort(v[i].begin(), v[i].end());
		rep(j, v[i].size()) {
			P[v[i][j].second] = { i,j + 1 };
		}
	}
	rep(i, m) {
		if (P[i].first < 10)cout << "00000" << P[i].first;
		else if (P[i].first < 100)cout << "0000" << P[i].first;
		else if (P[i].first < 1000)cout << "000" << P[i].first;
		else if (P[i].first < 10000)cout << "00" << P[i].first;
		else if (P[i].first < 100000)cout << "0" << P[i].first;
		else cout << P[i].first;
		if (P[i].second < 10)cout << "00000" << P[i].second;
		else if (P[i].second < 100)cout << "0000" << P[i].second;
		else if (P[i].second < 1000)cout << "000" << P[i].second;
		else if (P[i].second < 10000)cout << "00" << P[i].second;
		else if (P[i].second < 100000)cout << "0" << P[i].second;
		else cout << P[i].second;
		cout << endl;
	}
	
	getchar();getchar();
	return 0;
}

Measured memory_bytes: 8576
from collections import deque
N=int(input())
AB=[list(map(int,input().split())) for i in range(N-1)]
P=[set() for i in range(N+1)]
C=[set() for i in range(N+1)]

for a,b in AB:
    P[a].add(b)
    P[b].add(a)
Cpath={}
stack=deque([1])
delset=set()
while stack:
    #print(C)
    #print(Cpath,"Cpath")
    a=stack[0]
    count=1
    for b in P[a]:
        #b=P[a][-1]
        while count in C[a]:
            count+=1
        C[a].add(count)
        C[b].add(count)
        Cpath[(a,b) if a<b else (b,a)]=count
        stack.append(b)
        #P[a].remove(b)
        P[b].remove(a)
    P[a].clear()
    stack.popleft()

print(max([Cpath[i] for i in Cpath]))
for a,b in AB:
    print(Cpath[(a,b)])


Measured memory_bytes: 123652
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 100000, MAX_M = 100000;
int N, M;
int A[MAX_M], B[MAX_M];
vector<pii> period;

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

  rep(i,M) {
    period.push_back(pii(B[i]-1, A[i]));
  }

  sort(all(period));

  int ans = 0, last = 0;
  for (int i = 0; i < M; ++i) {
    if (last >= period[i].sc) continue;
    ++ans;
    last = period[i].fi;
  }

  cout << ans << endl;
}


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

int main()
{
    int n;
    cin >> n;
    vector<unsigned long long> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << 0 << endl;
            exit(0);
        }
    }

    unsigned long long ans = 1;

    for (int i = 0; i < n; i++)
    {
        if ((to_string(a[i]).length() + to_string(ans).length()) > 20)
        {
            cout << -1 << endl;
            exit(0);
        }
        else if (ans >= LONG_LONG_MAX / a[i])
        {
            cout << -1 << endl;
            exit(0);
        }

        ans *= a[i];
        if (ans > 1000000000000000000)
        {
            cout << -1 << endl;
            exit(0);
        }
    }

    cout << ans << endl;
}

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


int main(int argc, char const *argv[])
{
    char a;
    char b;
    char c;
    cin>>a>>b>>c;
    int countf=0;
    int counts=0;
    if (a=='5') {
        countf++;
    } 
    else if (a=='7')
    {
        counts++;
    }  
    if (b=='5') {
        countf++;
    } 
    else if (b=='7')
    {
        counts++;
    }  
    if (c=='5') {
        countf++;
    } 
    else if (c=='7')
    {
        counts++;
    }
    
    if (countf==2&&counts==1) {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N = 0;
  cin >> N;
  int sum=0;
  for (int i=0;i<N;i++){
    int l ,r;
  	cin >> l;
    cin >> r;
  	sum+=r-l+1;
  } 
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  char s[110000];
  int res=0;
  cin >> N >> s;

  vector<char> v;
  char prev='X';
  rep(i,N){
    if(prev!=s[i]) v.push_back(s[i]);
    prev = s[i];
  }

  for(auto it=v.begin();it!=v.end();it++){
    res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 512
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Aug  4 19:19:34 2018
//
package main

import (
	"fmt"
	"sort"
)

var N int
var arr []int

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	fmt.Scan(&N)
	arr = make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
		arr[i] = arr[i] - (i + 1)
	}

	sort.Ints(arr)
	b := arr[(0+len(arr))/2]
	var min int64
	for i := range arr {
		min += int64(abs(arr[i] - b))
	}

	fmt.Println(min)
}


Measured memory_bytes: 6704
H, W = list(map(int, input().split()))
S =[list(input()) for _ in range(H)]
N=H*W
INF=float('inf')
L=[[INF]*N for _ in range(N)]
for i in range(N):
    h=i//W
    w=i%W
    # print(i,h,w)
    if S[h][w]=='.':
        L[i][i]=0
    if w>0 and S[h][w-1]=='.':
        L[i][i-1]=1
    if w<W-1 and S[h][w+1]=='.':
        L[i][i+1]=1
    if h>0 and S[h-1][w]=='.':
        L[i][i-W]=1
    if h<H-1 and S[h+1][w]=='.':
        L[i][i+W]=1
# print(L)

for i in range(N):
    via=L[i]
    if via[i]==INF:
        continue
    for j in range(N):
        st=L[j]
        if st[j]==INF:
            continue
        for k in range(N):
            L[j][k]=min(st[i]+via[k], st[k])
# print(L)
ans=0
for i in range(N):
    for j in range(N):
        if L[i][j]!=INF:
            ans=max(ans,L[i][j])
print(ans)

Measured memory_bytes: 75612
#include<bits/stdc++.h>
#define ll long long
#define inf(x) (ll)(1e##x)
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int f[100100],pri[100100],tot,n;
map<pair<ll,ll>,int> mp;
ll get_sqrt(ll p){
	ll x=sqrtl(p);
	while(x*x<p) x++;
	while(x*x>p) x--;
	if(x*x!=p) return -1;
	else return x;
}
int main(){
	for(int i=2;i<=2155;i++){
		if(!f[i]){f[i]=i;pri[++tot]=i;}
		for(int j=1;pri[j]*i<=2155;j++){
			f[pri[j]*i]=pri[j];
			if(f[i]==pri[j]) break;
		}
	}
	read(n);
	for(int i=1;i<=n;i++){
		ll x;read(x);
		pair<ll,ll> now=make_pair(1,1);
		for(int i=1;i<=tot;i++)
			if(x%pri[i]==0){
				int k=0;
				while(x%pri[i]==0) k++,x/=pri[i];
				k%=3;
				if(k==1) now.first*=pri[i];
				if(k==2) now.second*=pri[i]; 
			}
		if(x){
			ll k=get_sqrt(x);
			if(~k) now.second*=get_sqrt(x);
			else now.first*=x;
		}
		mp[now]++;
	}
	int ans=0;
	for(auto&p:mp){
		auto now=p.first;
		if(now.first==now.second) ans++;
		else{
			swap(now.first,now.second);
			if(mp.count(now)){
				if(mp[now]<p.second||mp[now]==p.second&&now<p.first)
					ans+=p.second;
			}
			else ans+=p.second;
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 6528
#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() {
   string S;
   cin >> S;

   ll ans = 0;
   const int len = S.size()-1;
   rep (i, 1<<len) {
      bitset<10> op(i);
      ll memo = 0;
      rep(j,len) {
         if(op.test(len-1-j)) {
            ans += (S.at(j)-'0') + memo;
            memo = 0;
         } 
         else memo = 10 * ((S.at(j)-'0') + memo);
      }
      ans += (S.at(len)-'0') + memo;
//      cout << "i : " << op << "    ans : " << ans << endl; 
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define ARRAY_MAX 50
#define COUNT_RESET 0
#define RETURN 0
#define ARRAY_END -1
#define TEST_ABSENT -1
#define BORDER_A 80
#define BORDER_B 65
#define BORDER_C 50
#define BORDER_D 30

struct test_result{
    signed short ssW_D_mid;
    signed short ssW_D_fin;
    signed short ssW_D_re;
    unsigned char ubW_D_eval;
};

unsigned char s_EVALUATE(struct test_result test);

int main(){
    struct test_result test[ARRAY_MAX];
    unsigned short usW_C_i;
    unsigned short usW_C_count = COUNT_RESET;

    for(usW_C_i = 0;usW_C_i < ARRAY_MAX;usW_C_i++){
        scanf("%d %d %d", &test[usW_C_i].ssW_D_mid, &test[usW_C_i].ssW_D_fin, &test[usW_C_i].ssW_D_re);
        if(test[usW_C_i].ssW_D_mid == -1 && test[usW_C_i].ssW_D_fin == -1 && test[usW_C_i].ssW_D_re == -1){
            break;
        }
        test[usW_C_i].ubW_D_eval = s_EVALUATE(test[usW_C_i]);
        usW_C_count++;
    }

    for(usW_C_i = 0;usW_C_i < usW_C_count;usW_C_i++){
        printf("%c\n", test[usW_C_i].ubW_D_eval);
    }

    return 0;
}

unsigned char s_EVALUATE(struct test_result test){
    signed short ssW_D_sum;
    unsigned char ubW_D_result;

    ssW_D_sum = test.ssW_D_mid + test.ssW_D_fin;

    if(test.ssW_D_mid == -1 || test.ssW_D_fin == -1){
        ubW_D_result = 'F';
    }
    else if(ssW_D_sum >= 80){
        ubW_D_result = 'A';
    }
    else if(ssW_D_sum >= 65){
        ubW_D_result = 'B';
    }
    else if(ssW_D_sum >= 50){
        ubW_D_result = 'C';
    }
    else if(ssW_D_sum >= 30){
        if(test.ssW_D_re >= 50){
            ubW_D_result = 'C';
        }
        else{
            ubW_D_result = 'D';
        }
    }
    else{
        ubW_D_result = 'F';
    }

    return ubW_D_result;
}


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

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

	int count = 0;
	int maxNum = 0;
	for (int i = 0; i < S.length(); i++) {
		for (int j = i; j < S.length(); j++) {
			if (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T') {
				count++;
			}
			else {
				maxNum = max(maxNum, count);
				count = 0;
				break;
			}

			if (j == S.length() - 1) {
				maxNum = max(maxNum, count);
				count = 0;
				break;
			}
		}
		
	}

	cout << maxNum << endl;
}




Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let (A, B, C): (i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = std::cmp::min(B / A, C);

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

char a[1001][1000];
int b[1001][1000];

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

    int h, w;
    cin >> h >> w;

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

    b[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = (i == 0); j < w; j++) {
            if (a[i][j] == '#') continue;
            int t = 0;
            if (i > 0) t = b[i - 1][j];
            if (j > 0) { t += b[i][j - 1]; if (t >= P) t -= P; }
            b[i][j] = t;
        }
    }

    cout << b[h - 1][w - 1] << endl;

    return 0;
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    int a, b, ans;

    cin >> a >> b;
    if (a < 6) ans = 0;
    else if (a < 13) ans = b/2;
    else ans = b;
    cout << ans << '\n';

    return 0;
}


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

int main()
{
  long long a,b,x;
  double sita;
  cin>>a>>b>>x;
  if(x>a*a*b/2)
  {
    sita=atan2(2*(a*a*b-x),a*a*a);
  }
  else
    sita=atan2(a*b*b,2*x);
  std::cout<<std::setprecision(10)<<sita*180/M_PI;
}

Measured memory_bytes: 256
#include <stdio.h>

int N,A[303][303];

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<N;i++) for (int j=0;j<N;j++) scanf("%d",&A[i][j]);

	long long ans = 0;
	for (int i=0;i<N;i++) for (int j=i+1;j<N;j++){
		bool g = 1;
		for (int k=0;k<N;k++) if (i != k && j != k){
			if (A[i][j] > A[i][k] + A[k][j]){
				puts("-1");
				return 0;
			}
			else if (A[i][j] == A[i][k] + A[k][j]){
				g = 0;
				break;
			}
		}
		if (g)
			ans += A[i][j];
	}
	printf ("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int H, W;
    cin >> H >> W;
    string field[H];
    
    int directionForX[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
    int directionForY[8] = {0, -1, -1, -1, 0, 1, 1, 1};
    int bombCounter;
    
    for(int i = 0; i < H; i++){
        cin >> field[i];
    }
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
             if(field[i][j] == '#'){
                    continue;
                }
            for(int k = 0; k < 8; k++){
                if(i + directionForX[k] < 0 or i + directionForX[k] >= H){
                    continue;
                }
                if(j + directionForY[k] < 0 or j + directionForY[k] >= W){
                    continue;
                }
                if(field[i + directionForX[k]][j + directionForY[k]] == '#'){
                    bombCounter++;
                }
            }
            
            field[i][j] = bombCounter + '0';
            bombCounter = 0;
        }
    }
    
    for(int i = 0; i < H; i++){
        cout << field[i] << endl;
    }
    
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include <intrin.h>  //AtCpder (gcc) 上ではこれがあると動かない。__popcnt用のincludeファイル。
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;






signed main() {
	int N, K;
	cin >> N >> K;

	int R, S, P;
	cin >> R >> S >> P;

	string T;
	cin >> T;

	int res = 0;
	vector<char> res_string(N, 'a');

	rep(i, N) {
		if (i < K) {
			if (T.at(i) == 'r') {
				res += P; 
				res_string.at(i) = 'p';
			}
			else if (T.at(i) == 's') {
				res += R;
				res_string.at(i) = 'r';
			}
			else {
				res += S;
				res_string.at(i) = 's';
			}
		}
		else if (T.at(i) != T.at(i-K) || res_string.at(i - K) == '-'){
			if (T.at(i) == 'r') {
				res += P;
				res_string.at(i) = 'p';
			}
			else if (T.at(i) == 's') {
				res += R;
				res_string.at(i) = 'r';
			}
			else {
				res += S;
				res_string.at(i) = 's';
			}
		}
		else {
			res_string.at(i) = '-';
		}
	}


	std::cout << res << endl;
	//rep(i, N) std::cout << res_string.at(i);
	//std::cout << endl;

}

Measured memory_bytes: 512
import sys

def print_arr(arr):
	for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	print()

n = int(input())
arr = list(map(int, input().split()))

for i in range(n):
	key = arr[i]
	j = i - 1
	while j >= 0 and arr[j] > key:
		arr[j + 1] = arr[j]
		j = j - 1
	arr[j + 1] = key
	print_arr(arr)



Measured memory_bytes: 5988
#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; ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n+1,-1);
  int c = 1, l = 0;
  {
    int v = 1;
    while (ord[v] == -1) {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }

  if (k < l) cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}


Measured memory_bytes: 5820
#include <cstdio>




int main() {
    for (int i = 1; i <= 3; i++) {
        char ch = fgetc(stdin);
        ch += 'A' - 'a';
        printf("%c", ch);
        while (ch != ' ' && ch != '\n')
            ch = fgetc(stdin);
    }
    return 0;
}


Measured memory_bytes: 128
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = I()
l = [0]*10000000
l[0] = s

for i in range(1,10000000):
    if l[i-1] % 2 == 0:
        l[i] = l[i-1]//2
    else:
        l[i] = l[i-1]*3+1
    if l[i] in l[:i-1]:
        ans = i+1
        break

print(ans)

Measured memory_bytes: 99696
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S=sc.next();
      String T=sc.next();
      if(T.substring(0,T.length()-1).equals(S)){
         System.out.println("Yes");
      }else{
         System.out.println("No");
      }
   }
}


Measured memory_bytes: 35584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(){
    string s;
    cin >> s;
    cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;
}

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

int GCD(int x,int y)
{
	if(x == 0)
	{
		return y;
	}
	
	if(y == 0)
	{
		return x;
	}
	
	if(x > y)
	{
		return GCD(x%y,y);
	}
	
	return GCD(x,y%x);
}

int LCM(int x,int y)
{
	int gcd = GCD(x,y);
	return x*y/gcd;
}

int main() {

	int X;
	cin>>X;
	
	if(X != 0)
	{
		cout<<LCM(360,X)/X<<endl;
	}
	else 
	{
		cout<<0<<endl;
	}

	return 0;
}

Measured memory_bytes: 3632
n, k = gets.split.map(&:to_i)

default_div = 10**9+7
count_arr=[]
# i箇所にjこの数を配置する。
1.upto(k+1) do |i|
  i_arr=[]
  prev_sum = 0
  0.upto([k-i+1,n-k-(i-1)+1].max) do |j|
    if j==0
      prev_sum += 1
      i_arr << prev_sum
    elsif i==1
      i_arr << 1
    elsif i==2
      i_arr << j + 1
    else
      prev_sum += count_arr[i-2][j]
      i_arr << prev_sum % default_div
    end
  end
  count_arr << i_arr
end
#puts count_arr.to_s

1.upto(k) do |i|
  # 青:i箇所に1個配置する
  #   残りの青(k-i)をi箇所に配置する組み合わせを求める
  # 赤:i-1箇所に１個配置する
  #   残りの赤(n-k-(i-1))をi+1箇所に配置する組み合わせを求める
  # ↑２つの積
  if n-k-(i-1)<0
    puts 0
    next
  end

  bl_conb = count_arr[i-1][k-i]
  red_conb = count_arr[i+1-1][n-k-(i-1)]

  puts bl_conb * red_conb % default_div
end

Measured memory_bytes: 21116
s = list(input())
K = int(input())

alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    if (26 - alphabet.index(s[i]) <= K) and s[i] != "a":
        K -= 26 - alphabet.index(s[i]) 
        s[i] = "a"
        
if K > 0:
    K = K % 26
    s[-1] = alphabet[(alphabet.index(s[i])+K)%26]
    
print("".join(s))

Measured memory_bytes: 4156
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX_N = 110;
const int MAX_V = 100100;

int N;
long long W, weight[MAX_N], value[MAX_N]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    rep(i, N) cin >> weight[i] >> value[i];
    rep(i, MAX_N) rep(j, MAX_V) dp[i][j] = INF;

    dp[0][0] = 0;

    // DPループ
    rep(i, N) {
        rep(sum_v, MAX_V) {
            // i 番目の品物を選ぶ場合
            chmin(dp[i+1][sum_v + value[i]], dp[i][sum_v] + weight[i]);
            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}

Measured memory_bytes: 86272
def resolve():
    a = list(map(int, input().split()))
    a = sorted(a)
    x = a[0]
    y = a[1]
    z = a[2]
    ans = z-y
    if (z-(ans+x)) % 2 == 0:
        ans += (z-(ans+x)) // 2
        print(ans)
    else:
        ans += (z - (ans + x)) // 2
        print(ans+2)
resolve()

Measured memory_bytes: 3064
import math
a=1000000007

m,n=[int(i) for i in input().split(" ")]

pow_list=[m]
x=int(math.log2(n))
for i in range(x+1):
    pow_list.append((pow_list[-1]**2)%a)

result=1
for i in range(x+1):
    if n>=2**(x-i):
        n-=2**(x-i)
        result=(result*pow_list[x-i])%a

print (result)

Measured memory_bytes: 7836
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
map<string, int> A;

signed main(){
    cin >> N;
    rep(i, N){
        string S;
        cin >> S;
        A[S]++;
    }

    cout << "AC x " << A["AC"] << endl;
    cout << "WA x " << A["WA"] << endl;
    cout << "TLE x " << A["TLE"] << endl;
    cout << "RE x " << A["RE"] << endl;
}

Measured memory_bytes: 3620
//g++  7.4.0
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

int n, k;
std::vector<int> v;

bool f(int x)
{
    long long int cnt = 0;
    for(int i=0; i<n; i++){
        cnt += (v[i]-1)/x;
        //cout << i << ":" << v[i] << ", " << cnt << endl;;
        if(cnt > k) return false;
    }
    return true;
}

int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    std::sort(v.begin(), v.end());
    const int maxa = v[n-1];
    
    // 今回の下限は1なのでlの初期値（条件を満たさない）は0
    // 例えば l=-1, r=2 の時f(0)を呼び出して落ちる
    //int l = -1, r = maxa;  
    int l = 0, r = maxa;
    
    while(std::abs(r-l) > 1){
        int m = (r+l)/2;
        //cout << "--- " << l << ", " << m << ", " << r << endl;
        if(f(m) == true){  // mで成功したらmより下を調べる
            r = m;
        }else{  // mで失敗したらmより上を調べる
            l = m;
        }
    }
            
    cout << r << endl;
}

Measured memory_bytes: 4208
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    int A[10];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int odds = 0, even = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] % 2 == 0)
        {
            even++;
        }
        else
        {
            odds++;
        }
    }
    if (odds == N)
    {
        res = pow(3, N) - 1;
    }
    else
    {
        res = pow(3, N) - pow(2, even);
    }

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define max 100005
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

/*
bool isDiff(int i,int j,int k){
    if((s[i]!=s[j])&&(s[j]!=s[k])&&(s[k]!=s[i])){
        return true; 
    }else{
        return false;
    }
}
*/

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

    ll r=0,g=0,b=0;
    rep(i,n){
        if(s[i]=='R'){
            r++;
        }else if(s[i]=='G'){
            g++;
        }else{
            b++;
        }
    }
    ll comb=r*g*b;

    for(int j=1;j<n;j++){
        rep(i,j){
            int  k=2*j-i;
            if(k<n){
                if(s[i]==s[j] || s[i]==s[k] || s[j]==s[k])continue;
                comb--;
            }
        }
    }
    cout<<comb<<endl;
    return 0;
}


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

int main()
{
	int A, B;
	int cnt = 0;
	cin >> A >> B;
	for ( int i = A; i <= B; i++ ) {
		string S, T;
		S = to_string(i);
		T = S;
		reverse(begin(T), end(T));
		if ( S == T ) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return ( 0 );
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll a,b,c,ans;
int main(void){
    cin>>a>>b;
    for(int i=0;i<b;i++){
        cin>>c;
        ans+=c;
    }
    if(a<=ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace agc010_b
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long times = x.Sum() / (n * (n + 1) / 2);
            long count = 0; long a = 0;
            bool flag = true;
            for (int i = 0; i < n; i++)
            {
                long dis = x[(i + 1) % n] - x[i];
                if ((times - dis) % n != 0) flag = false;
                count += (times - dis) / n;
                if (i + 1 < n) a += (n - 1 - i) * ((times - dis) / n);
                else a += n * ((times - dis) / n);
            }
            if (flag && count == times && x.Min() >= times && a == x[n - 1]) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 22880
<?php
$n = trim(fgets(STDIN));
for($i = 0; $i < $n-1; $i++){
    list($from, $to, $length) =  explode(" ", trim(fgets(STDIN)));
    $connect[$from][$to] = $length;
    $connect[$to][$from] = $length;
}
for($i = 1; $i <= $n; $i++){
    $map[$i] = false;
}
dfs(1, 0);
for($i = 1; $i <= $n; $i++){
    echo $map[$i]."\n";
}

function dfs($from, $color){
    global $map;
    global $connect;
    $map[$from] = $color;
    foreach($connect[$from] as $to => $length){
        if($map[$to] === false){
            if($length % 2 == 1){
                dfs($to, 1 - $color);
            }else{
                dfs($to, $color);
            }
        }
    }
}



Measured memory_bytes: 71032
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int k;
    cin >> k;

    for (size_t i = 0; i < k; i++) {
        cout << "ACL";
    }
    cout << "\n";
}


Measured memory_bytes: 3612
s = gets.to_i

h = {
  0 => 0,
  1 => 0,
  2 => 0,
  3 => 1,
}

3.upto(s) do |x|
  r = 0
  3.upto(x-3) do |i|
    t = x - i
    r += h[t]
  end
  h[x] = r + 1
end

puts h[s] % 1000000007


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

int main() {
	ll a,b;
	cin>>a>>b;
	a--;b--;
	cout << 100 << " "<<100<<endl;
	for(ll i=0;i<50;i++){
		for(ll j=0;j<100;j++){
			if(i%2!=0&&a!=0&&j%2!=0&&j!=99){
					a--;
					cout << ".";
			}
			else{
				cout << "#";
			}
		}
		cout <<endl;
	}
	for(ll i=0;i<50;i++){
		for(ll j=0;j<100;j++){
			if(i%2!=0&&b!=0&&j%2!=0&&j!=99){
					b--;
					cout << "#";
			}
			else{
				cout << ".";
			}
		}
		cout <<endl;
	}	
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
h,w=gets.split.map(&:to_i)
a=Array.new
h.times do a.push(gets.chomp.split("")) end
hoge=Array.new
for i in 0...w
    if a.all?{|e|e[i]=="."}
        hoge.push(i)
    end
end
hoge.reverse.each do |i|
    a.each do |e|
        e.slice!(i)
    end
end
a.each do |e|
    if e.all?{|f|f=="."}
        a.delete(e)
    end
end
if a.size==1
    a[0].delete(".")
end
a.each do |elem|
    puts elem.join
end

Measured memory_bytes: 2556
#include <stdio.h>
 
int main(void)
{
    int n;
    int c[100];
    int v;
    int i, j;
     
    scanf("%d", &n);
     
    for (i = 0; i < n; i++){
        scanf("%d", &c[i]);
    }
     
    for (i = 1; i < n; i++){
        for (j = 0; j < n; j++){
            printf("%d", c[j]);
            if (j < n - 1){
                printf(" ");
            }
        }
        printf("\n");
        v = c[i];
        j = i - 1;
        while (j >= 0 && c[j] > v){
            c[j + 1] = c[j];
            j--;
            c[j + 1]= v;
        }
    }
     
    for (i = 0; i < n; i++){
        printf("%d", c[i]);
        if (i < n - 1){
            printf(" ");
        }
    }
    printf("\n");
    return (0);
}




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

int main(){
    int i=0;
    string o,e;
    cin >> o >> e;
    if(o.size()==e.size()){
        for(i=0;i<o.size();i++){
            cout << o[i] << e[i];
        }
        cout << endl;
    }
    else {
        for(i=0;i<o.size()-1;i++){
            cout << o[i] << e[i];
        }
        cout << o[o.size()-1] << endl;
    }
    return 0;
}

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

int main()
{
  int n;
  cin>>n;
  int r = n % 10;
  if(r == 2 || r == 4 || r == 5|| r == 7|| r == 9)
  {
      cout<<"hon\n";
  }
  else if(r == 0 || r == 1 || r == 6 || r == 8)
  {
      cout<<"pon\n";
  }
  else if(r == 3)
  {
      cout<<"bon\n";
  }

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int  n,m;
long long int a[200005];
bool cmp(int x, int y)
{
	return abs(x) < abs(y);
}
int main()
{
	int pn=0 ,nn = 0;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (a[i] >= 0)
			pn++;
		else
			nn++;
	}
	int l=1, r=n;
	long long ans = 1;
	if (!pn && m % 2 == 1)
	{
		sort(a + 1, a + 1 + n, cmp);
		for (int i = 1; i <= m; i++) 
			ans = a[i] * ans % mod;
	}
	else
	{
		sort(a + 1, a + 1 + n, greater< int >());
		while (m)
		{
			if (m % 2 == 1)
			{
				ans = ans * a[l] % mod;
				l++, m--;
			}
			else
			{
				if (a[l] * a[l + 1] >= a[r] * a[r - 1])
				{
					ans = ans * a[l] % mod * a[l + 1] % mod;
					l += 2,m -= 2;
				}
				else
				{
					ans = ans * a[r - 1] % mod * a[r] % mod;
					r -= 2,m -= 2;
				}
			}

		}
	}
	cout << (ans % mod + mod) % mod << endl;
}

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

YES = "Possible"  # type: str
NO = "Impossible"  # type: str


def main():
    h, w = map(int, input().split())
    c = sum([input().count("#") for _ in range(h)])
    print("Possible" if h + w - 1 == c else "Impossible")

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  bool can = false; 
  cin >> x >> y;
  int n = 4 * x;
  if(n == y) {
    can = true;
  }
  else {
    for(int i = 0; i < x; i++) {
      n -= 2;
      if(n == y) {
        can = true;
        break;
      }
    }
  }
  if(can) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  int dif = vec.at(N-1) - vec.at(0);
  cout << dif << endl;
  
}

Measured memory_bytes: 3608
using System;
using System.Linq;
using System.Collections.Generic;


namespace Test1 {

    class ClassMain {

        
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = ints[0]; 
                //int n = int.Parse(line);                
                if(n==0){break;}
                int r = ints[1];

                int[] card = Enumerable.Range(1,n).ToArray();
                Array.Reverse(card);

                while (r-- > 0) {
                    ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    int p = ints[0];
                    int c = ints[1];

                    int[] after = new int[n];
                    for (int i = 0; i < n; i++) {
                        if (i < c) {
                            after[i] = card[p - 1 + i];
                        }
                        else if (i < p + c - 1) {
                            after[i] = card[i - c];
                        }
                        else {
                            after[i] = card[i];
                        }
                    }
                    card=after;
                }

                Console.WriteLine(card[0]);

            }   
        }   
    }
}

Measured memory_bytes: 6212
using System;

namespace ARC098_D___Xor_Sum_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            var totalSum = new long[N + 1];
            var totalXor = new long[N + 1];
            for (int i = 1; i < N + 1; i++)
            {
                totalSum[i] = totalSum[i - 1] + A[i - 1];
                totalXor[i] = totalXor[i - 1] ^ A[i - 1];
            }

            long right = 1; long left = 1;
            long result = 0;
            while (right <= N)
            {
                if ((totalSum[right] - totalSum[left - 1]) == (totalXor[right] ^ totalXor[left - 1]))
                {
                    result += right - left + 1;
                    right++;
                }
                else
                {
                    left++;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 31324
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> L(2*N);
  rep(i,2*N)
  {
    cin >> L[i];
  }
  sort(ALL(L));
  int sum = 0;
  rep(i,2*N)
  {
    if(i%2==0) sum += L[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3588
//----------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
typedef pair<int64_t,int64_t> pii;
typedef int64_t myint;

const myint INF=INT64_MAX;
const double EPS=1e-10;

void init(){cin.tie(0);ios::sync_with_stdio(false);}
//----------------------------------------------------

typedef struct edge{
  myint to;
  myint cost;
}Edge;

int V=10;
vector<vector<Edge>> G(10);
myint d[10][10];

void dijkstra(int s){
  priority_queue<pii,vector<pii>,greater<pii>> que;

  for(int i=0;i<V;i++){
    d[s][i]=INF;
  }

  d[s][s]=0;
  que.push(pii(0,s));

  while(!que.empty()){
    pii p = que.top();
    que.pop();

    int v=p.second;
    if(d[s][v] < p.first) continue;
    for(int i=0;i<G[v].size();i++){
      Edge e = G[v][i];

      if(d[s][e.to]>d[s][v]+e.cost){
        d[s][e.to]=d[s][v]+e.cost;
        que.push(pii(d[s][e.to],e.to));
      }
    }
  }
}

pii solve(myint n){
  for(int i=0;i<V;i++){
    vector<Edge>().swap(G[i]);
  }

  for(int i=0;i<n;i++){
    int a,b,c;
    cin >> a >> b >> c;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
  }

  for(int i=0;i<V;i++){
    dijkstra(i);
  }

  vector<myint> cost(V);
  for(int i=0;i<V;i++){
    cost[i]=INF;
  }

  bool isExist;
  for(int i=0;i<V;i++){
    isExist=false;
    for(int j=0;j<V;j++){
      if(d[i][j]!=INF && i!=j){
        cost[i]-=d[i][j];
          isExist=true;
      }
    }
    if(isExist){
      cost[i]=INF-cost[i];
    }
  }

  pii best = pii(0,cost[0]);
  for(int i=1;i<V;i++){
    if(best.second > cost[i]){
      best = pii(i,cost[i]);
    }
  }
  return best;
}

int main(){
  init();

  myint n;
  while(cin >> n,n!=0){
    pii best = solve(n);
    cout << best.first << " " << best.second << endl;
  }
  return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>


using namespace std;

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

    bool flag = true;
    int c_count = 0;
    if(S[0] != 'A'){
        flag = false;
        cout << "WA" << endl;
        return 0;
    }
    for (int i = 1; i < S.size(); i++)
    {
        /* code */
        if(isupper(S[i])){
            if((2 <= i) && (i < S.size()-1)){
                if(S[i] == 'C'){
                    c_count++;
                }else{
                    flag = false;
                    break;
                }
            }else{
                flag = false;
                break;
            }
        }

    }
    if(flag == true && c_count == 1){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256