akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define y1 FUCK_THE_y1
#define pI pair <int, int>
#define mp make_pair
#define fr first
#define sc second
#define LD long double
int n;
const int N = 300000;
int x1, y1, x2, y2;
int xi[N], yi[N];
    LD pi = acos(-1), ans;
 
pI L[N]; int tot;
int ai[N], cnt = 0;
int main()
{
    cin >> x1 >> y1 >> x2 >> y2;
    cin >> n;
    for (int i = 1; i <= n; ++ i)
        cin >> xi[i] >> yi[i];
    if (x1 > x2) swap(x1, x2), swap(y1, y2);
    if (y1 < y2)
    {
        for (int i = 1; i <= n; ++ i)
            if (xi[i] >= x1 && xi[i] <= x2 && yi[i] >= y1 && yi[i] <= y2)
                L[++ tot] = mp(xi[i], yi[i]);
        sort(L + 1, L + tot + 1);
        for (int i = 1; i <= n; ++ i)
        {
            int d = lower_bound(ai, ai + cnt + 1, L[i].sc) - ai;
            ai[d] = L[i].sc; if (d == cnt + 1) cnt ++;
        }
        ans = (x2 - x1 + y2 - y1) * 100.0 - cnt * (2 - pi / 2) * 10 + (cnt == min(y2 - y1, x2 - x1) + 1? pi * 5: 0);
    }
    else
    {
        for (int i = 1; i <= n; ++ i)
            if (xi[i] >= x1 && xi[i] <= x2 && yi[i] >= y2 && yi[i] <= y1)
                L[++ tot] = mp(xi[i], y1 - yi[i] + 1);
        sort(L + 1, L + tot + 1);
        for (int i = 1; i <= n; ++ i)
        {
            int d = lower_bound(ai, ai + cnt + 1, L[i].sc) - ai;
            ai[d] = L[i].sc; if (d == cnt + 1) cnt ++;
        }
        ans = (x2 - x1 + y1 - y2) * 100.0 - cnt * (2 - pi / 2) * 10 + (cnt == min(y1 - y2, x2 - x1) + 1? pi * 5: 0);
    }
    cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
 
    double pi = 3.14159265359;
    double r;
    cin >> r;
 
    cout<< 2*pi*r << "\n";
 
  return 0;
 
}

Measured memory_bytes: 3804
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
struct edge{
  int to, cost;
};
struct S{
  int d, p, g; // dist point gas
};
bool operator < (const S& s, const S& t){
  return s.d > t.d;
}
typedef vector<edge> edges;

int getid(map<string, int>& ID, string s){
  int m = ID.size();
  if(ID.count(s))return ID[s];
  else return (ID[s] = m);
}

int main(){
  int N, M, cap;
  while(cin>>N>>M>>cap && N){
    cap *= 10;
    map<string, int> ID;
    string src, dest;
    cin>>src>>dest;
    int srcid = getid(ID, src);
    int destid = getid(ID, dest);
    vector<edges> g(6000);
    REP(i, N){
      string s1,s2;int c;
      cin>>s1>>s2>>c;
      int u = getid(ID, s1);
      int v = getid(ID, s2);
      g[u].push_back((edge){v, c});
      g[v].push_back((edge){u, c});
    }
    bool gas[6000] = {};
    REP(i, M){
      string s; cin>>s;
      gas[getid(ID, s)] = true;
    }
    bool used[6000][201] = {};
    priority_queue<S> que;
    que.push((S){0, srcid, cap});
    while(!que.empty()){
      S s = que.top(); que.pop();
      if(s.p == destid){
        cout<<s.d<<endl;
        goto END;
      }
      if(used[s.p][s.g]) continue;
      used[s.p][s.g] = true;
      FORIT(it, g[s.p]){
        if(it->cost <= s.g){
          S next = (S){s.d + it->cost, it->to, (gas[it->to])?cap:(s.g - it->cost)};
          que.push(next);
        }
      }
    }
    cout<<-1<<endl;
END:;
  }
  return 0;
}

Measured memory_bytes: 8440
pub struct Poper<'a> {
	iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Poper<'a> {
	pub fn new(iter: std::str::SplitWhitespace) -> Poper {
		Poper { iter: iter }
	}
	pub fn read<T: std::str::FromStr>(&mut self) -> T
	where
		<T as std::str::FromStr>::Err: std::fmt::Debug,
	{
		self.iter.next().unwrap().parse().unwrap()
	}
}

// https://atcoder.jp/contests/abc129/submissions/5849596
const MOD: i64 = 1_000_000_007;
#[derive(Copy, Clone, Hash, Debug)]
struct ModInt {
	x: i64,
}
impl ModInt {
	fn new(x: i64) -> Self {
		ModInt { x: x % MOD }
	}
	fn pow(self, e: i64) -> Self {
		if e == 0 {
			Self::new(1)
		} else if e % 2 == 1 {
			self.pow(e - 1) * self
		} else {
			let y = self.pow(e / 2);
			y * y
		}
	}
	#[allow(dead_code)]
	fn inv(self) -> Self {
		self.pow(MOD - 2)
	}
}
impl<T: Into<ModInt>> std::ops::Add<T> for ModInt {
	type Output = Self;
	fn add(self, other: T) -> Self {
		let other = other.into();
		let sum = self.x + other.x;
		ModInt {
			x: if sum >= MOD { sum - MOD } else { sum },
		}
	}
}
impl<T: Into<ModInt>> std::ops::Sub<T> for ModInt {
	type Output = Self;
	fn sub(self, other: T) -> Self {
		let other = other.into();
		let sum = self.x - other.x;
		ModInt {
			x: if sum < 0 { sum + MOD } else { sum },
		}
	}
}
impl<T: Into<ModInt>> std::ops::Mul<T> for ModInt {
	type Output = Self;
	fn mul(self, other: T) -> Self {
		let other = other.into();
		ModInt {
			x: self.x * other.x % MOD,
		}
	}
}
impl<T: Into<ModInt>> std::ops::Div<T> for ModInt {
	type Output = Self;
	fn div(self, other: T) -> Self {
		let other = other.into();
		self * other.inv()
	}
}
impl From<i64> for ModInt {
	fn from(x: i64) -> Self {
		ModInt::new(x)
	}
}
impl std::fmt::Display for ModInt {
	fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
		self.x.fmt(f)
	}
}
impl<T: Into<ModInt>> std::ops::AddAssign<T> for ModInt {
	fn add_assign(&mut self, other: T) {
		*self = *self + other;
	}
}
impl<T: Into<ModInt>> std::ops::SubAssign<T> for ModInt {
	fn sub_assign(&mut self, other: T) {
		*self = *self - other;
	}
}
impl<T: Into<ModInt>> std::ops::MulAssign<T> for ModInt {
	fn mul_assign(&mut self, other: T) {
		*self = *self * other;
	}
}
impl<T: Into<ModInt>> std::ops::DivAssign<T> for ModInt {
	fn div_assign(&mut self, other: T) {
		*self = *self / other;
	}
}

fn main() {
	let input = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = Poper::new(input.split_whitespace());
	let n: i64 = iter.read();
	let k: i64 = iter.read();
	let r: i64 = n - k;
	let r1 = r + 1;
	let k1 = k - 1;

	for i in 1..k + 1 {
		let mut p = concnt(r1, i);
		if 0 < p {
			p = {
				let mut t = ModInt::new(p);
				t *= concnt(k1, i - 1);
				t.x
			};
		}
		println!("{}", p);
	}
}

fn concnt(n: i64, k: i64) -> i64 {
	if n < k {
		return 0;
	}
	if k <= 0 {
		return 1;
	}
	let mut r = ModInt::new(1);
	let mut n = n;
	for _ in 0..k {
		r *= n;
		n -= 1;
	}
	for i in 1..k + 1 {
		r /= i;
	}
	r.x
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define PI 3.14159265359
#define rep(i,n) for(int i=0; i<n; ++i)
#define INF 1001001001

typedef long long ll;

int main() {
    ll x, y;
    cin >> x >> y;

    int ans = 0;
    do {
        ++ans;
        x *= 2;
    } while (x <= y);

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

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

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

    vector<string> s{4};
    for (int i = 0; i < 4; i++)
    {
        s[i].push_back(ss[i]);
    }

    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());

    if (s.size() == 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int A,B,C,X,Y,ans=0,Ans=1000000000,i;
	
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&X);
	scanf("%d",&Y);
	
	
	for(i=0;i<=X||i<=Y;i++){
		
		if(X-i>=0&&Y-i>=0){
		
		ans=A*(X-i)+B*(Y-i)+C*2*i;
		

		
		} else if(X-i<0&&Y-i>=0){
			
			ans=B*(Y-i)+C*2*i;
			

		}else if(Y-i<0&&X-i>=0){
			
			ans=A*(X-i)+C*2*i;
			

		}
		
		if(Ans>ans){
			
			Ans=ans;
			

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

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


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

struct Edge{
  int to, cost;

  Edge(int t, int c = 0): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
  bool operator<(const Edge& rhs) const{
	return cost < rhs.cost;
  }

};
using Graph =  vector< vector<Edge> >;

void add_edge(Graph& graph, int u, int v, int cost = 0){
  graph[u].push_back(Edge(v,cost));
  graph[v].push_back(Edge(u,cost));
}
int lowlink(int u, int p, int& num, Graph& G, VI& ord, VI& low){
  int res = 0;
  ord[u] = low[u] = num++;
  
  for(auto& e: G[u]){
	int to = e.to;
	if(to == p) continue;
	if(ord[to] < 0){
	  res += lowlink(to, u, num, G, ord, low);
	  low[u] = min(low[u], low[to]);
	  if(ord[u] < low[to])
		++res;
	}
	else{
	  low[u] = min(low[u], ord[to]);
	}
  }

  return res;
}
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int V, E;
  cin >> V >> E;
  Graph G(V);
  REP(i,E){
	int s, t;
	cin >> s >> t;
	add_edge(G, s, t);
  }

  int num = 0;
  VI ord(V,-1), low(V);
  lowlink(0, -1, num, G, ord, low);

  vector<PII> ans;
  REP(i,V)
	for(auto& e: G[i])
	  if(ord[i] < ord[e.to] && ord[i] < low[e.to])
		ans.EB(min(i,e.to), max(i,e.to));
  SORT(ans);
  for(auto&& e: ans)
	cout << e.FF << " " << e.SS << endl;  

  return 0;
}

Measured memory_bytes: 5436
import java.io.*;
public class Main {
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	}
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        }
    }
}

Measured memory_bytes: 30748
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int n,l;
  cin >> n >> l;
  string s[100];
  for(int i=0; i<n; i++) {
    cin >> s[i];
  }
  sort(s,s+n);
  for(int i=0; i<n; i++) {
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,d;
int main()
{
	cin>>n>>d;
	int maxx=2*d+1;
	for(int i=1;;++i)
	{
		if(i*maxx>=n)
		{
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Abs(x) ((x)<0 ? ((x)*(-1)):(x))
int main(void){
  string s;
  cin>>s;
  int length=s.length();
  int i=0,j=0;
  int count=0;
  int key[26];
  for(i=0,j=length-1;Abs(i-j-1)>1;){
    if(s[i] == s[j]){
      i++;
      j--;
    }else{
      if(s[i]!= 'x' && s[j]!='x'){
        cout<<-1<<endl;
        return 0;
      }
      count++;
      if(s[i]=='x'){
        i++;
      }else if(s[j]=='x'){
        j--;
      }
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 512
N, A, B = map(int, input().split())

total = 0

for n in range(1, N + 1):
    i = n
    num = 0
    while n > 9:
        w = n % 10
        n = n // 10
        num += w
    num += n
    if num >= A and num <= B:
        total += i

print(total)

Measured memory_bytes: 3060
L1= []
L2= []
N= 0
while True:
	x,y= map(int,input().split())
	if(x==y==0):
		break
	if(x> y):
		x,y= y,x
	L1.append(x)
	L2.append(y)
	N= N+1

for i in range(N):
	print(L1[i],L2[i])

Measured memory_bytes: 8128
#include<stdio.h>
int main()
{
	char S[11],T[12];
	scanf("%s",S);
	scanf("%s",T);
	for(int i=0;S[i]!='\0';i++){
		if(S[i]!=T[i]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1724
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import re

PATTERN = re.compile(r"[2-9]*[mcxi]")
NUMBERS = "23456789"
TABLE = {"m": 1000, "c": 100, "x": 10, "i": 1}


def mcxi2int(mcxi_str):
    answer = 0
    for segment in re.findall(PATTERN, mcxi_str):
        answer += TABLE[segment[-1]] * \
            (int(segment[0]) if segment[0] in NUMBERS else 1)
    return answer


def int2mcxi(number):
    mcxi_prefixes = dict()
    mcxi_prefixes["m"], cxi = divmod(number, 1000)
    mcxi_prefixes["c"], xi = divmod(cxi, 100)
    mcxi_prefixes["x"], mcxi_prefixes["i"] = divmod(xi, 10)
    result = ""
    for char in "mcxi":
        if mcxi_prefixes[char] == 1:
            result += char
        elif mcxi_prefixes[char] > 1:
            result += str(mcxi_prefixes[char]) + char
    return result


if __name__ == "__main__":
    n = int(input())
    for i in range(n):
        mcxi1, mcxi2 = input().split()
        print(int2mcxi(mcxi2int(mcxi1) + mcxi2int(mcxi2)))

Measured memory_bytes: 7832
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
typedef pair<int,int> ii;
const int MAX_V = 101;
const int IINF = INT_MAX;
struct Edge { int dst,weight,hour,comp; };
struct Data {
  int cur,weight,hour,bitmask;
  bool operator < ( const Data &data ) const {
    if( weight != data.weight ) return weight > data.weight;
    if( hour   != data.hour   ) return hour   > data.hour;
    if( cur    != data.cur    ) return cur    > data.cur;
    return bitmask > data.bitmask;
  }
};
int V,E,H,K,S,T;
vector<Edge> G[MAX_V];
int mindist[MAX_V][1<<8][27];//,dp[1<<8];
//vector<vector<vector<int> > > mindist(MAX_V,vector<int>(1<<8,vector<int>(27)));
vector<int> dp(1<<8,0);
 
//iwefaojfwajoefopwaefjpawoejfawopejfjaweog:ghwouuuuuoooooofjewjafoeoiyaaaaafewafw
vector<ii> pass(333);
 
void set_up(){
  int P;
    cin >> P;
    assert( 0 <= P && P <= ((1<<K)-1));
 
    int l,d,k;
    rep(i,P){
 
      cin >> l >> d;
      assert( 1 <= l && l <= K );
      assert( 1 <= d && d <= 10000 );
      pass[i].first = d;
      pass[i].second = 0;
      rep(j,l) {
    cin >> k;
    assert( 1 <= k && k <= K );
    --k;
    pass[i].second |= (1<<k);
      }
    }
 
  rep(i,(1<<K)) dp[i] = IINF;
  dp[0] = 0;
  rep(i,(1<<K)) if( dp[i] != IINF ) {
    rep(j,P) {
      int bit = i | pass[j].second;
      dp[bit] = min(dp[bit],dp[i]+pass[j].first);
    }
  }
}
 
void compute(){
 
  set_up();
  priority_queue<Data> Q;
  rep(i,V) rep(j,(1<<K)) rep(k,H+1) mindist[i][j][k] = IINF;
  rep(i,(1<<K)) if( dp[i] != IINF ) {
    Q.push((Data){S,dp[i],0,i});
    mindist[S][i][0] = dp[i];
  }
  while( !Q.empty() ){
    Data data = Q.top(); Q.pop();
    //cout << data.cur << " " << data.weight  << " " << data.hour << " <= " << H << endl;
    if( data.cur == T ) { cout << data.weight << endl; return; }
    rep(i,G[data.cur].size()){
      int next = G[data.cur][i].dst;
      int nhour = data.hour + G[data.cur][i].hour;
      int cost = data.weight;
      if( !( ( data.bitmask >> G[data.cur][i].comp ) & 1 ) ) cost += G[data.cur][i].weight;
      if( nhour > H ) continue;
      if( mindist[next][data.bitmask][nhour] > cost) {
    mindist[next][data.bitmask][nhour] = cost;
    Q.push((Data){next,cost,nhour,data.bitmask});
      }
    }
  }
  puts("-1");
}
 
int main(){
  while( cin >> V >> E >> H >> K, V|E|H|K ) {
    assert( 2 <= V && V <= 100 );
    assert( 1 <= E && E <= 500 );
    assert( 1 <= H && H <= 24 );
    assert( 1 <= K && K <= 8 );
 
 
    rep(i,V) { G[i].clear(); }
 
    int a,b,c,h,r;
    rep(i,E) {
      cin >> a >> b >> c >> h >> r;
      assert( 1 <= a && a < b && b <= V );
      assert( 1 <= c && c <= 10000 );
      assert( 1 <= h && h <= H );
      assert( 1 <= r && r <= K );
      --a, --b, --r;
      G[a].push_back((Edge){b,c,h,r});
      G[b].push_back((Edge){a,c,h,r});
    }
     
    cin >> S >> T;
    assert( 1 <= S && S <= V );
    assert( 1 <= T && T <= V );
    --S, --T;
     
 
 
    compute();
     
  }
  return 0;
}

Measured memory_bytes: 5628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
template<class Type>
Type solve(Type res = Type()){
    // test(); return res;
    int N,M; cin >> N >> M;
    
    vector<pii> ans;
    
    int NN = 2*M+1;
    if(M%2 == 1){
        for(int i = 1; i < M;i++){
            int j = M+1-i;
            if(i < j){
                ans.emplace_back(i,j);
            }
        }
        for(int i = M+1; i < NN;i++){
            int j = NN-i+(M+1);
            if(i < j){
                ans.emplace_back(i,j);
            }
        }
    }else{
        for(int i = 1; i < M;i++){
            int j = M+2-i;
            if(i < j){
                ans.emplace_back(i,j);
            }
        }
        for(int i = M+2; i < NN;i++){
            int j = NN-i+(M+2);
            if(i < j){
                ans.emplace_back(i,j);
            }
        }
    }
    for(auto p:ans){
        cout << p.first << " " << p.second << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 4252
#include <stdio.h>

int main(){
	int k,a,b;
	int flag = 0;
	
	scanf("%d",&k);
	scanf("%d %d",&a,&b);
	
	for(int i=a;i<=b;i++){
//		printf("%d  ",i);
		if(i % k == 0){
			flag = 1;
			break;
		}
	}
	
	if(flag == 1) printf("OK");
	else printf("NG");
	
	return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
Graph G;
  
/*------------------------------------------------------------------*/

int main(){
    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int MAX = *max_element(h.begin(), h.end());
    int ans = 0;

    while(true){
        int mi = 101;
        MAX = *max_element(h.begin(), h.end());
        if(MAX <= 0) break;

        rep(i, n){
            if(h[i] <= 0 and mi == 101) continue;
            if(i == n - 1 and h[i] > 0){
                mi = min(h[i], mi);
                ans += mi;
                rep(j, n){
                    h[j] -= mi; 
                }
                break;
            }
            if(h[i] > 0){
                mi = min(h[i], mi);
            }
            if(h[i] <= 0){
                ans += mi;
                rep(j, i){
                    h[j] -= mi;
                }
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <vector>

int main() {
	int n;
	std::string s;
	std::cin >> n >> s;
	int a[100];
	int nSum = 0;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == 'I') {
			nSum += 1;
			a[i] = nSum;
		}
		else {
			nSum -= 1;
			a[i] = nSum;
		}
	}
	int max = 0;
	for (int i = 0;i < s.size();i++) {
		if (max <= a[i]) {
			max = a[i];
		}
	}
	std::cout << max << std::endl;
	return 0;
}
	


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	//二分探索による解法
	//cを固定すると、bに対してaが複数存在してしまいややこしい。
	//bを固定する。(真ん中を固定するのが肝)
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		int b[] = fs.nextIntArray(n);
		int c[] = fs.nextIntArray(n);
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
				
		long ans = 0;
		for(int i=0;i<n;i++) {
			int now = b[i];
			int l = -1, r = n;
			while(l+1<r) {
				int m = (l+r)/2;
				if(a[m]<now)l=m;
				else r = m;
			}
			int memo = l;
			
			l = -1; r = n;
			while(l+1<r) {
				int m = (l+r)/2;
				if(now<c[m])r=m;
				else l=m;
			}
			ans += ((long)memo+1)*(n-r);
		}
		System.out.println(ans);
		
	}
}


//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 50828
// finish date: 2018/10/30

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


struct PY {
    int p, y;

    bool operator<(const PY &another) const {
        //メンバ変数であるnum1で比較した結果を
        //この構造体の比較とする
        return y < another.y;
    }

};

string to6(int n) {
    string str = to_string(n);
    while (str.length() != 6) {
        str = '0' + str;
    }
    return str;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<PY> py(M);
    rep(i, M) {
        int p, y;
        cin >> p >> y;
        py[i].p = p;
        py[i].y = y;
    }
    vector<PY> py2 = py;
    sort(py2.begin(), py2.end());
    vi num(N + 1, 0);
    map<PY, int> mp;
    rep(i, M) mp[py2[i]] = ++num[py2[i].p];
    rep(i, M) cout << to6(py[i].p) << to6(mp[py[i]]) << endl;

    return 0;
}



Measured memory_bytes: 9728
//package src.com.jetman.atcoder;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @description:
 * @author: Jetman
 * @create: 2020-08-29 14:39
 **/
public class Main {

    Scanner sc = new Scanner(System.in);

    private void slove() {
        String s = sc.next();
        String t = sc.next();

        int slen = s.length();
        int tlen = t.length();
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i <= slen-tlen; i++) {
            int tmp = 0;
            for (int j = 0; j < tlen; j++) {
                if (s.charAt(i+j) != t.charAt(j)) {
                    tmp++;
                }
            }
                ans = Math.min(ans,tmp);
        }

        System.out.println(ans);

    }

    public static void main(String[] args) {
        new Main().slove();
    }
}


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

struct card{
  int c;
  int n;
};

int pokerHand(int rate[], const vector<card> &v){
  int num[15] = {0,};
  int s_num[4] = {0,};
  bool bst = false;
  bool flash = false;
  bool four=false;
  bool three=false;
  bool fullhouse=false;
  bool two_pair=false;
  bool one_pair=false;
  int st = -1;
  int pair = 0;

  for(int i = 0; i < v.size(); ++i){
    s_num[ v[i].c ]++;
    if( s_num[ v[i].c ] >= 5 ){
      flash = true;
    }
    num[v[i].n]++;
    if( v[i].n == 1 ) num[14]++;
    if( num[v[i].n] >= 4 ){
      four=true;
      three=false;
    }
    if( num[v[i].n] == 3 ){
      three = true;
      pair--;
    }
    if( num[v[i].n] == 2 ){
      pair++;
    }
  }
  
  if( pair >= 1 && three ){
    fullhouse = true;
  }else if( pair == 2 ){
    two_pair =true;
  }else if(pair == 1 ){
    one_pair=true;
  }
  
  int cont=0;
  int start = -1;
  for(int i = 1; i < 15; ++i){
    if( num[i] > 0 ){
      ++cont;
    }else{
      cont = 0;
      start = -1;
      continue;
    }
    if( cont == 1 ){
      start = i;
    }
    if( cont == 5 ){
      st = start;
      bst = true;
    }
  }

  if( st == 10 && flash && bst ){
    return rate[8];
  }else if( flash && bst ){
    return rate[7];
  }else if( four ){
    return rate[6];
  }else if( fullhouse ){
    return rate[5];
  }else if( flash ){
    return rate[4];
  }else if( bst ){
    return rate[3];
  }else if(three){
    return rate[2];
  }else if(two_pair){
    return rate[1];
  }else if(one_pair){
    return rate[0];
  }else return 0;
}

int main()
{
  for(int tc=1;;++tc){

    int N;
    cin >> N;
    if( cin.eof())break;
    if( tc>1 ) cout<<endl;
    int point[4][13];
    int rate[9];
    for(int i = 0; i < 4; ++i){
      for(int j = 0; j < 13; ++j){
	cin >> point[i][j];
      }
    }
    for(int i = 0; i < 9; ++i){
      cin >> rate[i];
    }
    for(int i = 0; i < N; ++i){
      vector<card> hand;
      int sum = 0;
      for(int j = 0; j < 5; ++j){
	string s;
	card c;
	cin >> s;
	switch(s[1]){
	case 'S':c.c=0;break;
	case 'C':c.c=1;break;
	case 'H':c.c=2;break;
	case 'D':c.c=3;break;
	}
	switch(s[0]){
	case 'A':c.n = 1;break;
	case 'T':c.n = 10;break;
	case 'J':c.n = 11;break;
	case 'Q':c.n = 12;break;
	case 'K':c.n = 13;break;
	default:
	  c.n=s[0]-'0';
	}
	sum += point[c.c][c.n-1];
	hand.push_back(c);
      }
      
      cout << sum * pokerHand( rate, hand ) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 928
#include <iostream>
#include <cmath>

using namespace std;
int main(){
  int N, D;
  cin >> N>> D;
  int X[N][D];
  int counter = 0;
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> X[i][j];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      //cout << X[i][j]<<' ';
    }
    //cout << endl;
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      //cout << "i:" << i << "j:"<<j << endl;
      int distance_2=0;
      for(int k=0;k<D;k++){
        distance_2 += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      if( ( static_cast<int>(sqrt(distance_2))*static_cast<int>(sqrt(distance_2)) ) == distance_2){
        counter++;
      }
    }
  }
  cout << counter << endl;
  return 0;
  
}

Measured memory_bytes: 256
<?php
$ac = 0;
$wa = 0;
$tle = 0;
$re = 0;
$num = trim(fgets(STDIN));
for($i=0; $i<$num; $i++){
    $result = trim(fgets(STDIN));
    switch($result){
        case $result == "AC":
            $ac += 1;
        break;
        case $result == "WA":
            $wa += 1;
        break;
        case $result == "TLE":
            $tle += 1;
        break;
        case $result == "RE":
            $re += 1;
        break;
    }
}
echo "AC x $ac"."\n"."WA x $wa"."\n"."TLE x $tle"."\n"."RE x $re";

?>


Measured memory_bytes: 16168
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int x = stoi(s.substr(0, 2));
  int y = stoi(s.substr(2, 2));
  if (x > 0 && x <= 12) {
    if (y > 0 && y <= 12) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  } else {
    if (y > 0 && y <= 12) {
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;
 
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

static const int M = 2000;

vector<bool> ab(100000, false);
vector<bool> ac(100000, false);
vector<bool> bc(100000, false);

bool match (char x, char y) {
  return (x == '?' || y == '?' || x == y);
}

/**
 * main
 */
int main () {
  string a; cin >> a;
  string b; cin >> b;
  string c; cin >> c;

  int la = int(a.length());
  int lb = int(b.length());
  int lc = int(c.length());

  REP(i, 0, la)
    REP(j, 0,lb)
      if (!match(a[i], b[j]))
        ab[i - j + 50000] = true;

  REP(i, 0, la)
    REP(j, 0,lc)
      if (!match(a[i], c[j]))
        ac[i - j + 50000] = true;

  REP(i, 0, lb)
    REP(j, 0,lc)
      if (!match(b[i], c[j]))
        bc[i - j + 50000] = true;

  int ans = 3 * M;

  for (int i = -2 * M; i <= 2 * M; i++) {
    for (int j = -2 * M; j <= 2 * M; j++) {
      if (!(ab[i + 50000] || ac[j + 50000] || bc[j - i + 50000])) {
        int L = min(0, min(i, j));
        int R = max(la, max(lb + i, lc + j));

        ans = min(ans, R - L);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)


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

  vector<ll> A(N);
  ll S = 0;
  rep0(i, N) {
    cin >> A[i];
    S += A[i];
  }

  ll ans = 1;
  vector<ll> R(N);
  rep(i, 1, sqrt(S) + 1) {
    if (S % i != 0) continue;
    
    rep0(t, 2) {
      ll k = i;
      if (t == 1) k = S / i;
      rep0(j, N) {
        R[j] = (A[j] % k);
      }
      sort(R.begin(), R.end());

      ll temp = 0, l = 0, r = N - 1;
      while (l < r) {
        if (R[l] % k == 0) l++;
        else if (R[r] % k == 0) r--;
        else if (R[l] < k - R[r]) {
          temp += R[l];
          R[r] += R[l];
          R[l] = 0;
        } else {
          temp += (k - R[r]);
          R[l] -= (k - R[r]);
          R[r] = 0;
        }
      }
      if (temp <= K) ans = max(ans, k);
      // cout << k << SP << temp << BR;
    }
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 1e-8;

int main(){
	char table[5][5];
	while(~scanf("%s",table)){
		if(table[0][0] == '0') break;
		for(int i=1;i<=2;i++){
			scanf("%s",table+i);
		}

		int winner=0;
		for(int i=0;i<3;i++){
			int w=0,b=0;
			for(int j=0;j<3;j++){
				if(table[i][j] == 'w') w++;
				if(table[i][j] == 'b') b++;
			}
			if(w==3) winner = 1;
			if(b==3) winner = -1;
		}

		for(int i=0;i<3;i++){
			int w=0,b=0;
			for(int j=0;j<3;j++){
				if(table[j][i] == 'w') w++;
				if(table[j][i] == 'b') b++;
			}
			if(w==3) winner = 1;
			if(b==3) winner = -1;
		}

		if(table[0][0] == table[1][1]
		&& table[1][1] == table[2][2]
		&& table[2][2] =='w') winner = 1;

		if(table[0][0] == table[1][1]
		&& table[1][1] == table[2][2]
		&& table[2][2] =='b') winner = -1;

		if(table[0][2] == table[1][1]
		&& table[1][1] == table[2][0]
		&& table[2][0] =='w') winner = 1;

		if(table[0][2] == table[1][1]
		&& table[1][1] == table[2][0]
		&& table[2][0] =='b') winner = -1;

		printf("%s\n", winner == 1 ? "w" : winner == -1 ? "b" : "NA");

	}
}

Measured memory_bytes: 3088
<?php
$n = intval(trim(fgets(STDIN)));
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$check = 1;
$break = 0;
for($i = 0; $i < $n; $i++) {
    if($a[$i] === $check) {
        $check++;
    } else {
        $break++;
    }
}
if($break === $n) {
    echo -1;
} else {
    echo $break;
}

Measured memory_bytes: 27120
X = input().split()
N = int(X[0])
K = int(X[1]) - 1
S = list(str(input()))

if S[K]=="A":
    S[K] = "a"
elif S[K]=="B":
    S[K] = "b"
elif S[K]=="C":
    S[K] = "c"
for i in S:
  print(i, end ="")

Measured memory_bytes: 3064
def euc(x, y):
	if y == 0: return x
	return euc(y, x%y)

N = int(raw_input())
A = map(int, raw_input().split())
x = A[0]
for i in range(1, N):
	x = x * A[i] / euc(x, A[i])
sum = 0
for i in range(0, N):
	sum += (x-1) % A[i]
print sum

Measured memory_bytes: 34664
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    int n, m, sum=0;
    cin >> n >> m;
    vector<int> v(n);
    for (int i=0; i<n; i++){
    	cin >> v[i];
    	sum+=v[i];
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    // for (int i=0; i<n; i++) 
    // 	cout << v[i] << " ";

   	if (v[m-1]*4*m<sum)
   		cout  << "No";
   	else cout << "Yes";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define MAX             1e9
#define MIN            -1e9
#define no_of_test(x)        int x; cin>>x; while(x--)
const double pi=3.14159265359;
//Actual Code Is At The Top
const int mod = 1e9 + 6;
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}
int main()
{   
	very_slow
//	no_of_test(x)
	{  
       double r;
	   cin>>r;
	   double k=(2.0)*pi*r;
        cout<<fixed<<setprecision(16)<<k<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
    long long max,min,a;
    int i,j,k;
    int tmp;
    int n;
    int m;
 
    scanf("%d",&n);
 
    scanf("%llu",&a);
    min = a;
 
    scanf("%llu",&a);
    max = a - min;
    if (min > a)
        min = a;
 
    for (i = 2; i < n; i++) {
        scanf("%lld",&a);
        if ( a-min > max)
            max = a-min;
        if (a < min)
            min = a;
    }
 
    printf("%lld\n",max);
    return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>
#include<math.h>


int main(void) {
  int X;
  int max = 1;
  scanf("%d", &X);
  for (int b = 1; b < 32; b++) {
    for (int p = 2; p < 10; p++) {
      if (max <= pow(b, p) && pow(b, p) <= X) max = pow(b, p);
    }
  }
  printf("%d", max);
  return 0;
}


Measured memory_bytes: 256
n=int(input()) #n<=3*(10**5)
s=list(input()) #E=右向いてる　W=左向いてる　リーダーより左側の人は全員Eになる。右側はWになる。
left,right=[0],[0] #一番端のときは隣居ない
left_num,right_num=0,0
for i in range(1,n): #左にいるWの人数　右にいるEの人数を調べる
    if s[i-1]=="W": #左側　0-(n-2)
        left_num+=1
    left.append(left_num) 
    if s[n-i]=="E": #右側　(n-1)-1
        right_num+=1
    right.append(right_num)
#print(left)
#print(right)
ans=1000000
for i in range(n): #リーダーによって振り向かせる人数を調べれ、minを更新
    num=left[i]+right[n-(i+1)]
    ans=min(ans,num)
print(ans)

Measured memory_bytes: 20428
#import<cstdio>
#import<map>
int main(){for(int n,i,a;scanf("%d",&n),n;puts(!a?"Yes":"No")){std::multimap<int,int> m;for(i=n;i--;m.insert(std::pair<int,int>(a,n)))scanf("%d%d",&n,&a);n=a=0;for(std::multimap<int,int>::iterator i=m.begin();n+=i->second,i!=m.end();++i)i->first<n?a=1:0;}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
using namespace std;
int main()
{
    IOS;
    int t=1;
	//cin>>t;
	while(t--)
	{
		int i,j,ans=0,count;
		string s,t,a;
		cin>>s;
		cin>>t;
		   ans=t.size();
		  	for(i=0;i<(int)s.size()-(int)t.size()+1;i++)
		{   count=0;
			a=s.substr(i,t.size());
			for(j=0;j<(int)t.size();j++)
			{
				if(a[j]==t[j])count++;
			}
			ans=min(ans,(int)t.size()-count);
		}
	    cout<<ans<<endl;
	}
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vi a(1<<n);
  rep(i,(1<<n)){
    cin>>a[i];
  }

  while(a.size()>1){
    vi b;
    rep(i,a.size()){
      if(a[i]!=a[i+1]) b.PB(abs(a[i]-a[i+1]));
      else b.PB(a[i]);
      i++;
    }
    a=b;
  }

  cout<<a[0]<<endl;


}

Measured memory_bytes: 3448
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		int n = sc.nextInt();boolean flag = false;
		while(n > 0) {
			int d = n % 10;
			if(d == 7) {
				flag = true;
				break;
			}
			n /= 10;
		}
		System.out.println((flag == true) ? "Yes" : "No");
		
	}

	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

}

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

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

    int ans = T.length();
    for (int i = 0; i <= (int)(S.length() - T.length()); ++i) {
        int count = 0;
        for (int j = 0; j < (int)T.length(); ++j) {
            if (S[i + j] != T[j]) count++;
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
n = gets.to_i
a = gets.split.map {|i| i.to_i}

flag = true
cnt = 0
while flag
	flag = false
	(n-1).downto(1) do |j|
		if a[j] < a[j-1]
			a[j], a[j-1] = a[j-1], a[j]
			flag = true
			cnt += 1
		end
	end
end

puts a.join(" ")
puts cnt

Measured memory_bytes: 8692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<int> g[200010];
    vector<bool> c(200010,false);
    rep(i,m){
      int a,b;
      cin>>a>>b;
      g[a].push_back(b);
      g[b].push_back(a);
      if(a==n){
        c[b]=true;
      }
      if(b==n){
        c[a]=true;
      }
    }
    rep(i,len(g[1])){
      if(c[g[1][i]]){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
    }
    cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 12016
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    for(int i=0;i<4;i++){
        cin >> a >> b;
        if(a==1) cout << 6000*b << endl;
        else if(a==2) cout << 4000*b << endl;
        else if(a==3) cout << 3000*b << endl;
        else cout << 2000*b <<endl;
    }
        
    }


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

#define ll long long

int main()
{
    int K;
    std::cin >> K;

    std::string S;
    std::cin >> S;

    int S_size = S.size();

    if(S_size <= K) {
        std::cout << S << std::endl;
    }
    else {
        std::cout << S.substr(0,K) << "..." << std::endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n, m;
    cin>>n>>m;
    vl a(m);
    forr(i, m)  cin>>a[i];
    forr(i, m)
    {
        n-=a[i];
    }
    if(n<0)
    {
        cout<<-1;
    }
    else 
    cout<<n;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3692
#include<stdio.h>
#define maxn 1000
int main(){
	int n,h,w;
	int ans=0;
	int a,b;
	scanf("%d %d %d",&n,&h,&w);
	for(int i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		if(a>=h && b>=w) ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,k,q,a[100010],x;
int main()
{
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=q;++i) {
		scanf("%d",&x);
		a[x]++;
	}
	for(int i=1;i<=n;++i) {
		if(k-(q-a[i])<=0) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

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

int binarySearch(int*,int,int);

int main(){
  int i,j,n,q,*S,*T;

  scanf("%d",&n);
  if(n > 100000)exit(1);
  S = malloc((n+1) * sizeof(int));
  for(i=0;i < n;i++){
    scanf("%d",&S[i]);
    if(S[i] < 0)exit(2);
  }
  scanf("%d",&q);
  if(q > 50000)exit(3);
  T = malloc(q * sizeof(int));
  for(i=0;i < q;i++){
    scanf("%d",&T[i]);
    if(T[i] < 0)exit(4);
    for(j=0;j < i;j++){
      if(T[j] == T[i])exit(5);
    }
  }
  j = 0;
  for(i=0;i < q;i++){
    if(binarySearch(S,T[i],n))j++;
  }
  printf("%d\n",j);
  return 0;  
}

int binarySearch(int *S,int t,int n){
  int mid,left = 0,right = n;
  while(left < right){
    mid = (left + right)/2;
    if(S[mid] == t)return 1;
    else if(t < S[mid])right = mid;
    else left = mid + 1;
  }
  return 0;
}



Measured memory_bytes: 2284