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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

template<typename T>
using reversed_priority_queue = \
    std::priority_queue<T, std::vector<T>, std::greater<T> >;

ll INF=1ll << 60;
ll H,W;
ll n_black = 0;
vector<vector<char>> s;
vector<vector<ll>> dist;

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

signed main() {
    cin >> H >> W;
    s.resize(H, vector<char>(W));
    dist.resize(H, vector<ll>(W, INF));
    rep(i,0,H)
        rep(j,0,W){
            cin>>s[i][j];
            if (s[i][j]=='#')
                n_black++;
        }
    // ダイクストラ
    reversed_priority_queue<pair<ll,PLL>> q; // {cost ,y, x}
    q.push(make_pair(0, make_pair(0,0)));
    while(!q.empty()){
        auto c = q.top().first;
        auto y = q.top().second.first;
        auto x = q.top().second.second;
        q.pop();
        if (c >= dist[y][x])
            continue;
        dist[y][x] = c;
        rep(k,0,4){
            ll nx = x + dx[k], ny = y + dy[k];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W)
                continue;
            if (s[ny][nx]=='#')
                continue;
            q.push(make_pair(c+1, make_pair(ny, nx)));
        }
    }
    if (dist[H-1][W-1]==INF)
        cout<<-1<<endl;
    else
        cout << H*W - n_black - (dist[H-1][W-1]+1) << endl;
    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    int m, n;
    cin >> n >> m;
    vector<string> a,b;
    REP(i, n){
        string tmp;
        cin >> tmp;
        a.PB(tmp);
    }
    REP(i, m){
        string tmp;
        cin >> tmp;
        b.PB(tmp);
    }

    REP(y1, n){ REP(x1, n) {
        bool flag = true;
        REP(y2, m){
            if (!flag) break;
            REP(x2, m) {
                int mx = x1 + x2;
                int my = y1 + y2;
                if(!RANGE(mx, my, n, n)){
                    flag = false;
                    break;
                }
                if(a[my][mx] != b[y2][x2]){
                    flag = false;
                    break;
                }
            }
        }
        if(flag){
            cout<< "Yes" << endl;
            return 0;
        }
    }}

    cout << "No" << endl;
}


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

long long n;

int main(){
     cin >> n;
     long long ans = n - 1;
     for(long long i = 1; i <= sqrt(n); i++){
     	if(n % i == 0){ 
     		ans = min(ans,i + n / i - 2);
     	}
     }
    	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

div_cnt = [0] * n

def search_div(data, n):
    while n != 1:
        for i in range(2, n + 1):
            if n % i == 0:
                data[i - 1] += 1
                n = int(n / i)
                break
        

for i in range(2, n + 1):
    search_div(div_cnt, i)

def count_num(data, n):
    cnt = 0
    for i in range(len(data)):
        if data[i] >= n - 1:
            cnt += 1
    
    return cnt
print(int(count_num(div_cnt, 75) + count_num(div_cnt, 25) * (count_num(div_cnt, 3) - 1) + count_num(div_cnt, 15) * (count_num(div_cnt, 5) - 1) + count_num(div_cnt, 5) * (count_num(div_cnt, 5) - 1) / 2 * (count_num(div_cnt, 3) - 2)))

Measured memory_bytes: 3064
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, a, b, c = map(int, readline().split())
l = [int(readline()) for _ in range(n)]

ans = float('inf')
for pattern in itertools.product(range(4), repeat=n):
    cnt = [0] * 4
    length = [0] * 4
    mp = 0
    for i, v in enumerate(pattern):
        if cnt[v] != 0 and 0 <= v <= 2:
            mp += 10
        cnt[v] += 1
        length[v] += l[i]
    if cnt[0] > 0 and cnt[1] > 0 and cnt[2] > 0:
        mp += abs(a - length[0]) + abs(b - length[1]) + abs(c - length[2])
        ans = min(ans, mp)

print(ans)

Measured memory_bytes: 9088
A, B, C, D = map(int, input().split())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a, b):
    return a*b//gcd(a, b)

E = lcm(C, D)

# B以下
ans_b_c = (B // C) + (B // D) - (B // E)
ans_b = B - ans_b_c
# A未満
ans_a_c = ((A - 1) // C) + ((A - 1) // D) - ((A - 1) // E)
ans_a = (A - 1) - ans_a_c

ans = ans_b - ans_a
print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);
            int a = scan.nextInt();
            int b = scan.nextInt();

            int area = a * b;
            int Lap = 2*a + 2*b;
            System.out.println(area+" "+Lap);
    
    }
}


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

using namespace std;

inline void quit(){ exit(0); }

typedef long long ll;

ll mpow(ll _x, ll _y, ll _mod){
    if(_y==0) return 1;
    if(_y==1) return _x%_mod;
    if(_y&1) return (mpow(_x, _y-1, _mod)*_x)%_mod;
    ll _tmp = mpow(_x, _y>>1, _mod);
    return (_tmp*_tmp)%_mod;
}

ll n;
ll arr[100002];
vector<pair<ll, ll> > sorted;
set<ll> idx;
ll ans;

int main(){
    scanf("%lld", &n);
    for(ll i=1; i<=n; i++){
        scanf("%lld", &arr[i]);
        sorted.push_back(make_pair(arr[i], i));
    }
    sort(sorted.begin(), sorted.end());
    reverse(sorted.begin(), sorted.end());

    for(ll i=0; i<n; i++){
        pair<ll, ll> tmp = sorted[i];
        if(i!=0){
            set<ll>::iterator it = idx.lower_bound(tmp.second);
            ll leftMin = 2, leftMax = tmp.second+1, rightMin = 2, rightMax = n+2-tmp.second;
            bool leftEx = 0, rightEx = 0;
            if(it != idx.begin()){
                leftEx = 1;
                set<ll>::iterator it2 = it; --it2;
                leftMin = tmp.second - *it2 + 1;
                if(it2 != idx.begin()){
                    set<ll>::iterator it3 = it2; --it3;
                    leftMax = tmp.second - *it3 + 1;
                }
            }

            if(it != idx.end()){
                rightEx = 1;
                set<ll>::iterator it2 = it; ++it2;
                rightMin = *it - tmp.second + 1;
                if(it2 != idx.end()){
                    rightMax = *it2 - tmp.second+ 1;
                }
            }

            if(it != idx.begin()) ans += tmp.first * (leftMax - leftMin) * (rightEx ? rightMin - 1 : n+1-tmp.second);
            if(it != idx.end()) ans += tmp.first * (rightMax - rightMin) * (leftEx ? leftMin - 1 : tmp.second);
        }
        idx.insert(tmp.second);
    }

    cout<<ans;
}


Measured memory_bytes: 7280
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        List<Long> list = new ArrayList<>();
        for (long i = 1; i <= Math.sqrt(n); i++) {
            if(n%i==0)list.add((i+n/i));
        }
        list.sort(Comparator.naturalOrder());
        System.out.println(list.get(0)-2);
    }
}


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

int main() {
    int n,m;
    cin >> n >> m;
    int a[n];
    int voteCounter = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        voteCounter += a[i];
    }
    //voteCounter /= (4 * m);//得票数の閾値に変換　これ以上なら大丈夫
    int popularCounter = 0;
    for(int i = 0; i < n;i++){
        if(voteCounter <= (a[i] * 4 * m)){
            popularCounter++;
        }
    }
    if(m <= popularCounter){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
//--------------------
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 1009
#define INF 1000000009
#define MOD 1000000007
typedef long long int ll;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%lld%lld",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<< endl;
#define tr2(x,y) cout<<x<<" "<<y<<" " << endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << " " << endl;

ll m[N][N], ret[N][N], res[N][N], n;

void mul(ll a[][N], ll b[][N]){
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			res[i][j] = 0;			
			for(int k = 1; k <= n; k++) res[i][j] += a[i][k]*b[k][j]%MOD;
		}
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			a[i][j] = res[i][j]%MOD;
	return;
}

void fast(ll exponent){
	for(int i = 1; i <= n; i++) ret[i][i] = 1;
	
	while(exponent > 0){
		if(exponent%2) mul(ret, m);
		mul(m,m);
		exponent >>= 1;
	}
	
	for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) m[i][j] = ret[i][j];
	return;
}
int main(){ 
    int i,j,t,x,y;
    ll k;
    cin >> n >> k;
    for(i=1; i<=n;i++){
        for(j=1; j<=n; j++){
            cin >> m[i][j];
        }
    }
    fast(k);
    ll ans=0;
    for(i=1; i<=n; i++){
        for(j=1; j<=n; j++){
            ans+=m[i][j];
        }
    }
    tr(ans%MOD);
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const long double INF = 1e10;

using vd = vector<long double>;
using V = vector<vd>;

using pi = pair<int,int>;

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

int main(){
    int w,h;
    cin >>w >>h;
    vector<string> s(h);
    rep(i,h) cin >>s[i];

    auto IN = [&](int y, int x){
        return 0<=y && y<h && 0<=x && x<w;
    };

    auto calc = [&](double m){
        V dp(h,vd(w,INF));

        queue<pi> que;
        rep(i,h)rep(j,w){
            if(s[i][j]=='g'){
                dp[i][j]=0;
                que.push({i,j});
            }
            if(s[i][j]=='*'){
                dp[i][j]=m;
                que.push({i,j});
            }
        }

        while(!que.empty()){
            pi pos = que.front();
            que.pop();
            rep(d,4){
                int ny = pos.fi+dy[d], nx = pos.se+dx[d];
                if(IN(ny,nx) && s[ny][nx]!='#' && s[ny][nx]!='*'){
                    if(dp[ny][nx] > dp[pos.fi][pos.se]+1){
                        dp[ny][nx] = dp[pos.fi][pos.se]+1;
                        que.push({ny,nx});
                    }
                }
            }
        }

        return dp;
    };

    long double l=0, r=INF;
    rep(loop,80){
        long double m = (l+r)/2;
        V E = calc(m);

        int n = 0;
        rep(i,h)rep(j,w)if(s[i][j]=='.' || s[i][j]=='s') ++n;

        long double sumE = 0;
        rep(i,h)rep(j,w){
            if(s[i][j]=='.' || s[i][j]=='s') sumE += E[i][j]/n;
        }

        if(sumE<m) r=m;
        else l=m;
    }
    // dbg(l);
    // dbg(r-l);

    V E = calc(l);
    long double ans=-1;
    rep(i,h)rep(j,w)if(s[i][j]=='s') ans = E[i][j];
    printf("%.15Lf\n", ans);
    return 0;
}



Measured memory_bytes: 7292
# can't AC without numpy, Python array handling with for is SLOW
import numpy as np
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()))
S = (np.array(S) == ".") * 1

# i行j列に置いたとき上下左右の方向それぞれに光の軌跡が何マス伸びるか(自マスを含む)
trailLeft = np.zeros((H, W), dtype=int)
trailRight = np.zeros((H, W), dtype=int)
trailUp = np.zeros((H, W), dtype=int)
trailDown = np.zeros((H, W), dtype=int)

for i in range(H):
    if i == 0:
        trailUp[i] = S[i]
        trailDown[H - i - 1] = S[H - i - 1] * 1
    else:
        trailUp[i] = (trailUp[i - 1] + 1) * S[i]
        trailDown[H - i - 1] = (trailDown[H - i] + 1) * S[H - i - 1]

for j in range(W):
    if j == 0:
        trailLeft[:, j] = S[:, j]
        trailRight[:, W - j - 1] = S[:, W - j - 1] * 1
    else:
        trailLeft[:, j] = (trailLeft[:, j - 1] + 1) * S[:, j]
        trailRight[:, W - j - 1] = (trailRight[:, W - j] + 1) * S[:, W - j - 1]

print(np.max(trailLeft + trailRight + trailUp + trailDown - 3))


Measured memory_bytes: 266540
#include <iostream>

using namespace std;

int hw[20];
int hd[20];

int main(void){
	int w,d;
	while(cin >> w >> d){
		if(w==0&&d==0)
			break;
		for(int i=0;i<w;++i) cin >> hw[i];
		for(int i=0;i<d;++i) cin >> hd[i];
		int ans=0;

		for(int i=0;i<w;++i){
			for(int j=0;j<d;++j){
				if(hw[i]==hd[j]){
					ans+=hw[i];
					hw[i]=hd[j]=0;
				}
			}
		}
		for(int i=0;i<w;++i) ans+=hw[i];
		for(int i=0;i<d;++i) ans+=hd[i];

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

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()){
      int A = in.nextInt();
      int B = in.nextInt();
      int C = in.nextInt();
      long K = in.nextLong();
      
      if (K % 2 == 0) {
        System.out.println(A - B);
      } else {
        System.out.println(B - A);
      }
    }
  }
}

Measured memory_bytes: 23124
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k-a-b>0) {
        cout << a - (k-a-b) << endl;
    }else {
        if(a>k) {
            cout << k << endl;
        }else {
            cout << a << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3624
n, y = map(int, input().split())

sum = y
wasFound = False
for i in range(n+1):
    if wasFound:
        break
    for j in range(n+1):
        if i+j > n:
            break
        rest = sum - i*10000 - j*5000
        if rest < 0:
            break
        k = int(rest/1000)
        if rest % 1000 == 0 and (i+j+k==n):
            print(i, j, k)
            wasFound = True
            break
if not wasFound:
    print(-1, -1, -1)


Measured memory_bytes: 3064
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int jousu(int x, int z) {
	int y = 1;
	for (int i = 0; i < x; i++) {
		y *= z;
	}
	return y;
}

int main() {
	int n, a = 0, b = 100000000, count = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (b > a) {
			b = a;
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI  =3.141592653589793238463; 
using namespace std;
typedef long long ll;
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
long long fast_power(long long base, long long power) {
    long long result = 1;
    while(power > 0) {
 
        if(power % 2 == 1) { // Can also use (power & 1) to make code even faster
            result = (result*base);
        }
        base = (base * base);
        power = power / 2; // Can also use power >>= 1; to make code even faster
    }
    return result;
}
ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}
void SieveOfEratosthenes(ll n, set<ll> &s) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (ll p=2; p<=n; p++) 
       if (prime[p]) s.insert(p*p); 
}
#define INF 1e9+5
int main()
{
    ll n,k;
    cin>>n>>k;
    vl h(n);
    for(ll i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vl dp(n,INF);
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<=i+k;j++)
        {
            if(j<n)
            {
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    //prv(dp);
    cout<<dp[n-1]<<endl;
}

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

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

    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    int half = n / 2;
    for (int i = 0; i < half; i++) {
        if (s[i] != s[i+half]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst<<": "; dbg(rst...); }

ll bin_pow(ll x, ll n, ll mod=MD){
	ll res = 1LL;
	for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
	return res;
}

vector<int64_t> fct, inv;
void finit(int cmx, ll mod =MD){
	fct.resize(cmx+20); inv.resize(cmx+20);
	fct[0] = fct[1] = inv[1] = inv[cmx] = 1;
	for(int i=2;i<cmx+3;i++) fct[i] = fct[i-1] * i % mod;
	for(ll x=fct[cmx], n=mod-2; n > 0; n >>=1, x = x*x %mod)
		if(n & 1) inv[cmx] = inv[cmx] * x %mod;
	for(int i=cmx;i>=1;i--) inv[i-1] = inv[i] * i % mod;
}
ll nCk(ll n, ll k, ll mod =MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret =fct[n] * inv[k] % mod * inv[n-k] % mod;
	return ret;
}

int main()
{
	const double PI = acos(-1);
	cin.tie(0); ios_base::sync_with_stdio(false);
	int k;
	string s;
	cin >>k >>s;
	int n=sz(s);
	finit(2002000);
	ll ans = 0;
	rep2(i, n, n+k+1){
		ll w = bin_pow(25, i-n) * bin_pow(26, n+k-i) % MD;
		(w *= nCk(i-1, n-1)) %=MD;
		(ans += w) %=MD;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 35640
// https://atcoder.jp/contests/agc029/tasks/agc029_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  multiset<ll> as;
  rep(i, N) {
    ll a;
    cin >> a;
    as.insert(a);
  }

  ll res = 0;

  while (!as.empty()) {
    auto num_it = --as.end();
    ll num = *num_it;

    ll sum = 1;
    while (sum <= num) sum *= 2;

    ll pair = sum - num;
    auto pair_it = as.find(pair);

    if (pair_it != as.end() && !(num_it == pair_it && as.count(num) == 1)) {
      res++;
      as.erase(pair_it);
    }

    as.erase(num_it);
  }

  cout << res << endl;
}

void solve2() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  ll res = 0;

  map<ll, ll> m;
  rep(i, N) m[-as[i]]++;

  auto dec = [&m](ll val) {
    m[val]--;
    if (m[val] == 0) m.erase(val);
  };

  while (!m.empty()) {
    ll num = -m.begin()->first;
    dec(-num);

    ll sum = 1;
    while (sum <= num) sum *= 2;

    ll p = sum - num;

    if (m.count(-p)) {
      res++;
      dec(-p);
    }
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  ll ans = 0;
  cin >> n;
  ans += n;
  cin >> n;
  ans += n;
  cin >> n;
  ans += n;
  
  //cout << fixed << setprecision(10);
  if(ans>=22) cout << "bust" << endl;
  else cout << "win" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
const int N = 3e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;


int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	int h, w, n;
	cin >> h >> w >> n;
	vector<pair<int,int>> bl(n); //block
	for(int i=0; i<n; i++){
		cin >> bl[i].first >> bl[i].second;
		bl[i].first--; //size ak
		bl[i].second--;
	}
	bl.emplace_back(h-1, w-1);
	n++;
	sort(bl.begin(), bl.end());
	vector<ll> inv(h+w+1); //inverse: phan so
	vector<ll> fact(h+w+1);
	vector<ll> fact_inv(h+w+1);
	inv[1] = 1;
	for(int i=2; i<h+w+1; i++){
		inv[i] = MOD - (MOD/i) * inv[MOD%i] % MOD; //1/n
	}
	fact[0] = 1; //n!
	fact_inv[0] = 1; //1/n!
	for(int i=1; i<h+w+1; i++){
		fact[i] = fact[i-1]*i % MOD;
		fact_inv[i] = fact_inv[i-1]*inv[i] % MOD;
	}
	auto comb = [&](int n, int k){
		if (n<0 || k<0) return 0LL;
		if (n < k) return 0LL;
		return fact[n]*fact_inv[n-k] % MOD * fact_inv[k] % MOD;
	};
	auto f = [&](int x, int y){
		return comb(x+y, y);
	};
	vector<ll> dp(n);
	for (int i=0; i<n; i++){
		dp[i] = f(bl[i].first, bl[i].second);
		for(int j=0; j<i; j++){
			if (bl[i].second >= bl[j].second){
				dp[i] = (dp[i] - dp[j]*f(bl[i].first - bl[j].first, bl[i].second - bl[j].second) % MOD + MOD) % MOD;
			}
		}
	}
	cout << dp[n-1] << endl;

	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

int main(){
	long long N;
	cin >> N;
	double odd;
	double even;
	if(N%2 == 0) {
		odd = N/2;
		even = N/2;
	} else {
		odd = N/2 + 1;
		even = N/2;
	}

	printf("%.10f\n", odd / (odd + even));
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 3e2+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second


int a[maxN][maxN];
int c[maxN][maxN];
int b[maxN];
int d[maxN];
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		d[i] = -1;
	}
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(d[x] == -1)
			d[x] = y;
		else if(d[x] != y)
		{
			puts("-1");
			return 0;
		}
	}
	if(d[1] == -1 && n > 1)
	{
		d[1] = 1;
	}
	else if(d[1] == 0 && n > 1)
	{
		puts("-1");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i] == -1)
			d[i] = 0;
	}
	int ans = 0;
	for(int i=1;i<=n;i++)
	{
		ans = ans*10 + d[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a+b == 15 {
		fmt.Println("+")
	} else if a*b == 15 {
		fmt.Println("*")
	} else {
		fmt.Println("x")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

int h, w;
v2<char> g;
map<pair<int, int>, vector<pair<int, int>>> adj;
v2<pair<int, int>> rep;
v2<bool> v;
int sx, sy;
int dx, dy;

const pair<int, int> INV = {-1, -1};

void dfs(const pair<int, int>& node, const pair<int, int>& start){
    v[node.F][node.S] = true;
    rep[node.F][node.S] = start;
    const vector<pair<int, int>> dirs = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
    for(auto& a : dirs){
        int nx = node.F+a.F, ny = node.S+a.S;
        if(nx < 0 ||nx >= h || ny < 0 || ny >= w) continue;
        if(g[nx][ny] == '#') continue;
        if(!v[nx][ny]){
            dfs({nx, ny}, start);
        }
    }
}

void solve(){
    cin >> h >> w >> sx >> sy >> dx >> dy;
    --sx, --sy, --dx, --dy;
     g = fill(h, w, '?');
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cin >> g[i][j];
        }
    }

    rep = fill(h, w, INV);
    v = fill(h, w, false);
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(!v[i][j] && g[i][j]=='.') dfs({i, j}, {i, j});
        }
    }
    
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            for(int l = -2; l <= 2; ++l){
                for(int m = -2; m <= 2; ++m){
                    int nx = i+m, ny = j+l;
                    if(nx <0 || nx >= h || ny < 0 || ny >= w) continue;
                    if(rep[i][j] == INV || rep[nx][ny] == INV) continue;
                    if(rep[i][j] != rep[nx][ny]){
                        adj[rep[i][j]].push_back(rep[nx][ny]);
                    }
                }
            }
        }
    }

    pair<int, int> st = rep[sx][sy];
    queue<pair<int, int>> q;
    q.push(st);
    set<pair<int, int>> v2;
    v2.insert(st);
    map<pair<int, int>, int> d;
    d[st] = 0;
    while(!q.empty()){
        auto node = q.front();
        q.pop();
        for(auto& next : adj[node]){
            if(!v2.count(next)){
                v2.insert(next);
                d[next] = 1+d[node];
                q.push(next);
            }
        }
    }

    auto end = rep[dx][dy];
    if(!d.count(end)){
        cout << "-1\n";
    }
    else{
        cout << d[end] << '\n';
    }
}

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

Measured memory_bytes: 49192
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
arr = []
chlst = []
while l = $stdin.gets do
  if lc == 0
    tmp = l.chomp.split(" ").map(&:to_i)
    nn = tmp[0]
    mm = tmp[1]
  elsif lc == 1
    arr = l.chomp.split(" ").map(&:to_i)
  else
    chlst << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

arr.sort!
chlst.sort_by! do |a, b| b end
chlst.reverse!

# body
if $debugFlag
  p arr
  p chlst
end

ptr = 0
cnt = 0
chlstSize = chlst.size
arr.size.times do |i|
  break if ptr >= chlstSize
  break if (arr[i] >= chlst[ptr][1])
  arr[i] = chlst[ptr][1]
  cnt += 1
  if cnt >= chlst[ptr][0]
    ptr += 1
    cnt = 0
  end
end

puts arr.inject(:+)


Measured memory_bytes: 14184
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vs vector<string>
#define vii vector<pii>
#define mi map<ll,ll>
#define mii map<pii,ll>
#define mc map<char,ll>
#define itr ::iterator
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>b;i--)
#define fne(i,a,b) for(ll i=a;i>=b;i--)
#define fm(it,m) for(it = m.begin();it != m.end();++it)
#define all(v) v.begin(),v.end()
#define M 1000000007
#define pi 3.14159265358979323846


int main()
{  
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif
   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   ll n=0,h=0,k=0,ans=0;
   cin>>n;

   f(i,0,n)
    { cin>>h;
      if(i==0)
        k = h;
      else if(i>0 && k>h)
       ans+=k-h;
      else k = h;
    }
    cout<<ans;
   return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define INF 999999999

using namespace std;

int n;
int a[105][105];
int d[105][105];


int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			scanf("%d", &a[i][j]);
			if (i == 0) {
				d[i][j] = d[i][j - 1] + a[i][j];
			}
			else {
				d[i][j] = d[i - 1][j] - d[i - 1][j - 1] + d[i][j - 1] + a[i][j];
			}
		}
	}

	int max = -INF;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 0; k < i; k++) {
				for (int l = 0; l < j; l++) {
					int cur = d[i][j] - d[k][j] - d[i][l] + d[k][l];
					if (cur > max)max = cur;
				}
			}
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 3308
import java.io.*;
class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine()),a[]=new int[n],i;
        long ans=0;
        String s[]=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        a[i]=Integer.parseInt(s[i]);

        for(i=1;i<n;i++)
        if(a[i]<a[i-1])
        {
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
        System.out.print(ans);
    }
}


Measured memory_bytes: 62136
n = gets.to_i
arr = Array.new(1440){[]}, Array.new(1440){[]}, Array.new(1440){[]}
n.times{|member|
	line = gets.chomp.split.map(&:to_i)
	3.times{|i| (line[i * 4] * 60 + line[i * 4 + 1]).upto(line[i * 4 + 2] * 60 + line[i * 4 + 3]){|j| arr[i][j] << member}}
}
3.times{|i|
	arr[i].uniq!
	arr[i].delete []
}
max = 0
arr[0].each{|ar0|
	arr[1].each{|ar1|
		arr[2].each{|ar2|
			l = (ar0 & ar1 & ar2).length
			max = l if max < l
		}
	}
}
puts max


Measured memory_bytes: 8156
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n;
  long long int ans=1,k=1e9+7;
  cin >> n;
  for(int i=1;i<=n;i++){
      ans*=i;
      if(ans>=k) ans=ans%k;
  }
  cout <<ans<<endl;
  }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split().Select(x => Int32.Parse(x)).ToList();
        var a = input[0];
        var b = input[1];
        var h = input[2];
        var m = input[3];
 
        var h_loc = Tuple.Create(a * Math.Cos(2 * Math.PI * (h / 12.0 + m / (12.0 * 60.0 ))), a * Math.Sin(2 * Math.PI * (h / 12.0 + m / (12.0 * 60.0 ))));
        var m_loc = Tuple.Create(b * Math.Cos(2 * Math.PI * (m / 60.0)), b * Math.Sin(2 * Math.PI * (m / 60.0)));
 
        var ret = Math.Pow(Math.Pow(h_loc.Item1 - m_loc.Item1, 2) + Math.Pow(h_loc.Item2 - m_loc.Item2, 2), 0.5);
        
        System.Console.WriteLine(ret);
 
    }
}

Measured memory_bytes: 28900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    int R;
    cin >> R;
    cout << R * 2 * 3.141592 << endl;
}

Measured memory_bytes: 3788
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int a[100000];
int main(){
  int N;
  cin >> N;
  rep(i, N) cin >> a[i];
  int ans = 0;
  rep(i, N){
    if(a[a[i] - 1] == i + 1) ans++;
  }
  cout << ans/2 << endl;
  return 0;
}


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

int a[101], dp[100010], n, k;

int func(int x)
{
    auto& res=dp[x];
    if (~res) return res;
    res=0;
    for(int i=0; i<n; ++i) if (x>=a[i])
        res=res||!func(x-a[i]);
    return res;
}

int main()
{
    cin>>n>>k;
    for(int i=0; i<n; ++i) cin>>a[i];
    fill(dp, dp+k+1, -1);
    cout<<(func(k) ? "First" : "Second")<<endl;
}


Measured memory_bytes: 5376
*s, = map(str, input())

a = [""]*(len(s))
ans = 0

def rec(i:int, a:list) -> None:
    if i == len(s)-1:
        global ans
        ans += eval("".join(_s+_a for _s, _a in zip(s, a)))
        return

    a[i] = ""
    rec(i+1, a)
    a[i] = "+"
    rec(i+1, a)

rec(0, a)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  ll n;
  cin>>n;
  veci v(n);
  {rep(i,n)cin>>v[i];}
  ll ans=0;
  ll  ma=0;
  rep(i,n){
    if(ma<v[i])ma=v[i];
    ans+=ma-v[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#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--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}());
const ll mod=100000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 200023;
int T;
ll n;
ll x;
ll y;
string str;

int main(int argc, char const *argv[])
{
#ifdef indiewar
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    cin >> T;
    T =1;
    while(T--)
    {
        cin >> str;
        if(str == "AAA" || str == "BBB")
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }


    }
    return 0;
}

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


int main()
{
	int n,m,c,i,j,b[300],count=0,sum=0,k;
	cin >> n >> m >> c;
	
	for(i=0;i<m;i++)
	{
		cin >> b[i];
	}
	
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cin >> k;
			sum += k*b[j];
		}
		sum += c;
		if(sum>0) count++;
		sum=0;
	}
	
	cout <<  count ;
	
	
	

}

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

using namespace std;

int main()
{

	int a = 0, b = 0, c = 0, d = 0, e = 0, maxy = 0, max = -1, ans = 1, count = 0, min = 0;

	int yoko = 0, tate = 0;
	std::string output, output2, output3, input = {};
	bool okada = false;
	int array[30][30],array2[30][30];
	int nearbydis;


	cin >> input ;
	if (input.size() == 2) {
		cout << input << endl;
	}
	else {
		cout << input[2] << input[1] << input[0] << endl;
	}
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  bool ans=true;
  rep(i,n) ans&=(a[i]%2==0);
  if(ans) cout << "second" << endl;
  else cout << "first" << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    if(n <= 999) {
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }

    return 0;
}


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

int main() {
  long long int A, B, C, K;
  cin >> A >> B >> C >> K;

  if(A>=K){
    cout << K << endl;
  }else if(A+B>=K){
    cout << A << endl;
  }
  else{
    cout << A-(K-A-B) << endl;
  }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int a = 1; a < n; a++){
        ans += (n-1) /a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <deque>

using namespace std;

int main(){
  deque<int> st;
  int n;
  while(~scanf("%d",&n)){
    if(n){
      st.push_back(n);
    }else{
      printf("%d\n",st.back());
      st.pop_back();
    }
  }
}

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

int main()
{
    int a, b, c, d, e, f;
    cin>>a>>b>>c>>d>>e>>f;
    int T=-1, S=0;
    for(int w=0; 100*w<=f; w+=a)
    for(int x=0; 100*(w+x)<=f; x+=b)
    for(int y=0; 100*(w+x)+y<=f; y+=c)
    for(int z=0; 100*(w+x)+y+z<=f; z+=d) {
        int s=y+z;
        int t=100*(w+x)+s;
        if (s<=(w+x)*e && t>0 && (T<0 || S*t<s*T)) S=s, T=t;
    }
    cout<<T<<' '<<S<<endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

inline int read() {
    int res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}

inline int sum(int x) {
    int res = 0;
    while (x) {
        res += x % 10;
        x /= 10;
    }
    return res;
}

ll l, r;

int main() {
    std::cin >> l >> r;
    ll now = l, ans = 1;
    for (now *= 2; now <= r; now *= 2) ans++;
    printf("%lld\n", ans);
    return 0;
}

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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 075_abc_c / Link: https://abc075.contest.atcoder.jp/tasks/abc075_c?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

void Lowlink(int v, int p, int &k, vector<int>& low, vector<int>& ord, vector<int>& used, vector<int>& parent, vector<vector<int>>& G) {
	used[v] = true;
	low[v] = ord[v] = k; k++;
	for (int i = 0; i < (int)G[v].size(); i++) {
		int u = G[v][i];
		if (used[u] == 0) {
			parent[u] = v;
			Lowlink(u, v, k, low, ord, used, parent, G);
			low[v] = min(low[v], low[u]);
		}
		else if (u != p) {
			low[v] = min(low[v], ord[u]);
		}
	}
}

void Art_Points(int root, vector<int>& points, vector<pair<int, int>>& bridges, vector<vector<int>>& G) {
	int n = (int)G.size();
	vector<int>low(n);
	vector<int>ord(n);
	vector<int>used(n, 0);
	vector<int>parent(n, 0);
	int k = 0;

	Lowlink(root, -1, k, low, ord, used, parent, G);
	const int BRIDGE = 1; 
	if (BRIDGE) {
		for (int v = 0; v < n; v++) {
			for (int i = 0; i < (int)G[v].size(); i++) {
				int u = G[v][i];
				if (ord[v] < low[u]) {
					if (u > v)
						bridges.push_back(pair<int, int>(v, u));
					else bridges.push_back(pair<int, int>(u, v));//
				}
			}
		}
		sort(bridges.begin(), bridges.end());
		bridges.erase(unique(bridges.begin(), bridges.end()), bridges.end());
	}
}
LL N, M;

LL ans = 0LL;

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

	cin >> N >> M;
	VVI G(N);
	FOR(i, 0, M) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	VI point;
	vector<PII> bei;
	Art_Points(0, point, bei, G);

	ans = SZ(bei);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int i=0;
    while(a>0 && c>0)
    {
        if(i&1)//Aloki attack
        {
            a-=d;
        }
        else
        {
            c-=b;
        }
        i++;
    }
    if(a<=0)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int i,j,k,n,m,x,y,t;
int a[111],ans[111];
int main(){
	scanf("%d",&n);for (i=1;i<=n;i++)scanf("%d",&a[i]);
	for (i=1;i<=n;i++){
		bool flag=0;
		for (j=n-i+1;j>=1;j--)
			if (a[j]==j){
				flag=1;x=j;break;
			}
		if (!flag){printf("-1\n");return 0;}
		ans[i]=a[x];
		for (j=x;j<=n-i;j++)a[j]=a[j+1];
	}
	for (i=n;i>=1;i--)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> N >> M;
}
void solve() {
  ;
  if (N > M) {
    swap(N, M);
  }

  rep(i, 1, M) { cout << N; }
  cout << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define lw 4280

int main(void){
	int w, i, a = 1150, b = 125, c = 140, d = 160;
	while (1){
		scanf("%d", &w);
		if (w == -1) break;
		if (w <= 10){
			printf("%d\n", lw - a);
		}else if (w <= 20){
			printf("%d\n", lw - (a+b*(w-10)));
		}else if (w <= 30){
			printf("%d\n", lw- (a+b*10+c*(w-20)));
		}else {
			printf("%d\n", lw - (a+b*10+c*10+d*(w-30)));
		}
	}
	return 0;
}

Measured memory_bytes: 600