akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
//using System.Collections.Generic;
	class Program
	{
		public static void Main(string[] args)
		{
			
			//??????????????§??°??????????????????????????¨??????????????????????????????????????£????????????
			
			Stream inputStream=Console.OpenStandardInput();
			StreamReader sr =new StreamReader(inputStream);
			string text =sr.ReadToEnd();
			sr.Close();
			
			string[] textArray=text.Replace("\r\n", "\n").Split('\n');
			
			double n=double.Parse(textArray[0]);
			int[] array= new int[(int)n];
			/*
			 * //??????????????????text???????????????????§?????????????
			array=Array.ConvertAll(text.Replace("\r\n", "\n").Split('\n')
                ,
                new Converter<string,int>( s 
                                          => int.Parse(s) ));
			*/
			//?????????????????????????????§??????????????¨?????????
            for(int k=0;k<array.Length;k++)
			{
            	array[k]=int.Parse(textArray[k+1]);
			}
			
			int cnt=0;
			int m=1;//?????£??????????????°???h=3???m?????????/??? h<n???
			
			while((Math.Pow(3,m+1)-1)/2<n)//?????????m+1??????
			{
				m++;
			}
			
		/*	
			for(int gap=2;(Math.Pow(3,gap)-1)/2<n;gap++)
			{			
				m++;
			}
		*/	
			int []  G=new int[m];//?????£??????????´???????????????£???????????????????????????????????????????????£??????
			for(int i=0;i<G.Length;i++)//??????.Length????????????????????? m=G.Length
			{
				G[m-1-i]=(int)((Math.Pow(3,i+1)-1)/2);
			}
			for(int s=0;s<G.Length;s++)
			{
				cnt+=sort( array, G[s]);//?????\???????????????????????????????????????????????´???????????????????????????????????????
				
				
				
			}
			//?????????????????????m???????????????G[i]????????????????????§???????????????G?????¨????????´??????count?????????
			//????????????????????????????????????
				var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
Console.SetOut(sw);
/*????????????????????????*/
			
			Console.WriteLine(m);
			for(int o=0;o<G.Length-1;o++)
			{
				Console.Write(G[o]+" ");
			}
			Console.Write(G[G.Length-1]+"\r\n");//???????????§?????????
			Console.WriteLine(cnt);//?????????
		
			for(int l=0;l<array.Length;l++)
			{
				Console.WriteLine(array[l]);
			
			}
			Console.Out.Flush();
			
		}
		public static int sort(int [] A,int g)
		{
			//g????????£??????
			int count=0;//??????????????°
			int v=0;
			int j=0;
			for (int k=0;k<g;k++)
			{
				//?????\?????????
			for(int i=k+g;i<A.Length;i+=g)
			{
				
				 v=A[i];
				 j=i-g;
				while(j>=0 &&
				       A[j]>v)//???&&????????§???????????????????????????
				{
					A[j+g]=A[j];
					
				A[j]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				j=j-g;
					//?????????????????£??????????????\??¨????????¢?????§???????????§????????????
					//??§????????????????????????????????????
				count ++; //????????????????????§????????????????????§??????????????¢??????
				
				}
				
			}
			}
			return count;
		}
		
	}
	

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mod 1000000007
#define inf 1e18
#define endl "\n"

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main()
{
    fastio
    ll test=1,n,i,k;

    // cin >> test;

    while(test--)
    {
        cin >> n >> k ;

        ll ar[n];

        for(i=0; i<n; i++) cin >> ar[i];

        for(i=k; i<n; i++)
        {
            if(ar[i]>ar[i-k])
                cout << "Yes\n";
            else
                cout << "No\n";
        }

    }


    return 0;
}

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

int a[101];

int main()
{
	int n,x,s=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=1;
	}
	
	for(int i=1;i<=100;i++)
	{
		if(a[i]==1) s++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

struct RollingHash
{
    vector<ll> hash, base; 
    ll b = 1007;
    RollingHash(vector<int> x)
    {
        hash.assign(x.size()+1, 0);
        base.assign(x.size()+1, 1);
        
        rep(i, 0, x.size())
        {
            hash[i+1] = (hash[i] * b + x[i]) % MOD;
            base[i+1] = (base[i] * b) % MOD;
        }
    }
    ll get_hash(int a, int b)
    {
        if (b < a) return 0;
        ll res = hash[b+1] - hash[a] * base[b-a+1] % MOD;
        if (res < 0) res+=MOD;
        return res;
    }
};


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

    vector<int> x(n);
    rep(i, 0, s.size())
        x[i] = s[i] - 'a';

    int ans = 0;
    RollingHash rf(x);
    rep(i, 0, n)
        for (int j = i; j < n; j++)
        {
            int l = 0;
            int r = n;
            while (l < r)
            {
                int mid = (l + r + 1) >> 1;
                if (i+mid-1<j and j+mid-1<n and rf.get_hash(i , i+mid-1 ) == rf. get_hash(j, j+mid-1))
                    l = mid;
                else
                    r = mid-1;
            }
            // cout << i << ' ' << j << ' ' << l << endl;
            ans = max(ans, l);
        }

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

Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().run();
	}
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int m = scan.nextInt();
			int a = scan.nextInt();
			if(n == 0 && m == 0 && a == 0){
				break;
			}
			Cross[] cr = new Cross[m];
			int maxHeight = 0;
			for(int i = 0;i < m;i++){
				int h = scan.nextInt();
				cr[i] = new Cross();
				cr[i].setCross(h,scan.nextInt(),scan.nextInt());
				if(h > maxHeight){
					maxHeight = h;
				}
			}
			for(int i = maxHeight;i > 0;i--){
				for(int j = 0;j < m;j++){
					if(cr[j].checkCross(i)){
						if(cr[j].checkPoint1(a)){
							a = cr[j].getPoint2();
						}else if(cr[j].checkPoint2(a)){
							a = cr[j].getPoint1();
						}
					}
				}
			}
			System.out.println(a);
		}
	}
	public class Cross{
		private int height;
		private int point1;
		private int point2;
		public Cross(){	
		}
		public void setCross(int height,int point1,int point2){
			this.height = height;
			this.point1 = point1;
			this.point2 = point2;
		}
		public boolean checkCross(int i){
			return (i == height)?true:false;
		}
		public boolean checkPoint1(int i){
			return (i == point1)?true:false;
		}
		public boolean checkPoint2(int i){
			return (i == point2)?true:false;
		}
		public int getPoint1(){
			return point1;
		}
		public int getPoint2(){
			return point2;
		}
	}
}

Measured memory_bytes: 62824
#include <bits/stdc++.h>
#define N 300010
#define mod 1000000007
using namespace std;
const int t[2][N]={{1,3,4,1,6,7,4,8,7},{2,0,5,1,2,5,4,5,7}};
int dp[N][10];
char s[N];
void dec(int &x){
	x+=x>>31&mod;
}
signed main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	dp[0][0]=1;
	for (int i=1;i<=len;++i){
		for (int j=0;j<=8;++j){
			if (s[i]!='1') dec(dp[i][t[0][j]]+=dp[i-1][j]-mod);
			if (s[i]!='0') dec(dp[i][t[1][j]]+=dp[i-1][j]-mod);
		}
	}
	dec(dp[len][5]+=dp[len][7]-mod);
	dec(dp[len][5]+=dp[len][8]-mod);
	dec(dp[len][5]+=dp[len][2]-mod);
	cout<<dp[len][5]<<endl;
	return 0; 
}       

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,m,x;
  cin >> n >> m >> x;
  int data[n][m+1];
  for(int i=0;i<n;i++){
    for(int j=0;j<m+1;j++){
      cin >> data[i][j];
    }
  }
  int money=1300000;
  for(int tmp=0;tmp<(1<<12);tmp++){
    bitset<12>s(tmp);
    int sum[m+1];
    for(int i=0;i<m+1;i++){
      sum[i]=0;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<m+1;j++){
        if(s.test(i)){
          sum[j]+=data[i][j];
        }
      }
    }
    bool q=true;
    for(int i=1;i<m+1;i++){
      if(sum[i]<x){
        q=false;
        break;
      }
    }
    if(q){
      money=min(money,sum[0]);
    }
  }
  if(money==1300000){
    cout << "-1" << endl;
  }
  else{
    cout << money << endl;
  }
}

Measured memory_bytes: 3628
# coding: utf-8
# Your code here!
while True:
    X,Y=map(int, input().split())
    if X==Y==0:
        break
    
    i=0
    if X<Y:
        X,Y=Y,X
    
    while Y!=0:
        X=X%Y
        X,Y=Y,X
        i+=1
    
    print(X, i)


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int main()
{
	string s;cin>>s;
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) cout<<"Bad"<<endl;
	else cout<<"Good";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1e9
 
int main()
{
    int N, a[100][100];
    int ans = -INF;
 
    scanf("%d" ,&N);
    for (int i = 0; i < N; i++) {
	for (int j = 0; j < N; j++) {
	    scanf("%d", &a[i][j]);
	    ans = max(ans, a[i][j]);
	}
    }
    for (int i = 0; i < N; i++) {
	int b[100] = {0};
	for (int j = i; j < N; j++) {
	    int sum = 0;
	    for (int k = 0; k < N; k++) {
		b[k] += a[j][k];
		sum = max(sum + b[k], 0);
		if(sum > 0) ans = max(ans, sum);
	    }
	}
    }
    printf("%d\n" ,ans);
    return 0;
}

Measured memory_bytes: 3232
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>
#include<limits.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	int N,K;
	scanf("%d %d",&N,&K);
	
	
	
	int ans[100] = {0} ;
	for(int i=0; i<K;i++ ){
		int d;
		scanf("%d",&d);
		for(int j=0; j<d; j++ ) {
			int check;
			scanf("%d",&check);
			ans[check-1] = 1;
		}
	}
	
	int sum = 0;
	for(int i=0;i<N;i++){
		if(ans[i] == 0)
		sum ++;
	}
	printf("%d",sum);
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(26);
	rep(i,n){
		string s;cin >> s;
		a.at(s.at(0)-'A')++;
	}
	int ans=0;
	sort(a.rbegin(),a.rend());
	while(true){
		bool flg=true;
		int cnt=0;
		rep(i,26){
			if(a.at(i)){
				a.at(i)--;
				cnt++;
			}
			if(cnt==k){
				flg=false;
				break;
			}
		}
		if(flg) break;
		ans++;
		sort(a.rbegin(),a.rend());
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

struct Data{
    int x, y, turn;
    Data(int x, int y, int turn):x(x),y(y),turn(turn) {}
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w, k; cin >> h >> w >> k;
    vector<vector<int>> maze(h, vector<int>(w, INF));
    int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; sx--; sy--; gx--; gy--;
    REP(i,h) REP(j,w){
        char c; cin >> c;
        if(c == '@') maze[i][j] = -1;
    }
    queue<Data> que;
    que.push({sx,sy,0});
    while(que.size()){
        int nx = que.front().x, ny = que.front().y, turn = que.front().turn; que.pop();
        REP(i,4){
            REPS(j,k){
                int x = nx + dx[i] * j, y = ny + dy[i] * j;
                if(!(x > -1 and x < h and y > -1 and y < w)) break;
                if(maze[x][y] <= turn) break;
                if(maze[x][y] > turn + 1){
                    que.push({x,y,turn+1});
                    maze[x][y] = turn + 1;
                }
            }
        }
    }
    cout << (maze[gx][gy] != INF ? maze[gx][gy] : -1) << endl;
}

Measured memory_bytes: 18784
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k,m;
  while(cin>>n>>k>>m,n||k||m) {
    queue<int> Q;
    FOR(i,1,n+1) Q.push(i);
    FOR(i,0,m) {
     int q = Q.front();
     Q.pop();
     if(i != m - 1) Q.push(q);
    }
    FOR(i,0,n-2) {
      FOR(j,0,k) {
        int q = Q.front();
        Q.pop();
        if(j != k - 1) Q.push(q);
      }
    }
    cout << Q.front() << endl;
  }
  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  map<int, vector<int>> mp;
  ll n, m;
  cin >> n >> m;
  vector<pair<int, int>> yp1, yp2;
  rep(i, m) {
    int p, y;
    cin >> p >> y;
    yp1.emplace_back(y, p);
    yp2.emplace_back(y, p);
  }

  sort(ALL(yp1));
  for (auto& p : yp1) {
    mp[p.second].push_back(p.first);
  }

  for (auto& p : yp2) {
    auto& v = mp[p.second];
    int num = int(lower_bound(ALL(v), p.first) - v.begin()) + 1;
    printf("%06d%06d\n", p.second, num);
  }

  return 0;
}


Measured memory_bytes: 14060
#include <bits/stdc++.h>
#define ll long long
 
using namespace std;
 
ll x,y,in;
 
int main(){
cin>>x>>y;
if(x<y){
cout<<x<<endl;
return 0;
}else if(x==y){
cout<<-1<<endl;
return 0;
}else{
if(x%y!=0){
cout<<x<<endl;
}else{
cout<<-1<<endl;
}
}
 
return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	long long N;
	cin >> N;

	long long sum = 0;
	for (long long i = 1; i <= N; ++i)
	{
		if ((i % 3 == 0) || (i % 5 == 0)) {
			
		}
		else {
			sum += i;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
#define INF (1000000000000)
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  ll V, E;
  cin >> V >> E;
  vector< vector< ll > > dist(V, vector<ll> (V, INF));
  for(ll i = 0; i< V; i++)
    dist[i][i] = 0;
  for(ll i = 0; i < E; i++){
    ll s,t,d;
    cin >> s >> t >> d;
    dist[s][t] = d;
  }
  for(ll i = 0; i < V; i++)
    for(ll j = 0; j < V; j++)
      for(ll k = 0; k < V; k++){
	dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }

  bool negative = false;
  for(ll i = 0; i < V; i++)
    if(dist[i][i] < 0)
      negative = true;

  if(negative == true){
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }

  for(ll i = 0; i < V; i++){
    for(ll k = 0; k < V; k++){
      if(k != 0)
	cout << ' ';
      if(dist[i][k] >= INF / 10)
	cout << "INF";
      else
	cout << dist[i][k];
    }
    cout << endl;
  }

    

}

Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll a,b,ans=10001;
    cin>>a>>b;
    for(ll i=10000;i>0;i--){
        if(i*8/100==a&&i*10/100==b){
            ans=i;
        }
    }
    cout<<(ans==10001?-1:ans)<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
b = [int(number) for number in input().split(' ')]

a = [0] * n

for i in range(len(a)):
  if i == 0:
    a[i] = b[i]
  elif i == len(a) -1:
    a[i] = b[i - 1]
  else:
    a[i] = min((b[i], b[i - 1]))

print(sum(a))

Measured memory_bytes: 38384
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let reader=readInts()
let n=reader[0]
var p=readInts()
var sorted=p
sorted.sort { $0 < $1 }
var diff=0

for i in 0..<n{
  if p[i] != sorted[i]{diff+=1}
}

if diff==2||diff==0{print("YES")}else{print("NO")}

Measured memory_bytes: 13744
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
	
	ios::sync_with_stdio(false);
    cin.tie(0);
    
    string ans;
    int n;
    cin>>n;
	switch(n % 10){
		case 2: case 4: case 5: case 7: case 9:
			cout<<"hon";
			break;
		case 0: case 1: case 6: case 8:
			cout<<"pon";
			break;
		case 3: 
			cout<<"bon";
			break;	
	}
    
    //cout<<ans;
    
	return 0;
}

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

vector<vector<int>> t;
int n;
vector<pair<int,int>> nn;

bool check(int a,int b){
    int aw=0,al=0;
    int bw=0,bl=0;
    for(int i=0;i<n;i++){
        if(t[a][i]==1)aw++;
        if(t[a][i]==-1)al++;
        if(t[b][i]==1)bw++;
        if(t[b][i]==-1)bl++;
    }
    if(aw>(n-1)/2||al>(n-1)/2||bw>(n-1)/2||bl>(n-1)/2){
        return false;
    }else{
        return true;
    }
}

int dfs(int id){
    int x=nn[id].first;
    int y=nn[id].second;
    id++;
    int ans=0;
    if(t[x][y]!=0){
        if(check(x,y)){
            if(id==nn.size()){
                ans+=1;
            }else{
                ans+=dfs(id);
            }
        }
    }else{
        t[x][y]=1;
        t[y][x]=-1;
        if(check(x,y)){
            if(id==nn.size()){
                ans+=1;
            }else{
                ans+=dfs(id);
            }
        }
        t[x][y]=-1;
        t[y][x]=1;
        if(check(x,y)){
            if(id==nn.size()){
                ans+=1;
            }else{
                ans+=dfs(id);
            }
        }
        t[x][y]=0;
        t[y][x]=0;
    }
    return ans;
}

int main(){

    while(1){
        int m;
        cin >> n;
        if(n==0)break;
        cin >> m;
        t.clear();
        t.resize(n,vector<int>(n,0));
        nn.clear();
        for(int i=1;i<n;i++){
            for(int j=0;j<i;j++){
                nn.push_back({i,j});
            }
        }
        for(int i=0;i<m;i++){
            int x,y;
            cin >> x >> y;
            x--;y--;
            t[x][y]=1;
            t[y][x]=-1;
        }
        int ans=dfs(0);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;



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

	ll H,N;
	cin >> H >> N;

	vector<ll> A(N);
	rep(i, N) {
		cin >> A[i];
	}

	sort(A.begin(), A.end());

	ll sum = 0;
	rep(i,N) {
		sum += A[i];
	}


	if (sum >= H) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
 
int main(void) {
    int h[300],w[300];
    int a,b,c,d,i,n;
    a=0;
    b=0;
    while(1){
    	scanf("%d %d",&h[a],&w[b]);
    	c=h[a];
    	d=w[b];
    	if(c==0&&d==0){
    		break;
    	}
    	for(i=0;i<c;i++){
    		for(n=0;n<d;n++){
    			if(n==0||n==d-1||i==0||i==c-1){
    			printf("#");
    		}else{
    			printf(".");
    		}
    		}
    		printf("\n");
    	}
    	printf("\n");
    	a++;b++;
    }
	return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    
     int x,a,b;
     int ans[10000];
     cin>>x>>a>>b;
     ans[0]=x-a;
     int i=0;
    while(ans[i]>=0){
        ans[i+1]=ans[i]-b;
        i++;
    }

     cout<<ans[i-1]<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
typedef long long ll;
static const ll maxLL = (ll)1 << 62;

int n,m,ans=0;
const int nmax=8;
int a[nmax],b[nmax];
bool graph[nmax][nmax];
bool all_visited=true;

int dfs(int v,int n,bool visited[nmax]){
    bool all_visited=true;
    
    rep(i,0,n){
        if(visited[i]==false)all_visited=false;
    }
    if(all_visited)return 1;
    
    int ret=0;
    
    rep(i,0,n){
        if(graph[v][i]==false)continue;
        if(visited[i])continue;
        
        visited[i]=true;
        ret+=dfs(i,n,visited);
        visited[i]=false;
    }
    return ret;
}

int main(){
    int n,m;
    cin>>n>>m;
    
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        graph[a-1][b-1]=graph[b-1][a-1]=true;
    }
    
    bool visited[nmax];
    rep(i,0,n)visited[i]=false;
    
    visited[0]=true;
    cout<<dfs(0,n,visited)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{  
    string s,ans;
    int k,i;
    
    cin>>s>>k;
    
    for(;i<s.size();i++){
           
    if(s.at(i)!='1')
    {
        ans = s.at(i);
        break;
    }
    
    }
        
    if(i+1>k) ans='1';
    
    cout<<ans<<endl;
         
    return 0;
    
}

Measured memory_bytes: 256
n, a, b, c = gets.split.map(&:to_i)
lengths = n.times.map{ gets.to_i }

arr = [0, 1, 2, 3]
(n-1).times do
    arr = arr.product([0,1,2,3]).collect{ |set| set.flatten }
end

ans = 10000000
arr.select{ |set| set.include?(1) && set.include?(2) && set.include?(3) }.each do |set|
    aa = 0
    bb = 0
    cc = 0
    count = [0, 0, 0]
    set.each_with_index do |len, i|
        if len == 1
            aa += lengths[i]
            count[len - 1] += 1
        elsif len == 2
            bb += lengths[i]
            count[len - 1] += 1
        elsif len == 3
            cc += lengths[i]
            count[len - 1] += 1
        end 
    end
    total = (aa - a).abs + (bb - b).abs + (cc - c).abs + (count.reduce(:+) - 3) * 10
    if ans > total
        ans = total
    end
end
puts ans
    

Measured memory_bytes: 34040
#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define min 0.000001
using namespace std;

int main(){
  while(1){
    int m;
    cin>>m;
    if(!m)break;
    double Asum=0;
    double cnt;
    int sum=0;
    rep(i,m-1){
      cin>>cnt;
      Asum+=sin(cnt*M_PI/180.0)/2;
      sum+=cnt;
    }
    Asum+=sin((360-sum)*M_PI/180.0)/2;
    double Bsum=0;
    int n;
    cin>>n;
    sum=0;
    rep(i,n-1){
      cin>>cnt;
      Bsum+=sin(cnt*M_PI/180.0)/2;
      sum+=cnt;
    }
    Bsum+=sin((360-sum)*M_PI/180.0)/2;
    double rest=abs(Asum-Bsum);
    if(rest<min)cout<<0<<endl;
    if(rest>=min && Asum>Bsum)cout<<1<<endl;
    else if(rest>=min && Bsum>Asum)cout<<2<<endl;
  }
  return 0;
}

Measured memory_bytes: 1264
#include "bits/stdc++.h"
using ll = long long;
using namespace std;


void solve() {
   int n;
   cin >> n;
   vector <int> v(n);
   for(auto &e: v) {
      cin >> e;
   }
   sort(v.begin(), v.end());
   int x = v.size() / 2;
   cout << v[x] - v[x - 1] << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3744
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $L = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  $S = "abcdefghijklmnopqrstuvwxyz";

  if(str_replace($n, "", $L) == $L){
    echo "a";
  }else{
    echo "A";
  }

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

int main() {
    int N;
    int A;
    cin >> N;
    cin >> A;
    if(N%500 <= A){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int dp[41][400][400] = {};
int main()
{
  int n, ma, mb;
  pair<pair<int, int>, int> p[41];
  cin >> n >> ma >> mb;
  FOR(i, 1, n + 1)
  {
    int a, b, c;
    cin >> a >> b >> c;
    p[i] = make_pair(make_pair(a, b), c);
  }
  REP(i, n + 1)
  {
    REP(j, 400)
    {
      REP(k, 400)
      {
        dp[i][j][k] = 40000;
      }
    }
  }

  dp[0][0][0] = 0;
  FOR(i, 1, n + 1)
  {
    REP(j, 400)
    {
      REP(k, 400)
      {
        dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k]);
        if (j - p[i].first.first >= 0 && k - p[i].first.second >= 0)
          dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - p[i].first.first][k - p[i].first.second] + p[i].second);
      }
    }
  }

  int ans = 40000;
  FOR(a, 1, 400)
  {
    FOR(b, 1, 400)
    {
      if (ma * b == mb * a)
      {
        ans = min(ans, dp[n][a][b]);
      }
    }
  }

  if (ans == 40000)
  {
    cout << -1 << endl;
  }
  else
  {
    cout << ans << endl;
  }
}


Measured memory_bytes: 25856
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	long sum = 0;
	rep(i,1,N+1){
		if(i % 3 != 0 && i % 5 != 0) sum += i;
	}cout<<sum<<endl;
}


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

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define DEBUG(x) { cout << #x << " = "; cout << (x) << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }

#define sqr(x) ((x) * (x))

#define ll long long int
#define MOD 1000000007
#define MN 200005
#define foru(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)


using namespace std;
void checkDefine();

ll n;
string a, b, c;
map<char, ll> m;

int main() {
	cin >> n;
	cin >> a >> b >> c;
	ll kq = 0;
	FOR(i, 0, n - 1){
		m[a[i]]++;
		m[b[i]]++;
		m[c[i]]++;
		ll res = 0;
		FOR(j, 0, 25){
			char c = (char)(j + 'a');
			if(m[c] > 0){
				res++;
			}
		}		
		if(res == 1){
			m[a[i]] = 0;
			m[b[i]] = 0;
			m[c[i]] = 0;
		}
		else if(res == 2){
			kq += 1;
			m[a[i]] = 0;
			m[b[i]] = 0;
			m[c[i]] = 0;
		}
		else if(res == 3){
			kq += 2;
			m[a[i]] = 0;
			m[b[i]] = 0;
			m[c[i]] = 0;
		}
	}	
	cout << kq;
	return 0;
}



void checkDefine(){
	ll n, a[MN];
	map<ll, ll> m;
	cin >> n;
	FOR(i, 0, n - 1) {
		cin >> a[i];
		m[a[i]]++;
	}

	string s; cin >> s;
	DEBUG(s);
	PR0(a, n);
	DEBUG("------------");
	EACH(it, m){
		cout << it->first << " " << it->second << endl;
	}
	//if(s.find("abc") != npos) // found
}
	




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, a, b) for(int i=(a); i<(int)(b); i++)

typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct Node { int from, to, cost; };

int dx[] ={-1, 0, 0, 1};
int dy[] ={0, -1, 1, 0};

int main(void){
	ll n, abcde[5];
	cin >> n;
	n--;
	rep(i, 5){
		cin >> abcde[i];
		if(i != 0){
			abcde[i] = min(abcde[i], abcde[i-1]);
		}
	}

	ll ans = 0;
	rep(i, 5){
		ll need = n / abcde[i];
		ans = max(ans, need+5);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# include "iostream"
# include "cstdio"
# include "algorithm" 

using namespace std;

const int maxm=1000+10; 

int n,	//n个蛋糕 
	m; 	//取出m个蛋糕 

long long 
	dp[9][maxm], 
	ans,now; 

int main(){
	long long x,y,z;
	register int i,j; 
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%lld%lld%lld",&x,&y,&z); 
		dp[1][i]=x+y+z; 
		dp[2][i]=x+y-z;
		dp[3][i]=x-y+z;
		dp[4][i]=-x+y+z;
		dp[5][i]=x-y-z;
		dp[6][i]=-x-y+z;
		dp[7][i]=-x+y-z;
		dp[8][i]=-x-y-z;
	}
	for(i=1;i<=8;i++){
		sort(dp[i]+1,dp[i]+1+n,greater<long long>());
		now=0; 
		for(j=1;j<=m;j++){
			now+=dp[i][j]; 
		}
		ans=max(ans,now); 
	}
	printf("%lld",ans); 
	return 0; 
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<stdio.h>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109311;
const long double pi = 3.1415926535897932384626433;
typedef pair<int, int> P;
struct edge { int to, cost; };

signed main() {
	int h, w, s, t; cin >> h >> w >> s >> t;
	if ((h & 1) && (w & 1)) {
		if ((s + t) & 1) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>
#include<string>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a;
	for (int i = 0; i < h; ++i) {
		string b;
		cin >> b;
		a.push_back(b);
	}
	for (int i = 0; i < h; ++i) {
		cout << a[i] << endl;
		cout << a[i] << endl;
	}
	return 0;
}

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

int main(){
  ll h,w; cin >> h >> w;
  vector<vector<string>> map(h+2,vector<string>(w+2));
  rep(i,h+2) rep(j,w+2) map.at(i).at(j) = ".";
  rep(i,h+2){
    if(i==0||i==h+1) continue;
    rep(j,w+2){
      if(j==0||j==w+1) continue;
      char tmp; cin >> tmp;
      map.at(i).at(j) = tmp;
    }
  }
  
 for(int i=1; i<h+1; i++){
   for(int j=1; j<w+1; j++){
     if(map.at(i).at(j)=="#"){
       cout << map.at(i).at(j);
     }else{
       //周辺マス地雷探査
       int jirai = 0;
       for(int m=i-1;m<=i+1;m++) for(int n=j-1;n<=j+1;n++) if(map.at(m).at(n)=="#") jirai++;
       cout << jirai;
     }
   }
   cout << endl;
 }
}

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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		int n;
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());
		n = (1000 - (n % 1000));
		System.out.println((n == 1000)? 0: n);  
	}

}


Measured memory_bytes: 32508
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;

void main() {
	int n = to!int(readln().strip());
	int m = to!int(readln().strip());
	int[20][20] g;
	foreach(i; 0..20) {
		foreach(j; 0..20) {
			g[i][j] = int.max/100;
		}
	}
	foreach(i; 0..m) {
		auto s = map!(a => to!int(a))(readln().strip().split(","));
		int a = s[0]-1;
		int b = s[1]-1;
		int c = s[2];
		int d = s[3];
		g[a][b] = c;
		g[b][a] = d;
	}
	auto s = map!(a => to!int(a))(readln().strip().split(","));
	int x1 = s[0]-1;
	int x2 = s[1]-1;
	int y1 = s[2];
	int y2 = s[3];
	foreach(k; 0..n) {
		foreach(i; 0..n) {
			foreach(j; 0..n) {
				g[i][j] = min(g[i][j], g[i][k]+g[k][j]);
			}
		}
	}
	writeln(y1-y2-g[x1][x2]-g[x2][x1]);
}

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

int main(){
    int N, M, L, Q;
    std::cin >> N >> M >> L;
    std::vector< std::vector< int > > AB(N);
    std::vector< std::vector< int > > ABC(N, std::vector< int >(N, -1));
    for(int i=0; i<M; i++){
        int tmpa, tmpb, tmpc;
        std::cin >> tmpa >> tmpb >> tmpc;
        tmpa--;
        tmpb--;
        AB[tmpa].push_back(tmpb);
        AB[tmpb].push_back(tmpa);
        ABC[tmpa][tmpb] = tmpc;
        ABC[tmpb][tmpa] = tmpc;
    }
    std::cin >> Q;
    std::vector< int > S(Q);
    std::vector< int > T(Q);
    for(int i=0; i<Q; i++){
        std::cin >> S[i] >> T[i];
        S[i]--;
        T[i]--;
    }
    
    std::vector< std::vector< long long > > StoTmin(N, std::vector< long long >(N, 1e18+1));
    for(int i=0; i<N; i++){
        std::priority_queue< std::pair< long long, int >, std::vector< std::pair< long long, int > >, std::greater< std::pair< long long, int > >  > pq;
        std::vector< long long > min_cost(N, 1e18+1);
        pq.push(std::pair< long long, int >(0, i));
        int cnt = 0;
        while(!pq.empty()){
            std::pair< long long, int > cost_pos = pq.top();
            pq.pop();
            
            if(min_cost[cost_pos.second] != 1e18+1){
                continue;
            }
            
            min_cost[cost_pos.second] = cost_pos.first;
            cnt++;
            if(cnt == N){
                break;
            }
            
            for(int j=0; j<AB[cost_pos.second].size(); j++){
                long long cost_tmp1 = cost_pos.first / (long long)1e10;
                long long cost_tmp2 = cost_pos.first % (long long)1e10 + ABC[cost_pos.second][AB[cost_pos.second][j]];
                if(ABC[cost_pos.second][AB[cost_pos.second][j]] > L){
                    continue;
                }
                if(cost_tmp2 > L){
                    cost_tmp1++;
                    cost_tmp2 = ABC[cost_pos.second][AB[cost_pos.second][j]];
                }
                //std::cout << " " << i << " " << cost_pos.second << " " << AB[cost_pos.second][j] << " " << cost_tmp1 << " " << cost_tmp2 << std::endl;
                long long cost_tmp = cost_tmp1 * (long long)1e10 + cost_tmp2;
                
                pq.push(std::pair< long long, int >(cost_tmp, AB[cost_pos.second][j]));
            }
        }
        for(int j=0; j<N; j++){
            StoTmin[i][j] = min_cost[j];
        }
    }
    
    for(int i=0; i<Q; i++){
        if(StoTmin[S[i]][T[i]] == 1e18+1){
            std::cout << -1 << std::endl;
        }else{
            std::cout << StoTmin[S[i]][T[i]] / (long long)1e10 << std::endl;
        }
    }
    
    return 0;
    
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  char X,Y;
  cin >> X >> Y;
  
  if(X>Y) cout << ">" << endl;
  else if(X<Y) cout << "<" << endl;
  else cout << "=" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int first, second, largest;
    scanf("%d %d %d", &first, &second, &largest);
    int big, small;

    if(first>second){
        big = first;
        small = second;
    }
    else{
        int tmp;
        tmp = first;
        big = second;
        small = tmp;
    }
    //printf("big is %d, small is %d", big, small);
    int i, count=0;
    for(i=small; i>0; i--){
        if(big%i==0 && small%i==0){
            count++;
            if(count == largest){
                printf("%d", i);
                break;
            }
        }
    }
}

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

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            string s = Console.ReadLine();
            int len = s.Length;

            Console.WriteLine(s[0].ToString() + (len - 2).ToString() + s[len - 1].ToString());


        }
    }
}


Measured memory_bytes: 11092
import math
import collections
from operator import mul
from functools import reduce



n=int(input())
s=input()
#v=list(map(int,input().split()))
e=[0]*(n+2)
w=[0]*(n+2)
for i in range(1,n+1):
    if s[i-1]=="W":
        e[i]=1
    e[i]+=e[i-1]
for i in range(1,n+1)[::-1]:
    if s[i-1]=="E":
        w[i]=1
    w[i]+=w[i+1]

m=100000000000000
for i in range(1,n+1):
    m=min(m,(e[i-1])+(w[i+1]))
print(m)


Measured memory_bytes: 46692
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int B[99];
int main(){
  int i;
  int res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N-1);Lj4PdHRW++){
      rd(B[Lj4PdHRW]);
    }
  }
  res = B[0] + B[N-2];
  for(i=(1);i<(N-1);i++){
    res +=min_L(B[i-1], B[i]);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190914-1

// --- original code ---
// int N, B[99];
// {
//   int res;
//   rd(N,B(N-1));
//   res = B[0] + B[N-2];
//   rep(i,1,N-1) res += min(B[i-1],B[i]);
//   wt(res);
// }


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

int main()
{
  int A, B, C, X, Y;
  std::cin >> A >> B >> C >> X >> Y;
  int n_a = 0;
  int n_b = 0;
  long min = 2 * 5000 * 10 * 10 * 10 * 10 * 10;

  for ( int n_ab = 0, limit = std::max(2*X, 2*Y); n_ab <= limit; n_ab += 2 ) {
    int total = std::max(A * (X - n_ab/2), 0) + std::max(B * (Y - n_ab/2), 0) + C * n_ab;
    if (total < min) {
      min = total;
    }
  }

  std::cout << min << std::endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a;
	cin >> n >> a;
	cout << n * n - a << "\n";
	return 0;
}


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


int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    int nokori = a - b;
    cout << c - min(c,nokori) << endl;
}


Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long double min(long double a, long double b)
{
    return a < b ? a : b;
}

int main(void)
{
    intmax_t A, B, H, M;
    double degree, ans = 0;
    const double PI = 3.14159265358979323846264338327950288;

    scanf("%jd%jd%jd%jd", &A, &B, &H, &M);

    degree = fabs(0.5 * ((60 * H) + M) - 6 * M);
    degree = min(360 - degree, degree);

    ans = sqrt(A * A + B * B - 2 * A * B * cos(degree * PI / 180));

    printf("%.10f\n", ans);

    return 0;
}


Measured memory_bytes: 2628
#ceilevenoddformula
import math
from queue import PriorityQueue
import bisect
import copy
import time
from collections import Counter
#map(int,input().split())
#int(x) for x in input().split()
n,d=map(int,input().split())
c=0
for i in range(n):
	a,b=map(int,input().split())
	x=math.sqrt(a**2+b**2)
	if x<=d:
		c+=1
print(c)



















 
          





























Measured memory_bytes: 72108
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

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

    int n;
    cin >> n;
    int cc = 0;
    bool ok = false;
    for (int i = 0; i < n;++i){
        int x, y;
        cin >> x >> y;
        if(x==y)
            cc++;
        else
            cc = 0;
        if(cc==3)
            ok = true;
    }

    if(ok)
        cout << "Yes";
    else
        cout << "No";

        return 0;
}


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

int main(){
    
    int n,k;
    cin >> n >> k;
    long double win=n;
    long double sum=0;
    long double num;
    win=1/win;

    for(int i=1; i<=n; i++){
        num=1.0;
        while(i*num<k){
            num*=2.0;
        }
        sum+=win/num;
        //cout << sum << endl;
    }
    cout << fixed << setprecision(15) << sum << endl;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define int long long int


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b and b==c)
		cout<<"No"<<endl;
	else if(a!=b && b!=c && c!=a)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#encoding utf-8
import math

def isAnswer(a, b, X):
    return int(math.pow(a, 5) - math.pow(b, 5)) == X

def pow5(x):
    if x < 0:
        return -1 * math.pow(abs(x), 5)
    return math.pow(x, 5)

def resolver(X):
    for b in range(-300, 300):
        a5 = X + pow5(b)
        if a5 < 0:
            continue
        a = int(math.pow(a5, 0.2))
        if isAnswer(a, b, X):
            return a, b 
    return 0, 0

def main():
    X = int(input())
    a,b = resolver(X)
    print(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9448
#include<cstdio>
using namespace std;
typedef long long LL;
LL X,W;char ch;
inline LL read()
{
	X=0,W=1;ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')W=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){X=(X<<1)+(X<<3)+ch-48;ch=getchar();}
	return X*W;
}
LL mod(LL p)
{
	if(p%4==1)return 1;
	if(p%4==3)return 0;
	if(p%4==2)return p+1;
	else return p;
}
LL a,b;
int main()
{
	LL n,m;
	n=read(),m=read();
	if(n==0)n++;
	a=mod(n-1),b=mod(m);
	printf("%lld",a^b);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
   
#define LOOPOUT (0)
#define CHECK_NUM (1)
#define INCLUDE3 (2)
#define END_CHECK_NUM (3)
   
void call(int n){
  int i = 1;
  int x = i;
  int f = CHECK_NUM;
while (f)
{
switch (f)
{
case CHECK_NUM:
  x = i;
  if ( x % 3 == 0 ){
    printf(" %d", i);
    f = END_CHECK_NUM;
    break;
  }
case INCLUDE3:
  if ( x % 10 == 3 ){
    printf(" %d", i);
    f = END_CHECK_NUM;
    break;
  }
  x /= 10;
  if ( x ) { f = INCLUDE3; break; }
case END_CHECK_NUM:
  if ( ++i <= n ) f = CHECK_NUM;
  else f = LOOPOUT;
  break;
default:
  break;
}
}
  putchar('\n');
}
   
int main(void)
{
int n;
scanf("%d", &n);
call(n);
return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void)
{
	int w;
	int line[30];
	int n;
	int i;
	int a, b, buf;
	
	scanf("%d", &w);
	for (i = 0; i < w; i++){
		line[i] = i + 1;
	}
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d,%d", &a, &b);
		
		buf = line[a - 1];
		line[a - 1] = line[b - 1];
		line[b - 1] = buf;
	}
	
	for (i = 0; i < w; i++){
		printf("%d\n", line[i]);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const ll inf=998244353;

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

int main()
{
    ll x, k, d;
    scanf("%lld%lld%lld",&x,&k,&d);
    x=x+1000000000000000;
    ll pa=k;
    k=0+1000000000000000;
    if(k<x)
    {
        swap(k,x);
    }
    ll ju=k-x, ans=0;
    if(ju/d>=pa)
    {
        printf("%lld\n",ju-d*pa);
    }
    else
    {
        ll bi=ju/d;
        //printf("%lld %lld\n",bi,ju);
        ll y=bi*d, y2=(bi+1)*d;
        if((pa-bi)%2==0)
        {
            printf("%lld\n",ju-y);
        }
        else
        {
            printf("%lld\n",y2-ju);
        }
    }
    return 0;
}


Measured memory_bytes: 3824