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

using namespace std;

#define ll long long

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	int x = (a-b)/c;
	cout << (a-b) - x*c << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3548
#!/usr/bin/python3

import os
import sys


def main():
    N, A, B, C, D = read_ints()
    print(solve(N, A, B, C, D))


def solve(N, A, B, C, D):
    return min((N + A - 1) // A * B, (N + C - 1) // C * D)


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5612
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    int t;
    t = a - e;
    if(abs(t) <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
ll INF = 1000000000;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  ll n,a,b;
  cin>>n>>a>>b;
  if(a>b) swap(a,b);
  ll ans = 0;
  ll min_dist = min((a+b-1)/2, ((2*n)-a-b+1)/2);
  if(abs(a - b) %2 == 0)
    ans = abs(a-b)/2;
  else
    ans = min_dist;
  cout << ans << endl;
}


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

int main(){
    int k; cin >> k;
    int x = 7; 

    for(int i = 0; i < k; i++){
        if(x % k == 0){
            cout << i+1 << endl;
            return 0;
        }

        x = (10 * x + 7) % k;
    }
    cout << "-1" << endl;

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define mp make_pair
#include <iostream>
#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


LL POW(LL x,LL y)
{
    LL ans=1;
    LL base=x;
    while(y)
    {
        if(y&1)
        {
            ans*=base;
        }
        base=base*base;
        y=y>>1;
    }
    return ans;
}



int main()
{    
    fastinput;
    LL n,i,j,k,t,temp,tc,m;
    cin>>n>>m;
    LL cnt=0,tot=0;
    vector<LL> a;
    for(i=0;i<n;i++)
    {
        cin>>j;
        tot+=j;
        a.pb(j);
    }

    for(auto x:a)
    {
        if(4*m*x>=tot)
        {
            cnt++;
        }
    }
    if(cnt>=m)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    

    
    


    
    return 0;
}


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

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

    double ans = 0;
    rep(i, n) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") ans += x;
        else ans += x * 380000;
    }

    printf("%.4f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, X, i=0;
  cin >> A >> B >> C >> X;
  for(int A1=0;A1<=A;A1++)
    for(int B1=0;B1<=B;B1++)
      for(int C1=C;C1>=0;C1--){
        if(A1*500+B1*100+C1*50 < X)
          break;
        if(A1*500+B1*100+C1*50 == X){
          i++;
          break;
        }
      }
  cout << i << endl;
}

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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define P first
#define I second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

const string p[2] = {"apple", "peach"};

int main(void){
    string in; getline(cin, in);

    pii pos = mp(0, 0);
    while(1){
        int res_ind = INF;
        rep(i, 2){
            int ind = in.find(p[i], pos.P);
            if(~ind && ind < res_ind) res_ind = ind, pos.I = i;
        }
        if(res_ind == INF) break;
        pos.P = res_ind;

        in.replace(pos.P ++, p[pos.I].size(), p[(!pos.I)]);
    }
    cout << in << endl;

    return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ld double
#define ll long long
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
#define fi first
#define se second
#define sync  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf (ll)1e16

const ld pi=(4.0*atan(1));
const int mxn=1e5+5;

set<ll> adj[mxn];
ll n,m;
vector<ll> shortestpath(){
    vector<ll> ret;
    
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
    vector<ll> dis(n+1,inf),pred(n+1,-1);
    dis[1]=0;
    pq.push({0,1});
    
    while(pq.size()){
        ll curr=pq.top().se;
        pq.pop();
        
        for (auto xd:adj[curr]){
            ll nwdis=dis[curr]+1;
            if (nwdis<dis[xd]){
                dis[xd]=nwdis;
                pred[xd]=curr;
                pq.push({dis[xd],xd});
            }
        }
    }
    
    ll mx=inf,wch=-1;
    for (ll i=2;i<=n;i++){
        if (dis[i]<mx){
            mx=dis[i];
            wch=i;
        }
    }
    
    if (wch==-1){
        return ret;
    }
    else{
        for (ll i=2;i<=n;i++){
            ret.pb(pred[i]);
        }
        return ret;
    }
}

int main() {
    
    sync
    ll tt=1;
    //cin>>tt;
    cout<<fixed<<setprecision(12);
    for (ll tc=1;tc<=tt;tc++){
       cin>>n>>m;
       for (ll u,v,i=0;i<m;i++){
           cin>>u>>v;
           adj[u].insert(v);
           adj[v].insert(u);
       }
        
       vector<ll> sol=shortestpath();
        
       if (!sol.size()){
           cout<<"No\n";
       }
       else{
           cout<<"Yes\n";
           for (auto xd:sol){
               cout<<xd<<"\n";
           }
       }
    }
    
	return 0;
}

Measured memory_bytes: 31648
N,M = list(map(int,input().split()))
P = [[] for i in range(N)]
for i in range(N):
    X,Y,Z = list(map(int,input().split()))
    P[i].append( X+Y+Z)
    P[i].append( X+Y-Z)
    P[i].append( X-Y+Z)
    P[i].append( X-Y-Z)
    P[i].append(-X+Y+Z)
    P[i].append(-X+Y-Z)
    P[i].append(-X-Y+Z)
    P[i].append(-X-Y-Z)

out = 0
for i in range(8):
    P.sort(key=lambda x:x[i],reverse=True)
    S = 0
    for j in range(M):
        S+=P[j][i]
    if S>out:
        out = S
print(out)


Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }

const ll INF=99999999999999;
const ll MOD=1000000007;

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll N): par(N), siz(N, 1LL) {
        for (ll i = 0; i < N; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll N) {
        par.resize(N);
        siz.assign(N, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < N; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    void merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return;
    }

    bool connected(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
 
int main() {
  ll n,m;
  cin >> n >> m;
  vl a(m),b(m);
  rep(i,m) cin >> a[i] >> b[i];
  ll x = n*(n-1)/2;
  UnionFind UF(n);
  ll num = 1;
  vl output;
  output.push_back(x);
  for(ll i=m-1; i>=0; i--){
    if(UF.connected(a[i]-1,b[i]-1)){
      output.push_back(output[output.size()-1]);
      continue;
    }
    
    x -= UF.size(a[i]-1)*UF.size(b[i]-1);
    output.push_back(x);
    UF.merge(a[i]-1,b[i]-1);
  }
  sort(ALL(output));
  rep(i,output.size()-1) cout << output[i+1] << endl;

 return 0;
}

Measured memory_bytes: 5364
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(void)
{
    //string a,b;
    int a,b,c,d;
    //char a,b,c;
    int i=0,sum=0;
    //char a,b='.';
    cin>>a>>b;
    cout<<(a-1)*(b-1);
    return 0;
}



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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    int cnt = 0, m = 0;
    rep(i, 0, n){
        cin >> h[i];
    }
    rep(i, 1, n){
        if(h[i - 1] >= h[i]){
            cnt++;
            m = max(m, cnt);
        }
        else{
            m = max(m, cnt);
            cnt = 0;
        }

    }
    cout << m << endl;
}


Measured memory_bytes: 640
n=int(raw_input())
l=[int(i) for i in raw_input().split()]
from collections import Counter 
c=Counter(l) 
ans=[]
for i in c: 
    if c[i]>=2:
        ans=ans+[i]*(c[i]//2)
ans.sort(reverse=1)
if len(ans)<=1:
    print(0)
else: 
    print(ans[0]*ans[1])

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

//struct edge {
//    int to;
//    int cost;
//};
//
//int dijkstra ( int l, int r, vector<vector<edge>> &g, int n ) {
//    vector<int> cost(n, 1e8);
//    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
//    cost[l] = 0;
//    que.push(make_pair(0, l));
//    bool ok = false;
//    while(!que.empty()) {
//        pair<int, int> now = que.top();
//        cout << now.first << " " << now.second << endl;
//        que.pop();
//        int v = now.second;
//        if ( cost[v] < now.first ) continue;
//        for ( auto u : g[v] ) {
//            if ( u.cost + cost[v] < cost[u.to] ) {
//                cost[u.to] = u.cost + cost[v];
//                que.push(make_pair(cost[u.to], u.to));
//            }
//        }
//    }
//    return cost[r];
//}

//const int N = 1000002;
//int n, m;
//vector<bool> mark(N);
//vector<vector<pair<ll, ll>>> g(N);
//vector<ll> cost(N, 1e18);

void dfs ( ll v, vector<bool> &mark, vector<vector<pair<ll, ll>>> &g, vector<ll> &cost ) {
//void dfs ( ll v ) {
    mark[v] = true;
//    for ( auto u : g[v] ) {
    for ( int i = 0; i < g[v].size(); ++i ) {
//        ll to = u.first;
//        ll len = u.second;
        ll to = g[v][i].first;
        ll len = g[v][i].second;
        if ( cost[to] == 1e18 ) {
            cost[to] = cost[v] + len;
        }
        if ( cost[to] != cost[v] + len ) {
            cout << "No" << endl;
            exit(0);
        }
        if ( !mark[to] ) {
            dfs(to, mark, g, cost);
//            dfs(to);
        }
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<pair<ll, ll>>> g(n+1);
    vector<bool> mark(n+1, false);
    vector<ll> cost(n+1, 1e18);
    rep(i, m) {
        ll l, r, d;
        cin >> l >> r >> d;
//        --l, --r;
        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }
//    rep(i, n) {
    for ( int i = 1; i <= n; ++i ) {
        if ( !mark[i] ) {
            cost[i] = 0LL;
            dfs(i, mark, g, cost);
//            dfs(i);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 18304
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll nl, nm;

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

  //n:S, m:c
  ll n, m;
  cin >> n >> m;
  
  if(m < n) cout << m/2 << endl;
  else if(n == m) cout << n/2 << endl;
  else{
    if(m >= 2*n){
      m -= 2*n;    
      cout << n + m/4 << endl;
    }
    // S < c < 2S
    // S:4 c:5
    else{
      cout << m/2 << endl;
    }
  }
  return 0;
}


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

using namespace std;


struct UnionFind {
    vector<int> parent; // parent[root] is the negative of the size.

    explicit UnionFind(int n) : parent(n, -1) {
    };                                       //初期化

    bool unite(int u, int v) {//ノードx,yが属する木を併合
        u = root(u);
        v = root(v);
        if (u == v) return false;
        if (parent[u] > parent[v]) swap(u, v);
        parent[u] += parent[v];
        parent[v] = u;
        return true;
    }

    bool find(int u, int v) {//ノードx,yが同じ木に属するかどうか
        return root(u) == root(v);
    }

    int root(int u) {//ノードuが属する木の根
        return parent[u] < 0 ? u : parent[u] = root(parent[u]);
    }

    int size(int u) {//ノードiを含む木の大きさ
        return -parent[root(u)];
    }
};


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

    vector<int> p(n), initPlace(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        initPlace[p[i]] = i;
    }

    UnionFind uf(n);
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uf.unite(x, y);
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (uf.find(initPlace[i], i)) {
            ans++;
        }
    }

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


Measured memory_bytes: 1408
Module Module1
    Sub Main()
        Dim input As String() = Console.ReadLine.Split(" "c)

        Dim num1 As Integer = Convert.ToInt32(input(0))
        Dim num2 As Integer = Convert.ToInt32(input(1))

        Dim answer As Integer = num1 + num2

        If (num1 - num2) > answer Then
            answer = num1 - num2
        End If

        If (num1 * num2) > answer Then
            answer = num1 * num2
        End If

        Console.WriteLine(answer)
    End Sub
End Module

Measured memory_bytes: 13268
import fractions # math.gcdはatcoderでは通らないので注意

A, B, C, D = map(int, input().split())

def lcm(x, y):
    return((x * y) // fractions.gcd(x, y)) # lcmという関数はない(mathでもない)

def f(x, y): # x以下の自然数でyで割り切れる個数
    return(x // y)

def g(x, y, z): # x以上y以下の自然数でzで割り切れる個数
    return(f(y, z) - f(x-1, z))

n = B - A + 1
cn = g(A, B, C)
dn = g(A, B, D)
cdn = g(A, B, lcm(C, D))

ans = n - (cn + dn - cdn)
print(ans)

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

int main(int argc, const char * argv[]) {
/*    int a,b,c;
    cin >>a>>b>>c;
    if(a==b){
        cout<<c<<endl;
    }
    if(b==c){
        cout<<a<<endl;
    }
    if (a==c){
        cout<<b<<endl;
    }*/
    int h,w,ans[52][52]={};
    char s[52][52];
    cin >>h>>w;
    for(int i=0;i<=h;i++){
        for(int j=0;j<=w;j++){
            if(i==0||j==0){
                s[i][j]='0';continue;
            }
            cin >>s[i][j];
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                continue;
            }
            if(s[i-1][j]=='#'){
                ans[i][j]+=1;
            }
            if(s[i+1][j]=='#'){
                ans[i][j]+=1;
            }
   //         cout <<ans[i][j]<<endl;
        }
    }
  //  cout <<"--------"<<endl;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                continue;
            }
            if(s[i][j-1]=='#'){
                ans[i][j]+=1;
            }
            if(s[i][j+1]=='#'){
                ans[i][j]+=1;
            }
   //         cout <<ans[i][j]<<endl;
        }
    }
  //  cout <<"--------"<<endl;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                continue;
            }
            if(s[i-1][j-1]=='#'){
                ans[i][j]+=1;
            }
            if(s[i-1][j+1]=='#'){
                ans[i][j]+=1;
            }
  //          cout <<ans[i][j]<<endl;
        }
    }
  //  cout <<"--------"<<endl;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                continue;
            }
            if(s[i+1][j-1]=='#'){
                ans[i][j]+=1;
            }
            if(s[i+1][j+1]=='#'){
                ans[i][j]+=1;
            }
   //         cout <<ans[i][j]<<endl;
        }
    }
 //   cout <<"--------"<<endl;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                cout<<"#";
            }
            else{
                cout <<ans[i][j];
            }
            if(j==w){
                cout <<endl;
            }
        }
    }
    
        return 0;
}


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

if X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
else:
    print(1)


Measured memory_bytes: 61620
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String s=sc.next();
        String t=sc.next();
        int l=s.length();
        int ans=1;
        for(int i=0;i<l;i++){
            char S=s.charAt(i);
            char T=t.charAt(i);
            if(S!=T){
                ans=0;
                break;
            }
        }
        if(ans==1){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        
        
        System.out.println();
    }
}

Measured memory_bytes: 35688
#include<stdio.h>

typedef struct {
	char suit;
	int value;
}Card;

void bubble(Card A[], int N) {
	int i, j;
	Card n;

	for (i = 0; i < N; i++) {
		for (j = N - 1; j >= i + 1; j--) {
			if (A[j].value < A[j - 1].value) {
				n = A[j];
				A[j] = A[j - 1];
				A[j - 1] = n;
			}
		}
	}
}

void selection(Card A[], int N) {
	int i, j, minj;
	Card n;

	for (i = 0; i < N; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j].value < A[minj].value) {
				minj = j;
			}
		}
		n = A[i];
		A[i] = A[minj];
		A[minj] = n;
	}
}

int isStable(Card C1[], Card C2[], int N) {
	int i;

	for (i = 0; i < N; i++) {
		if (C1[i].suit != C2[i].suit) {
			return 0;
		}
	}
	return 1;
}

void print(Card A[], int N) {
	int i;

	for (i = 0; i < N; i++) {
		if (i > 0)printf(" ");
		printf("%c%d", A[i].suit, A[i].value);

	}

	printf("\n");

}

int main() {
	int n, i;
	Card C1[36], C2[36];
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf(" %c%d", &C1[i].suit, &C1[i].value);

	}

	for (i = 0; i < n; i++) C2[i] = C1[i];

	bubble(C1, n);
	selection(C2, n);

	print(C1, n);
	printf("Stable\n");
	print(C2, n);

	if (isStable(C1, C2, n) == 1) {
		printf("Stable\n");
	}
	else {
		printf("Not stable\n");
	}
	return 0;

}



Measured memory_bytes: 2056
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int N, K;
int h[100000];//0-idx　柱の高さをメモする
int dp[100000];//dp[i] := i(0-idx)本目の柱にたどりつくまでの最低コスト

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++)cin >> h[i];

	//例によって、1本目の時点では当然コストが0
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		int best = 1145141919;
		//iのK本前まで見ていく
		for (int j = 1; j <= K; j++) {
			if (i - j >= 0) {
				best = min(best, dp[i - j] + abs(h[i] - h[i - j]));
			}
		}
		dp[i] = best;
	}
	
	cout << dp[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let H:i32 = iter.next().unwrap().parse().unwrap();
    let W:i32 = iter.next().unwrap().parse().unwrap();
    let h:i32 = iter.next().unwrap().parse().unwrap();
    let w:i32 = iter.next().unwrap().parse().unwrap();
    println!("{}", (H-h)*(W-w));
}


Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,m,range;
  cin>>n; m=n/2;
  int d[n];
  rep(i,n){
    cin>>d[i];
  }
  sort(d,d+n);
  range=d[m]-d[m-1];
  if(range>=1){
    cout<<range;
  }else{
    cout<<0;
  }
}

Measured memory_bytes: 640
import java.math.BigInteger
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    val (a, b) = readInts()
    (1..1000).forEach {
        if ((it * 0.08).toInt() == a && (it * 0.1).toInt() == b) {
            println(it)
            return
        }
    }
    println(-1)
}


Measured memory_bytes: 38028
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll w,h,x,y;cin>>w>>h>>x>>y;
	ld ans=(ld)((ld)(w)*(ld)(h));
	ans=(ld)(ans/2.00000);
	bool ok= (2*x==w) and  (2*y==h);
	cout<<ans<<" "<<ok;
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>//g-石头,p-纸
#include<cstring>//出纸的次数<=出石头的次数
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
char a[1000000+5];
ll n,ans;
ll gn,pn,gt,pt;
int main()
{
	scanf("%s",a);
	n=strlen(a);
	for(int i=0;i<n;i++)
	{
		if(a[i]=='g')
			gn++;
		else
			pn++;
	}
	printf("%lld\n",n/2-pn);
	return 0;
}

Measured memory_bytes: 384
import sys
S = str(input())
ls = len(S)
T = str(input())
lt = len(T)

if lt > ls:
  print("UNRESTORABLE")
  sys.exit()

ans = ""
for i in range(ls-lt+1):
  Flag = True
  for j in range(lt):
    #print(S[-1-i-j],T[-1-j],i,j)
    if S[-1-i-j] == T[-1-j] or S[-1-i-j] == "?":
      continue
    else:
      Flag = False
  if Flag:
    now = i #後ろから何文字目か
    break
if not Flag:
  print("UNRESTORABLE")
  sys.exit()  
now = ls - now -lt
#print(S[:now],T,S[now+lt:],now)
ans = S[:now]+T+S[now+lt:]
for i in range(len(ans)):
  if ans[i] == "?":
    ans = ans[:i]+"a"+ans[i+1:]
print(ans)
      


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

int main() {
	set<char> S;
	char x, alph = 'a';
	while(cin >> x) S.insert(x);
	for( auto itr = S.begin(); itr != S.end(); itr++ ){
		if( *itr != alph ){
			cout << alph << endl;
			return 0;
		}
		alph++;
	}
	if( alph == '{' ) cout << "None" << endl;
	else cout << alph << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
    {

        int a,b,c,d;
        cin>>a>>b>>c>>d;
        while(1){
            c=c-b;
            if(c<=0){
                cout<<"Yes";
                break;
            }
            a=a-d;
            if(a<=0){
                cout<<"No";
                break;
            }
        }


    }


Measured memory_bytes: 3520
#include <iostream>

using namespace std;

bool dp[100005];

int main(int argc, char *argv[])
{
	int N, K;
	int a[105];

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	dp[0] = false;
	for (int i = 1; i <= K; i++) {
		for (int j = 0; j < N; j++) {
			if (i - a[j] >= 0) {
				dp[i] |= !dp[i - a[j]];
			}
		}
	}

	if (dp[K]) {
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
using namespace std;

vector<long long> c;

int main() {
	long long int a, b; cin >> a >> b;
	int count = 0;
	while (a <= b) {
		a *= 2;
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
  int n;
  cin >> n;
  cout << pow(n,3);
}


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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5+10;
const int inf = 1e9+7;

int n, m, q, l, r;
vector <int> v[1000];

int main() {
    scanf("%d%d%d", &n, &m, &q);
    for(int i = 1, x, y; i <= m; i++) {
        scanf("%d%d", &x, &y);
        v[x].pb(y);
    }
    for(int i = 1; i <= n; i++)
        sort(all(v[i]));

    while(q--) {
        scanf("%d%d", &l, &r);
        int ans = 0;
        for(int i = l; i <= r; i++) {
            ans += upper_bound(all(v[i]), r) - v[i].begin();
        }
        cout << ans << endl;
    }

}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define PB push_back

main(){
  string se;
  cin>>se;
  int n;
  cin>>n;
  int ans=0;
  string str;
  while(n--){
    cin>>str;
    str+=str;
    if(str.find(se)!=string::npos)++ans;
  }
  cout<<ans<<endl;
}

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

int main(){
  int a,b,c,k;cin >> a >> b >> c >> k;
  int ans = 0;
  for(int i=0;i<k;++i){
    if(a > 0){a -= 1;ans += 1;}
    else if(b > 0){b -= 1;}
    else if(c > 0){c -= 1;ans -= 1;}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define FOR(i,a,b) for(int i=(int)a; i<(int)b; ++i)
#define REP(i, n) FOR(i,0,n)
template<class T> void CHMAX(T & a, T b) { a = (a >= b ? a : b); }
constexpr int INFINT = (1 << 30) - 1;
using PAIR = std::pair<int, int>;

bool isP[1000006];
void Eratosthenes() {
	REP(i, 1000006) isP[i] = true;
	isP[1] = false;
	for (int i = 2; i * i <= 1000006; ++i) {
		if (isP[i]) {
			for (int j = 2; i * j <= 1000006; ++j) isP[i * j] = false;
		}
	}
}

int mp[2003][2003];
PAIR inv[1000006];
const int mid = 1001;

int dy4[] = { 0, -1, 0, 1 };
int dx4[] = { 1, 0, -1, 0 };

void makemap() {
	REP(i, 2003) REP(j, 2003) mp[i][j] = INFINT;
	int y = mid, x = mid;
	int now = 1;
	mp[y][x] = 1;
	inv[1] = PAIR(y, x);
	int dist = 0;
	while (true) {
		REP(d, 4) {
			if (d % 2 == 0) ++dist;
			REP(_, dist) {
				y += dy4[d];
				x += dx4[d];
				mp[y][x] = ++now;
				inv[now] = PAIR(y, x);
				if (now >= 1000003) return;
			}
		}
	}
}

int main() {
	Eratosthenes();
	makemap();

	int m, n;
	while (std::cin >> m >> n, m || n) {
		std::vector<PAIR> dp(m + 1, PAIR(-1, -1));

		auto rec = [&](auto && f, int x) -> PAIR {
			if (x > m) return PAIR(0, 0);
			PAIR& res = dp[x];
			if (res.first != -1) return res;
			res = PAIR(0, 0);

			PAIR pos(inv[x]);
			CHMAX(res, f(f, mp[pos.first + 1][pos.second - 1]));
			CHMAX(res, f(f, mp[pos.first + 1][pos.second + 0]));
			CHMAX(res, f(f, mp[pos.first + 1][pos.second + 1]));
			if (isP[x]) {
				++res.first;
				if (res.first == 1) CHMAX(res.second, x);
			}
			return res;
		};
		rec(rec, n);
		std::cout << dp[n].first << " " << dp[n].second << std::endl;
	}
	return 0;
}


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

#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
#define CLR(arr,val) memset(arr,val,sizeof(arr))

typedef long long LL;

int main(){
    string s;
    cin>>s;
    int n=s.size(),tmp,ans=INF;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1]) tmp=max(n-i,i),ans=min(ans,tmp);
    }
    if(ans==INF) cout<<n<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

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

  ans := 0
  for i := 0; i <= a; i++ {
    for j := 0; j <= b; j++ {
      for k := 0; k <= c; k++ {
        if i * 500 + j * 100 + k * 50 == x {
          ans++
        }
      }
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,x,y;
	long long sum=0,mn=1000000007;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&x,&y);
		sum+=x;
		if(x>y)
			mn=min(mn,(long long)y);
	}
	if(mn==1000000007)
		mn=sum;
		
	printf("%lld",sum-mn);
	return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N, M;
  cin >> N >> M;

  vector<tuple<int, int, int>> pref_year_id(M);
  for (int i = 0; i < M; i++) {
    int pid, year;
    cin >> pid >> year;
    pref_year_id.at(i) = make_tuple(pid, year, i);
  }

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

  vector<int> pref_id(M), city_id(M), cnt(N + 1);
  for (auto& pyi : pref_year_id) {
    int pid, id;
    tie(pid, ignore, id) = pyi;
    pref_id.at(id) = pid;
    cnt[pid]++;
    city_id.at(id) = cnt[pid];
  }

  for (int i = 0; i < M; i++) {
    cout << setfill('0') << setw(6) << pref_id.at(i);
    cout << setfill('0') << setw(6) << city_id.at(i) << endl;
  }
  return 0;
}


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};




int n,m,a[100010],b[100010];
 
signed main(){
	cin>>n>>m;
	rep(i,0,m){
	    int x,y;
	    cin>>x>>y;
	    a[x]++;a[y]++;
	}
	rep(i,0,n+1){
	    if(a[i]%2){
	        cout<<"NO"<<endl;
	        return 0;
	    }
	}
	cout<<"YES"<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define si size
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi 3.14159265359
#define er erase
#define in insert
#define em empty
#define ft front
#define fo(i,n) for(i = 0; i < n; i++)
#define ro(i,n) for(i = n - 1; i >= 0; i--)
#define fr(i,j,n) for(i = j; i < n; i++)
#define rf(i,j,n) for(i=n-1;i>=j;i--)
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::pair<int,int> ii;
typedef std::vector<ii> vii;
typedef std::vector<std::string> vs;
typedef double dl;
typedef long double ld;
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> vll;
#define filename ""
using namespace std;

int main()
{
    /*
	freopen(filename".in","r",stdin);
	freopen(filename".out","w",stdout);
	*/
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    */
    /*
    ios::sync_with_stdio(0);
    */
    int a,b,c;
    cin>>a>>b>>c;
    if (a+b>=c)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    re 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N

int main(){
	FIO;
	string s,t; cin >> s >> t;
    bool flag = 1;
    for(int i = 0 ; i < s.size() ; i++){
        if(s[i] != t[i]) flag = 0;
    }
    if(s.size() != t.size()-1) flag = 0;
    cout << (flag ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3612
def ma():
    return map(int,input().split())
def main():
    n,k=ma()
    A=list(ma())
    ans=[]
    exp=[0]*(n+1)
    now=1
    
    while True:
        ans.append(now)
        exp[now]=1
        now=A[now-1]
        if exp[now]==1:
            use=ans.index(now)
            tool=len(ans)-use
            break 

    if use>=k:
        print(ans[k])
        exit()
    else:
        p=(k-use)%tool
        print(ans[use+p])

main()

Measured memory_bytes: 94656
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";} cout << endl;
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


#define MAX_AA  (ll)1e18;
#define MIN_AA  (ll)-1e18;


int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a;
    rep(i, n){ ll tmp; cin >> tmp; a.push_back(tmp);}
    sort(a.begin(), a.end());

    ll l = MIN_AA;//OK
    ll r = MAX_AA;//NG
    while(abs(l - r) > 1){
        ll mid = (l + r) / 2;

        bool ok = [&]{
            ll tot = 0;
            rep(i, n){
                if (a[i] >= 0){
                    int l = -1, r = n;
                    while(abs(l-r) > 1){
                        int c = (l + r) / 2;
                        if (a[i]*a[c] < mid) l = c; else r = c;
                    }
                    tot += r;
                } else {
                    int l = -1, r = n;
                    while(abs(l-r) > 1){
                        int c = (l + r) / 2;
                        if (a[i]*a[c] < mid) r = c; else l = c; 
                    }
                    tot += n - r;
                }
                if (a[i] * a[i] < mid) tot--;
            }
            tot /= 2;
            return tot < k;
        }();
        if(ok) l = mid; else r = mid; 
    }

    cout << l << endl;
}



Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {
    static int pay(int x) {
        if (x == 1) {
            return 300000;
        } else if (x == 2) {
            return 200000;
        } else if (x == 3) {
            return 100000;
        } else {
            return 0;
        }
    }
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int x = std.nextInt();
        int y = std.nextInt();
        int ans = 0;
        if (x == 1 && y == 1) {
            ans += 400000;
        }

        ans += pay(x);
        ans += pay(y);
        System.out.println(ans);
    }
}


Measured memory_bytes: 22100
import java.util.Scanner;

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

		int a= sc.nextInt();
		int b= sc.nextInt();
		int c= sc.nextInt();
		int d= sc.nextInt();
		int e= sc.nextInt();
		int k = sc.nextInt();

		int x[] = new int[10];

		x[0] = Math.abs(a-b);
		x[1] = Math.abs(a-c);
		x[2] = Math.abs(a-d);
		x[3] = Math.abs(a-e);
		x[4] = Math.abs(b-c);
		x[5] = Math.abs(b-d);
		x[6] = Math.abs(b-e);
		x[7] = Math.abs(c-d);
		x[8] = Math.abs(c-e);
		x[9] = Math.abs(d-e);

		for (int i = 0; i < x.length; i++) {
			if (x[i] > k) {
				System.out.println(":(");
				return;
			}
		}
		System.out.println("Yay!");
	}
}


Measured memory_bytes: 21588
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
 
signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> p(M);
    std::vector<std::string> S(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&p[i]);
        std::cin >> S[i];
    }
    vector<bool> flag(N,false);
    vector<int> wa(N,0);
    int waans = 0;
    REP(i,M){
        if(S[i]=="AC") flag[p[i]-1]=true;
        if(S[i]=="WA"&&flag[p[i]-1]==false) wa[p[i]-1]++;
    }
    int ac = 0;
    REP(i,N){
        if(flag[i]==true){
            ac++;
            waans+=wa[i];
        }
    }
    cout<<ac<<" "<<waans<<endl;
    return 0;
}


Measured memory_bytes: 7296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
        String input = br.readLine();
        System.out.println(new StringBuffer(input).reverse());
    }
 
}

Measured memory_bytes: 24056
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int a[7],b,c,d;
   for(int i=1;i<=6;i++){
    cin>>a[i];
   }
   cin>>b;
   for(int i=0;i<b;i++){
    cin>>c>>d;
   if(c==a[1]){
    if(d==a[2])cout<<a[3]<<endl;
    if(d==a[3])cout<<a[5]<<endl;
    if(d==a[5])cout<<a[4]<<endl;
    if(d==a[4])cout<<a[2]<<endl;
   }else if(c==a[2]){
    if(d==a[1])cout<<a[4]<<endl;
    if(d==a[4])cout<<a[6]<<endl;
    if(d==a[6])cout<<a[3]<<endl;
    if(d==a[3])cout<<a[1]<<endl;
   }else if(c==a[3]){
    if(d==a[1])cout<<a[2]<<endl;
    if(d==a[2])cout<<a[6]<<endl;
    if(d==a[6])cout<<a[5]<<endl;
    if(d==a[5])cout<<a[1]<<endl;
   }else if(c==a[4]){
    if(d==a[1])cout<<a[5]<<endl;
    if(d==a[5])cout<<a[6]<<endl;
    if(d==a[6])cout<<a[2]<<endl;
    if(d==a[2])cout<<a[1]<<endl;
   }else if(c==a[5]){
    if(d==a[1])cout<<a[3]<<endl;
    if(d==a[3])cout<<a[6]<<endl;
    if(d==a[6])cout<<a[4]<<endl;
    if(d==a[4])cout<<a[1]<<endl;
   }else if(c==a[6]){
    if(d==a[2])cout<<a[4]<<endl;
    if(d==a[4])cout<<a[5]<<endl;
    if(d==a[5])cout<<a[3]<<endl;
    if(d==a[3])cout<<a[2]<<endl;
   }
}
}

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

int fib(int n)
{
  static int memos[45];
  if (n < 2) return 1;
  if (memos[n] != 0) return memos[n];
  return memos[n] = fib(n - 1) + fib(n - 2);
}

int main(void)
{
  int n;
  cin >> n;
  cout << fib(n) << endl;
  return 0;
}

Measured memory_bytes: 1160
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=200005;
multiset<int> S;
int main(){
 //   freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int i,n,m;
    scanf("%d",&n);
    for (i=1;i<=n;i++){
        int x;scanf("%d",&x);
        S.insert(x);
    }
    scanf("%d",&m);
    for (i=1;i<=m;i++){
        int x;scanf("%d",&x);
        if (S.find(x)==S.end()) break;
         else S.erase(S.find(x));
    }
    puts(i<=m?"NO":"YES");

    return 0;
}


Measured memory_bytes: 9600
N=int(input())
A=[int(input())for _ in range(N)]
A.sort()
ans=0
check=0
ptr=0
while(ptr<N):
    cc=A[ptr]
    f=0
    while ptr<N and A[ptr]==cc:
        f+=1
        ptr+=1
    ans+=f%2
print(ans)

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

main() {
	int N, Y;
	cin >> N >> Y;
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= N - i; ++j) {
			int k = N - i - j;
			if (10000 * i + 5000 * j + 1000 * k == Y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

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

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

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

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

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int a; int b;
    cin >> a >> b;
    if ((a + b) % 2 != 0)
        cout << (a + b + 1) / 2 << endl;
    else
        cout << (a + b) / 2 << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s = sc.read_chars();

    let ans = if s[0] == 'R' {
        if s[1] == 'R' {
            if s[2] == 'R' {
                3
            } else {
                2
            }
        } else {
            1
        }
    } else {
        if s[1] == 'R' {
            if s[2] == 'R' {
                2
            } else {
                1
            }
        } else {
            if s[2] == 'R' {
                1
            } else {
                0
            }
        }
    };
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2248