akhauriyash/Code-Regression huggingface dataset:
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

ll N = 2;

bool ok(ll n) {
    if (n <= N) {
        if (to_string(n) <= to_string(N)) return 1;
        return 0;
    }
    if (to_string(n) > to_string(N)) return 1;
    return 0;
}

int query(ll mid) {
    cout << "? " << mid << endl;
    char ans; cin >> ans;
    if (ans == 'Y') return 1;
    return 0;
}

ll po10(ll z) {
    ll ans = 1;
    F0R(i,z) ans *= 10;
    return ans;
}

void get() {
    ll lo = 1e10, hi = (1e11)-1; 
    while (lo < hi) {
        ll mid = (lo+hi)/2;
        
        // find first which gives yes
        if (query(mid)) hi = mid;
        else lo = mid+1;
    }
    
    while (lo % 10 == 0) lo /= 10;
    ll p = 1;
    while (10*p <= lo) p *= 10;
    
    ll lo1 = 0, hi1 = 9;
    
    while (p*po10(hi1) > 1e18) hi1--;
    
    while (lo1 < hi1) {
        if (lo != 1) {
            ll mid = (lo1+hi1+1)/2;
            if (query(p*po10(mid))) lo1 = mid;
            else hi1 = mid-1;
        } else {
            ll mid = (lo1+hi1)/2;
            if (query((10*p-1)*po10(mid))) hi1 = mid;
            else lo1 = mid+1;
        }
    }
    
    cout << "! " << lo*po10(lo1) << endl;
}

int main() {
    get();
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    long long aa = abs(b * c * (a / 2) - b * c * (a / 2 + a % 2));
    long long bb = abs(a * c * (b / 2) - a * c * (b / 2 + b % 2));
    long long cc = abs(b * a * (c / 2) - b * a * (c / 2 + c % 2));
    cout << min(min(aa, bb), cc);
    return 0;
}


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

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

vector<P> prifac(ll n){
	vector<P> ret;
	for(ll i = 2 ; i*i <= n ; i ++){
		if(n%i == 0){
			int cnt = 0;
			while(n%i == 0){
				cnt ++;
				n /= i;
			}
			ret.push_back(P(i,cnt));
		}
	}
	if(n > 1)ret.push_back(P(n,1));
	return ret;
}

vector<ll> divisors(ll n){
	vector<P> vec = prifac(n);
	vector<ll> ret;
	ret.push_back(1);
	for(int i = 0 ; i < vec.size() ; i ++){
		P p = vec[i];
		int m = ret.size();
		for(int j = 0 ; j < m ; j ++){
			ll t = ret[j];
			for(int k = 0 ; k < p.second ; k ++){
				t *= p.first;
				ret.push_back(t);
			}
		}
	}
	return ret;
}

int main(){
	ll n;
	cin >> n;
	
	vector<ll> vec = divisors(n);
	ll ret = 0;
	for(int i = 0 ; i < vec.size() ; i ++){
		if(n/vec[i]+2 <= vec[i])ret += vec[i]-1;
	}
	cout << ret << endl;
}


Measured memory_bytes: 384
program garden
  implicit none
  integer :: n, i
  integer(8) :: k, l = 0_8, x = 3000000000000000000_8, m, s
  integer(8), dimension(100000) :: w = 0_8, d = 0_8
  read(*,*) n, k
  do i = 1, n
    read(*,*) w(i), d(i)
  end do
  do while (x-l > 1_8)
    m = (x+l)/2_8
    s = 0_8
    do i = 1, n
      if (m < w(i)) cycle
      s = s+(m-w(i))/d(i)+1_8
    end do
    if (s < k) then
      l = m
    else
      x = m
    end if
  end do
  write(*,'(i0)') x
end program garden

Measured memory_bytes: 1792
a, b, m = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
m1 = min(A) + min(B)
m2 = 1000000
for i in range(m):
    l = list(map(int, input().split(' ')))
    lp = A[l[0] - 1] + B[l[1] - 1] - l[2]
    if lp < m2:
        m2 = lp        
print(m1 if m1 < m2 else m2)


Measured memory_bytes: 18736
/**
 *    author:  FromDihPout
 *    created: 2020-05-16   
**/

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, pref = "", suff = "";
    int q;
    cin >> s >> q;
    bool rev = 0;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = !rev;
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            if ((f == 1 && !rev) || (f == 2 && rev)) {
                pref += c;
            }
            else {
                suff += c;
            }
        }
    }
    string ans = "";
    if (rev) {
        reverse(suff.begin(), suff.end());
        reverse(s.begin(), s.end());
        ans += suff + s + pref;
    }
    else {
        reverse(pref.begin(), pref.end());
        ans += pref + s + suff;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1348
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char str1[110],str2[110];
int main()
{
	cin>>str1;
	cin>>str2;
	int n=strlen(str1);
	bool flag=false;
	for(int i=0;i<n;i++)
	{
		if(strcmp(str1,str2)==0){
			flag=true;
			break;
		}
		char c=str1[n-1];
		for(int i=n-1;i>0;i--) str1[i]=str1[i-1];
		str1[0]=c;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;

    int days = 0;
    for (int i = 0; i < 3; i++){
        if (s.at(i) == t.at(i)){
            days++;
        }
    }

    cout << days << endl;
}


Measured memory_bytes: 256
from math import gcd

N = int(input())
A = list(map(int, input().split()))
exist = [0] * (10**6 + 1)
for a in A:
    exist[a] += 1

g = A[0]
for a in A[1:]:
    g = gcd(g, a)

if g != 1:
    print('not coprime')
elif all([sum(exist[i::i]) <= 1 for i in range(2, 10**6+1)]):
    print('pairwise coprime')
else:
    print('setwise coprime')

Measured memory_bytes: 228172
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct  UndirectedGraph{
    vector<vector<int>> g;
    vector<int> clr;
    vector<int> dis;
    int V;

    UndirectedGraph(int V) : V(V),
    g(vector<vector<int>>(V)),
    clr(vector<int>(V,0))
    {}

    //don't add (v,u) after adding (u,v)
    void add_edge(int u,int v){
        g[u].push_back(v);
        g[v].push_back(u);
    }


    //二部グラフ判定
    bool dfs_nib(int v,int c){
        clr[v]=c;
        for(auto x:g[v]){
            if(clr[x]==c) return false;
            if(clr[x]==0 && !dfs_nib(x,-c) ) return false;
        }
        return true;
    }
    bool isNib(){
        bool ret=true;
        for(int i=0;i<V;i++)if(clr[i]==0){
            if(!dfs_nib(i,1)){
                ret=false;break;
            }
        }
        return ret;
    }

    //distance
    void bfs(int st){
        dis=vector<int>(V,INF);
        vector<bool> checked(V,false);
        //bfsは距離を決定したら最短距離がそれで決まるから距離決定時にスタンプ
        dis[st]=0;checked[st]=true;
        queue<int> q;
        q.push(st);
        while(!q.empty()){
            auto now=q.front();q.pop();
            for(auto x:g[now]){
                if(checked[x]) continue;
                checked[x]=true;
                dis[x]=dis[now]+1;
                q.push(x);
            }
        }
    }
};

signed main(){
    int n;
    cin>>n;
    UndirectedGraph g(n);
    char s[n][n];
    rep(i,n){
        rep(j,n){
            char t;cin>>t;
            s[i][j]=t;
            if(t=='1'&&i>j){
                g.add_edge(i,j);
            }
        }
    }
    if(!g.isNib()){
        cout<<-1<<endl;
        return 0;
    }

    int ans=0;
    rep(i,n){
        g.bfs(i);
        int x=*max_element(ALL(g.dis));
        ans=max(x,ans);
    }   
    cout<<ans+1<<endl;
    return 0;
}


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

int main() {
  string b;

  
 cin>>b;
  char a=b.at(0),c=b.at(1),d=b.at(2);
  if(a =='7' || c=='7' || d=='7')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
 
 
}



Measured memory_bytes: 3628
class struct:
  def __init__(self,a,b):
    self.a=a
    self.b=b
_a,_b=map(int,input().split())
b=str(bin(_b))[2:]
a=str(bin(_a))[2:].zfill(len(b))
l=[2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,4294967296,8589934592,17179869184,34359738368,68719476736,137438953472,274877906944,549755813888,1099511627776]
l2=[0]*len(b)
_b+=1
for i in range(len(b)):
  x=_a//l[i]
  x_amr=_a%l[i]
  y=_b//l[i]
  y_amr=_b%l[i]
  z_a=(y*l[i]//2+max(0,y_amr-l[i]//2))-(x*l[i]//2+max(0,x_amr-l[i]//2))
  z_b=(y*l[i]//2+min(y_amr,l[i]//2))-(x*l[i]//2+min(x_amr,l[i]//2))
  l2[i]=struct(z_a,z_b)
l2.reverse()
s=''
for i in l2:
  s+=str(i.a%2)
print(int(s,2))

Measured memory_bytes: 3188
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int d=s.nextInt();
		char[]c=s.next().toCharArray();
		for(int i=0;i<c.length;++i)
			c[i]=(char)((c[i]-'A'+d)%26+'A');
		System.out.println(c);
	}
}


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

typedef long long ll;

ll n,a,b;
int main()
{
    cin>>n>>a>>b;
    if((b-a)%2==0)cout<<(b-a)/2<<endl;
    else {
        ll ans1=(a-1)+(b-1)+1;
        ll ans2=(n-a)+(n-b)+1;
        cout<<min(ans1,ans2)/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll mod = 1e9+7;
const ll INF = 2e9;
const double PI = 3.1415926535;


int main(void){
    int n; cin >> n;
    int now = 0;
    for(int i = 0;i < n;i++){
        int h; scanf("%d", &h);
        if(h > now)now = h - 1;
        else if(h < now){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  tarea
//
//  Created by AdÃ¡n LÃ³pez Alatorre on 3/31/17.
//  Copyright Â© 2017 AdÃ¡n LÃ³pez Alatorre. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string.h>
#include <bitset>
#include <set>
#include <cstdio>
#include <cmath>
#include <vector>
#include <iomanip>
#include <queue>
#include <climits>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;

const ll MOD = 1e9 + 7, maxN = 5e3 + 6, maxV = 1e17;

string s, arr[maxN];

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

    set<string> mys;
    
    cin >> s;
    
    for(int i = 0; i < s.size(); i++){
        arr[i] = s.substr(i);
    }
    
    sort(arr, arr + s.size());
    
    int k;
    cin >> k;
    
    for(int i = 0; mys.size() < k; i++){
        for(int j = 0; j < arr[i].size() && mys.size() < k; j++){
            mys.insert(arr[i].substr(0, j + 1));
        }
    }
    
    for(auto it = mys.begin(); it != mys.end(); it++){
        if(!--k){
            cout << *it << '\n';
            break;
        }
    }
    
}


Measured memory_bytes: 16128
#include <iostream>

using namespace std;

int main() {
    int n, a[100];

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

    int ans = 0;
    for (int i=1; i<n; i++) {
        if (a[i] == a[i-1]) {
            ans++;
            i++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = input().split()
n = int(s[0])

st = ['a','b','c','d','e','f','g','h','i','j','k']

#initialize
inis = [1,1,1,1,1,1,1,1,1,1,1]

def print_str( arry , num):
   str_a = ''
   for i in range(num):
     #print(arry,i)
     str_a = str_a + st[arry[i]-1]
   print(str_a)

# len = 1 .. 10
def do_number_n( len ):
   global inis
   tsti = 0
   k = len - 1    
   print_str( inis , len)
   while True:
      inis[k] += 1
      for j in range(k,0,-1):
         #print(inis[0:j],j)
         if ( max(inis[0:j]) + 2 ) <= inis[j]  :
         #if ( inis[j-1] + 2 ) <= inis[j]  :
            inis[j-1] += 1
            inis[j] = 1
         #print('test:  {},{},   {}'.format(j,k,inis))
            
      #最後まで行った。
      if inis[0] > 1 :
         return        
      print_str( inis , len)
  
def main():
  do_number_n(n)
    
main()


Measured memory_bytes: 4428
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
double dp[303][303][303]={};
double dfs(int i,int j,int k,int n)
{
  // if(dp[i][j][k]!=-1)      return dp[i][j][k];
  if((i<0)||(j<0)||(k<0))    return 0;
	else if((i==0)&&(j==0)&&(k==0)) return dp[i][j][k]=0;
  else if(dp[i][j][k]!=-1)      return dp[i][j][k];
	return dp[i][j][k]= ((double)n/(i+j+k)) + ((((double)i)/(i+j+k) * (dfs(i-1,j,k,n)))+(((double)j)/(i+j+k) * (dfs(i+1,j-1,k,n)))+(((double)k)/(i+j+k) * (dfs(i,j+1,k-1,n))));
return 0;
}
int main()
{ ios_base::sync_with_stdio(false); cin.tie(0);
	// MEM(dp,-1);
  for(int i=0;i<303;i++)
    for(int j=0;j<303;j++)
      for(int k=0;k<303;k++)
        dp[i][j][k]=-1;
  int i,n;cin>>n;
	int a=0,b=0,c=0,z=0,count[4]={};
  for(i=0;i<n;i++)
	{   cin>>z;
    if(z==1) a++;
		if(z==2) b++;
		if(z==3) c++;
	}
  double ans=dfs(a,b,c,n);
  cout<<fixed<<setprecision(12)<<ans;
}


Measured memory_bytes: 217600
import java.util.*;
public class Main{
  public static void main(String args[]){
  	Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    long arr[]=new long[n];
    for(int i=0;i<n;i++){
    	arr[i]=sc.nextLong();
    }
    int i=0,start=0;
    long count=0;
    while(i<n){
    	if(arr[start]>=arr[i]){
          count+=arr[start]-arr[i];
        }
      else{
      	start=i;
      }
      i++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 60944
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n)
{
    KAKA
    vector<ll> v(n);
    //ld sum = 0;
    vector<ll> vec;
    pragi(0,n)
    {
        cin>>v[i];
        vec.eb(v[i] - i - 1);
    }
    sort all(vec);
    if(n & 1)
    {
      ll mid = vec[(n/2)];
      ll ans = 0;
      pragi(0,n)
      {
          ans += llabs(vec[i] - mid);
      }
      cout<<ans<<"\n";
    }
    else
    {
        ll mid1 = vec[(n/2) - 1],mid2 = vec[(n/2)];
        ll mid = (mid1 + mid2)/2;
        ll ans1 = 0,ans2 = 0,ans3 = 0;
        pragi(0,n)
        {
           // ans1 += llabs(vec[i] - mid);
            ans2 += llabs(vec[i] - mid1);
            ans3 += llabs(vec[i] - mid2);
        }
        cout<<min(ans2,ans3);
    }
    
}
int main()
{
    KAKA
    ll n;
    cin>>n;
    Compute(n);
}

Measured memory_bytes: 6828
s = gets.chomp("")

size = s.length
s = s.to_i

ans = 0
  case size
  when 1 then
    ans = s
  when 2 then
    ans += 9
  when 3 then
    ans = s - 99 + 9
  when 4 then
    ans += 909
  when 5 then
    ans = s - 9999 + 909
  when 6 then
    ans += 90909
  end

puts ans


Measured memory_bytes: 1788
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		
		System.out.println(c+" "+a+" "+b);

		
	}
	
}


Measured memory_bytes: 21332
s = int(input())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0
for i in range(1,s//3+1):
        r = s - (i * 3)
        ans += combinations_count(r + i - 1, r)
print(ans %(10 ** 9 + 7))

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

using ll = long long;

int main() {
    int H, W, K;  cin >> H >> W >> K;
    vector<vector<char>> c(H, vector<char>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> c[i][j];
        }
    }

    ll ans = 0;
    for (int i = 0; i < (1 << H); ++i) {
        for (int j = 0; j < (1 << W); ++j) {
            ll sum = 0;
            for (int i_ = 0; i_ < H; ++i_) {
                for (int j_ = 0; j_ < W; ++j_) {
                    if (((i >> i_) & 1) && ((j >> j_) & 1) && c[i_][j_] == '#') ++sum;
                }
            }
            if (sum == K) ++ans;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#define ll long long 
using namespace std;

int main() {
   #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
 ll ans{}, a{},b;
  string s;
  cin >> s;
 ll n=s.size();
 for(ll i=0;i<(1<<n-1);i++){
  a=0;
    for(ll j=0;j<n;j++){
      a=a*10+s[j]-'0';
      if(i & 1<<j) {
          ans+=a;
          a=0;
      }
     
    }

    b=a;
    ans+=a;
    
 }
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 3544
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str0[1005];
char str1[1005];


void solve()
{
    scanf("%s%s", str0, str1);
    int n0 = strlen(str0), n1 = strlen(str1);
    int i, j;
    int ans = INF;
    for (i = 0; i <= n0-n1; i++) {
        int cnt = 0;
        for (j = 0; j < n1; j++) {
            if (str0[i + j] != str1[j]) cnt++;
        }
        ans = MIN(ans, cnt);
    }
    printf("%d\n", ans);


    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



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

int n,m;

int main(){
    scanf("%d%d",&n,&m);
    int maxr = 0;
    for(int i=1;i*i<=m;i++){
        if(m%i==0){
            if(i>=n)maxr = max(maxr,m/i);
            if(m/i>=n)maxr = max(maxr,i);
        }
    }
    printf("%d\n",maxr);
    return 0;
}

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

using namespace std;

typedef long long ll;

bool vis[100050];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
	int n;
	ll k;
	map<int, ll> mp;
	cin >> n >> k;
	vector<int> v;
	for(int i=0; i<n; i++){
		int x, y;
		cin >> x >> y;
		if(!vis[x]){
			v.push_back(x);
			vis[x] = true;
		}
		mp[x] += y;
	}
	sort(v.begin(), v.end());
	int ans;
	ll pre = 0;
	for(int i=0; i<v.size(); i++){
		if(mp[v[i]] + pre >= k){
			ans = v[i];
			break;
		}
		pre += mp[v[i]];
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4604
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N = I()
    A = LI()
    d = collections.OrderedDict()
    A = sorted(A)[::-1]
    for a in A:
        if not a in d:
            d[a] = 1
        else:
            d[a] += 1
    l_num = -1
    ans = 0
    for num, freq in d.items():
        if freq < 2:
            continue
        else:
            if l_num == -1:
                l_num = num
            else:
                ans = l_num * num
                break
        if freq >= 4:
            ans = num * num
            break
    print(ans)
main()



Measured memory_bytes: 116884
#include <bits/stdc++.h>  // ver2.1.8
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(Z,0,a.size()-1)cout<<a[Z]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

vector<pair<int,int>> fac(int n) {  //  素因数分解
vector<Pii>r;for(int i=2;i*i<=n;++i){if(n%i)continue;r.emplace_back(i,0);while(n%i==0){
n/=i;r.back().second++;}}if(n!=1)r.emplace_back(n,1);return r;}

int comb(int n, int r){  //  nCr (MOD環境下)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
 
signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,m;
  cin >> n >> m;
  int ans = 1,qw;
  vector<Pii> a = fac(m);
  
  rep(i,0,a.size()){
    qw = a[i].second;
    ans *= comb(n+qw-1,qw);
    ans %= MOD;
  }
  cout << ans << endl;
  
  return 0;
}

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

int main() {
   int N, D;
   cin >> N >> D;
   vector<vector<int>>X(N,vector<int>(D));

   for (int i = 0; i < N; i++)
   {
       for (int j = 0; j < D; j++)
       {
          cin >> X[i][j];
       }
   }
   
   int answer = 0;
   
   for (int i = 0; i < N; i++)
   {
       for (int j = 0; j < i; j++)
       {
          int dis = 0;
          for (int k = 0; k < D; k++)
          {
              dis += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
          }
          
          for (int k = 0; k < sqrt(dis) + 1 ; k++)
          {
              if (k * k == dis)
              {
                  answer++;
              }
              
          }
          
       }
   }

   cout << answer << endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 入力値を分割する
    String input[] = sc.nextLine().split(" ");

    // 作る個数
    int make = Integer.parseInt(input[0]);
    // 作れる個数
    int cook = Integer.parseInt(input[1]);
    // 1回にかかる時間
    int time = Integer.parseInt(input[2]);

    int amari = make % cook;
    int kaisuu = amari == 0 ? make/cook : make/cook + 1;
    // かかる時間
    int result = kaisuu * time;
    System.out.println(result);
  }
}


Measured memory_bytes: 35584
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int M = in.nextInt();
		ArrayList<int[]> listEdge = new ArrayList<int[]>();
		//boolean[][] edge = new boolean[M+1][M+1];
		boolean[] visited = new boolean[N+1];
		int count = 0;
		
		for(int i = 0; i < M; i++){
			int[] edge = {in.nextInt(), in.nextInt()};
			listEdge.add(edge);
		}
		
		for(int j = 0; j < M; j++){
			int[] rem = listEdge.remove(0);
			
			Arrays.fill(visited, false);
			LinkedList<Integer> queue = new LinkedList<Integer>();
			queue.addFirst(1);
			visited[1] = true;
			
			while(queue.size() != 0){
				int q = queue.remove(0);
				for(int i = 0; i < listEdge.size(); i++){
					int[] edge = listEdge.get(i);
					if(edge[0] == q && !visited[edge[1]]){
						visited[edge[1]] = true;
						queue.addFirst(edge[1]);
					}else if(edge[1] == q && !visited[edge[0]]){
						visited[edge[0]] = true;
						queue.addFirst(edge[0]);
					}
				}
			}
			
			
			boolean isBridge = false;
			for(int i = 1; i <= N; i++){
				if(!visited[i]){
					isBridge = true;
					break;
				}
			}
			if(isBridge) count++;
			
			listEdge.add(rem);
		}
		
		System.out.println(count);		
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#pragma GCC optimize("02")
#define ll long long
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
struct ios{
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline ios & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	int len=s.size();
	while(len--) putchar('x');
	puts("");
	return 0;
}


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

int main(){
	int N;
	int arr[51];
	long long sum =0;
	cin>>N;
	for(int i=0; i<N; i++){
		cin>>arr[i];
	}
	for(int i=0; i<N-1; i++){
		for(int j=i+1; j<N; j++){
			sum += arr[i] * arr[j];
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}
	
	public void debug() {
	}
	
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	/*/
	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);
	//*/
	int N = 0;
	int[] A = null;
	HashMap<Integer,Integer> map = new HashMap<>();
	int ans=0;
	
	public void input() throws IOException {
		/*
		S = br.readLine();
		/*/
		N = in.nextInt();
		A = in.nextInt(new int[N]);
		//*/
	}
	

 
	public void solve() throws IOException {
		for(int a: A) {
			if(map.containsKey(a)){
				map.put(a, map.get(a)+1);
			}else{
				map.put(a, 1);
			}
		}
		for(int k: map.keySet()){
			int v = map.get(k);
			if(k < v){
				ans += (v-k);
			}else if(k > v){
				ans += v;
			}
		}
		
	}
	
	public void output() {
		out.println(ans);
		out.flush();
	}
}


 
//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }
 
	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}
 
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/

Measured memory_bytes: 30932
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    stack<char> st;
    rep(i, n) {
        if ( st.empty() || st.top() == ')' ) st.push(s[i]);
        else if ( st.top() == '(' ) {
            if ( s[i] == ')' ) {
                st.pop();
            }
            else {
                st.push(s[i]);
            }
        }
    }
    int left_cnt = 0;
    int right_cnt = 0;
    while(1) {
        if ( st.empty() ) break;
        if ( st.top() == '(' ) ++left_cnt;
        if ( st.top() == ')' ) ++right_cnt;
        st.pop();
    }
    string ans = s;
    rep(i, right_cnt) ans = '(' + ans;
    rep(i, left_cnt) ans += ')';
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import itertools as itr


input()
An = list(map(int, sys.stdin.readline().rstrip().split()))

n = max(An)
r = 0
for a in An:
  if a == n:
    continue

  if abs(2*a-n) < abs(2*r-n):
    r = a
print(n,r)  

Measured memory_bytes: 14348
import sys
import heapq
from collections import defaultdict

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N, K = na()

A_array = na()

cusum = 0
mod_array = [0]
for i, a in enumerate(A_array):
    cusum = (cusum + a) % K
    mod = (cusum + K - (i+1)) % K
    mod_array.append(mod)

# print(mod_array)

ans = 0
mod_queue = []
cnt_dic = defaultdict(int)
for i, v in enumerate(mod_array):
    heapq.heappush(mod_queue, (i, 1, v))

while(len(mod_queue)):
    i, q, v = heapq.heappop(mod_queue)
    if q == 1:
        ans += cnt_dic[v]
        cnt_dic[v] += 1
        if i + K <= N:
            heapq.heappush(mod_queue, (i+K-0.5, 2, v))
    else:
        cnt_dic[v] -= 1
    # print(i, v, q, ans)

print(ans)


Measured memory_bytes: 142176
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll r, d, x;
int main() {
	cin >> r >> d >> x;
	REP(i, 10) {
		cout << x * r - d << endl;
		x = x * r - d;
	}
}

Measured memory_bytes: 256
// Practice AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut tree = vec![vec![]; n + 1];
    for i in 0..n - 1 {
        let a = get!(usize);
        let b = get!(usize);
        tree[a].push(i);
        tree[b].push(i);
    }
    let col = tree
        .iter()
        .map(Vec::len)
        .max()
        .unwrap();
     
     let mut edges = vec![0; n - 1];
     
     for v in 1..n + 1 {
         let mut used = vec![false; col + 1];
         for &e in &tree[v] {
             used[edges[e]] = true;
         }
         let mut c = 1;
         for &e in &tree[v] {
             if edges[e] == 0 {
                 while used[c] {
                     c += 1;
                 }
                 edges[e] = c;
                 c += 1;
             }
         }
     }
     
     println!("{}", col);
     for e in edges {
         println!("{}", e);
     }
}

Measured memory_bytes: 14716
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
using namespace std;
typedef long long ll;
const ll LINF = 1e18;

const int K = 3; // a, b, c
ll dp[100001][K];
ll a[100001][K];

int main() {
    int N; cin >> N;
    REP(i, N) cin >> a[i][0] >> a[i][1] >> a[i][2];

    for(int i=0; i<N; i++) {
        REP(k1, K) { // i+1
            ll score = 0;
            REP(k2, K) { // i
                if (k1 != k2) {
                    chmax(score, dp[i][k2]+a[i][k2]);
                }
            }
            dp[i+1][k1] = score;
        }
    }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int n; char s[110];
	scanf("%d %s", &n, s);
	int x = 0, res = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'I') x++;
		if(s[i] == 'D') x--;
		res = max(res, x);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main() 
{
  ll a,b,x; cin>>a>>b>>x;
  ll n=b/x;
  ll m=0;
  if(a>0) m=(a-1)/x;
  else m=-1;
  cout<<n-m<<endl;
  return 0;
}


Measured memory_bytes: 3636
import Control.Applicative
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n B.getLine >>= mapM_ B.putStrLn

solve :: [ByteString] -> [ByteString]
solve ss = let imp = M.empty :: Map ByteString Int
               mp = foldl' (\m s -> M.insertWith (+) s 1 m) imp ss
           in sort $
              snd $
              M.foldlWithKey' (\(ct, ls) k v ->
                                             if ct < v then (v, [k])
                                             else if ct == v then (ct, k:ls)
                                                  else (ct, ls)) (0, []) mp


Measured memory_bytes: 74748
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.map!(to!int), a = rd[0], b = rd[1];
  if (a == b) writeln("a == b");
  else writeln(a > b ? "a > b" : "a < b");
}

Measured memory_bytes: 2440
#include <bits/stdc++.h>
using namespace std;
int main(){
    int arr[3];
    for(int i=0;i<3;i++){
        cin>>arr[i];
    }
    sort(arr,arr+3);
    printf("%d %d %d\n",arr[0],arr[1],arr[2]);
    return 0;
}


Measured memory_bytes: 3264
tiles = input()

even_0 = 0
even_1 = 0
odd_0 = 0
odd_1 = 0

for i, t in enumerate(tiles):
    if i % 2 == 0:
        if t == '0':
            even_0 += 1
        else:
            even_1 += 1
    else:
        if t == '0':
            odd_0 += 1
        else:
            odd_1 += 1

# print(even_0, even_1, odd_0, odd_1)

if even_0 + odd_1 >= even_1 + odd_0:
    print(even_1 + odd_0)
else:
    print(even_0 + odd_1)

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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

int main(){
	long long x, s = 100, cnt = 0;
	cin >> x;

	while(s < x){
		s *= 1.01;
		//cout << s << endl;
		cnt++;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3632
H,W = map(int,input().split())
A = [[s for s in input()] for i in range (H)]
sumh = 0
h = [False]*H
w = [False]*W
for i in range(H):
    for j in range(W):
         if A[i][j] == '#':
             h[i] = True
             w[j] = True

for i in range(H):
    if h[i] :
        for j in range(W):
            if w[j]  :
                print(A[i][j],end ='')

        print()






Measured memory_bytes: 4468
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{ 
    ll n;
    cin>>n;
    set<ll > s;
    ll i;
    for(i=0;i<n;i++){
        ll x;
        cin>>x;
        s.insert(x);
    }
    cout<<(((int)s.size()==n)?"YES\n":"NO\n");
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 12976
#include <stdio.h>

int main () {
int i,j;
char n[100000] = {0};
int  x[1001] = {0};

i = 0;
j = 0;


while(1) {
scanf("%c",&n[i]);
if(n[i] == '0' && n[i-1] == '\n'|| n[0] == '0') {break;}

if(n[i] >= '1' && '9' >= n[i] && n[i] != '\n') {
x[j] += n[i]-48;
}
  if(n[i] == '\n') {
j = j + 1;
}

i= i+1;

}

for(i=0; i < j;i++) {
printf("%d",x[i]);
printf("\n"); 

} 

return 0;

}

Measured memory_bytes: 648
//#pragma comment(linker, "/STACK:102400000,102400000") 手动扩栈
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <queue>
#include<string>
#include <set> //插入时相同的不插，边插边排序，里面还有multiset可以重复
#include <algorithm>
#define foc(i,x,y) for(int i = x ; i <= y ; i ++)
#define rea(i,x,y) for(int i = x ; i >= y ; i --)
#define scf(a) scanf("%d",&a)
#define sca(a,b) scanf("%d%d",&a,&b)
#define pri(a) printf("%d\n",a)
#define pri_(a) printf("%d ",a)
#define prn printf("\n")
#define mem(a) memset(a,0,sizeof(a))
#define LL long long
using namespace std;
const double eps = 1e-9;
const int maxn = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main()
{
    string s;
    cin >> s;
    if(s.length()==2)
    {
        cout << s << endl;
    }
    else
    {
        cout << s[2] << s[1] << s[0] << endl;
    }
    return 0;
}


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


int main() {
	int N, X;
	cin >> N >> X;
	vector<int> m(N);
	for (int i = 0; i < N; ++i) cin >> m.at(i);

	int Xsub = X - accumulate(m.begin(), m.end(), 0);
	int minm = *min_element(m.begin(), m.end());
	cout << N + Xsub / minm << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  if (b <= k)
    k -= b;
  else {
    cout << ans << endl;
    return 0;
  }

  if (c <= k) {
    k -= c;
    ans -= c;
  } else
    ans -= k;
  cout << ans << endl;
}


Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main() {
    string s,t,u;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    cin>>u;
    if(u==s){
        cout<<a-1<<" "<<b<<endl;
    }else cout<<a<<" "<<b-1<<endl;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var s = Console.ReadLine();
        if (s == "SAT")
            Console.WriteLine(1);
        else if (s == "FRI")
            Console.WriteLine(2);
        else if (s == "THU")
            Console.WriteLine(3);
        else if (s == "WED")
            Console.WriteLine(4);
        else if (s == "TUE")
            Console.WriteLine(5);
        else if (s == "MON")
            Console.WriteLine(6);
        else 
            Console.WriteLine(7);
        


        Console.Out.Flush();
    }
}




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


using namespace std;

template <typename T>
class arr {
  int n;
  T *a;
  void raise(int x) {
    T *b=a;
    a=new T[x];
    copy(b,b+n,a);
    delete b;
  }
  T& operator << (T x) {
    if ((n&-n)==n) {
      raise(n<<1);
    }
    a[n++]=x;
  }
  void resize(int x) {
    if (n<x) {
      raise(1<<(32-__builtin_clz(x)));
    }
    n=x;
  }
  arr() {
    n=0;
    a=NULL;
  }
  arr(int x) {
    n=0;
    a=NULL;
    resize(x);
  }
  T& operator << (int x) {
    return a[x];
  }
};

typedef pair <long long, int> pii;

const int N=1e5+5;
struct dijkstra {
  vector<int> ver[N];
  vector<int> val[N];

  void add(int u,int v,int w) {
    ver[u].push_back(v);
    val[u].push_back(w);
  }
  
  bool vis[N];
  long long dist[N];
 
  void solve(int s) {
    priority_queue <pii, vector <pii>, greater <pii> > que;
    memset(dist, 0x3f3f, sizeof(dist));
    memset(vis, 0, sizeof(vis));
    dist[s] = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
      int u = que.top().second;
      que.pop();
      if (vis[u]) {
        continue;
      }
      vis[u] = 1;
      for (int o = 0; o < (int) ver[u].size(); ++o) {
        int v = ver[u][o];
        if (val[u][o] + dist[u] < dist[v]) {
          dist[v] = val[u][o] + dist[u];
          que.push(make_pair(dist[v], v));
        }
      }
    }
  }
} ga,gb;

int main() {
  int n;
  int m;
  int s;
  int t;
  cin>>n>>m>>s>>t;
  for (int i=0;i<m;++i) {
    int u,v,a,b;
    cin>>u>>v>>a>>b;
    ga.add(u,v,a);
    ga.add(v,u,a);
    gb.add(u,v,b);
    gb.add(v,u,b);
  }
  ga.solve(s);
  gb.solve(t);
  long long f=1e15;
  long long cur=0;
  vector<long long> ans;
  for (int i=n;i>=1;--i) {
    cur=max(cur,f-ga.dist[i]-gb.dist[i]);
    ans.push_back(cur);
  }
  reverse(ans.begin(),ans.end());
  for (auto i:ans) {
    cout<<i<<endl;
  }

  return 0;
}


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

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
    for(int64_t i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

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

    // setwise
    int g = A[0];
    for (int i = 0; i < N; ++i) {
        g = gcd(g, A[i]);
    }

    if (g != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    // pairwise
    unordered_set<int> divisors;
    for (int i = 0; i < N; ++i) {
        auto primes = prime_factor(A[i]);
        for (const auto &[p, cnt] : primes) {
            if (divisors.count(p)) {
                cout << "setwise coprime" << endl;
                return 0;
            }
            divisors.insert(p);
        }
    }
    cout << "pairwise coprime" << endl;
    return 0;
}


Measured memory_bytes: 7216
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

template<class T, class Compare = greater<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = less<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

//===
// nCr mod p
// p is prime
// 1 <= k <= n <= 1e7

void init_comb(long long modulus);
void init_comb(void);
long long combination(long long n, long long k);
long long pow_mod(long long n, long long m);

long long _modulus = (long long)1e9 + 7;
long long fact[10000007];
long long fact_inv[10000007];

void init_comb(long long modulus) {_modulus = modulus; }
void init_comb(void) {
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    for (int i = 2; i <= 100005; i++) {
        fact[i] = fact[i - 1] * i % _modulus;
        fact_inv[i] = pow_mod(fact[i], _modulus - 2);
    }
}

long long combination(long long n, long long k) {
    static long long f;

    if (f != _modulus) f = _modulus, init_comb();

    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;

    return fact[n] * (fact_inv[k] * fact_inv[n - k] % _modulus) % _modulus;
}

long long pow_mod(long long n, long long m) {
    //n ** m;
    long long ret = 1;

    while (m) {
        if (m & 1) {
            ret = ret * n % _modulus;
        }

        n = n * n % _modulus;
        m = m >> 1;
    }

    return ret;
}
//===

llong n, k;
llong a[100005];
llong cnt[100005];
llong g;
const llong MOD = (llong)(1e9) + 7;

int main() {
    
    cin >> n;
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
        
        cnt[a[i]]++;
        if (cnt[a[i]] >= 2) {
            g = a[i];
        }
    }

    llong x = 0;
    for (int i = 0; i <= n; i++) {
        if (g == a[i]) break;
        x++;
    }
    for (int i = n; i >= 0; i--) {
        if (g == a[i]) break;
        x++;
    }

    for (int i = 1; i <= n + 1; i++) {
        llong ans = combination(n + 1, i) - combination(x, i - 1);
        if (ans < 0) ans += MOD;
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 9344