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

using namespace std;

int N, d[509][509], x[509 * 509], y[509 * 509], ap[509][509];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

void update (int i, int j)
{
    bool ok = 0;
    if ((i == 1 || j == 1 || i == N || j == N) && ap[i][j] == 0 && d[i][j] == 1)
        d[i][j] = 0, ok = 1;
    for (int k=0; k<4; k++)
    {
        int x = i + dx[k], y = j + dy[k];
        if (1 <= x && x <= N && 1 <= y && y <= N && d[x][y] + ap[i][j] < d[i][j])
            d[i][j] = d[x][y] + ap[i][j], ok = 1;
    }
    if (ok)
    {
        for (int k=0; k<4; k++)
        {
            int x = i + dx[k], y = j + dy[k];
            if (1 <= x && x <= N && 1 <= y && y <= N)
                update (x, y);
        }
    }
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N * N; i++)
{
    int k;
    scanf ("%d", &k);
    x[i] = (k - 1) / N + 1, y[i] = (k - 1) % N + 1;
}
for (int i=1; i<=N; i++)
    for (int j=1; j<=N; j++)
        d[i][j] = 1 + min (min (i - 1, j - 1), min (N - i, N - j)),
        ap[i][j] = 1;
int ans = 0;
for (int kk=1; kk<=N * N; kk++)
{
    int i = x[kk], j = y[kk];
    ans += d[i][j] - 1, ap[i][j] = 0;
    update (i, j);
}
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 18928
program prob3
    implicit none
    integer::n, m, d
    real(8)::ans
    read(*,*) n, m, d
    if(d == 0) then
        ans = dble(1)*dble(m-1) / dble(n)
    else
        ans = dble(2)*dble(n-d)*dble(m-1) / dble(n)**2
    end if
    write(*,*) ans
    stop
end program

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

using lint = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3] || s[3] == s[4])
		cout << "Bad\n";
	else cout << "Good\n";
}



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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){

    bool flag=false;
    ll ans=1,sum=0;

    ll n,m;
    int two=-1;

    cin >>n>>m;
    vector<ll> a(n);
    rep(i,n){
        int ai,cnt=0;
        cin>>ai;

        while(ai%2==0){
            ai/=2;
            cnt++;
        }

        if(two!=-1 && cnt!=two){
            puts("0");return 0;
        }else if(two==-1)two=cnt;

        ans = lcm(ans,ai);
    }
    
    ans <<= two-1;
    ans = m/ans;
    ans = (ans+1)/2;
    //db(ans);ln;

    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC135A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine()
                    .Split(' ').Select(x => int.Parse(x))
                    .ToArray();
            var m = n[0] + n[1];
            if (m % 2 == 0) {
                Console.WriteLine(m / 2);
            }
            else {
                Console.WriteLine("IMPOSSIBLE");
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#define INF (1ll << 62)
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
typedef map<int, vector<int>> Graph;
typedef map<int, map<int, ll>> WGraph;
typedef pair<int, int> Edge;
vector<ll> bellmanford(int v, WGraph &g, int r)
{
    vector<ll> cost(v, INF);
    cost[r] = 0;
    rep(_, v)
    {
        rep(i, v)
        {
            for (auto x : g[i])
            {
                int j = x.first;
                ll c = x.second;
                if (cost[j] > cost[i] + c)
                {
                    if (_ == v - 1)
                    {
                        cost[j] = -INF;
                    }
                    else
                    {
                        cost[j] = max(-INF, cost[i] + c);
                    }
                }
            }
        }
        rep(i, v)
        {
            for (auto x : g[i])
            {
                int j = x.first;
                ll c = x.second;
                if (cost[j] > cost[i] + c)
                {
                    cost[j] = max(-INF, cost[i] + c);
                }
            }
        }
    }

    return cost;
}

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    WGraph g;
    rep(i, m)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        c = -c;
        g[a][b] = c;
    }
    auto cost = bellmanford(n, g, 0);
    if (-cost[n - 1] == INF)
    {
        cout << "inf" << endl;
    }
    else
    {

        cout << -cost[n - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<algorithm>
double dp[51][5000]={},r;
int main()
{
	int X,Y,Z,V[4],N,E,A,i,j,k,x,x2;
	while(scanf("%d%d%d",&X,&Y,&Z),X)
	{
		int p[51]={},a[51]={};
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(i=0;i<X;++i)scanf("%d",V+i);
		while(Z--)
		{
			scanf("%d%d%d",&N,&E,&A);
			if(E==1)p[N]=A;
			else if(E==2)a[N]=A;
			else a[N]=-A;
		}
		for(i=0;i<Y;++i)
			for(j=0;j<X;++j)
			{
				x=std::min(Y,i+V[j]);
				x2=std::min(Y,x+p[x]);
				for(k=0;k<4901;++k)
					dp[x2][std::max(0,k+a[x])]+=dp[i][k]/X;
			}
		for(r=k=0;k<5000;++k)r+=dp[Y][k]*k;
		printf("%d\n",int(r+1e-8));
	}
	return 0;
}

Measured memory_bytes: 2756
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll x[5];
    rep(i, 5){
        cin >> x[i];
    }

    rep(i, 5){
        if(x[i] == 0){
            cout << i + 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

struct edge{
	int to;
	int cost;
};


const int MAX_N = 100005;

int n,m,k,ss;
bool C[MAX_N];
vector<int> CC;
ll d[MAX_N];
int dd[MAX_N];
vector<int> G[MAX_N];
vector<edge> GG[MAX_N];
deque<int> deq;

void dijkstra(int s)
{
	priority_queue<P,vector<P>,greater<P> > que;
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		vector<edge>::iterator it = GG[v].begin();
		while(it != GG[v].end()){
			if(d[it->to] > d[v] + it->cost){
				d[it->to] = d[v] + it->cost;
				que.push(P(d[it->to],it->to));
			}
			it++;
		}
	}
}

int main()
{
	int p,q,x,y,z;
	scanf("%d%d%d%d",&n,&m,&k,&ss);
	scanf("%d%d",&p,&q);
	for(int i=0;i<k;i++){
		scanf("%d",&x);
		C[x-1]=true;
		CC.push_back(x-1);
	}	
	for(int i=0;i<m;i++){
		scanf("%d",&x);
		scanf("%d",&y);
		G[x-1].push_back(y-1);
		G[y-1].push_back(x-1);
	}
	fill(dd,dd+n,INF);
	rep(i,CC.size()){
		deq.push_back(CC[i]);
		dd[CC[i]]=0;
		while(!deq.empty()){
			int u = deq[0];
			deq.pop_front();
			rep(j,G[u].size()){
				if(dd[G[u][j]]>dd[u]+1){
					dd[G[u][j]]=dd[u]+1;
					deq.push_back(G[u][j]);
				}
			}
		}
	}
	fill(d,d+n,(1LL << 60));
	rep(i,n){
		rep(j,G[i].size()){
			edge e;
			e.to=G[i][j];
			if(e.to==n-1){
				e.cost=0;
				GG[i].push_back(e);
				continue;
			}
			if(0<dd[e.to]&&dd[e.to]<=ss){
				e.cost=q;
				GG[i].push_back(e);
			}else if(dd[e.to]!=0){
				e.cost=p;
				GG[i].push_back(e);
			}
		}
	}
	dijkstra(0);
	printf("%lld\n",d[n-1]);
	return 0;
}

Measured memory_bytes: 18404
import math

H,W = map(int,input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    L = [[H,W], [W,H]]
    ans = 1e10
    for H,W in L: 
        Hp = [H, math.ceil(H/2), math.floor(H/2)]
        for x in range(1, W):
            S = [Hp[0]*x, Hp[1]*(W-x), Hp[2]*(W-x)]
            temp = max(S) - min(S)
            if ans > temp:  ans = temp

    ans = min([ans, W, H])
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>


int main()
{
    // std::cout << std::fixed << std::setprecision(10);
    
    int r, d, x; std::cin >> r >> d >> x;
    for(int i=0; i<10; i++)
    {
        x = r*x - d;
        std::cout << x << std::endl;
    }

    return 0;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;

int main(){

    int v[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;

    cout << v[n - 1] << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    long a, b;
    char op;
    for(;;) {
        scanf("%ld %c %ld", &a, &op, &b);
        if(op == '?') {
            break;
        } else if(op == '+') {
            printf("%ld\n", a + b);
        } else if (op == '-') {
            printf("%ld\n", a - b);
        } else if (op == '*') {
            printf("%ld\n", a * b);
        } else {
            printf("%ld\n", a / b);
        }
    }
}


Measured memory_bytes: 2068
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/09/20 20:59:36
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int a,b,c; cin>>a>>b>>c;
  auto m = max({a,b,c});
  auto d = m-a+m-b+m-c;
  if (d%2)
    d += 3;
  cout << d/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;
const ll mod = 998244353;

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { return mint(*this)+=a; }
  mint operator-(const mint a) const { return mint(*this)-=a; }
  mint operator*(const mint a) const { return mint(*this)*=a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this)/=a; }
  bool operator==(const mint a) const { return x == a.x; }
  bool operator!=(const mint a) const { return x != a.x; }
  friend ostream &operator<<(ostream &os, const mint &p) { return os << p.x; }
  friend istream &operator>>(istream &is, mint &a) {
    ll t;
    is >> t;
    a = mint(t);
    return (is);
  }
};

int main()
{
  ll a,b,c,d; cin>>a>>b>>c>>d;
  ll x = c - a;
  ll y = d - b;

  vector<vector<mint>> dp(x+1, vector<mint>(y+1, 0));
  dp[0][0] = 1;
  for (int i=0; i<=x; i++) {
    for (int j=0; j<=y; j++) {
      if (i==0 && j==0) continue;
      if (i==0) {
        dp[i][j] = dp[i][j-1] * a;
      }
      else if (j==0) {
        dp[i][j] = dp[i-1][j] * b;
      }
      else {
        ll t = (b+j-1) * (a+i-1);
        dp[i][j] = dp[i-1][j] * (b+j) + dp[i][j-1] * (a+i) - dp[i-1][j-1]*t;
      }
    }
  }
  cout << dp[x][y] << endl;

  return 0;
}


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

i = 0
Ap = A
Bp = B
Cp = C
while A%2 == 0 and B%2 == 0 and C%2 == 0:
  A = Bp//2 + Cp//2 
  B = Ap//2 + Cp//2 
  C = Bp//2 + Ap//2 
  i += 1
  Ap = A
  Bp = B
  Cp = C
  if A == B == C:
    i = -1
    break


print(i)

Measured memory_bytes: 9120
#include <stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    
    scanf("%d %d",&a,&b);
    
    d=a/b;
    r=a%b;
    f=a/(double)b;
    
    printf("%d %d %f",d,r,f);
    
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n;cin>>n;
    
    if(n%2==0){
        int i=5,cnt=0;
        n/=2;
        while(n/i){
            cnt+=(n/i);
            i*=5;
        }
        cout<<cnt;
        return 0;
    }

    cout<<0;
    
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double n = sc.nextDouble();
    double k = sc.nextDouble();
    double answer = 0;
    for(double i=1;i<=n;i++){
      double coinCnt =0;
      coinCnt=Math.ceil((Math.log(k)/Math.log(2))-(Math.log(i)/Math.log(2)));
      if(coinCnt<=0){
        coinCnt=0;
      }
      answer += 1/Math.pow(2,coinCnt);
    }
    System.out.println(answer*(1/n));
  }
}

Measured memory_bytes: 23348
use std::io::BufReader;
use std::io::BufRead;
use std::io;

fn main() {
    let reader = io::stdin();
    let mut stdin = BufReader::new(reader.lock());
    let mut buf = String::new();

    let _ = stdin.read_line(&mut buf);
    let vec: Vec<i32> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let n = vec[0];
    let k = vec[1];

    if n % k == 0 {
        println!("{}", 0);
    } else {
        println!("{}", 1);
    }
}



Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
struct T{
	int x,id;
}a[210000];
int f[210000];
int cmp(T x,T y)
{
	return x.x<y.x;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i].x),a[i].id=i;
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++)
	{
		if (i<=(n-1)/2+(n-1)%2) f[a[i].id]=a[(n-1)/2+(n-1)%2+1].x;
		else f[a[i].id]=a[(n-1)/2+(n-1)%2].x;
	}
	for (int i=1;i<=n;i++) printf("%d\n",f[i]);
 } 

Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
ll GCD(ll x,ll y){
    if(y==0){
        return x;
    }else{
        return GCD(y, x % y);
    }
}
ll LCM(ll x,ll y){
    return x / GCD(x, y) * y;
}
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll sum = 0;
    vector<ll> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec[i];
    }
    for (int i = 0; i < n - 1;i++){
        sum += min(abs(vec[i + 1] - vec[i]) * a, b);
    }
    cout << sum << endl;
}


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

int n,a[100005];

int main() {
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    for(int i=1;i<=n;i++) {
        if(i+1>a[i+1]) {
            int j=0;
            while(a[j+i+1]==i)++j;
            if((a[i]-i)%2 || j%2) cout<<"First";
            else cout<<"Second";
            return 0;
        }
    }
}


Measured memory_bytes: 640
N = int(input())
red = []
for i in range(N):
    a,b = map(int,input().split())
    red.append((a,b))

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

red =  sorted(red,  key=lambda x:x[0])
blue = sorted(blue, key=lambda x:x[0])

ans = 0

for i in range(N):
    c = blue[i][0]
    d = blue[i][1]

    ind = -1
    y_max = -1
    for j in range(N - ans):
#        print('red = ',red[j])
        a = red[j][0]
        b = red[j][1]

        if a < c and b < d and y_max < b:
            ind = j
            y_max = b
        elif a > c:
            break

    if ind > -1:
        ans += 1
#        print('pop',c,d,red[ind])
        red.pop(ind)
#        print('remove',red)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>

typedef long long ll;

int main()
{
  ll N, M;
  std::cin >> N >> M;

  std::vector<ll> va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  ll sum = std::accumulate(va.begin(), va.end(), 0LL);
  double tol = sum / 4.0 / (double)M;

  ll cnt = N;
  for (ll i = 0; i < N; i++) {
    if (va[i] < tol) {
      cnt--;
    }
  }

  if (cnt >= M) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
function main(input) {
    var N = input[0]-0;
    var bmap = {};
    for(var i=1;i<=N;i++){
        bmap[input[i]] = (bmap[input[i]]||0)+1 ;
    }
    var M = input[N+1]-0;
    for(var i=N+2;i<N+2+M;i++){
        bmap[input[i]] = (bmap[input[i]]||0)-1 ;
    }
    var ans = 0;
    Object.keys(bmap).forEach(key=>{
        ans = Math.max(ans, bmap[key]);
    })
    console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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

int main() {
    int A, B, C, K; cin >> A >> B >> C >> K;
    while (B <= A) {
        if (K <= 0) break;
        B *= 2;
        K--;
    }
    while (K > 0) {
        C *= 2;
        K--;
    }
    if (A < B && B < C) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
    
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

const int SIZE = 2e5+100;
int a,b,c;

int main(){
    cin >> a >> b >> c;
    cout << max(0,c-(a-b)) << endl;
}

Measured memory_bytes: 764
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (h, w, n) = (v[0], v[1], v[2]);
    let mut grids = HashSet::new();
    for _ in 0..n {
        let v = read_vec::<i64>();
        grids.insert((v[0] - 1, v[1] - 1));
    }
    let mut answers = [0; 10];
    for &(y, x) in grids.iter() {
        for y_offset in -2..1 {
            if y + y_offset < 0 {
                continue;
            }
            if y + y_offset + 2 > h - 1 {
                continue;
            }
            for x_offset in -2..1 {
                if x + x_offset < 0 {
                    continue;
                }
                if x + x_offset + 2 > w - 1 {
                    continue;
                }
                let x_origin = x + x_offset;
                let y_origin = y + y_offset;
                let mut count = 0;
                for x_search in x_origin..x_origin + 3 {
                    for y_search in y_origin..y_origin + 3 {
                        if grids.contains(&(y_search, x_search)) {
                            count += 1;
                        }
                    }
                }
                answers[count] += 1;
            }
        }
    }
    for i in 1..10 as usize {
        answers[i] /= i as i64;
    }
    answers[0] = (h - 2) * (w - 2) - (1..10).map(|x| answers[x]).sum::<i64>();

    for &ans in answers.iter() {
        println!("{:?}", ans);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 10492
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int b[N+1];
  for(int i=1;i<=N;i++) cin >> b[i];

  vector<int> ans;

  //cout << " aaa" << endl;
  while(N>0){
    //cout << N << endl;
    bool found = false;
    for(int i=N;i>=1;i--){
      if(b[i] == i){
        for(int j=i;j<N;j++){
          b[j] = b[j+1];
        }
        found = true;
        ans.push_back(i);
        break;
      }
    }
    if(!found){
      cout << -1 << endl;
      return 0;
    }
    N--;
  }

  reverse(ans.begin(),ans.end());
  for(int i=0;i<(int)ans.size();i++){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
S1=input()
T=input()
lens1=len(S1)
lent=len(T)
ans="z"*(lens1+1)
def OK(k):
    for i in range(lent):
        if S1[k+i]!=T[i] and S1[k+i]!="?":
            return False
    return True
for i in range(lens1-lent+1):
    if OK(i):
        Stmp=""
        for j in range(lens1):
            if i<=j<i+lent:
                Stmp+=T[j-i]
            elif S1[j]=="?":
                Stmp+="a"
            else:
                Stmp+=S1[j]
        if Stmp<ans:
            ans=Stmp
if ans!="z"*(lens1+1):
    print(ans)
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e9;

int main(){
	int N,M;
	cin>>N>>M;
	int a[50],b[50],c[50],d[50];
	rep(i,N)cin>>a[i]>>b[i];
	rep1(i,M)cin>>c[i]>>d[i];
	rep(i,N){
		int ans=0;
		int dist=MAX;
		rep1(j,M){
			int x=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(x<dist){dist=x;ans=j;}
		}
		cout<<ans<<endl;
		
	}
}

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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int N=read();
	string U[N];
	REP(i,N){
		cin >> U[i];
	}
	int M=read();
	string T[M];
	bool keyOpend = false; 
	REP(i,M){
		cin >> T[i];
		REP(j,N){
			if(T[i].compare(U[j])==0){
				if(keyOpend){
					cout << "Closed by " << T[i] << endl;
				}
				else{
					cout << "Opened by " << T[i] << endl;
				}
				keyOpend = !keyOpend;
				break;
			}
			if(j==N-1) cout << "Unknown " << T[i] << endl;
		}
	}
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << x
#define print(x) cout << x << '\n'
#define debug(x) cerr << #x << ": " << x << '\n'
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll list[n + 1];
        ans = 0;
        rep(i, n){
            cin >> list[i];
        }
        list[n] = 0;
        while(1){
            bool flag = true;
            bool flag2 = false;
            rep(i, n + 1){
                if(list[i] == 0){
                    if(flag2){
                        ans++;
                        flag2 = false;
                    }
                }else{
                    list[i]--;
                    flag = false;
                    flag2 = true;
                }
            }
            if(flag){
                break;
            }
        }
        print(ans);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    string s;
    cin >> n >> s;
    vector<int> a(n);
    REP(i,n){
        if(s[i]=='R') a[i]=0;
        if(s[i]=='G') a[i]=1;
        if(s[i]=='B') a[i]=2;
    }
    vector<ll> cnt(3);
    REP(i,n) cnt[a[i]]++;
    ll ans=1;
    REP(i,3) ans*=cnt[i];
    REP(j,n)REP(i,j){
        int k=j+(j-i);
        if(k<n){
            if(a[i]==a[j]) continue;
            if(a[i]==a[k]) continue;
            if(a[k]==a[j]) continue;
            ans--;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;



int main() {
    int n,count = 0;
    string s;
    cin >> n >> s;
    rep(i,n-2) {
        string str = s.substr(i,3);
        if(str == "ABC") {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    auto func = [](int a) {
        if (a > 3) {
            return 0;
        } else {
            return (4 - a) * 100000;
        }
    };
    int ans = 0;
    if (x * y == 1) {
        ans = 400000;
    }
    cout << ans + func(x) + func(y) << endl;
    return 0;
}


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

void solve(long long N, string S){
	int ans = 0;
	for (int i = 1; i < N; i++) {
		string left = S.substr(0, i);
		string right = S.substr(i, S.length());

		map<char, int> hits;
		for (int j = 0; j < left.length(); j++){
			char c = left.c_str()[j];
			if (right.find(c) != std::string::npos) {
				hits[c] = 1;
			}
		}
		ans = max(int(hits.size()), ans);
	}
	cout << ans << endl;
}

int main(){	
	long long N;
	string S;
	scanf("%lld",&N);
	cin >> S;
	solve(N, S);
	return 0;
}



Measured memory_bytes: 256
N, W = list(map(int, input().split(" ")))
dp =  [[0] * (W+1) for _ in range(N+1)]
 
for i in range(0, N):
	weight, value = map(int, input().split(" "))
	for w in range(1, W+1):
		if w >= weight:
			dp[i + 1][w] = max([dp[i][w - weight] + value, dp[i][w]])
		else:
			dp[i + 1][w] = dp[i][w]
print(dp[N][W])

Measured memory_bytes: 119644
M, D = map(int, input().split())
ans = 0
for j in range(1, M+1):
    for i in range(1, D+1):
        d = str(i).zfill(2)
        if j == int(d[0])*int(d[1]) and int(d[0]) >= 2 and int(d[1]) >= 2:
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cins(string, 3, s);
    cout << s[0][0] << s[1][1] << s[2][2] << "\n";
}

Measured memory_bytes: 256
#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;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

vector<bool> prime(60000);
VI pr;
void eratos ( int n){
	prime[2] = true; prime[0] = prime[1] = false;
	for(int i = 3; i <= n; i += 2) prime[i] = true, prime[i+1] = false;
	int limit = (int)sqrt((double)n) + 1;
	for(int i = 3; i <= limit; i += 2){
		if(!prime[i]) continue;
		for(int j = i * i, k = i * 2; j <= n; j += k) prime[j] = false;
	}
	rep(i, n+1) if(prime[i]) pr.push_back(i);
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	eratos(55555);
	int ct = 1;
	for(auto x: pr) if(x%5==1){
		cout <<x <<" ";
		if(ct++ >=n) break;
	}
	cout <<"\n";
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define mk make_pair
#define endl '\n'

int main()
{
    IOS;
    int x;
    cin>>x;
    int sign=x/abs(x);
    x=abs(x);
    int a,b;
    for (int i = 0; i <= 200; i++)
    {
        for (int j = -i; j <= i; j++)
        {
            ll v1,v2;
            v1=pow(i,5);
            v2=pow(j,5);
            if(v1-v2==x)
            {
                a=i;
                b=j;
                break;
            }
        }
        
    }
    a=a*sign;
    b=b*sign;
    cout<<a<<" "<<b;
}

Measured memory_bytes: 4112
#include <iostream>
using namespace std;;
int main(){
    int n; cin >> n;
    int B[n]; for (int i=0; i<n-1; i++) cin >> B[i];
    int ans = B[0]+B[n-2];
    for (int i=0; i<n-2; i++){
        ans += min(B[i], B[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
  int price;
  scanf("%d",&price);
  bool disable[10];
  for(int i = 0;i < 10;i++){
	disable[i] = false; 
  }
  int K;
  scanf("%d",&K);
  for(int i = 0;i < K;i++){
 	int n;
 	scanf("%d",&n);
	disable[n] = true; 
  }
  int tmp;
  while(true){
   tmp = price;
   while(!disable[tmp % 10] && tmp != 0){
	tmp /= 10;
   }
   if(tmp == 0) break;
   price++;
  }
  printf("%d\n",price);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


template<typename T>
struct SegmentTree{
private:
    int n;
    T E;
    vector<T> node;
    inline void updatef(T& x,T& y){
        x = y;
        //x += y;
        //x = max(x,y);
        //x = min(x,y);
    }
    inline T queryf(T& x,T& y){
        //return x*y;
        //return x+y;
        //return max(x,y);
        return min(x,y);
    }

public:
    SegmentTree(int sz,T E_):E(E_){
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
    }

    SegmentTree(vector<T>& A,T E_):E(E_){
        int sz=A.size();
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
        rep(i,sz)node[i+n-1]=A[i];
        for(int i=n-2;i>=0;--i){
            node[i]=queryf(node[2*i+1], node[2*i+2]);
        }
    }
    void update(int k,T x){
        k+=n-1;
        updatef(node[k],x);
        while(k>0){
            k=(k-1)/2;
            node[k]=queryf(node[2*k+1], node[2*k+2]);
        }
    }
       //[a,b)での和を返す
    T get(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l)return E;
        if(a<=l&&r<=b)return node[k];
        T xl=get(a,b,2*k+1,l,(l+r)/2);
        T xr=get(a,b,2*k+2,(l+r)/2,r);
        return queryf(xl, xr);
    }
};


struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
        par[x]+=par[y];
        par[y]=x;
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};
int main(){
    int n,k;
    cin>>n>>k;
    SegmentTree<int> sg(2*n, inf),sg2(2*n,inf);
    int a[n];
    rep(i,n){
        cin>>a[i];
        sg.update(i,a[i]);
        sg2.update(i,-a[i]);
    }
    UnionFind uf(n+1);
    REP(i,1,n-k+1){
        if(sg.get(i-1,i+k-1)==a[i-1]&&sg2.get(i,i+k)==-a[k+i-1]){
            uf.unite(i-1,i);
        }
    }
    vector<int> sum(n);
    rep(i,n-1){
        sum[i+1]=(a[i]>a[i+1]);
    }
    rep(i,n)sum[i+1]+=sum[i];
    rep(i,n-k+1){
        if(sum[i]==sum[i+k-1])uf.unite(i,n);
    }
    int ans = 0;
    rep(i,n-k+1){
        if(uf.find(i)==i)++ans;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    ll x; cin>>x;
    ll m=100;
    ll i=0;
    while(m<x){
        ll M=m/100;
        m=m+M;
        i++;
        //cout<<m<<endl;
    }
    cout<<i<<endl;
    
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }


int main() {
	string s;
	cin >> s;
	if (s.length() == 2) {
		cout << s;
	}
	else if (s.length() == 3) {
		for (int i = 2; i >= 0; i--) {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N;
    cin >> N;
    bool f=false;
    int out = 0;
    for (int i=0;i<=N;i++){
        //cerr << i << " " << (int)(i*1.08) << " " << i*1.08 << endl;
        if((int)(i*1.08) == N){
            out = i;
            f=true;
            break;
        }
    }
    if(f){
        cout << out << endl;
    }else{
        cout << ":(" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
' Imports System.Collections.Generic
' Imports System.Globalization
' Imports System.IO
' Imports System.Linq
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim r As Integer = Console.ReadLine()
        Console.WriteLine(3 * r ^ 2)
        Return
    End Sub
End Class

Measured memory_bytes: 28484
#include <bits/stdc++.h>
using namespace std;;
int main () {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> data(H, vector<int> (W,3));
  vector<int> hdata(H,0),wdata(W,0);
  for(int i = 0; i < H; i++) {
    char a , b = ' ';
    int count = 0;
    for(int j = 0; j < W; j++) {
      cin >> a;
      if (a == '.') data.at(i).at(j) = 0;
      else data.at(i).at(j) = 1;
      if (a == '.' && a == b) count++;
      b = a;
      if ((count == W - 1 && W != 1) || (a == '.' && W == 1)) hdata.at(i) = 1;
    }
  }
  for(int i = 0; i < W; i++) {
    int a , b = -1;
    int count = 0;
    for(int j = 0; j < H; j++) {
      a = data.at(j).at(i);
      if (a == 0 && a == b) count++;
      b = a;
      if ((count == H - 1 && H != 1) || (a == 0 && H == 1)) wdata.at(i) = 1;
    }
  }
  for(int i = 0; i < H; i++) {
    if (hdata.at(i) == 1) continue;
    for(int j = 0; j < W; j++) {
      if (wdata.at(j) == 1) continue;
      if(data.at(i).at(j) == 0) cout << '.';
      else cout << '#';
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	
	int input;
	
	scanf("%d", &input);
	
	if (input/100 == 7){
		puts("Yes");
	}else if ((input - (input/100)*100)/10 == 7){
		puts("Yes");
	}else if ((input - (input/10)*10) == 7){
		puts("Yes");
	}else{
		puts("No");
	}
	
	return 0;
}


Measured memory_bytes: 1636
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define INF 1e+9
#define MAX_V 100000

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int y[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<(int)G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                y[e.to] = v;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    cin >> V;
    int E;
    cin >> E;
    for (int i=0; i<E; ++i) {
        int a, b;
        cin >> a >> b;
        edge e = {b-1, 1};
        G[a-1].push_back(e);
        e = {a-1, 1};
      
        G[b-1].push_back(e);
    }
    dijkstra(0);
    cout << "Yes" <<endl;
  
    for (int i=1; i<V; ++i) {
        if(d[i] != INF)
            cout <<  y[i]+1 << endl;
    }
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define R(i,n) for(int i = 0; i < (n); i++)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class T> ostream &operator<<(ostream& os, set<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.FI << "," << P.SE << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int licz(int x){
  string pom = to_string(x);
  int res = 0;
  for(char el:pom){
    res += el - '0';
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n;
  cin >> n;
  int res = 1e9;
  for(int a = n-1;a >= 1;a--){
    int b = n - a;
    mini(res,licz(a)+licz(b));
  }
  cout << res << "\n";
}




Measured memory_bytes: 256
N,K = map(int,input().split())
*A, = map(int,input().split())

mod = 10**9+7

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i]>A[j]:
            ans += 1
            ans %= mod
ans = ans*K%mod
C = {}
for a in A:
    C[a] = C.get(a,0)+1
C2 = [N-C[a] for a in A]
ans2 = K*(K-1)*sum(C2)//4%mod
ans = (ans+ans2)%mod
print(ans)

Measured memory_bytes: 41692
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}

vi g[N];
int n,dp[N],si[N];
bool vis[N];

void dfs(int x){
	vis[x]=si[x]=dp[x]=1;
	int t=0;
	for(int y:g[x]){
		if(vis[y]) continue;
		dfs(y);
		if(si[y]&1) t++;
		dp[x]&=dp[y];si[x]+=si[y];
	}
	if(t>1) dp[x]=0;
}

int main(){
#ifdef rqgao2014
//	freopen("input.txt","r",stdin);
	srand(time(0));
	time_tester(0);
#endif
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;scanf("%d%d",&x,&y);
		g[x].pb(y);g[y].pb(x);
	}
	dfs(1);
	if(!dp[1]||si[1]&1) puts("First"); else puts("Second");
#ifdef rqgao2014
	time_tester(1);
#endif
	return 0;
}


Measured memory_bytes: 6656