akhauriyash/Code-Regression huggingface dataset:
#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>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  int x=0;
  ll ans=1;
  int temp=0;
  while(temp+1<n){
    if(x==0){
      if(a[temp+1]-a[temp]>0)x=1;
      else if(a[temp+1]-a[temp]<0)x=-1;
    }
    else if(x==1){
      if(a[temp+1]-a[temp]<0){
        ans++;
        x=0;
      }
    }
    else{
      if(a[temp+1]-a[temp]>0){
        ans++;
        x=0;
      }
    }
    temp++;
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 640
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007


class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n,m,x;
  cin >> n >> m >> x;
  ll a[n][m+1];
  for(int i=0;i<n;i++){
    for(int j=0;j<m+1;j++){
      cin >> a[i][j];
    }
  }
  ll ans = MOD;
  ll state[m];
  for(int i=0;i<(1<<n);i++){
    ll temp = 0;
    bool flag = true;
    for(int j=0;j<m;j++) state[j] = 0;
    for(int j=0;j<n;j++){
      if(i&(1<<j)){
        temp += a[j][0];
        for(int v=1;v<m+1;v++) state[v-1] += a[j][v];
      }
    }
    for(int j=0;j<m;j++){
      if(state[j] < x) flag = false;
    }
    if(flag) ans = min(ans,temp);
  }
  if(ans == MOD) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)

int N, K;

int Sum[200010];
map<int, int> counter;

int f(int a)
{
	a += K * (int)1e9;
	return a % K;
}

signed main()
{
	cin >> N >> K;

	int ans = 0;

	rep1(i, N) {
		cin >> Sum[i];
		Sum[i] %= K;
		Sum[i] += Sum[i-1];
		Sum[i] %= K;
	}

	rep(i, N+1) {
		if (i - K >= 0) counter[f(Sum[i - K] - (i - K))]--;
		ans += counter[f(Sum[i] - i)];
		counter[f(Sum[i] - i)]++;
	}

	cout << ans << endl;
}


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

int main() {
  int A,B;
  cin >> A>>B;

  if (A==1) {
    if(B==2){
      cout<<3<<endl;
    }
    else{
      cout<<2<<endl;
    }
  }
  else if(A==2){
    if(B==1){
      cout<<3<<endl;
    }
    else{
      cout<<1<<endl;
    }
  }
  else{
    if(B==1){
      cout<<2<<endl;
    }
    else{
      cout<<1<<endl;
    }
  }
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a,b,c=map(int,input().split())
s=input()
l=['']*k
for i in range(n):
  l[i%k]+=s[i]
ans=0
d={'s':a,'p':b,'r':c}
for i in range(k):
  x=l[i]
  now=x[0]
  memo=0
  for j in range(len(x)):
    if x[j]==now:
      memo+=1
    else:
      ans+=(max(1,(memo+1)//2))*d[now]
      now=x[j]
      memo=1
  ans+=(max(1,(memo+1)//2))*d[now]
print(ans)

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll k,n,h[100000];
ll dp[100000];
ll solve(ll num)
{
  ll i;
  if(num==n-1)
    return 0;
  if(num>n-1)
    return 1000000;
    if(dp[num]!=-1)
      return dp[num];
  ll ans=INT_MAX;
  for(i=1;i<=k;i++)
  {
    ans=min(abs(h[num+i]-h[num])+solve(num+i),ans);
  }
  return dp[num]=ans;
}
int main()
{
  ll i;
  for(i=0;i<100000;i++)
    dp[i]=-1;
  cin>>n>>k;
  for(i=0;i<n;i++)
    cin>>h[i];
solve(0);
cout<<dp[0];
  return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int x=n%10;
    if((x==2)||(x==4)||(x==5)||(x==7)||(x==9)){
        printf("hon\n");
    }else if((x==0)||(x==1)||(x==6)||(x==8)){
        printf("pon\n");
    }else{
        printf("bon\n");
    }
}

Measured memory_bytes: 1660
#!/usr/bin/env python3
import sys


def solve(T: str):
    return T.replace('?', 'D')

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    T = next(tokens)  # type: str
    print(solve(T))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

int main() {
	int w;
	while (cin >> w, w != -1) {
		int cost = 3130;
		if (w > 30)cost -= 1250 + 1400 + (w - 30) * 160;
		else if (w > 20)cost -= 1250 + (w - 20) * 140;
		else if (w > 10)cost -= (w - 10) * 125;
		cout << cost << endl;
	}
}

Measured memory_bytes: 3000
#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;
  int K;
  cin >> N >> K;
  int a[N];
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    sum += a[i];
  }

  vector<int> div;
  for(int i = 1; i * i <= sum; i++){
    if(sum % i == 0){
      div.push_back(i);
      div.push_back(sum / i);
    }
  }

  int ans = 1;
  for(int i = 0; i < div.size(); i++){
    int d = div[i];
    int r[N];
    for(int j = 0; j < N; j++){
      r[j] = a[j] % d;
    }

    sort(r, r + N);

    //累積和
    int sm1[N+1], sm2[N+1];
    fill(sm1, sm1 + N + 1, 0);
    fill(sm2, sm2 + N + 1, 0);
    for(int j = 0; j < N; j++){
      sm1[j+1] = sm1[j] + r[j];
      sm2[j+1] = sm2[j] + (d - r[j]);
    }

    /*cout << d << endl;
    for(int j = 0; j < N; j++) cout << r[j] << " ";
    cout << endl;
    for(int j = 0; j <= N; j++) cout << sm1[j] << " ";
    cout << endl;
    for(int j = 0; j <= N; j++) cout << sm2[j] << " ";
    cout << endl;*/


    for(int j = 0; j <= N; j++){
      if(sm1[j] - sm1[0] == sm2[N] - sm2[j]){
        if(sm1[j] - sm1[0] <= K){
          //cout << "hoge" << endl;
          ans = max(ans, d);
          break;
        }
      }
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef struct{
    int flag;
    int dist;
    int michi;
    vector<int> next;
}ROOM;

int main(){
    int N,M,A,B;
    queue<int> toVisit;
    cin >> N >> M;
    ROOM room[N];
    for(int i=0; i<M; i++){
        cin >> A >> B;
        A--;B--;
        room[A].next.push_back(B);
        room[B].next.push_back(A);
    }
    for(int i=0; i<N; i++){
        room[i].dist=1e9;
        room[i].flag=0;
        if(room[i].next.size()==0){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes\n";
    int now=0,s,minp,mind;
    room[0].flag=1;
    room[0].dist=0;
    room[0].michi=0;
    while(1){
        for(int i=0; i<room[now].next.size(); i++){
            s=room[now].next.at(i);
            if(room[now].dist+1<room[s].dist){
                room[s].dist=room[now].dist+1;
                room[s].michi=now;
                if(room[s].flag==0) toVisit.push(s);
            }
            
        }
        if(toVisit.size()==0) break;
        now=toVisit.front();
        toVisit.pop();
        room[now].flag=1;
    }
    for(int i=1; i<N; i++){
        cout << room[i].michi+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 11580
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{		
		int N = Int32.Parse(Console.ReadLine());
		int[] a = new int[N];
		string[] args = Console.ReadLine().Split(' ');
		for(int i = 0; i < N; i++)
			a[i] = Int32.Parse(args[i]);

		int ans = 0;
		int prev = -1;
		for(int i = 0; i < N; i++)
		{
			if((prev != -1) && (prev == a[i]))
			{
				ans++;
				prev = -1;
			}
			else
			{
				prev = a[i];
			}
		}

		Console.WriteLine(ans);
	}
}





Measured memory_bytes: 13140
use proconio::{input, fastout};
use std::collections::{BinaryHeap, HashSet};


#[fastout]
fn main() {
    input! {
        x: usize,
        y: usize,
        z: usize,
        k: usize,
        mut aa: [usize; x],
        mut bb: [usize; y],
        mut cc: [usize; z],
    }

    aa.sort();
    aa.reverse();
    bb.sort();
    bb.reverse();
    cc.sort();
    cc.reverse();

    let mut heap = BinaryHeap::new();

    heap.push((aa[0]+bb[0]+cc[0], 0, 0, 0));

    let mut set = HashSet::new();
    set.insert((0, 0, 0));

    for _ in 0..k {
        if let Some((p, a, b, c)) = heap.pop() {
            println!("{}", p);
            if a + 1 < x && !set.contains(&(a+1, b, c)) {
                heap.push((aa[a+1]+bb[b]+cc[c], a+1, b, c));
                set.insert((a+1, b, c));
            }
            if b + 1 < y && !set.contains(&(a, b+1, c)) {
                heap.push((aa[a]+bb[b+1]+cc[c], a, b+1, c));
                set.insert((a, b+1, c));
            }
            if c + 1 < z && !set.contains(&(a, b, c+1)) {
                heap.push((aa[a]+bb[b]+cc[c+1], a, b, c+1));
                set.insert((a, b, c+1));
            }

        }
    }
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,b=0,i=0,j,c=0,s=100000;
    string w;
    cin >> w;
    n=w.size();
    for(char c='a';c<='z';c++)
    {
       for(i=0;i<n;i++)
       {
            if(w[i]==c)
            {
                b++;
            } 
        }
        if(b%2!=0)
        {
            cout << "No" << endl;
            return 0;
        }
        b=0;
    }
    cout << "Yes" << endl;

    return 0;

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  vector<int> a=input(5);
  rep(i,5){
    if(a[i]==0){
      cout << i+1 << endl;
    }
  }
  
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <tuple>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)
#define STRING(str) #str
#define DEBUG 0
#if DEBUG
    #define dump(var) dump2(STRING(var), var)
#else
    #define dump(var)
#endif

template <typename T>
void dump2(const string& name, const T& value)
{
    cerr << name << ": " << value << endl;
}
void dump2(const string& name, const tuple<ll,ll,ll>& value)
{
    ll a,b,c;
    tie(a,b,c) = value;
    cerr << name << ": (" << a << ", " << b << ", " << c << ")" << endl;
}

void solve()
{
    ll ans = 0;
    ll A,B;
    cin >> A >> B;
    if (A == 2 || B == 2) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

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


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Run(Console.In);
        }

        private static void Run(TextReader textReader)
        {
            long memberCount;// 参加人数
            long initPoint;　// 初期ポイント
            long responseCount;　// 回答数
            {
                var items = textReader.ReadLine().Split(' ');
                memberCount = long.Parse(items[0]);
                initPoint = long.Parse(items[1]);
                responseCount = long.Parse(items[2]);
            }

            var array = new long[memberCount];

            for (long loopCount = responseCount - 1; loopCount >= 0; loopCount--)
            {
                var targetIndex = long.Parse(textReader.ReadLine()) - 1;
                array[targetIndex]++;
            }

            foreach (var v in array)
            {
                if ((initPoint - responseCount + v) <= 0)
                {
                    Console.Out.WriteLine("No");
                }
                else
                {
                    Console.Out.WriteLine("Yes");
                }
            }
        }
    }
}


Measured memory_bytes: 16092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		int[] divisorArr = new int[n+1];
		
		for(int i = 2; i <= n; i++) {
			for(int j = 1; j*i <= n; j++) {
				divisorArr[j*i]++;
			}
		}
		
		
		long ans = 0;
		for(int i = 1; i <= n; i++) {
			ans += (long)i * (divisorArr[i]+1);
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 72612
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int H,A; cin>>H>>A;

  int ans = (H+A-1)/A;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(4100000)

N,M = map(int,input().split(' '))

already_reach = [-1]*(N+1)
already_reach_1st = [-1]*(N+1)
already_reach_2nd = [-1]*(N+1)
graph = [[] for _ in range(N+1)]
for _ in range(M):
    u,v = map(int,input().split(' '))
    graph[u].append(v)
S,T = map(int,input().split(' '))

next_list = []
def search(S_list,current_count=0):
    next_list = []
    for s in S_list:
        for i1 in graph[s]:
            #print(already_reach_1st)
            if already_reach_1st[i1] != -1:
                continue
            already_reach_1st[i1] = 0
            for i2 in graph[i1]:
                #print(already_reach_2nd)
                if already_reach_2nd[i2] != -1:
                    continue
                already_reach_2nd[i2] = 0
                for i3 in graph[i2]:
                    if already_reach[i3] == -1: #はじめての到達
                        already_reach[i3] = current_count+1
                        next_list.append(i3)
    if len(next_list) > 0:
        search(next_list,current_count+1)
search([S])
print(already_reach[T])

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

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

    int ans = 0;
    int m = 0;
    for(char c : s){
        if(c == 'I') m++;
        else m--;
        ans = max(ans,m);
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

int main(){
    double r;
    cin >> r;
    printf("%.5f ", M_PI*r*r);
    printf("%.5f\n", 2*M_PI*r);
    return 0;
}

Measured memory_bytes: 3204
#include<stdio.h>
#include<math.h>
int main(){

double x1,y1,x2,y2;
double a;
double x,y;

scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

x=fabs(x2-x1);
y=fabs(y2-y1);

a=sqrt(x*x+y*y);

printf("%f\n",a);

return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {
    lli N, K;
    cin >> N >> K;

    lli counter = 1;
    lli num = K;
    do {
        if (N < num) {
            cout << counter << endl;
            return 0;
        }

        ++counter;
        num = num * K;

    }while (true);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace aoj{
	class program{
	
	static void Main() {
	
	int len = int.Parse(Console.ReadLine());
	char[] sep = new char[] {' '};
	string[] tmp=Console.ReadLine().Split(sep,
	StringSplitOptions.RemoveEmptyEntries);
	sort s = new sort(len, tmp);
	s.showlist();
	for(int i=1;i<len;i++){
		s.insert(i);
		s.showlist();
	}
	}
}

class sort{
	List<int> list = new List<int>();
	public sort(int len, string[] tmp){
	for(int i=0;i<len;i++)
	list.Add(int.Parse(tmp[i]));
	}
	public void showlist(){
	string str="";
	foreach(int n in list)
	str+=String.Format("{0} ",n);
	Console.WriteLine(str.Trim());
	}
	public void insert(int index){
		for(int i=index;i>0;i--){
			if(list[i]<list[i-1])
				swap(i,i-1);
		}
	}
	void swap(int i,int j){
		int tmp=list[i];
		list[i]=list[j];
		list[j]=tmp;
	}
}
}

Measured memory_bytes: 6320
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	vector<vector<ll>> M(n,vector<ll>(n));
	rep(i,n)
	rep(j,n)
	{
		cin>>M[i][j];
	}
	vector<vector<bool>> aaa(n,vector<bool>(n));
	
	
	rep(i,n)
	rep(j,n)
	{
		aaa[i][j]=true;
	}

	ll ans=0;
	rep(k,n)
	rep(i,n)
	rep(j,n)
	if(M[i][j]>M[i][k]+M[k][j])
	{
		cout<<-1<<endl;
		return 0;
	}
	else if(M[i][j]==M[i][k]+M[k][j]&&i!=j&&k!=j&&k!=i)
	{//i=0,j=2,k=1
		//cout<<i<<":"<<j<<endl;
		aaa[i][j]=false;
	}


	rep(i,n)
		rep(j,n)
		{
			//cout<<aaa[i][j];
			if(i>j&&aaa[i][j])ans+=M[i][j];
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
def printF(field,w,h):
    for i in range(h):
        print(field[i])

def getp(f,p,y,x,h,w,v):
    if y<0 or x<0 or x>=w:
        return 0
    if y>=h:
        if v==True:
            return 1
        return 0

    
    k = f[y][x]
    r = 0
    if k==0:
        if p[y][x]>=0:
            return p[y][x]

        r = getp(f,p,y+1,x-1,h,w,False)+getp(f,p,y+1,x,h,w,True)+getp(f,p,y+1,x+1,h,w,False)
        p[y][x] = r
    elif k==1:
        r = 0
    elif k==2:
        if v == True:
            if p[y][x]>=0:
                return p[y][x]
            r = getp(f,p,y+2,x,h,w,True)
            p[y][x] = r
        else:
            r = 0

    #print("gp({},{},{}):({},{})".format(x,y,v,k,r))
    return r

w,h = map(int,input().split())
while w!=0 and h != 0:
    field = []

    for i in range(h):
        field.append(list(map(int,input().split())))
        

    #initialize
    p = []
    for i in range(h):
        p.append([-1]*w)

    #calc

    print(sum(map(lambda x:getp(field,p,0,x,h,w,True), range(w))))

    w,h = map(int,input().split())


Measured memory_bytes: 5616
n = int(input())
A = list(map(int,input().split()))

parent = [(0,-1)]
now = 0
for i,a in enumerate(A):
    if now < a:
        parent.append((a,i))
        now = a
A.sort()
ans = [0]*n
cnt = 0
p = parent[-1][1]
for a in A[::-1]:
    if parent[-1][0] >= a:
        p = parent[-1][1]
        ans[p] += cnt*(parent[-1][0] - parent[-2][0])
        parent.pop()
    if parent[-1][0] < a:
        cnt += 1
        ans[p] += a - parent[-1][0]
print('\n'.join(str(i) for i in ans))


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

// n： 演算回数
// c: 答えをひとつだけ出すためのカウンタ
void find_seven(vector<int> &vec, string calc, int Sum, int n, int &c) {

    // 停止条件
    if (n == 4) {
        if (Sum == 7 && c == 0) {
            c++;
            cout << calc + "=7" << endl;
            return;
        }
        return;
    }

    // 処理
    int Sum_pl, Sum_mi;
    Sum_pl = Sum + vec.at(n);
    Sum_mi = Sum - vec.at(n);

    // 再帰
    find_seven(vec, calc + '+' + to_string(vec.at(n)), Sum_pl, n + 1, c);
    find_seven(vec, calc + '-' + to_string(vec.at(n)), Sum_mi, n + 1, c);
}


void show_calc(vector<int> &vec, int &c) {

    // 結果をここに埋め込む
    vector<string> calc(0);

    find_seven(vec, to_string(vec.at(0)), vec.at(0), 1, c);
}

int main() {

    string S;
    cin >> S;

    // 格納
    vector<int> vec(4);
    for (int i = 0; i < 4; i++) {
        char s = S.at(i);
        vec.at(i) = int(s) - 48; //数字は48から始まるらしい..
    }

    int c = 0;

    show_calc(vec, c);
}


Measured memory_bytes: 3692
A,B,C = list(map(int,input().split()))
if A==B==C:
    if A%2 == 0:
        print(-1)
    else:
        print(0)
else:
    count = 0
    while not A%2 and not B%2 and not C%2:
        if (B+C)%2 or (A+C)%2 or (A+B)%2:
            break
        A,B,C = (B+C)//2,(A+C)//2,(A+B)//2
        count += 1
    print(count)

Measured memory_bytes: 3064
n,y = map(int,input().split())
for a in range(y//10000+1):
    for b in range((y-10000*a)//5000+1):
        c = n-a-b
        if c >=0 and 10000*a + 5000*b + 1000*c == y:
            print(a,b,c)
            exit()
print(-1,-1,-1)

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

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];

	while ( scanf("%s",s) != EOF ) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a*b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}


Measured memory_bytes: 2744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  if (n % 2 == 0) cout << 1.0 / 2 << endl;
  else cout << (n / 2 + 1) * 1.0 / n << endl;
}


Measured memory_bytes: 3800
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a, b, c, d = il()
    print(max(a * b, c * d))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10164
#include<stdio.h>
#include<string.h>
int main()
{
    int i;
    char ch[1000],fh[1000],gh[1000];
    scanf("%s",ch);
    scanf("%s",fh);
    scanf("%s",gh);
    int l=0,k=0,m=0;
    l=strlen(ch);
    k=strlen(fh);
    m=strlen(gh);

    char a,b,c,d;
    a=ch[l-1];

    b=fh[0];
    c=fh[k-1];
    d=gh[0];
    if(a==b&&c==d)
    {
    printf("YES\n");

    }
     else
     {
     printf("NO\n");
    }



}




Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  string t="";
  for(int i=0;i<s.length();i+=2)
  {
    t+=s[i];
  }
cout<<t<<endl;
  return 0;

}


Measured memory_bytes: 592
s = input()
a_cnt = s.count('a')
b_cnt = s.count('b')
c_cnt = s.count('c')
if max(a_cnt, b_cnt, c_cnt) <= min(a_cnt, b_cnt, c_cnt) + 1:
    ans = 'YES'
else:
    ans = 'NO'
print(ans)

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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineInt();
            var a = ReadLineInt();
            Console.WriteLine((n*n)-a);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    while(K--) {
        int d;
        cin >> d;
        while(d--) {
            int A;
            cin >> A;
            v[--A]++;
        }
    }

    int ans = 0;
    for(auto e: v) {
        if(!e) ++ans;
    }

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


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n, m; cin >> n >> m;

    using P = pair<int, int>;
    vector<P> student(n);
    for(int i = 0; i < n; i++)
    {
        int a, b; cin >> a >> b;
        student[i] = make_pair(a, b);
    }
    vector<P> check_point(m);
    for(int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;
        check_point[i] = make_pair(a, b);
    }

    for(int i = 0; i < n; i++)
    {
        int ans = INF;
        int idx = -1;
        for(int j = 0; j < m; j++)
        {
            int d = abs(student[i].first - check_point[j].first) + abs(student[i].second - check_point[j].second);
            if(ans > d)
            {
                ans = d;
                idx = j + 1;
            }
        }
        cout << idx << endl;
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 100010
#define ll long long
using namespace std;

ll p1[maxn],p2[maxn],ans,prime[maxn],check[maxn],tot,n;

map <ll,ll> s,sqr;
map <ll,bool> vis;

void init(){
    for(int i=2;i<=100000;i++){
        if(!check[i]) prime[++tot]=i,sqr[1ll*i*i]=i;
        for(int j=1;j<=tot&&prime[j]*i<=100000;j++){
            check[prime[j]*i]=1;
            if(i%prime[j]==0) break;
        }
    }
}

int main(){
    init();
    scanf("%lld",&n);
    for(ll cnt=1;cnt<=n;cnt++){
        ll x,a=1,b=1;
        scanf("%lld",&x);
        for(int i=1;i<=tot;i++){
            int sum=0;
            if(1ll*prime[i]*prime[i]*prime[i]>x) break;
            if(x%prime[i]!=0) continue;
            while(x%prime[i]==0) x/=prime[i],sum++;
            sum%=3;
            if(sum==0) continue;
            for(int j=0;j<sum;j++) a*=prime[i];
            for(int j=sum;j<3;j++) b*=prime[i];
        }
        ll tmp=sqr[x];
        if(tmp*tmp==x) a*=x,b*=tmp;
        else a*=x,b*=x*x;
        p1[cnt]=a;p2[cnt]=b;
        s[a]++;
    }
    for(int i=1;i<=n;i++){
        ll x;
        if(vis[p1[i]]||vis[p2[i]]) continue;
        if(s[p1[i]]>s[p2[i]]) x=p1[i];
        else x=p2[i];
        vis[p1[i]]=vis[p2[i]]=true;
        if(x==1) ans++;
        else ans+=s[x];
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 34304
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    string s;
    cin >> s;
    
    
    int l=s.length();
    int abc[26]={};
    for(int i=0; i<l; i++){
        abc[s[i]-'a']++;
    }
    
    if(l<=25){
        cout<<s;
        for(int i=0; i<26; i++){
            if(abc[i]==0){
                cout<<(char)('a'+i)<<endl;
                return 0;
            }
        }
        return 0;
    }
    
    else if(l==26){
        if(s=="zyxwvutsrqponmlkjihgfedcba"){
            cout<<-1<<endl;
            return 0;
        }
        
        
        
        for(int right=l-2; right>=0; right--){
            
            char c='z'+1;
            for(int last=right+1; last<l; last++){
                if(s[last]>s[right]){
                    c=min(c,s[last]);
                }
            }
            
            if(c=='z'+1){
                continue;
            }
            
            
            for(int i=0; i<right; i++){
                cout<<s[i];
            }
            cout<<(char)c<<endl;
            return 0;
            
        }
    }
    

    return 0;
}


Measured memory_bytes: 256
num = int(input())
point= [0,0]
while(num > 0):
    x = input()
    t,h = x.split(" ")
    if(t > h):
        point[0] += 3
    elif(t == h):
        point[0] += 1
        point[1] += 1
    else:
        point[1] +=3
    
    num -= 1
print("{} {}".format(point[0],point[1]))    
    



Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    ll N, K, cnt = 1;
    string S;
    cin >> N >> K;
    cin >> S;

    vector <int> num;
    
    if (S[0] == '0') num.push_back(0);
    for (int i = 1; i < N; i++) {
        if (S[i-1] == S[i]) cnt++;
        else {
            if(S[i] == '0') {
                num.push_back(cnt);
                cnt = 1;
            }
            else {
                num.push_back(cnt);
                cnt = 1;
            }
        }
    }
    if (cnt != 0) num.push_back(cnt);
    if (S[N-1] == '0') num.push_back(0);

    vector <int> sum(num.size()+1, 0);
    for (int i = 0; i < num.size(); i++) {
        sum[i+1] = sum[i] + num[i];
    }
    int ans = 0;
    int add = 2*K + 1;

    for (int i = 0; i < num.size(); i+=2) {
        int left = i;
        int right = min(i+add, int(num.size()));
        ans = max(ans, sum[right] - sum[left]);
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 1272
#include<iostream>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[n];
  int i,j,s;
  s=0;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }

  for(i=0;i<n;i++)
  {
    for(j=i+1;j<n;j++)
    {
      s=s+(a[i]*a[j]);
                  }
                }
  cout<<s;
  return 0;
}



Measured memory_bytes: 764
#include<iostream>
using namespace std;
using uint = unsigned int;

int main() {
	uint N;
	cin >> N;
	
	string S;
	cin >> S;
	
	if(N % 2 == 1) {
		cout << "No";
	} else {
		if(S.substr(0, N/2) == S.substr(N/2)) {
			cout << "Yes";
		} else {
			cout << "No";
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;
 
int main()
{
    IOS();
   
    ld a,b,h,x,y;
    cin>>a>>h>>x;
    if(x<=(a*a*h)/2)
    {
        y=(2*x)/(a*h);
        cout<<fixed<<setprecision(10)<<atan(h/y)*180/3.14159265<<'\n';
    }
    else
    {
        y=(2*x-a*a*h)/(a*a);
        cout<<fixed<<setprecision(10)<<atan((h-y)/a)*180/3.14159265<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;


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

    int n,k; cin >> n >> k;
    std::vector<int> h(n); rep (i,n) cin >> h[i];

    sort(h.begin(), h.end(), std::less<int>());

    ll ans = 0;

    rep(i,n-k){
        ans += h[i];
    }

    cout << ans << endl;


    return 0;
}

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

int main(){
    int S, W;
    cin >> S >> W;
    if(S > W) cout << "safe" <<endl;
    else if(W >= S) cout << "unsafe" << endl;
    return 0;
}

Measured memory_bytes: 3640
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Crossing
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = 500;

/* typedef */

/* global variables */

int es[MAX_M][MAX_M], ens[MAX_M];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int m = 2;
  for (; m * (m - 1) < n * 2; m++);

  if (m * (m - 1) != n * 2)
    puts("No");
  else {
    for (int i = 0, k = 0; i < m; i++)
      for (int j = i + 1; j < m; j++, k++) {
	es[i][ens[i]++] = k;
	es[j][ens[j]++] = k;
      }

    printf("Yes\n%d\n", m);
    for (int i = 0; i < m; i++) {
      printf("%d", ens[i]);
      for (int j = 0; j < ens[i]; j++) printf(" %d", es[i][j] + 1);
      putchar('\n');
    }
  }
  
  return 0;
}


Measured memory_bytes: 2304
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        for(int i=str.length()-1;i>=0;i--){
            System.out.print(c[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 25860
#coding:utf-8
n = int(input())
a = list(map(int, input().split()))

avg = sum(a) / n
ans = 0
diff = abs(avg - a[0])

for i in range(n):
  if abs(avg - a[i]) < diff:
    ans = i
    diff = abs(avg - a[i])
    
print(ans)
  

Measured memory_bytes: 3060
/*
	*	Created By: 'Present_Sir'
	*	Created On: Saturday 22 August 2020 08:07:43 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define int long long
using namespace std;


void solve(){
    int h,w;
    cin>>h>>w;

    vector < int > r(h,0),c(w,0);
    map < pair < int, int >, int > mp;
    int q;
    cin>>q;
    int rm=0,cm=0;
    int ri=0,ci=0;
    for(int i=0; i<q; ++i){
        int x,y;
        cin>>x>>y;
        --x,--y;
        mp[{x,y}]++;
        r[x]++;
        c[y]++;
        if(r[x] > rm){
            ri = x;
            rm = r[x];
        }
        if(c[y] > cm){
            ci = y;
            cm = c[y];
        }
    }
    vector < int > rmajor,cmajor;
    for(int i=0; i<h; ++i){
        if(r[i] == rm){
            rmajor.push_back(i);
        }
    }
    for(int i=0; i<w; ++i){
        if(c[i] == cm){
            cmajor.push_back(i);
        }
    }
    int ans = rm+cm;
    if(mp.count({ri,ci})){
        for(int i=0; i<(int)rmajor.size(); ++i){
            for(int j=0; j<(int)cmajor.size(); ++j){
                if(!mp.count({rmajor[i],cmajor[j]})){
                    cout<<ans<<endl;
                    return;
                }
            }
        }
        --ans;
    }
    cout<<ans<<endl;
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 34980
a = int(input())
b = int(input())
c = int(input())
g = int(input())
tmp = []
for x in range(a+1):
    for y in range(b+1):
        for z in range(c+1):
            tmp.append(500*x + 100*y + 50*z)
ans = tmp.count(g)
print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
long long n, k;
struct abset {
    long long a;
    long long b;
};
bool cmp (const abset &l, const abset &r) {
    return l.a < r.a;
}

int main() {
    cin >> n >> k;
    vector<abset> all;
    long long x, y;
    abset data;
    for(long long i = 0; i < n; ++i) {
        cin >> x >> y;
        data.a = x;
        data.b = y;
        all.push_back(data);
    }

    sort(all.begin(), all.end(), cmp);

    long long ansno = 0;
    
    for(long long i = 0; ; ++i) {
        if(k > all.at(i).b) {
            k -= all.at(i).b;
        }else {
            ansno = all.at(i).a;
            break;
        }
    }

    cout << ansno << endl;


}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int ans=4e18;
string str;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> str;
	rep(sz(str)-2) ans=min(ans,abs(753ll-(100*(str[i]-'0')+10*(str[i+1]-'0')+(str[i+2]-'0'))));
	print1(ans);
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, X = map(int, input().split())
Ls = list(map(int, input().split()))

pos = 0
ans = 0

if pos <= X:
    ans += 1

for l in Ls:
    pos += l
    if pos <= X:
        ans += 1

print(ans)    



Measured memory_bytes: 7880