akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// #define amari(x) ((x) % 1000000007)
#define amari(x) ((x) % 998244353)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(long i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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


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

  long a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k%2) {
    if (b-a > 1e18) {
      cout << "Unfair" << endl;
    } else {
      cout << b-a << endl;
    }
  } else {
    if (a-b > 1e18) {
      cout << "Unfair" << endl;
    } else {
      cout << a-b << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		if(x < 1200) {
			System.out.println("ABC");
		}else {
			System.out.println("ARC");
		}

	}

}

Measured memory_bytes: 21588
n = int(input())
ans = 0
a = list(map(int,input().split()))
now = a[0]
cnt = 1
p = []
for i in range(n-1):
    if now == a[i+1]:cnt+=1
    else:
        p.append(cnt)
        now = a[i+1]
        cnt = 1
p.append(cnt)
for x in p:
    ans+=x//2
print(ans)
    
 

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

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var d = input[0];
            var t = input[1];
            var s = input[2];

            var minute = (double)d / s;
            if(minute <= t)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 28292
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
long long A[100002];
int main(){
        REP(i,100002){
           A[i]=0;
        }
	int N;
	cin>>N;
	REP(i,N){
	   cin>>A[i];
	}
	long long ans=0;
	REP(i,N){
	    ans+=A[i]/2;
	    if(A[i]%2==1&&A[i+1]>0){
	       ans++;
	       A[i+1]--;
	    }
	}
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

int main() {
    int n;
    vector<double> ansarr;
    while(true){
        cin>>n;
        if(n==0) break;
        double x[n], y[n], z[n], r[n];
        for(int i=0;i<n;++i){
            cin>>x[i]>>y[i]>>z[i]>>r[i];
        }
        vector<vector<pair<int, double> > > edge(n);
        double zero = 0;
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                if(i==j) continue;
                edge[i].push_back(mp(j, max(zero, sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2) + pow(z[i] - z[j], 2)) - r[i] - r[j])));
            }
        }
        priority_queue<pair<double, int>, vector<pair<double, int> >, greater<pair<double, int> > > que;
        que.push(mp(0, 0));
        pair<double, int> state;
        double dist;
        int town;
        double DP[n];

        for(int i=0;i<n;++i){
            DP[i] = -1;
        }

        while(!que.empty()){
            state = que.top();que.pop();
            dist = state.fi;
            town = state.se;
            if(DP[town] != -1) continue;
            DP[town] = dist;
            for(int i=0;i<edge[town].size();++i){
                if(DP[edge[town][i].fi] != -1) continue;
                que.push(mp(edge[town][i].se, edge[town][i].fi));
            }
        }
        double ans = 0;
        for(int i=0;i<n;++i){
            ans += DP[i];
        }
        ansarr.push_back(ans);
    }
    for(int i=0;i<ansarr.size();++i){
        cout<<fixed<<setprecision(3)<<ansarr[i]<<endl;
    }
}




Measured memory_bytes: 3476
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k= int(input())
data_list = [a,b,c,d,e]
if max(data_list)-min(data_list)<=k:
    print('Yay!')
else:
    print(':(')

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

int main(){
  int n;
  cin >> n;
  int x;
  vector<long long> X;

  for(int i=0;i<n;i++){
    cin >> x;
    X.push_back(x);
  }

  int min=X[0],max=X[0];
  long sum=0;

  for(int i=0;i<X.size();i++){
    sum+=X[i];
    if(X[i]<min) min=X[i];
    if(X[i]>max) max=X[i];
  }

  cout << min << " " <<max << " " << sum << endl;

  return 0;
}



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

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];
        public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        for(int i = 1;i < 1000;i++){
            if(a<=k*i&&k*i<=b){
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }
    
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll bfs(ll h, ll w){
  ll diff = h*w;
  //atleast 1 length of edge
  REP1(a, w){
    if((w-a) % 2 == 0)
      diff = min(diff, abs((w-a)*h/2 - h*a));
    else{
      ll shorter = min(h*a, h*((w-a-1)/2));
      ll longer = max(h*a, h*((w-a-1)/2+1));
      diff = min(diff, abs(longer - shorter));
    }
  }

  REP1(a, w){
    if(h % 2 == 0)
      diff = min(diff, abs((w-a)*h/2 - h*a));
    else{
      ll shorter = min(h*a, (h-1)/2*(w-a));
      ll longer = max(h*a, ((h-1)/2+1)*(w-a));
      diff = min(diff, abs(longer - shorter));
    }
  }

  return diff;
}

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

  ll h, w;
  cin >> h >> w;

  //cout << bfs(h, w) << endl;
  //cout << bfs(w, h) << endl;
  cout << min(bfs(h, w), bfs(w, h)) << endl;

  
  
}


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

int main()
{
	int size = 10;
	int n;  cin >> n;

	vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; }

	
	for (int i = 0; i < n; i++) { 
	
		vector<char> tmp(size);

		for (int j = 0; j < size; j++) { 
			tmp[j] = s[i][j]; 
		}

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

		for (int j = 0; j < size; j++) {
			s[i][j] = tmp[j];
		}

	}


	sort(s.begin(), s.end());
		
	long long ans = 0;
	for (int i = 0; i < n - 1; ) {
	
		long long tmp_ans = 0;
		long long tmp_cnt;
		for (int j = 1; i + j < n; j++) {

			if (s[i] == s[i + j]) {

				if (j == 1) {
					tmp_ans = 1;
					tmp_cnt = 2;
				}
				else {
					tmp_ans += tmp_cnt;
					tmp_cnt++;
				}
			}
			else {
				ans += tmp_ans;
				i += j;
				break;
			}
			
			if (i + j == n - 1) {
				ans += tmp_ans;
				i += j;
			}
		}	

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    REV(s);
    int n = sz(s);
    int p = 0;
    while (p < n) {
	if (s[p] != 'm' and s[p] != 'r' and s[p] != 'e') break;
	if (s[p] == 'm') {
	    if (p + 4 >= n or s.substr(p, 5) != "maerd") break;
	    p += 5;
	} else if (s[p] == 'e') {
	    if (p + 4 >= n or s.substr(p, 5) != "esare") break;
	    p += 5;
	} else if (s[p] == 'r') {
	    if (p + 5 < n and s.substr(p, 6) == "resare") {
		p += 6;
	    } else if (p + 6 < n and s.substr(p, 7) == "remaerd") {
		p += 7;
	    } else {
		break;
	    }
	}

	if (p == n) {
	    cout << "YES" << endl;
	    return;
	}
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 3788
n = int(input())
w = [input() for _ in range(n)]
w_used = set()
pre_word = ""
for i in range(n):
    if i == 0:
        pre_word = w[i]
        w_used.add(w[i])
        continue
    if pre_word[-1] != w[i][0] or w[i] in w_used:
        print("No")
        break
    w_used.add(w[i])
    pre_word = w[i]
else:
    print("Yes")

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

set<string> st;

void solve(){
	st.insert("hi");
	st.insert("hihi");
	st.insert("hihihi");
	st.insert("hihihihi");
	st.insert("hihihihihi");
	string s;
	cin >> s;
	if (st.find(s) != st.end()) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,C;cin>>A>>B>>C;
  cout << 9*max({A,B,C})+A+B+C<<endl;
  return 0;
}


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

int main() {
  double a, b;
  cin >> a >> b;
  double la = a/0.08;
  double lb = b/0.1;
  double ra = (a+1)/0.08;
  double rb = (b+1)/0.1;
  double l = max(la, lb);
  double r = min(ra, rb);
  int n = ceil(l);
  if (n < r) {
    cout << n << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 300005
using namespace std;

int main()
{
    FLASH
    ll n;
    cin >> n;
    ll ans = (n + 999) / 1000;
     ans = ans * 1000;
    cout << (ans - n);
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll s;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    ll ok=1e9, ng=0;
    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        if(mid*mid>=s) ok=mid;
        else ng=mid;
    }
    if(ok*(ok-1)>=s){
        cout <<0<<" "<<0<<" "<< ok<<" "<< 1<<" "<< ok*(ok-1)-s<<" "<<ok-1<<"\n";
    }
    else{
        cout <<0<<" "<<0<<" "<< ok<<" "<< 1<<" "<< ok*ok-s<<" "<<ok<<"\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int gcd(int a,int b){
   if(a%b==0) return b;
   return gcd(b,a%b);
}
int digit(long long num){
   int cnt=0;
   while(num!=0){
      cnt+=num%10;
      num=num/10;
   }
   return cnt;
}
int main(void){
   string N;
   cin>>N;
   int L=N.size();
   bool flag=true;
   for(int i=1;i<L;i++){
      if(N[i]!='9') flag=false;
   }
   int c=N[0]-'0';
   if(flag) cout<<c+9*(L-1)<<endl;
   else cout<<c+9*(L-1)-1<<endl;
   return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(){
	char s[1005];
	scanf("%s",s);
	int i=0;
	while(s[i]!='\0') i++;
	if(s[i-1]=='s') s[i]='e',s[i+1]='s',s[i+2]='\0';
	else s[i]='s',s[i+1]='\0';
	printf("%s",s);
	return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n >= 3 && n <= 10000) {
			int i = 1;
			int x, a, b, c;
			for (i = 1; i <= n; i++) {
				x = i;
				if (x % 3 == 0) {
					System.out.print(" " + x);
				} else {
					while (true) {
						if (x % 10 == 3) {
							System.out.print(" " + i);
							break;
						}
						x /= 10;
						if (x != 0)
							continue;
						else
							break;
					}
				}
			}

			System.out.printf("\n");
			sc.close();
		}
	}
}

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

int main(){
    int N,D;cin >> N>>D;
    int x[N][D];
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++)
        cin >> x[i][j];
    }
    int l[N*(N-1)/2]; int m=0;
    for(int i=0;i<N*(N-1)/2;i++) l[i]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i>j){
                for(int k=0;k<D;k++){
                    l[m]+=pow(x[i][k]-x[j][k],2);                 
                }
                m++;
            }
        }
    }
    int X=sqrt(D)*40;
    int count=0;
    for(int i=0;i<N*(N-1)/2;i++){
        for(int m=1;m<=X;m++){
            if(m*m==l[i]){
                count++;
                break;
            }
        }

    }
    cout << count << endl;
}

Measured memory_bytes: 3652
def solve(arr, target):
	dict = {}
	return solve_rec(0, arr, target, dict)

def solve_rec(i, arr, target, dict):

	res = False

	key = str(i) + '-' + str(target)
	if key in dict:
		res = dict[key]
	elif target == 0:
		res = True
	elif i >= len(arr):
		res = False
	else:
		res1 = solve_rec(i + 1, arr, target, dict)
		res2 = solve_rec(i + 1, arr, target - arr[i], dict)
		res = res1 or res2

	dict[key] = res		
	return res

n = int(input())
arr = list(map(int, input().split()))
q = int(input())
targets = list(map(int, input().split()))
for i in range(q):
	res = solve(arr, targets[i])
	if res == True:
		print('yes')
	else:
		print('no')



Measured memory_bytes: 6420
# 貪欲　左から見て行って最善は右にも影響のある箱あｋら先に食べていくこと
N, x = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
for i in range(1,N):
    if A[i-1] + A[i] > x:
        if A[i] >= A[i-1]+A[i]-x: #右の箱だけ食べて条件を満たせる
            ans += A[i-1]+A[i]-x
            A[i] -= A[i-1]+A[i]-x
        else: # 左の箱も食べないといけない
            ans += (A[i] + A[i-1]) - x
            A[i] = 0
print(ans)

Measured memory_bytes: 14252
fun main(args: Array<String>) {
    val (N, A, B) = listOfInt()
    val ans = Math.min(A * N, B)
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int n, m;
    cin >> n >> m;

    vector<int> a(m);
    rep(i, m) cin >> a[i];

    sort(a.rbegin(), a.rend());

    int num[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    int dp[n+1];
    fill_n(dp, n+1, -1000000);
    dp[0] = 0;

    for(int i = 1; i <= n; ++i){
        for(int j = 0; j < m; ++j){
            if(i-num[a[j]] < 0) continue;
            dp[i] = max(dp[i], dp[i-num[a[j]]]+1);
        }
    }

    string ans = "";
    int remain = n;

    while(remain != 0){
        for(int j = 0; j < m; ++j){
            if(remain-num[a[j]] < 0) continue;
            if(dp[remain-num[a[j]]] == dp[remain]-1){
                ans += a[j]+'0';
                remain -= num[a[j]];
                break;
            }
        }
    }

    ppp(ans);

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
data = gets.split.map { |e| e.to_i }
swap_count = 0

for i in 0..N-1
  (N-1).downto(i+1) do |j|
    if data[j] < data[j-1]
      data[j],data[j-1] = data[j-1],data[j]
      swap_count += 1
    end
  end
end

puts data.join(" ")
p swap_count

Measured memory_bytes: 6108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

/*
    let's try computer shogi!!!
    greedyに塗ればOK（多分
*/

struct domino{
  int id;
  bool tate;
};


int main(){
  int N;
  long int mod = 1000000007;
  string l1;
  string l2;
  vector<domino> dms;
  cin >> N;
  cin >> l1 >> l2;
  long int p = 1;
  for(int i=0;i<N;++i){
    domino d;
    if(l1[i]==l2[i]){
      d.id =i;
      d.tate = true;
      dms.push_back(d);
    }else{
      if(i<N-1){
	if(l1[i]==l1[i+1]){
	  d.id =i;
	  d.tate = false;
	  dms.push_back(d);
	}
      }
    }
  }
  /*
  for(int i=0;i<dms.size();++i){
    cout<<dms[i].id<<","<<dms[i].tate<<endl;
  }
  */

  int befc = -1;
  for(int i=0;i<dms.size();++i){
    if(dms[i].tate){
      if(befc == -1){
	p = p*3 % mod;
      }else if(befc == 2){
	// 縦縦の続き
	p = p*2 % mod;
      }
      befc = 2; //beforeは縦
    }else{
      if(befc == -1){
	p = p*6 % mod;
      }else if(befc == 2){
	p = p*2 % mod;
      }else if(befc == 1){
	p = p*3 % mod;
      }
      befc = 1;
    }
  }
  cout<<p<<endl;
  return 0;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] $){
		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt();

		if (String.valueOf(n).indexOf("7") != -1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 27004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

ll n, k;
vector<ll> a, f;

bool solve(ll m) {
  ll cnt = 0;
  rep(i, n) {
    if (a[i] * f[i] > m) {
      cnt += a[i] - m / f[i];
    }
  }
  return cnt <= k;
}

int main() {
  cin >> n >> k;
  a.resize(n);
  f.resize(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> f[i];

  sort(a.begin(), a.end());
  sort(f.begin(), f.end(), greater<ll>());

  ll l = -1, r =1e12 + 5;
  while (r - l > 1) {
    ll m = (l + r) / 2;
    if (solve(m)) {
      r = m;
    }
    else l = m;
  }
  cout << r << endl;



  
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define re(i,a,n) for(i=a;i<=n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second


ll binpow(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return binpow(n, p-2, p);
}

vector<ll> used;
vector<vector<ll>> adj;
ll res;

void dfs(ll u)
{
      res++;
      used[u]=1;
      for(auto v:adj[u])
      {
            if(!used[v]) dfs(v);
      }
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,n,i,f=0,j,ans=0,k,x,r,l,t;
    cin >> n;
    m=1e6+1;
    ll MAXN=m;
    ll spf[m];
    spf[0]=spf[1]=1;
    spf[2]=2;
    for ( i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for ( i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for ( i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for ( j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    }
    vector<ll> a(n);
    
    rep(i,n)
    {
          cin >> a[i];
          
    }
    t=a[0];
    for(i=1;i<n;++i) t=__gcd(t,a[i]);
    set<ll> s;
    f=0;
    rep(i,n)
    {
          ll temp=a[i];
          while(temp!=1)
          {
                //cout << spf[temp];
                if(s.find(spf[temp])!=s.end())
                {
                      f=1;
                      break;
                }
                x=spf[temp];
                s.insert(spf[temp]);
                while(temp%x==0) temp/=x;
                
          }
          if(f) break ;
    }
    if(f==0) cout << "pairwise coprime" ;
    else
    {
          if(t==1) cout << "setwise coprime" ;
          else cout << "not coprime" ;
    }
    
    return 0;
}

Measured memory_bytes: 18768
#include<stdio.h>
int main(void){
    int a,b,as;
    char op;
    do{
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?'){
            break;
        }
        else if(op=='+'){
            as=a+b;
            printf("%d\n",as);
        }
        else if(op=='-'){
            as=a-b;
            printf("%d\n",as);
        }
        else if(op=='*'){
            as=a*b;
            printf("%d\n",as);
        }
        else if(op=='/'){
            as=a/b;
            printf("%d\n",as);
        }
        else if(op=='%'){
            as=a%b;
            printf("%d\n",as);
        }
    }while(1);
    return 0;
}


Measured memory_bytes: 2056
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;

void main() {
    immutable int INF = 1 << 29;

    auto N = readln.chomp.to!int;
    auto A = new int[](2*N);
    auto C = new bool[](2*N);
    foreach (i; 0..2*N) {
        auto s = readln.split;
        A[i] = s[1].to!int;
        C[i] = s[0] == "B";
    }

    auto BR = new int[](N+1);
    auto WR = new int[](N+1);
    foreach (i; 0..2*N) {
        if (C[i]) BR[A[i]] = i;
        else      WR[A[i]] = i;
    }

    auto dpB = new int[][](N+1, 2*N+1); //座標iまでで、jより大きいBの数
    auto dpW = new int[][](N+1, 2*N+1); //座標iまでで、jより大きいWの数

    foreach (i; 0..N+1) foreach (j; 0..2*N) dpB[i][j+1] = dpB[i][j] + (C[j] && A[j] > i);
    foreach (i; 0..N+1) foreach (j; 0..2*N) dpW[i][j+1] = dpW[i][j] + (!C[j] && A[j] > i);

    auto dp = new int[][](N+1, N+1);
    foreach (i; 0..N+1) dp[i].fill(INF);
    dp[0][0] = 0;

    foreach (n; 1..2*N+1) {
        foreach (b; 0..n+1) {
            int w = n - b;
            if (b > N || w > N) continue;
            stdout.flush;
            if (b > 0) {
                dp[b][w] = min(dp[b][w], dp[b-1][w] + dpB[b][BR[b]+1] + dpW[w][BR[b]+1]);
            }
            if (w > 0) {
                dp[b][w] = min(dp[b][w], dp[b][w-1] + dpW[w][WR[w]+1] + dpB[b][WR[w]+1]);
            }
        }
    }

    dp[N][N].writeln;
}


Measured memory_bytes: 82940
#include<stdio.h>
#define N_MAX 40
 
typedef struct data
{
    int value;
    char mark;
}Data;
 
Data C[N_MAX], C1[N_MAX], C2[N_MAX];
 
void BubbleSort(Data C[N_MAX], int N);
void SelectionSort(Data C[N_MAX], int N);
  
void BubbleSort(Data C1[N_MAX], int N)
{   
    int i, j, flag=0;
    Data work;
 
    for(i=0; i<N; i++){
        for(j=N-1; j>i; j--){
            if(C1[j].value < C1[j-1].value){
                work=C1[j];
                C1[j]=C1[j-1];
                C1[j-1]=work;
            }
        }
    }
    for(i=0; i<N; i++){
        printf("%c%d", C1[i].mark, C1[i].value);
        if(i!=N-1) printf(" ");
    }
    printf("\nStable\n");
}
 
 
 
void SelectionSort(Data C2[N_MAX], int N)
{
    int i, j, flag=0;
    Data work;
    int minj;
 
    for(i=0; i<N; i++){
        minj=i;
        for(j=i; j<N; j++){
            if(C2[j].value < C2[minj].value){
                minj = j;
                }
        }
            work = C2[i];
            C2[i] = C2[minj];
            C2[minj] = work;
    }
 
    for(i=0; i<N; i++){
        printf("%c%d", C2[i].mark, C2[i].value);
        if(i!=N-1)printf(" ");
    }
         
    printf("\n");
 
    for(i=0; i<N; i++){
        if(C2[i].mark != C1[i].mark)
            flag = 1;
    }
 
    if(flag == 1)
        printf("Not stable\n");
    else
        printf("Stable\n");
}
 
int main()
{
    int N;
    int i;
 
    scanf("%d", &N);
 
    for(i=0; i<N; i++){
        scanf(" %c%d", &C[i].mark, &C[i].value);
    }   
 
    for(i=0; i<N; i++){
        C1[i] = C[i];
        C2[i] = C[i];
    }
 
 
    BubbleSort(C1, N);
    SelectionSort(C2, N);
 
    return 0;
 
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

vector<string> s(401);
bool done[401][401];
ll h, w;
ll B, W;

int main(){

    ll ans = 0LL;
    cin >> h >> w;
    s.resize(h);
    rep(i, h) cin >> s[i];

    rep(i, h){
        rep(j, w){
            if(s[i][j] == '.' or done[i][j]) continue;
            B = W = 0;
            queue<ll> q;
            done[i][j] = true;
            q.push(i*w+j);
            while(!q.empty()){
                ll x = q.front()%w, y = q.front()/w; q.pop();
                if(s[y][x] == '#') ++B;
                else ++W;
                rep(i, 4){
                    ll xx = x+dx[i], yy = y+dy[i];
                    if(xx < 0 or w <= xx or yy < 0 or h <= yy) continue;
                    if(s[y][x] == s[yy][xx] or done[yy][xx]) continue;
                    done[yy][xx] = true;
                    q.push(yy*w+xx);
                }
            }
            ans += B*W;
        }
    }
    ppp(ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

const int INF = 1e9;
int coins[4] = {10,50,100,500};
bool flag = false;

int main() {
  int price,c[4];
  while(1){
    cin>>price;
    if(price==0) break;
    REP(i,0,4)cin>>c[i];
    int ans[4] = {}, m = INF;
    REP(i,0,c[0]+1){
      REP(j,0,c[1]+1){
        REP(k,0,c[2]+1){
          REP(l,0,c[3]+1){
            int pay = 10*i+50*j+100*k+500*l;
            if(price > pay) continue;
            int ex[4] = {};
            pay -= price;
            for(int ii=3; 0<=ii; ii--){
              if(pay >= coins[ii]){
                ex[ii] = pay/coins[ii];
                pay = pay%coins[ii];
              }
            }
            if((i!=0&&ex[0]!=0)||(j!=0&&ex[1]!=0)||(k!=0&&ex[2]!=0)||(l!=0&&ex[3]!=0)) continue;
            if(m > (c[0]+c[1]+c[2]+c[3])+(-1)*(i+j+k+l)+(ex[0]+ex[1]+ex[2]+ex[3])){
              m = (c[0]+c[1]+c[2]+c[3])+(-1)*(i+j+k+l)+(ex[0]+ex[1]+ex[2]+ex[3]);
              ans[0]=i; ans[1]=j; ans[2]=k; ans[3]=l;
            }
          }
        }
      }
    }
    if(flag)cout<<endl;
    flag = true;
    REP(i,0,4){
      if(ans[i]!=0) cout<<coins[i]<<" "<<ans[i]<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3108
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<P>D(N);
	rep(i, N)cin >> D[i].first >> D[i].second;
	rep(i, N - 2) {
		bool isOK = true;
		rep(j, 3) {
			if (D[i + j].first != D[i + j].second)isOK = false;
		}
		if (isOK) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3632
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n = int(input())
    a = input().split()
    b = []
    c = []
    if n%2==0:
        for i in range(n):
            if i%2:
                b.append(a[-i])
            else:
                c.append(a[i])
        print(' '.join(b+c))
    else:
        m = [a[-1]]
        a = a[:-1]
        n -= 1
        for i in range(n):
            if i%2:
                b.append(a[-i])
            else:
                c.append(a[i])
        print(' '.join((b+c+m)[::-1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 28100
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
using namespace std;
int main(){
    int a,b;
    string s,d,e,t,f;
    cin >> s;
    d=s.substr(2,1);
    e=s.substr(3,1);
    t=s.substr(4,1);
    f=s.substr(5,1);
    if(d==e && t==f){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
}

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

int n,a[200010],l[200010],r[200010];

int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        l[i]=max(l[i-1],a[i]);
    }
    for(int i=n;i>0;i--){
        r[i]=max(r[i+1],a[i]);
    }
    for(int i=1;i<=n;i++)cout<<max(l[i-1],r[i+1])<<endl;
}

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

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

    int l[n];
    int longest=0;
    int total=0;
    for(int i=0; i<n; i++){
        cin >> l[i];
        total+=l[i];
        if(longest<=l[i]){
            longest=l[i];
        }
    }

    if(longest<total-longest){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int q,i,j,k;
  string s,t;
  scanf("%d\n",&q);
  for(i=0;i<q;i++){
    cin >> s >> t;
    int dp[1010][1010];
    for(j=0;j<=s.size();j++){
      for(k=0;k<=t.size();k++){
        dp[j][k]=0;
      }
    }
    for(j=1;j<=s.size();j++){
      for(k=0;k<=t.size();k++){
        dp[j][k]=max(dp[j][k-1],dp[j-1][k]);
        if(s[j-1]==t[k-1]){
          dp[j][k]=max(dp[j][k],dp[j-1][k-1]+1);
        }
      }
    }
  printf("%d\n",dp[s.size()][t.size()]);
  }
  return 0;
}


Measured memory_bytes: 7264
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define LL long long
#define pb push_back
#define mp make_pair
#define M 1000000007
 
#define K 5001
 
int n, a, b;
 
int main() {
	scanf("%d%d%d", &n, &a, &b);
	
	if (a > b) {
		puts("0");
		return 0;	
	}
	 
	if (n == 1) {
		if (a != b) puts("0"); else puts("1");
		return 0;	
	}
	
	if (n == 2) {
		puts("1");
		return 0;	
	}
	
	n -= 2;
	
	LL diff = (LL)n * (LL)(b - a);
	printf("%lld\n", diff + 1);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;

enum Eptype {
  BOTTOM = 0,
  LEFT = 1,
  TOP = 2,
};

class EndPoint {
public:
  int x, y;
  Eptype t;
  int rightx; // empty if not LEFT
  EndPoint() {}
  EndPoint(int x, int y, Eptype t) : x(x), y(y), t(t) {}
  EndPoint(int x, int y, Eptype t, int rightx) : x(x), y(y), t(t),rightx(rightx) {}
  bool operator<(const EndPoint ep) {
    if (y == ep.y)
      return t < ep.t;
    return y < ep.y;
  }
};

int manhattan_scan(vector<EndPoint> &epts) {
  sort(epts.begin(), epts.end());
  set<int> xs;
  int count = 0;

  for (int i = 0; i < epts.size(); i++) {
    EndPoint ept = epts[i];
    if (ept.t == BOTTOM) {
      xs.insert(ept.x);
    } else if (ept.t == TOP) {
      xs.erase(ept.x);
    } else if (ept.t == LEFT) {
      auto lb = lower_bound(xs.begin(), xs.end(), ept.x);
      auto ub = upper_bound(xs.begin(), xs.end(), ept.rightx);
      count += distance(lb, ub);
    }
  }
  return count;
}

int main() {
  int n;
  cin >> n;
  vector<EndPoint> epts;
  for (int i = 0; i < n; i++) {
    Eptype t1, t2;
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      t1 = BOTTOM;
      t2 = TOP;
      if (y1 > y2) {
        t1 = TOP;
        t2 = BOTTOM;
      }
      epts.push_back(EndPoint(x1, y1, t1));
      epts.push_back(EndPoint(x2, y2, t2));
    } else {
      // push only left endpoint with right-x
      if (x1 < x2) {
        epts.push_back(EndPoint(x1, y1, LEFT, x2));
      } else {
        epts.push_back(EndPoint(x2, y2, LEFT, x1));
      }
    }
  }
  cout << manhattan_scan(epts) << endl;
}

Measured memory_bytes: 8772
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int N,M,P;
  while(cin>>N>>M>>P){
    if(N==0) break;
    vector<int> X(N);
    REP(i,N)cin>>X[i];
    int sum=0;
    REP(i,N)sum+=X[i];
    double money = sum*100;
    money *= (double)(100-P)/100;
    if(X[M-1])money /= (double)X[M-1];
    else money =0;
    cout<<(int)money<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(readline())
    a = list(map(int, readline().split()))
    ans = [0] * n
    v = 2 ** 30
    for i in range(30):
        v //= 2
        check = [False] * n
        cnt = 0
        for j, aa in enumerate(a):
            if aa >= v:
                a[j] -= v
                check[j] = True
                cnt += 1
        if cnt % 2 == 1:
            for j, c in enumerate(check):
                if not c:
                    ans[j] += v
        else:
            for j, c in enumerate(check):
                if c:
                    ans[j] += v
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 146492
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 510000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a)
int main(){
  lli A=INF,B=0,C=INF,D=INF,E,F,N,M,K,sum=0,num=0,cnt=1,next=0;
  string S;cin>>S;
  A=S.size();
  rep(i,0,A)if(S[i]=='p')B++;
  Out(A/2-B);
}


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

int X, Y, Z;

int main () {
  cin >> X >> Y >> Z;

  int ans = X / (Z+Y);
  if(X % (Z+Y) < Z) ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int x[3000];
int r,D;

signed main(){
    FASTER;
    cin>>r>>D>>x[2000];
    for(int i=2001;i<=2010;i++){
        x[i]=x[i-1]*r - D;
        cout<<x[i]<<"\n"; 
    }
    
}

Measured memory_bytes: 3620
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;

int main(int argc, char const *argv[]) {
    int n;cin>>n;
    vector<long long> a(n),b(n),mi(n),ma(n);
    vector<pair<long long,long long>> pll(0);
    long long sua=0,sub=0,sumi=0;
    for(int i=0;i<n;++i){
        cin>>a[i]>>b[i];
        sua+=a[i];
        sub+=b[i];
        pll.push_back(pair<long long, long long>(a[i],i));
        pll.push_back(pair<long long, long long>(b[i],i));
        mi[i]=min(a[i],b[i]);
        ma[i]=max(a[i],b[i]);
        sumi+=mi[i];
    }
    long long res = min(sua,sub);
    sort(mi.begin(),mi.end());
    sort(ma.begin(),ma.end());
    sort(pll.begin(),pll.end());
    long long tmp = 0;
    vector<int> num(n);
    int manu = 0;
    for(int i=0;i<n;++i){
        tmp += pll[i].first;
        num[pll[i].second]++;
        manu = max(manu,num[pll[i].second]);
    }
    if(manu==2)res=min(res,tmp);
    else{
        if(pll[n-1].second != pll[n].second)res=min(res,tmp-pll[n-1].first+pll[n].first);
        else{
            res=min(res,tmp-pll[n-1].first+pll[n+1].first);
            res=min(res,tmp-pll[n-2].first+pll[n].first);
        }
    }
    cout<<res<<endl;
    return 0;
}

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

int main(void){
	int N,A=0,B=0;
	cin >> N;
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin >> a.at(i);
	}
	sort(a.begin(),a.end());
	for(int i=N-1;i>=0;i-=2){
		A+=a[i];
	}
	for(int i=N-2;i>=0;i-=2){
		B+=a[i];
	}
	cout << A-B << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int my[7][7] = {{0,300,500,600,700,1350,1650},
					{300,0,350,450,600,1150,1500},
					{500,350,0,250,400,1000,1350},
					{600,450,250,0,250,850,1300},
					{700,600,400,250,0,600,1150},
					{1350,1150,1000,800,600,0,500},
					{1650,1500,1350,1300,1150,500,0}};

int ds[7][7] = {{0,6,13,18,23,43,58},
					{6,0,7,12,17,37,52},
					{13,7,0,5,10,30,45},
					{18,12,5,0,5,25,40},
					{23,17,10,5,0,20,35},
					{43,37,30,25,20,0,15},
					{58,52,45,40,35,15,0}};

bool half(int len,int l,int r){
	if(len > 40) return false;
	const int x = 17*60+30,y=19*60+30;
	return (x <= l && l <= y) || (x <= r && r <= y);
}

int main(){
	int n;
	while(cin>>n,n){
		int nt; {int a,b; cin>>a>>b; nt = a * 60 + b; }
		int m; cin>>m;
		int mt; {int a,b; cin>>a>>b; mt = a * 60 + b; }
		int len = ds[n-1][m-1];
		bool h = half(len,nt,mt);
		int mo = my[n-1][m-1];
		if(h) mo = ((mo/50+1)/2) * 50;
		cout << mo << endl;
	}

	return 0;
}

Measured memory_bytes: 1160