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

int partition(int *A, int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j=p; j<r; j++) {
        if(A[j] <= x) {
            i++;
            int tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    int tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;
    
    return i+1;
}

int main() {
    int n;
    scanf("%d", &n);
    int A[n];
    for (int i=0; i<n; i++) scanf("%d", &A[i]);
    
    int q = partition(A, 0, n-1);
    
    for(int i=0; i<n; i++) {
        if(i) printf(" ");
        if(i==q) printf("[%d]", A[i]);
        else printf("%d", A[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2984
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector <int> v[100005];
vector <ll> w[100005];
int sz[100005],son[100005],n,tag=0;
ll ans=0;
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
inline ll readll()
{ll x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10ll+c-'0',c=getchar();
return x;
}
void dfs1(int pos,int fa)
{int i;sz[pos]=1;
for (i=0;i<v[pos].size();i++)
{if (v[pos][i]!=fa)
{dfs1(v[pos][i],pos);
sz[pos]+=sz[v[pos][i]];
son[pos]=max(son[pos],sz[v[pos][i]]);
int p=min(sz[v[pos][i]],n-sz[v[pos][i]]);
ans+=2ll*((ll)p)*w[pos][i];
}
}
son[pos]=max(son[pos],n-sz[pos]);
}
ll mine;
void dfs2(int pos,int fa)
{int i;sz[pos]=1;
for (i=0;i<v[pos].size();i++)
{if (v[pos][i]!=fa)
{dfs2(v[pos][i],pos);
sz[pos]+=sz[v[pos][i]];
int p=min(sz[v[pos][i]],n-sz[v[pos][i]]);
if (2*p==n) {mine=w[pos][i];tag=1;}
}
}
}
int main (){
	int i,a,b,j;
	ll val;
	n=read();
	for (i=1;i<n;i++)
	{a=read();b=read();val=readll();
	v[a].push_back(b);w[a].push_back(val);
	v[b].push_back(a);w[b].push_back(val);
	}
	dfs1(1,0);
	int minn=233333,pl=-1;
	for (i=1;i<=n;i++)
	{if (son[i]<minn)
	{minn=son[i];pl=i;}
	}
	dfs2(pl,0);
	if (!tag)
	{mine=2333333333ll;
	for (i=0;i<v[pl].size();i++)
	{mine=min(mine,w[pl][i]);}
	}
	ans-=mine;
	printf ("%lld",ans);
	return 0;
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
const int maxn=50;
const ll inf=1000000000000LL;
vector<int> g[maxn+5];
ll w[maxn+5],v[maxn+5];
int n,x,d,len;
ll dp[50*50*50+5];
vector<pair<ll,ll> > a;
void dfs(int k)
{
    v[k]=1;
    for(auto u:g[k])
    {
        dfs(u);
        v[k]+=v[u];
        w[k]+=w[u];
    }
}
struct wjmzbmr
{
    ll w,v,num;
}b[maxn+5];
bool cmp(const wjmzbmr x,const wjmzbmr y)
{
assert(log(x.w)+log(y.v)<=log(1000000000000000LL)&&log(x.v)+log(y.w)<=log(1000000000000000LL));
return 1.0*x.v/x.w>=1.0*y.v/y.w;
}
ll work()
{
    ll ans=0;
    for(int i=0;i<=125000;++i)
        if(dp[i]<=x)
        {
            ll res=i;
            ll now=x-dp[i];
            for(int j=1;j<=len;++j)
                if(b[j].num==inf||1.0*b[j].num*b[j].w>1.0*now)
                {
                    res+=now/b[j].w*b[j].v;
                    break;
                }
                else res+=b[j].num*b[j].v,now-=b[j].num*b[j].w;
            ans=max(ans,res);
        }
    return ans;
}
int main()
{
 
    scanf("%d%d%d",&n,&x,&d);
    scanf("%lld",&w[1]);
    for(int i=2;i<=n;++i)
    {
        int x;
        scanf("%lld%d",&w[i],&x);
        g[x].push_back(i);
    }
    dfs(1);
    for(int i=1;i<=n;++i)
    {
        int num=min(d,50);
        if(i==1) num=50;
        int pw=1;
        while(num>=pw)
        {
            a.push_back(mp(w[i]*pw,v[i]*pw));
            num-=pw;
            pw<<=1;
        }
        if(num) a.push_back(mp(w[i]*num,v[i]*num));
        if(i==1||d>50) b[++len]={w[i],v[i],d-50LL};
        if(i==1) b[len].num=inf;
    }
    //for(auto x:a) printf("%lld %lld\n",x.first,x.second);
    sort(b+1,b+len+1,cmp);
    //for(int i=1;i<=len;++i) printf("%lld %lld %lld\n",b[i].w,b[i].v,b[i].num);
    for(int i=0;i<=125000;++i) dp[i]=inf;
    dp[0]=0;
    for(auto x:a)
        for(int j=125000;j>=x.second;--j)
            dp[j]=min(dp[j],dp[j-x.second]+x.first);
    //for(int i=0;i<=50;++i) printf("%d : %lld\n",i,dp[i]);
    //printf("x : %d\n",x);
    printf("%lld\n",work());
    return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long h;
    cin >> h;

    long long ret = 0, power = 1;
    while (h > 0) {
        ret += power;
        h /= 2;
        power *= 2;
    }

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3552
/*
                    Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }      
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 
signed main()
{   jaldi
    int n,m;
    cin>>n>>m;
    int a[n],i,res=0;
    multiset<int>s;
    for(i=0;i<n;i++)
    {   cin>>a[i];
        s.insert(a[i]);
    }
    while(m--)
    {   auto it=s.end();
        it--;
        int x=*it;
        s.erase(it);
        s.insert(x/2);
    }
    for(int x:s)
    res+=x;
    cout<<res;    
}

Measured memory_bytes: 5760
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       String name;
       N = N%10;
       if(N==3){
           name="bon";
       }else if(N==0 || N==1 || N==6 || N==8){
           name = "pon";
       }else{
           name = "hon";
       }
       System.out.println(name);
       
        }
    
}


Measured memory_bytes: 27048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n,r;
  cin >> n >> r;
  if(n>=10) cout << r << endl;
  else{
    cout << r+100*(10-n) << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(obj) obj.begin(), obj.end()
 using namespace std;

 
int main()
{
    long int n;
    cin >> n;
    vector<string> a(n);
    string x;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        sort(all(x));
        a[i] = x;
    }
    sort(all(a));
 
    long int ans = 0;
    long int c = 1;
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] == a[i + 1])
            c++;
        else
        {
            ans += (c * (c - 1)) / 2;
            c = 1;
        }
    }
    ans += (c * (c - 1)) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0;
	cin >> n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
		ans+=b[i]-a[i]+1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007


int n, x, y;
set<pii> se;
vector<pii> vi;
vector<pii> rvi;
map<pii, int> ma;
vector<pll> g[1<<20];
vector<bool> visited(1<<20, false);
vector<ll> dist(1<<20, LONG_LONG_MAX);

bool comparator(const pii& u, const pii& v) {
    if(u.second < v.second) return true;
    return u.first < v.first;
}

int weight1(int i) {
    int x = vi[i].first-vi[i+1].first;
    int y = vi[i].second-vi[i+1].second;
    return min(abs(x), abs(y));
}

int weight2(int i) {
    int x = rvi[i].first-rvi[i+1].first;
    int y = rvi[i].second-rvi[i+1].second;
    return min(abs(x), abs(y));
}

int main() {
  std::ios::sync_with_stdio(false);
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin>>n;
  rep(i, n) {
      cin>>x>>y;
      se.insert({x, y});
  }

  for(auto it = se.begin();it != se.end();it++) {
      vi.pb(*it);
      rvi.pb({(*it).second, (*it).first});
  }

  sort(rvi.begin(), rvi.end());
  rep(i, vi.size()) {
      swap(rvi[i].first, rvi[i].second);
      ma[vi[i]] = i+1;
  }

  rep(i, vi.size()-1) {
      g[i+1].pb({weight1(i), i+2});
      g[i+2].pb({weight1(i), i+1});

      int x = ma[rvi[i]];
      int y = ma[rvi[i+1]];
      g[x].pb({weight2(i), y});
      g[y].pb({weight2(i), x});
  }

  set<pll> pq;
  pq.insert({0, 1});
  ll answer = 0;


  while(not pq.empty()) {
      pii temp = *(pq.begin());
      pq.erase(pq.begin());
      if(visited[temp.second]) continue;
      visited[temp.second]=1;
      dist[temp.second]=temp.first;
      answer = answer + (long long)(temp.first);
      for(auto&z:g[temp.second]) {
          if(not visited[z.second] and z.first < dist[z.second]) {
              pq.erase({dist[z.second], z.second});
              dist[z.second]=z.first;
              pq.insert({z.first, z.second});
          }
      }
  }

  cout<<answer<<endl;

  return 0;
}


Measured memory_bytes: 56556
str=gets.chomp
#NSWE
n=false
s=false
w=false
e=false
str.chars do |c|
  if c == "N"
    n = true
  elsif c == "S"
    s = true
  elsif c == "W"
    w = true
  elsif c == "E"
    e = true
  end
end

if ((n == s) && (w == e))
  puts "Yes"
else
  puts "No"
end


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1e6;
int dp[maxn]; VI G[maxn];

bool topsort(const int n)
{
    VI degree(n);
    FOR(u,0,n) FOR_ALL(v,G[u])
        degree[*v]++;
    queue<int> Q;
    FOR(u,0,n) if (!degree[u])
        Q.push(u);
    int m = 0;
    while (Q.size()) {
        const int u = Q.front(); Q.pop();
        FOR_ALL(v,G[u]) if (--degree[*v] == 0)
            Q.push(*v);
        m++;
    }
    return n == m;
}

int dfs(const int u)
{
    int& ans = dp[u];
    if (-1 == ans) {
        ans = 1;
        FOR_ALL(v,G[u])
            ans = max(ans, dfs(*v)+1);
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while (cin >> n) {
        int cnt = 0; map<PII,int> node; const int nmatch = n*(n-1)/2;
        FOR(i,0,nmatch)
            G[i].clear();
        FOR(i,1,n+1) {
            VI A;
            FOR(j,0,n-1) {
                int u = i; int v; cin >> v;
                if (v < u)
                    swap(u,v);
                const PII k(u,v);
                if (!in_(k,node)) 
                    node[k] = cnt++;
                A.push_back(node[k]);
            }
            FOR(j,0,A.size()-1)
                G[A[j]].push_back(A[j+1]);
        }
        if (!topsort(nmatch))
            cout << -1 << endl;
        else {
            memset(dp,-1,sizeof(dp));
            int ans = 0;
            FOR(i,0,nmatch)
                ans = max(ans,dfs(i));
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 74592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String c1 = sc.next();
		String c2 = sc.next();

		if (!c1.substring(0, 1).equals(c2.substring(2, 3))) {
			System.out.println("NO");
		} else if (!c1.substring(1, 2).equals(c2.substring(1, 2))) {
			System.out.println("NO");
		} else if (!c1.substring(2, 3).equals(c2.substring(0, 1))) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}

		sc.close();
	}
}

Measured memory_bytes: 24916
void main() {
	auto R = readAs!real;
	writeln(2*R*PI);
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int64_t x;
	std::cin >> x;
	std::map<int64_t, int64_t> map;
	map[x] = 1;
	int64_t res = 0;
	while (map.size()) {
		auto greatest = std::prev(map.end());
		if (greatest->first == 0) break;
		res += greatest->second;
		map[greatest->first / 2] += greatest->second * 2;
		map.erase(greatest);
	}
	std::cout << res << std::endl;
	return 0;
}



Measured memory_bytes: 256
n = gets.to_i
h = Array.new(n+1) { Array.new }
m = Array.new(n+1) { Array.new }
(1..n).each do |t|
  ai = gets.to_i
  ai.times do
    x, y = gets.split.map(&:to_i)
    m[t] << x if y == 0
    h[t] << x if y == 1
  end
end
max = 0
(2 ** n).times do |pattern|
  catch(:hoge) do
    n.times do |i|
      next if 1<<i & pattern == 0

      m[i+1].each do |m|
        throw(:hoge) if pattern[m-1] != 0
      end

      h[i+1].each do |h|
        throw(:hoge) if pattern[h-1] != 1
      end
    end
    max = [max, pattern.to_s(2).count('1')].max
  end
end
puts max

Measured memory_bytes: 1788
#include<stdio.h>
int main(){
	char s[1200];
	int c;
	int cnt=0;
	
	
	while((c=getchar())!=EOF){
		if(c>='a'&&c<='z'){
			c=c-32;
		}else if(c>='A'&&c<='Z'){
			c=c+32;
		}
		s[cnt]=c;
		cnt++;
		putchar(c);
	}
	
	return 0;
}

Measured memory_bytes: 2600
s = input()

q = int(input())
query = []

for _ in range(q):
    query = input().split()
    if query[0] == 'replace':
        a, b = map(int, query[1:3])
        s = s[:a] + query[3] + s[b+1:]
    elif query[0] == 'reverse':
        a, b = map(int, query[1:3])
        r = s[b:a-1:-1] if a != 0 else s[b::-1]
        s = s[:a] + r + s[b+1:]
    elif query[0] == 'print':
        a, b = map(int, query[1:3])
        print(s[a:b+1])



Measured memory_bytes: 5620
#include <bits/stdc++.h>
#include <cstring>
#define ll long long
using namespace std;
const int maxn = 2e6 + 1;
const int mod = 1e9+7;
ll inv[maxn], fac[maxn];
void init()
{ //o(n)的组合数
    inv[0] = fac[0] = 1;
    inv[1] = 1;
    for (int i = 1; i < maxn; i++)
        fac[i] = fac[i - 1] * i % mod;
    inv[1] = 1;
    for (int i = 2; i < maxn; i++)
        inv[i] = (ll)(mod - mod / i) * inv[mod % i] % mod;
    inv[0] = 1;
    for (int i = 1; i < maxn; i++)
        inv[i] = inv[i - 1] * inv[i] % mod;
}
ll com(int n, int m) { return fac[n] * inv[m] % mod * inv[n - m] % mod; }
int main()
{
    init();
    int n, m;
    cin >> n>>m;
    if((n+m)%3 != 0) cout<<0<<endl;
    else
    {
        int k = (n +m)/3;
        n -= k,m -= k;
        if(n < 0 || m < 0) cout<<0<<endl;
        else cout<<com(n+m,n)<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 31488
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        scan.close();
        String[] strArray = str.split("");
        int strLength = strArray.length;
        boolean result = true;

        for(int i = 0; i < strLength / 2;i++){
            if(strArray[i].equals(strArray[strLength - i - 1])){}
            else{result = false; break;}
        }

    if(result && strLength > 3){
        int kai1 = (strLength - 1) / 2;
        for(int i = 0; i < kai1 / 2 ;i++){
            if(strArray[i].equals(strArray[kai1 - i - 1])){}
            else {result = false; break;}
        }

        int kai2 = (strLength + 3) / 2;
        if(result){
            int count = 0;
            for(int i = kai2 - 1; i < strLength - (kai1 / 2) ; i++){
                if(strArray[i].equals(strArray[strLength - count - 1])){}
                else {result = false; break;}
                count++;
            }
        }
    }

    if(result) System.out.println("Yes");
    else System.out.println("No");
    }
}

Measured memory_bytes: 23764
#include<stdio.h>

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}


int main(void){
    int n;
    scanf("%d",&n);
    int number[200000];
    int tmp[200000];
    for(int i=0;i<n;i++){
        scanf("%d",&number[i]);
        tmp[i]=number[i];
    }
    quick_sort(number,0,n-1);
   for(int i=0;i<n;i++){
        if(tmp[i]==number[n-1]){
           printf("%d\n",number[n-2]);
        }
        else{
            printf("%d\n",number[n-1]);
        }
    }
    return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,s;
  cin>>n;
  s=n%10;
  if(s==2||s==4||s==5||s==7||s==9)
   cout << "hon"<<endl;
  else if(s==3)
    cout << "bon"<<endl;
  else
    cout << "pon";
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	long long ans = 0; int p = min(x, y);
	ans += p * min(a + b, c * 2);
	if (x > y)ans += (x - p)*min(a, c * 2);
	if (x < y)ans += (y - p)*min(b, c * 2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N;
  cin >> N;
  vector<pair<int, int> > red(N);
  vector<pair<int, int> > blue(N);
  REP(i, N){
    cin >> red[i].first >> red[i].second;
  }
  REP(i, N){
    cin >> blue[i].first >> blue[i].second;
  }
  sort(blue.begin(), blue.end());

  int x, y, pair;
  int ans =0;
  REP(i, N){
    pair = -1;
    x = blue[i].first;
    y = blue[i].second;
    for(int j=0; j<N; ++j){
      if(x > red[j].first && y > red[j].second){
        if(pair==-1) pair=j;
        else if(red[pair].second<red[j].second) pair=j;
      }
    }
    if(pair!=-1){
      ++ans;
      red[pair].second = 2*N;
    }
  }

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int dp[1001][1001];//sのi文字目までをtのj文字目までに一致させる最小コスト

//文字列stを文字列tarに変換するときに、
//挿入: insert, 削除: del, 置換: replace のコストがかかるときの編集距離を求める
int editdist(string st,string tar,int insert,int del,int replace)
{
	//初期化
	fill(dp[0],dp[1001],1e8-1);
	dp[0][0]=0;
	for(int i=0;i<st.size();i++)
		dp[i+1][0]=del*(i+1);
	for(int i=0;i<tar.size();i++)
		dp[0][i+1]=insert*(i+1);
	//ここからdp
	for(int i=1;i<st.size()+1;i++)
	{
		for(int j=1;j<tar.size()+1;j++)
		{
			dp[i][j]=min(dp[i-1][j]+del,dp[i][j-1]+insert);
			int tmp=dp[i-1][j-1];
			if(st[i-1]!=tar[j-1])
				tmp+=replace;
			dp[i][j]=min(dp[i][j],tmp);
		}
	}
	return dp[st.size()][tar.size()];
}

int main()
{
	string s,t;
	cin>>s>>t;
	cout<<editdist(s,t,1,1,1)<<endl;
}


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

int main()
{
    int X;
    cin >> X;
    int k = 1;

    while (true)
    {
        int tar = k * X;
        if (tar % 360 == 0)
        {
            cout << k << endl;
            return 0;
        }
        ++k;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, q;
string s;
V<char> t;
V<int> d;
bool check_l(int m){
  FOR(i, 0, q) if(s[m] == t[i]){
    m += d[i];
    if(m < 0) return true;
    if(m >= n) return false;
  }
  return false;
}
bool check_r(int m){
  FOR(i, 0, q) if(s[m] == t[i]){
    m += d[i];
    if(m >= n) return true;
    if(m < 0) return false;
  }
  return false;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q >> s;
  FOR(i, 0, q){
    char _t, _d;
    cin >> _t >> _d;
    t.pb(_t);
    d.pb((_d=='L') ? -1 : 1);
  }
  int l, r;
  int ok, ng, mid;
  ok = -1, ng = n;
  while(abs(ok-ng) > 1){
    mid = (ok+ng) / 2;
    if(check_l(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  l = ok;

  ok = n, ng = -1;
  while(abs(ok-ng) > 1){
    mid = (ok+ng) / 2;
    if(check_r(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  r = ok;
  cout << r-l-1 << endl;
}

Measured memory_bytes: 1936
N = int(input())
A = list(map(int, input().split()))
ans = 1
lim = 10**18
if 0 in A:
    print(0)
else:
    for k in range(N):
        ans *= A[k]
        if ans > lim:
            print(-1)
            break
    else:
        print(ans)

Measured memory_bytes: 84540
S = input()
FLG = True

for i,step in enumerate(S):
    if step in "UD":
        continue
    if step == "L" and i % 2 == 0:
        FLG = False
        break
    if step == "R" and i % 2 == 1:
        FLG = False
        break

if FLG:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#[allow(unused_macros)]
macro_rules! debug {
  ($($e:expr), *) => {println!(concat!($(stringify!($e), " = {:?}\n"), *), $($e), *)}
}

use std::collections::HashMap;

fn main() {
  let _ = get::val::<usize>();
  let xs = get::list::<usize>();

  let mut ns = HashMap::new();
  for x in xs {
    *ns.entry(x).or_insert(0) += 1
  }

  let ans = ns.iter().map(|(&k,&v)|if v<k {v} else {v-k}).sum::<usize>();
  println!("{}", ans)
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    map<char, lli> cnt;
    rep(i, s.size()) cnt[s.at(i)]++;
    bool ans = true;
    if(cnt.size() != 2) ans = false;
    for(auto c: cnt){
        if(c.second != 2) ans = false;
    }
    (ans) ? Yes() : No();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;

	cin >> N;

	bool checker = true;

	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if(a % 2 == 0) {
			if(a % 3 != 0 && a % 5 != 0) {
				checker = false;
			}
		}
	}

	if(checker) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long long int h, w;
    cin >> h >> w;
    if (w == 1 || h == 1) {
        cout << 1 << endl;
    } else if (h % 2 == 0 || w % 2 == 0) {
        cout << (long long int)(h * w / 2) << endl;
    } else {
        cout << (long long int)((h * w + 1) / 2) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
const ll mo=1e9+7;
ll fac(ll n)
{
	ll ans=1;
	for(ll i=1;i<=n;++i)
	{
		ans=ans*i;
		if(ans>=mo)ans%=mo;
	}
	return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;cin>>n>>m;
    if(n<m)swap(n,m);
    if(n-m>1)
    {
    	cout<<"0\n";
    	return 0;
    }
    else
    {
    	ll n1=fac(n),m1=fac(m),ans;
    	//cout<<n1<<' '<<m1<<" n1 m1\n";
    	if(n==m)
    	{
    		ans=(2*(n1*m1)%mo)%mo;
    	}
    	else
    	{
    		ans=(n1*m1)%mo;
    	}
    	cout<<ans<<'\n';
    }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define N_PRODUCT 6


int main() {
    i64 X; cin >> X;
    i64 xlim = X + 1;
    vector<bool> dp(xlim + 1, false);
    dp[0] = true;

    REP(i, N_PRODUCT) {
        i64 price = 100 + i;

        REP(x, xlim + 1) {
            if (x - price >= 0 && dp[x - price]) dp[x] = true;
        }
    }

    cout << dp[X] << endl;

    return 0;
}

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

int n;
long long ans;

int main() {
	scanf("%d", &n);
	for(int d = 1; d <= n; d++) {
		long long cnt = n / d;
		ans += cnt * (cnt + 1) / 2 * d;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int kame = 0;
  int zuru = 0;
  int x = 0;
  int y = 0;
  cin >> x >> y;
  
  for(kame = 0; kame <= x; kame++){
    zuru = x - kame;
    if(2*zuru + 4*kame == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}
  

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,ans;

  while(cin>>a>>b){
    c=a+b;
    ans=1;
    while(c>=10){
      c/=10;
      ans++;
    }
    cout<<ans<<endl;
  }

  return(0);
}

Measured memory_bytes: 2980
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var u = Console.ReadLine();
		var v = Console.ReadLine();
		
		if(u == v)
		{
			Console.WriteLine("Yes");
			return;
		}
		
		var s = u.ToCharArray();
		var t = v.ToCharArray();
		
		var map = new Dictionary<char, HashSet<char>>(30);
		var map2 = new Dictionary<char, HashSet<char>>(30);
		/*
		var smap = new Dictionary<char, int>(30);
		var tmap = new Dictionary<char, int>(30);
		*/
		for(int i = 0; i < s.Length; i++)
		{
		/*
			if(!smap.ContainsKey(s[i]))
				smap.Add(s[i], 0);
			if(!tmap.ContainsKey(t[i]))
				tmap.Add(t[i], 0);
			smap[s[i]]++;
			tmap[t[i]]++;
			*/
			if(!map.ContainsKey(t[i]))
			{
				map.Add(t[i], new HashSet<char>());
				map[t[i]].Add(s[i]);
			}
			else if(!map[t[i]].Contains(s[i]))
			{
				Console.WriteLine("No");
				return;
			}
			
			if(!map2.ContainsKey(s[i]))
			{
				map2.Add(s[i], new HashSet<char>());
				map2[s[i]].Add(t[i]);
			}
			else if(!map2[s[i]].Contains(t[i]))
			{
				Console.WriteLine("No");
				return;
			}
		}
		/*
		if(smap.Count == 28)
		{
			Console.WriteLine("No");
			return;
		}
		*/
		Console.WriteLine("Yes");
		
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



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

vector<int> D;

bool check(int num) {
	bool ret = true;
	while (num > 0) {
		for (int i = 0; i < D.size(); i++) {
			if (num % 10 == D[i]) {
				ret = false;
				break;
			}
		}
		if (!ret) break;
		num /= 10;
	}
	return ret;
}

int main() {
	int N, K;
	cin >> N >> K;
	D = vector<int>(K, 0);
	for (int i = 0; i < K; i++) cin >> D[i];
	while (true) {
		if (check(N)) break;
		else N++;
	}
	cout << N << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!{
        n: u32,
        s: [String; n]
    }
    let mut ans = [0, 0, 0, 0];
    let result = [String::from("AC"), String::from("WA"), String::from("TLE"), String::from("RE")];
    for text in s {
        for i in 0..4{
            if text == result[i] {
                ans[i] += 1;
            }
        }
    }
    for i in 0..4{
        println!("{} x {}", result[i], ans[i]);
    }
}


Measured memory_bytes: 7780
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b){
            System.out.println("a < b");
        }else if(a > b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26160
#include<iostream>
//#include<cmath>
using namespace std;

int main(){
    int a,b;
    //cout<<"please input 2 numbers.\n"<<endl;
    cin >>a>>b;
    if (a>b){
        cout<<"a > b"<<endl;
        }else if (a==b){
            cout<<"a == b"<<endl;
        }
        else{
        cout<<"a < b"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    vector<int> b={2000,1800,1600,1400,1200,1000,800,600,400};
    int x;
    cin >> x;
    For(i,0,9){
        if(x>=b[i]){
            cout << i << endl;
            return;
        }
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

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

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

string s[110];

int main() {
	ll N, L;
	cin >> N >> L;
	repi(i, 0, N) rd(s[i]);
	sort(s, s + N);
	repi(i, 0, N) wr(s[i]);
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
st = []
cp = []
for i in range(n):
    a,b = map(int, input().split())
    st.append([a,b])

for i in range(m):
    c,d = map(int, input().split())
    cp.append([c,d])

ans = []
for x in st:
    t = []
    for y in cp:
        t.append(abs(x[0]-y[0])+abs(x[1]-y[1]))
    ans.append(t.index(min(t))+1)

for i in range(n):
    print(ans[i])

Measured memory_bytes: 3064
// 2011/07/01 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	int cnt[4] = {0};

	while(true){
		string str;
		cin >> str;
		if(cin.eof())
			break;

		for(int i=0; i<str.size(); i++)
			if(str[i]==',')
				str[i] = ' ';

		istringstream ist(str);
		string num, bld;
		ist >> num >> bld;

		if(bld=="A")
			cnt[0]++;
		else if(bld=="B")
			cnt[1]++;
		else if(bld=="AB")
			cnt[2]++;
		else if(bld=="O")
			cnt[3]++;
	}

	for(int i=0; i<4; i++)
		cout << cnt[i] << endl;

	return 0;
}

Measured memory_bytes: 0
N,D = map(int,input().split())
X = list()
ans = 0
for i in range(0,N):
    XN = list(map(int,input().split()))
    X.append(XN)
    if i > 0:
        k = i - 1
        while(k >= 0):
            delta = 0
            for j in range(0,D):
                delta += (X[i][j] - X[k][j])**2
            if float.is_integer(delta**(1/2)) :
                ans += 1
            k -= 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    int numdatasets; cin >> numdatasets;
    rep(i, numdatasets) {
        int goalx, goaly; cin >> goalx >> goaly;
        int numcatnips; cin >> numcatnips;
        //マタタビは2つの座標の間に置かれる
        vector<pii> cantreachfromleft;
        vector<pii> cantreachfrombottom;
        rep(j, numcatnips) {
            int oneendofcatnipplacex, oneendofcatnipplacey;
            int theotherendofcatnipplacex, theotherendofcatnipplacey;
            cin >> oneendofcatnipplacex >> oneendofcatnipplacey;
            cin >> theotherendofcatnipplacex >> theotherendofcatnipplacey;
            if (oneendofcatnipplacex == theotherendofcatnipplacex) {
                cantreachfrombottom.push_back({max(oneendofcatnipplacey, theotherendofcatnipplacey),
                    oneendofcatnipplacex});
            } else if (oneendofcatnipplacey == theotherendofcatnipplacey) {
                cantreachfromleft.push_back({oneendofcatnipplacey,
                    max(oneendofcatnipplacex, theotherendofcatnipplacex)});
            }
        }
        int numroutes00toij[goaly + 1][goalx + 1];
        rep(i, goaly + 1) {
            rep(j, goalx + 1) {
                numroutes00toij[i][j] = 0;
            }
        }
        numroutes00toij[0][0] = 1;
        rep(i, goaly + 1) {
            rep(j, goalx + 1) {
                if (i - 1 >= 0) numroutes00toij[i][j] += numroutes00toij[i - 1][j];
                if (j - 1 >= 0) numroutes00toij[i][j] += numroutes00toij[i][j - 1];
                rep(k, cantreachfromleft.size()) {
                    if (cantreachfromleft[k].first == i) {
                        if (cantreachfromleft[k].second == j) {
                            numroutes00toij[i][j] -= numroutes00toij[i][j - 1];
                        }
                    }
                }
                rep(k, cantreachfrombottom.size()) {
                    if (cantreachfrombottom[k].first == i) {
                        if (cantreachfrombottom[k].second == j) {
                            numroutes00toij[i][j] -= numroutes00toij[i - 1][j];
                        }
                    }
                }
            }
        }
        if (numroutes00toij[goaly][goalx]) cout << numroutes00toij[goaly][goalx] << endl;
        else cout << "Miserable Hokusai!" << endl;
    }
}



Measured memory_bytes: 3068
// O(V^3)
fn all_shortest_path(adjm: &mut Vec<Vec<i64>>) -> bool {
    let n = adjm.len();
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                if adjm[i][j] > adjm[i][k] + adjm[k][j] && adjm[i][k] != INF && adjm[k][j] != INF {
                    adjm[i][j] = adjm[i][k] + adjm[k][j];
                }
            }
        }
    }
    for i in 0..n {
        if adjm[i][i] < 0 {
            return false;
        }
    }
    true
}

fn solve() {
    let (v, e): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut adjm = vec![vec![INF; v]; v];
    for _ in 0..e {
        let (s, t, cost): (usize, usize, i64) = (read::<usize>(), read::<usize>(), read::<i64>());
        adjm[s][t] = cost;
    }
    for i in 0..v {
        adjm[i][i] = 0;
    }
    if all_shortest_path(&mut adjm) {
        for i in 0..v {
            for j in 0..v {
                if adjm[i][j] == INF {
                    print!("INF");
                } else {
                    print!("{}", adjm[i][j]);
                }
                if j != v - 1 {
                    print!(" ");
                }
            }
            println!("");
        }
    } else {
        println!("NEGATIVE CYCLE");
    }
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;
const INF: i64 = 100_000_000_000;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 9088
N, K, Q = gets.strip.split(' ').map(&:to_i)
A = []
Q.times do
  A.push gets.to_i
end
if K > Q
  N.times { puts 'Yes' }
else
  scores = Array.new(N, K - Q)
  A.each do |a|
    scores[a-1] += 1
  end

  scores.each do |r|
    msg = 'Yes'
    msg = 'No' if r <= 0
    puts msg
  end
end


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

const int N = 100010;

int sg[N], n, k, a[N], vis[N];

int mex(int x) {
	memset(vis, 0, sizeof(vis));
	for(int i = 1; i <= n; ++i) {
		if(x - a[i] >= 0) vis[sg[x - a[i]]] = 1;
	}
	for(int i = 0; i <= 100000; ++i) if(!vis[i]) return i;
}

int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
	}
	for(int j = 1; j <= k; ++j) sg[j] = mex(j);
	if(sg[k]) puts("First");
	else puts("Second");
}

Measured memory_bytes: 1024