akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int N, m; cin >> N >> m;
    vector<vector<int>> s(m);
    REP(i, m){
        int k; cin >> k;
        s[i].resize(k);
        REP(j, k){
            cin >> s[i][j];
            --s[i][j];
        }
    }
    vector<int> p(m);
    REP(i, m) cin >> p[i];
    int ans = 0;
    for (int i = 0; i < (1 << N); ++i) {
	bool ok = true;
	for (int j = 0; j < m; ++j) {
		int c = 0;
		for (int id : s[j]) {
			if ((i >> id) & 1) {
				++c;
			}
		}
		c %= 2;
		if (c != p[j]) {
			ok = false;
		}
	}
	if (ok) {
		++ans;
	}
}
cout << ans << endl;


}

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


int main()
{
    string base = "0123456789";
    for (int i = 0; i < 10; i++) s.insert(base[i]);
    string str;
    int i, res = 0;
    while (cin >> str) {
        i = str.size()-1;
        while (i >= 0) {
            if (s.find(str[i]) != s.end()) {
                int t = 1;
                while (s.find(str[i]) != s.end() && i >= 0) {
                    res += int(str[i]-'0') * t;
                    t *= 10;
                    i--;
                }
            }
            i--;
        }
    }
    cout << res << endl;
    return 0;
}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

const string YES = "Yes";
const string NO = "No";
void solve(std::string S) {
    bool ok = true;
    for (int i = 0; i < S.size() - 1; i += 2) {
        if (S[i] != 'h' or S[i + 1] != 'i') {
            ok = false;
            break;
        }
    }
    if (S.size() % 2 != 0) ok = false;

    cout << (ok ? YES : NO) << endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
/*#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>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
# define ll unsigned long long
# define int long long  //comment it out when MLE
# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 998244353
//# define MOD 163577857
# define pi acos(-1)
# define fi first
# define se second
#define REP(i,n) for (int i = 1; i <= n; i++)
const ll mod = 1000000007;
const int K = 2;
//typedef vector<vector<int> > matrix;
/*
int add(int a, int b,int mod) {
    a%=mod;
    b%=mod;
	a += b;
	if (a >= mod) a -= mod;
	if(a<0)
    {
        a += mod;
        a %= mod;
    }
	return a;
}

int mul(ll a, int b,int mod) {
    a%=mod;
    b%=mod;
	a *= b;
	a += mod;
	return a % mod;
}
int po(int a,int b,int mod)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return po(mul(a,a,mod),b/2,mod);
    return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
}


ll fact[1000003];
ll inv[1000003];

void fact0()
{
	int i,j;
	fact[0]=1;
	for(i=1;i<=200000;i++)
	{
		fact[i]=i*fact[i-1]%mod;
	}
	inv[0]=1;
	inv[1]=1;
	ll p=mod;
	for (i=2; i<=200000; i++)
		inv[i] = (p - (p/i) * inv[p%i] % p) % p;

	for(i=2;i<=200000;i++)
	{
		inv[i]*=inv[i-1];
		inv[i]%=mod;
	}
}
*/

signed main(){
   gok

   int a[5];
   for(int i=0;i<5;i++)
    cin>>a[i];

   int an=1;
   for(int i=0;i<5;i++)
   {
       if(a[i]==0)
       {
           an=i+1;
           break;
       }
   }
cout<<an;



















 return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define mp make_pair
#define np next_permutation
#define pb push_back
#define all(x) x.begin(),x.end()
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
using namespace std; 
const int maxn=500+5;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
vi v[maxn];
int dp[maxn][maxn];
int n,m,q,li,ri,pi,qi;
void solve(){
	rep(i,1,n+1) sort(v[i].begin(),v[i].end());
	memset(dp,0,sizeof(dp));
	rep(l,1,n+1){
		for(int r=l;r<=n;r++){
			dp[l][r]=dp[l][r-1];
//			if(r-1<l) continue;
			dp[l][r]+=(v[r].size()-(lower_bound(v[r].begin(),v[r].end(),l)-v[r].begin()));
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	while(cin>>n>>m>>q){
		rep(i,0,m){
			cin>>li>>ri;
			v[ri].pb(li);
		}
		solve();
		rep(i,0,q){
			cin>>pi>>qi;
			cout<<dp[pi][qi]<<endl;
		}
	}
} 

Measured memory_bytes: 3200
from string import ascii_lowercase

s = input()
k = int(input())

d = {c: (26 - i) % 26 for i, c in enumerate(ascii_lowercase)}

ret = ''
for c in s[:-1]:
    if d[c] <= k:
        k -= d[c]
        ret += 'a'
    else:
        ret += c

k %= 26
idx = (ascii_lowercase.index(s[-1]) + k) % 26
c = ascii_lowercase[idx]
ret += c

print(ret)


Measured memory_bytes: 4088
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll P, Q, R;
    cin >> P >> Q >> R;
    cout << min({ P + Q,Q + R,P + R });
    //
    return 0;
}

Measured memory_bytes: 3660
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	a, _ := strconv.Atoi(stringLineScan())
	b, _ := strconv.Atoi(stringLineScan())
	c, _ := strconv.Atoi(stringLineScan())
	d, _ := strconv.Atoi(stringLineScan())
	e, _ := strconv.Atoi(stringLineScan())
	f, _ := strconv.Atoi(stringLineScan())
	m := 0.0
	g := 0
	h := 0
	for i := 0; i <= f/(b*100); i++ {
		x := f - i*b*100
		for j := 0; j <= x/(a*100); j++ {
			w := b*i + a*j
			s := smaller(w*e, f-100*w)
			for k := 0; k <= s/d; k++ {
				t := k*d + (s-k*d)/c*c
				u := float64(t) / float64(100*w+t)
				if u >= m {
					g = 100*w + t
					h = t
					m = u
				}
			}
		}
	}
	fmt.Println(g, h)
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


Measured memory_bytes: 640
#include<stdio.h>

#define SENTINEL 2000000000

int cnt=0;

void merge(int *A,int left,int mid,int right)//分割した配列を小さい順に結合
{
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1],R[n2];
  int k,i,j;
  for (i=0;i<n1;i++) L[i] = A[left + i];
  for (i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = SENTINEL;//EOF
  R[n2] = SENTINEL;//EOF
  i = 0;
  j = 0;
  for(k=left;k<right;k++){//iが左の要素番号,jが右の要素番号
    cnt++;//比較するたびcntをインクリメント
    if(L[i]<=R[j]){//左が小さい場合
      A[k] = L[i];
      i=i+1;
    }else{ //右が小さい場合
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(int *A,int left,int right)
{
  int mid;
  if(left+1<right){//二分探索のように左端が右端を超えたら終了
    mid = (left + right)/2;
    mergeSort(A, left, mid);//左半分で再帰
    mergeSort(A, mid, right);//右半分で再帰
    merge(A, left, mid, right);//結合
  }
}

int main(void)
{
    int n,i;
    int A[500001];
    int left,right;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    left=0;
    right=n;
    mergeSort(A,left,right);
    for(i=0;i<n;i++){
      if(i!=0) printf(" ");
      printf("%d",A[i]);
    }
    printf("\n%d\n",cnt);
    
    return 0;
}


Measured memory_bytes: 5580
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var s = line[0];
        var t = line[1];
        line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var u = Console.ReadLine().Trim();
        if (u == s) a--;
        else b--;
        Console.WriteLine("{0} {1}", a, b);
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    double a, b;

    cin >> a >> b;

    double c = ceil((a + b) / 2.0);
    int x = (int)c;

    cout << x << '\n';

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
int main(void)
{
  int a,b,c,total=0;
  scanf("%d",&a);
  scanf("%d %d",&b,&c);
  while(total <= c)
  {
     total += a;
     if(total >= b && total <= c)
     {
       printf("OK");
       break;
     }
     if(total > c)
     {
       printf("NG");
       break;
     }
  }
 
  return 0;
}

Measured memory_bytes: 1728
from math import ceil
n = int(input())
def solve(a, k):
	if a < k:
		return 0
	while a%k != 0:
		a -= ceil((a%k)/((a//k)+1)) * ((a//k)+1)
	return a//k
ans = 0
for _ in range(n):
	a, k = map(int, input().split())
	ans ^= solve(a, k)
if ans == 0:
	print("Aoki")
else:
	print("Takahashi")

Measured memory_bytes: 40556
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MAX = 200005;

int main() {
    vector<bool> prime(MAX, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i * i <= MAX; i++) {
        if (!prime[i]) continue;
        for (int j = i * i; j < MAX; j += i) {
            prime[j] = false;
        }
    }
    int x;
    cin >> x;
    for (int i = x; i < MAX; i++) {
        if (prime[i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[] n = new int[51];//0~50
        Arrays.fill(n, 0);
        for(int i = 0;i<10;i++){
            for(int j = 0;j<10;j++){
                for(int k = 0;k<10;k++){
                    for(int l=0;l<10;l++){
                        n[i+j+k+l]++;
                    }
                }
            }
        }
        
        try{
            String s;
            while((s=br.readLine())!=null){
                System.out.println(n[Integer.parseInt(s)]);
            }
        }catch(Exception ex){
            System.exit(0);
        }
    }
}

Measured memory_bytes: 24132
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

ll n,q;

void solve(ll u,ll v)
{
    while(u != v){
        if(u > v) swap(u,v);
        v = (v+n-2)/n;
    }
    cout << u << "\n";
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> q;
    rep(i,q){
        ll u,v;
        cin >> u >> v;
        if(n == 1){
            cout << min(u,v) << "\n";
        }else{
            solve(u,v);
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
int a[100000];
int main()
{
  int n,k,i,s,m;
  for(;;){
    scanf("%d%d",&n,&k);
    if(n==0 && k==0) break;
    s = 0;
    for(i=0;i<k;i++){
      scanf("%d",&a[i]);
      s += a[i];
    }
    m = s;
    for(;i<n;i++){
      scanf("%d",&a[i]);
      s += a[i];
      s -= a[i-k];
      if(m<s) m = s;
    }
    printf("%d\n",m);
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
struct node
{
    int a,b,c,d;
}re[250050];
int a[550][550];
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
        scanf("%d",&a[i][j]);
    int cnt=0;
    for(int i=1;i<h;i++)
        for(int j=1;j<=w;j++)
        if(a[i][j]%2==1) a[i][j]--,a[i+1][j]++,re[cnt].a=i,re[cnt].b=j,re[cnt].c=i+1,re[cnt].d=j,cnt++;
    for(int j=1;j<w;j++)
        if(a[h][j]%2==1) a[h][j]--,a[h][j+1]++,re[cnt].a=h,re[cnt].b=j,re[cnt].c=h,re[cnt].d=j+1,cnt++;
    printf("%d\n",cnt);
    for(int i=0;i<cnt;i++)
        printf("%d %d %d %d\n",re[i].a,re[i].b,re[i].c,re[i].d);
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

ll power(ll int x,ll int n)
{if(n==0)return 1;
else if(n%2 == 0)return power(x*x,n/2);
else return x*power(x*x,(n-1)/2);}

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}

void solve()
{
  ll x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  if(x1==0)
    cout<<1;
  else
    if(x2==0)
      cout<<2;
  else
    if(x3==0)
      cout<<3;
  else
    if(x4==0)
      cout<<4;
  else
    cout<<5;
    
}


int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    
}
//pr12


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a, b, c;
ll k;
int main()
{
	scanf("%d%d%d", &a, &b, &c);
	scanf("%lld", &k);
	if(k & 1) printf("%d\n", b - a);
	else printf("%d\n", a - b);
	return 0;
}

Measured memory_bytes: 3788
import numpy as np
a,b,x = map(int,input().split())
if x < (a * a * b) / 2:
  ans=np.arctan((a * b * b) / (2 * x))
else:
  ans=np.arctan((2 * b)/a - (2 * x)/(a**3))
ans = 180 * ans / np.pi
print(ans)

Measured memory_bytes: 12484
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int H, W;
    char map[101][101];
    bool frow[101] = {false}, fcol[101] = {false};
    cin >> H >> W;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            cin >> map[i][j];
            if (map[i][j] == '#') {
                frow[i] = true;
                fcol[j] = true;
            }
        }
    }
    for (int i = 1; i <= H; ++i) {
        bool f = false;
        for (int j = 1; j <= W; ++j) {
            if (frow[i] && fcol[j]) {
                cout << map[i][j];
                f = true;
            }
        }
        if (f) {
            cout << endl;
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
	int n,num[50],score[50]={0},tmp;
	int s_max,ans_num;
	vector<int> pin;

	while(cin>>n){
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin>>num[i];
			score[i]=0; pin.clear();
			for(int j=0;j<9;j++){
				cin>>tmp; score[i]+=tmp; pin.push_back(tmp);
				if(tmp==10) continue;
				cin>>tmp; score[i]+=tmp; pin.push_back(tmp);
			}

			cin>>tmp; score[i]+=tmp; pin.push_back(tmp);
			cin>>tmp; score[i]+=tmp; pin.push_back(tmp);
			if(pin[pin.size()-2]==10 || pin[pin.size()-1]+pin[pin.size()-2]==10){
				cin>>tmp; score[i]+=tmp; pin.push_back(tmp);
			}


			for(int j=0,k=0;j<9;j++){
				if(pin[k]==10){
					score[i]+=pin[k+1]+pin[k+2]; k++;
				}else if(pin[k]+pin[k+1]==10){
					score[i]+=pin[k+2]; k+=2;
				}else{k+=2;}
			}

		}
		
		for(int i=0;i<n;i++){
			s_max=-1;
			for(int j=0;j<n;j++){
				if(score[j]>s_max || score[j]==s_max && num[j]<num[ans_num]){
					 s_max=score[j]; ans_num=j;
				}

			}
			cout<<num[ans_num]<<" "<<score[ans_num]<<endl;
			score[ans_num]=-1;
		}
	}
	
	return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS

    long double now=100;
    ll x;
    cin>>x;
    for (int i=1;;i++)
    {
        now*=(1.01);
        now-=fmod(now,1.0);
        if (now>=x)
        {
            cout<<i<<endl;
            return 0;
        }
    }
}



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

int main(void){
  int i,n,sum1=0,sum2=0;
  static int a[100000]={};
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
    sum1+=a[i];
    if(i%2==0)sum2+=a[i];
  }

  int tmp=sum2*2-sum1;

  for(i=0;i<n;i++){
    cout<<tmp<<endl;
    tmp=(a[i]-tmp/2)*2;
  }

	return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <algorithm>
using namespace std;
int vis[105];
int f[105];
int n, m, x;
int main(){
	int i, temp;
	scanf("%d %d %d", &n, &m, &x);
	for(i=1; i<=m; i++)
		scanf("%d", &temp), vis[temp]=1;
	for(i=x-1; i+1; i--)
		f[i]=vis[i]+f[i+1];
	for(i=x+1; i<=n; i++)
		f[i]=vis[i]+f[i-1];
	printf("%d", min(f[0], f[n]));
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n, k int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	fmt.Scan(&k)

	kth := []rune(s[k - 1: k])[0]
	var res []rune

	for _, r := range s {
		if r == kth {
			res = append(res, r)
		} else {
			res = append(res, '*')
		}
	}

	fmt.Println(string(res))
}

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i + 1 < s.length(); ++i) {
        if (s[i] != s[i + 1]) {
            ++ans;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	int ans[26];
	for(int i=0; i<26; i++) ans[i] = INT_MAX;
	for(int i=0; i<N; i++){
		string S;
		cin >> S;
		int c[26] = {};
		for(int j=0; j<S.size(); j++){
			c[S[j]-'a']++;
		}
		for(int j=0; j<26; j++){
			ans[j] = min(ans[j], c[j]);
		}
	}
	string a = "";
	for(int i=0; i<26; i++){
		for(int j=0; j<ans[i]; j++){
			a += (char)('a'+i);
		}
	}
	cout << a << endl;

	return 0;
}


Measured memory_bytes: 256
import * as fs from "fs";


let lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
let N = Number(lines[0]);
let Graph: number[][] = new Array(N).fill(0).map(() => new Array());
let incomingDegrees: number[] = new Array(N).fill(0);

for(let i=0; i<N-1; i++) {
    let [a, b] = lines[i+1].split(" ").map(Number);
    a -= 1;
    b -= 1;
    Graph[a].push(b);
    Graph[b].push(a);
    incomingDegrees[a] += 1;
    incomingDegrees[b] += 1;
}

let C: number[] = lines[N].split(" ").map(Number).sort((a, b) => b-a);

let oneDegreeNodes: number[] = [];

for(let i=0; i<N; i++) {
    if (incomingDegrees[i] == 1)
        oneDegreeNodes.push(i);
}

let assignment: number[] = new Array(N).fill(C[0]);
let answer: number = 0;

while(oneDegreeNodes.length != 1) {
    let node = oneDegreeNodes.pop();
    assignment[node] = C.pop();
    answer += assignment[node];
    for(let neighbour of Graph[node]) {
        incomingDegrees[neighbour] -= 1;
        if (incomingDegrees[neighbour] == 1)
            oneDegreeNodes.push(neighbour);
    }
}
console.log(answer);
console.log(...assignment);


Measured memory_bytes: 40244
import java.util.Scanner;

public class Main {

    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        String s = in.nextLine();
        long ans = 0;
        int size = s.length();
        int spaces = size - 1;

        long spacesWithin, reps;
        long num;
        for (int i = 0; i < size; i++) {
            for (int j = i; j < size; j++) {
                spacesWithin = spaces - 1 - (j - i);
                if (!(i == 0 || j == (size - 1))){
                    --spacesWithin;
                }
                spacesWithin = Math.max(0, spacesWithin);
                reps = 1 << spacesWithin;
                num = Long.parseLong(s.substring(i, j + 1));
                ans += (reps * num);
            }
        }

        System.out.println(ans);
    }
}
























Measured memory_bytes: 21716
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem D


def execute_janken(self, other):
    if self == 'p' and other == 'g':
        return 1
    elif self == 'g' and other == 'p':
        return -1
    else:
        return 0


if __name__ == '__main__':
    s = input()
    p_count = 0
    g_count = 0
    score = 0
    hand = ''

    for si in s:
        if p_count == g_count:
            hand = 'g'
            g_count += 1
        elif p_count < g_count:
            hand = 'p'
            p_count += 1

        score += execute_janken(self=hand, other=si)

    print(score)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

string x;

int main(){
  cin >> x;
  int l = x.size();

  int ans = 0;
  int ct = 0;

  REP(i, l) {
    if(x[i] == 'S') {
      ct++;
    } else if(ct == 0) {
      ans++;
    } else {
      ct--;
    }
  }

  cout << 2 * ans << endl;

  return 0;
}


Measured memory_bytes: 640
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;

int main() {
    int x, n;
    cin >> x >> n;
    unordered_set < int > p;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        p.insert(t);
    }

    int ans = -100;
    for (int a = -200; a <= 200; ++a) {
        if (!p.count(a)) {
            if (abs(x-a) < abs(x-ans)) {
                ans = a;
            }
        }
    }

    cout << ans;

    return 0;
}


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

signed main(){
  
  int N, M;
  cin>>N>>M;
  
  string s, t;
  cin>>s>>t;
  
  int minl =  N * M /__gcd( N, M );
  
  map<int,char> memo;
  
  int A = 0, x = minl / (int)s.size();
  
  for(int i=0;i<(int)s.size();i++,A+=x) memo[A] = s[i];
  
  int B = 0, y = minl / (int)t.size();
  
  for(int i=0;i<(int)t.size();i++,B+=y){
    
    if( memo.count( B ) && memo[B] != t[i] ){
      cout<<-1<<endl;
      return 0;
    }
    
  }
  
  cout<<minl<<endl;  
  
  return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int ans=1,N,K;
  cin>>N>>K;
  rep(i,N){
    if(ans*2<ans+K)ans*=2;
    else ans+=K;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%3d", arr[i][j]); } cout << endl; }

using namespace std;

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;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int a,b;
int main() {
    cin >>a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(a > 5) {
        cout << b / 2 << endl;
    }else{
        cout << 0 << endl;
    }

}




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

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

    vector<int> a(n);
    int sum = 0;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end(), greater<>());

    int count = 0;
    for (auto i = 0; i < n; i++) {
        if(a[i] * (4 * m) >= sum) count++;
        if(count == m) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << ("No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char s[1024] = "";
    int i;

    fgets(s, sizeof(s), stdin);

    for (i = 0; s[i] != '\0'; ++i){
        if ('a' <= s[i] && s[i] <= 'z'){
            s[i] -= 'a' - 'A';
        }
    }

    printf("%s", s);

    return (0);
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
using namespace std;
int N, A[2][100];
int collect(int i, int j, int candies) {
    if (i == 1 && j == N - 1) return candies + A[1][N-1];
    if (i > 1 || j >= N) return 0;
    candies += A[i][j];
    return max(collect(i + 1, j, candies), collect(i, j + 1, candies));
}
int main() {
    cin >> N;
    for (int i = 0; i < 2; i++)
        for (int j = 0; j < N; j++)
            cin >> A[i][j];
    cout << collect(0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("out.o", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	cout << n*n;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long int
#define N 100000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */
int main()
{
    ll n,m;
    cin >> n >>  m;

    if(n>1)
    n=(n*(n-1))/2;
    else
    {
        n=0;
    }
    
    if(m>2)
    m=(m*(m-1))/2;
    else
    {
        m=0;
    }

    cout << n+m ;
    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define vll vector<long long int>
#define vpii vector<pair<int,int>>
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define MAX 1000000000000000000
#define test int t; cin>>t;
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()

using namespace std;

ll nxt(){
    ll x;
    cin>>x;
    return x;
}

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS

    ll x = nxt(), k = nxt(), d = nxt();
    ll pos = LLONG_MAX, neg = LLONG_MIN;
    ll res;
    if(x<0) x = -x;
    // if(x>=0){
        ll steps = x/d;
        if(steps>=k){
            res = x-k*d;
        }
        else{
            res = x-steps*d;
            k-=steps;
            //cout<<k<<endl;
            if(k%2) res = (ll)abs(res-d);
        }
    // }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 3632
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val grid = (0 until h).map { readLine()!!.toCharArray() }.toTypedArray()
    val dx = listOf(0, 1, 1, 1, 0, -1, -1, -1)
    val dy = listOf(-1, -1, 0, 1, 1, 1, 0, -1)
    for (i in 0 until h) {
        for (j in 0 until w) {
            if (grid[i][j] == '.') {
                var cnt = 0
                for (k in 0 until 8) {
                    val x = j + dx[k]
                    val y = i + dy[k]
                    if (x in 0 until w && y in 0 until h) {
                        if (grid[y][x] == '#') cnt++
                    }
                }
                grid[i][j] = '0' + cnt
            }
        }
    }
    println(grid.joinToString("\n") { it.joinToString("") })
}


Measured memory_bytes: 38172
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}




string str;

bool solve() {
    stack<char> st;
    int n = str.size();
    
    for (int i = 0; i < 10000; ++i) st.push(-1);
    for (int i = 0; i < n; ++i) {
        char c = str[i];
        if (c != 'w') st.push(c);
        else {
            if (st.top() == 'e') st.pop();
            else return false;
            
            if (st.top() == 'm') st.pop();
            else return false;
            
            if (st.top() == -1 && i != n-1) return false;
        }
    }
    
    if (st.top() == -1) return true;
    else return false;
}

int main() {
    while (cin >> str) {
        bool res = solve();
        if (res) cout << "Cat" << endl;
        else cout << "Rabbit" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1208
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    println!("{}",if a<1200{"ABC"}else if a<2800{"ARC"}else{"AGC"})
}


Measured memory_bytes: 4352
def main():
    x, n = map(int, input().split())
    ps = list(map(int, input().split()))

    for i in range(n//2 + 2):
        if x - i not in ps:
            print(x-i)
            return
        if x + i not in ps:
            print(x+i)
            return


if __name__ == '__main__':
    main()


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

template< typename T >
struct BinaryIndexedTree {
	vector<T> data;

	BinaryIndexedTree(int size):data(size+1,0) {}

	T sum(int k) {
		T res=0;
		for(++k;k>0;k-=(k&-k)) res+=data[k];
		return res;
	}

	void add(int k,T x) {
		for(++k;k<(int)data.size();k+=(k&-k)) data[k]+=x;
	}
};

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

	int n,q;
	cin>>n>>q;
	BinaryIndexedTree<long long> tree(n+1);
	while(q--) {
		int type,x,y;
		cin>>type>>x>>y;
		if(type==0) {
			tree.add(x,y);
		}
		else {
			cout<<tree.sum(y)-tree.sum(x-1)<<endl;
		}
	}

	return 0;
}



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

#include <stdio.h>

/******
*	?????????????????????
******/
/******??¢?????´?????????
*	?????????????????????????????????
*	?????????????????????????????¨???????????????????????§????????????
*	??¢???????????????
******/

#define ALPHABET 26


int main(void)
{
	char string[1200]={0};			//??????????????????????????????????????????
	int count[ALPHABET]={0};		//?????¢?????????????????????????????????????????°????????°????????????
	int num ;					//??????ch?????????(0~25)	
	char ch = '0';
	int i =0;
//----------------------------------------------------------------??\???
	
	while ( scanf("%c", &ch) != EOF ){
	
		
//		scanf(" %c", &ch);
		string[i]=ch;
	

			//ch?????¢???????????????????????¨??????????????????
		num = 0;
		num = ch - 'A';		// ?????? ch ????????? ??±??????????????°0~25(a~z)
		
		if( 32 <=  num && num <= 57 ){		//??????????°????????????¨????????§???????????????
			num = num - 32;
		}else {
		//??§???????????¨????????§????????????????????????????????????
		}
		
		if(0 <=  num && num < ALPHABET){//?????§???????????¨?????????????????????0~25
				count[num]++;			//???????????§?????????????????????
		}else{
			//??????????????????;
		}
		i++;
	}
//-----------------------------------------------------------------??????
	for (num = 0 ; num < ALPHABET; num++){
		
		printf("%c : %d\n", (num+'a'),  count[num]);		//?????¢?????????????????????????????°?????????
	}
	return 0;

}

Measured memory_bytes: 1136
#include<bits/stdc++.h>
#define IL inline
#define RI register int
#define eps 1e-8
char a[10010];
bool c,f;
int main()
{
    std::cin>>a;
    for(int i=0; i<strlen(a); i++) {
        if(a[i]=='C') c=true;
        if(a[i]=='F'&&c) f=true;
    }
    if(f) std::cout<<"Yes"<<std::endl;
    else std::cout<<"No"<<std::endl;
}

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

using namespace std;

int memo[200][200][200];

int solve(int a, int b, int c) {
    if (a > 199 || b > 199 || c > 199)
        return 1e7;
    if (a == b && a == c)
        return 0;

    int &r = memo[a][b][c];

    if (r == -1) {
        r = 1 + min(solve(a + 1, b + 1, c), solve(a + 1, b, c + 1));
        r = min(r, 1 + min(solve(a, b + 1, c + 1), solve(a + 2, b, c)));
        r = min(r, 1 + min(solve(a, b + 2, c), solve(a, b, c + 2)));
    }

    return r;
}

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

    memset(memo, -1, sizeof memo);
    int a, b, c;
    cin >> a >> b >> c;
    cout << solve(a, b, c) << '\n';

    return 0;
}


Measured memory_bytes: 31488
#include <iostream>

using namespace std;

void select_sort(int A[], int N){
    int tmp;
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(i != minj){
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
        }

    }
}

int main(){
    int A[3];

    cin >> A[0];
    cin >> A[1];
    cin >> A[2];

    select_sort(A, 3);

    for(int i = 0; i < 3; i++){
        if(i > 0){
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;

    return 0;
}


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

int main(){
	int h, w, i, j, k, x, y, ans;
	string s[60];
	int dx[]={-1, 0, 1, -1, 0, 1, -1, 0, 1};
	int dy[]={-1, -1, -1, 0, 0, 0, 1, 1, 1};
	cin>>h>>w;
	for(i=0; i<h; i++) cin>>s[i];
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			if(s[i][j]=='#') continue;
			ans=0;
			for(k=0; k<9; k++){
				x=i+dx[k];
				y=j+dy[k];
				if(x<0 || x>=h) continue;
				if(y<0 || y>=w) continue;
				if(s[x][y]=='#') ans++;
			}
			s[i][j]=char('0'+ans);
		}
	}
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			cout<<s[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int N = (int) 2e5 + 10;
char S[N];
int n;

int main() {
    #ifdef LOCAL
        freopen("Data.inp", "r", stdin);
        freopen("Data.out", "w", stdout);
    #endif

    scanf("%s", S + 1);
    n = strlen(S + 1);

    stack<int> T;
    for (int i = 1; i <= n; ++i) {
        if (S[i] == 'S') T.push(0); else {
            if (T.size() && T.top() == 0) T.pop();
            else T.push(1);
        }
    }

    printf("%d", (int) T.size());
    return 0;
}


Measured memory_bytes: 1280
{-# OPTIONS_GHC -O #-}

import Data.List (scanl, unfoldr, foldl')
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as S

import Control.Monad
import Control.Monad.ST
import Data.STRef
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV

msort :: MV.STVector s Int -> MV.STVector s Int -> (Int,Int) -> STRef s Int -> ST s ()
msort xv buf (s,e) ra
  | n == 1 = return ()
  | True = do
    msort xv buf lr ra
    msort xv buf rr ra
    forM_ [s..e-1] $ \i -> MV.unsafeRead xv i >>= MV.unsafeWrite buf i
    ac <- msort2 xv buf s lr rr 0 0
    modifySTRef' ra (+ac)
  where
    n = e - s
    m = s + (n+1) `div` 2
    lr@(ls,le) = (s,m)
    rr@(rs,re) = (m,e)
--
msort2 :: MV.STVector s Int -> MV.STVector s Int -> Int -> (Int,Int) -> (Int,Int) -> Int -> Int -> ST s Int
msort2 xv buf s (ls,le) (rs,re) ra rc
  | ls==le && rs==re = return ra
  | rs==re = MV.unsafeRead buf ls >>= MV.unsafeWrite xv s >> msort2 xv buf (s+1) (ls+1,le) (rs,re) (ra+rc) rc
  | ls==le = MV.unsafeRead buf rs >>= MV.unsafeWrite xv s >> msort2 xv buf (s+1) (ls,le) (rs+1,re) ra (rc+1)
  | True = do
    l <- MV.unsafeRead buf ls
    r <- MV.unsafeRead buf rs
    if l<=r
      then MV.unsafeWrite xv s l >> msort2 xv buf (s+1) (ls+1,le) (rs,re) (ra+rc) rc
      else MV.unsafeWrite xv s r >> msort2 xv buf (s+1) (ls,le) (rs+1,re) ra (rc+1)

invc ss = runST $ do
  v <- V.unsafeThaw $ V.fromList ss :: ST s (MV.STVector s Int)
  let len = MV.length v
  ra <- newSTRef (0::Int)
  buf <- MV.new len :: ST s (MV.STVector s Int)
  msort v buf (0, len) ra
  readSTRef ra

si as x = invc $ scanl (\ac a->if a>=x then ac+1 else ac-1) 0 as

bsearch f (a,b)
  | a+1 == b = a
  | f m  = bsearch f (m,b)
  | True = bsearch f (a,m)
  where m = (a + (b-a)`div`2)

ff av as tn x = niv >= ceiling ((fromIntegral tn) / 2.0)
  where
    niv = (-) tn $ si as $ av V.! x

main=do
  n<-readLn::IO Int
  as<-unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[Int]
  let av = V.fromList $ S.toAscList $ S.fromList as
  let tn = (n*(n+1))`div`2
  print $ (V.!) av $ bsearch (ff av as tn) (-1,V.length av)

Measured memory_bytes: 30076
//http://www.deqnotes.net/acmicpc/prim/
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
Point2D p2d=new Point2D.Double(d1,d2);
//import static java.lang.System.*;
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        String L=sc.next();
        long mod=(long) (1e9+7);
        int l=L.length();
        long[][] dp=new long[l][2];//0→equal,1→smaller
        dp[0][0]=2;
        dp[0][1]=1;
        for (int i = 1; i < l; i++) {
            if(L.charAt(i)=='1'){
                dp[i][1]=(3*dp[i-1][1]+dp[i-1][0])%mod;
                dp[i][0]=(2*dp[i-1][0])%mod;
            }else {
                dp[i][1]=(3*dp[i-1][1])%mod;
                dp[i][0]=dp[i-1][0];
            }
        }
        out.println((dp[l-1][0]+dp[l-1][1])%mod);
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static String nextLine() {
            return s.nextLine();
        }

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

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

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

        static boolean hasNext() {
            return s.hasNext();
        }

        static boolean hasNextInt() {
            return s.hasNextInt();
        }

    }

}

Measured memory_bytes: 29288
#include <stdio.h>

int main() {
  int N;
  int A[21];
  int B[21];
  int C[21];
  int tmp=0;
  int j = 0;
  int S = 0;
  scanf("%d",&N);
  for (int i = 0; i < N; i++) {
    scanf("%d",&A[i]);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d",&B[i]);
  }
  for (int i = 0; i < N-1; i++) {
    scanf("%d",&C[i]);
  }
  for (int i = 1; i < N; i++) {
    if (A[i] == A[i-1]+1) {
      j = A[i];
      tmp = tmp + C[j-2];
    }
  }
  for (int i = 0; i < N; i++) {
    S = S+B[i];
  }
/*  printf("%d\n",S);
  printf("%d\n",tmp);*/
  printf("%d\n",S+tmp);
  return 0;
}


Measured memory_bytes: 128
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] count;
    int i, a, l, r;
    String s;
    char[] c;

    count = new int[4];
    for(;sc.hasNextLine();){
      s = sc.nextLine();
      c = new char[s.length()];
      for(i = 0;i < s.length();i++)c[i] = s.charAt(i);
      l = 0; r = 0;
      for(i = 0;i < s.length();i++){
        if(c[i] == ','){
          r = i;
          a = readint(c, l, r);
          l = r + 1; r = s.length();
        }
      }
      if(c[l] == 'A' && r - l == 1)count[0]++;
      else if(c[l] == 'B')count[1]++;
      else if(c[l] == 'A' && r - l == 2)count[2]++;
      else count[3]++;

    }
    for(i = 0;i < 4;i++)out.println(count[i]);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int readint(char[] ch, int l, int r){
    int i, d, res;
    d = 1; res = 0;
    for(i = r - 1;i >= l;i--){
      res += d * (int)(ch[i] - '0');
      d *= 10;
    }
    return res;
  }
}

Measured memory_bytes: 17148