akhauriyash/Code-Regression huggingface dataset:
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    n = gets.chomp.to_i
    as = gets.split.map do |c|
      c.to_i - 1
    end
    bs = gets.split.map(&:to_i)
    cs = gets.split.map(&:to_i)

    last_a = 999
    ans = 0
    as.each do |a|
      ans += bs[a]
      if last_a + 1 == a
        ans += cs[last_a]
      end
      last_a = a
    end

    puts ans
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 4092
import itertools
import math

def dist(a,b,c,d):
    return math.sqrt((a-c)*(a-c)+(b-d)*(b-d))

N = int(input())
XY = [0]*N
for i in range(N):
    XY[i] = tuple(map(int,input().split()))

s = 0
for i in itertools.permutations(XY):
    for j in range(N-1):
        XY0 = i[j]
        XY1 = i[j+1]
        s += dist(XY0[0],XY0[1],XY1[0],XY1[1])

print(s / math.factorial(N))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 bool appear[3][3];
int main() {
  vector<vector<int>> A (3,vector<int>(3));
  for (int i=0;i<3;i++){
   for (int j=0;j<3;j++){
    cin >> A.at(i).at(j); 
   }
  }
  int N;
  cin >> N;
  
  vector<int> B(N);
  for (int i=0;i<N;i++){
   cin >> B.at(i);
  }

    for (int i=0;i<N;i++){
  for (int k=0;k<3;k++){
   for (int j=0;j<3;j++){
    if (A.at(k).at(j) == B.at(i)){
     A.at(k).at(j)=0; 
    }
   }
  }
  }


  if (A.at(0).at(0)+A.at(0).at(1)+A.at(0).at(2)==0 ||
     A.at(1).at(0)+A.at(1).at(1)+A.at(1).at(2)==0 ||
     A.at(2).at(0)+A.at(2).at(1)+A.at(2).at(2)==0 ||
     A.at(0).at(0)+A.at(1).at(0)+A.at(2).at(0)==0 ||
     A.at(0).at(1)+A.at(1).at(1)+A.at(2).at(1)==0 ||
     A.at(0).at(2)+A.at(1).at(2)+A.at(2).at(2)==0 ||
     A.at(0).at(0)+A.at(1).at(1)+A.at(2).at(2)==0 ||
     A.at(2).at(0)+A.at(1).at(1)+A.at(0).at(2)==0 ){
   cout << "Yes" << endl; 
  }
  else {
   cout << "No" << endl;  
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) for(auto (a): v )   cerr << a << endl
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

LL gcd(LL m, LL n) {

  if (m < n) {
    swap(m, n);
  }

  while (n != 0) {
    LL n_new = m % n;
    m = n;
    n = n_new;
  }

  return m;

}


void func() {
  LL N, M;
  cin >> N >> M;
  LD MD = M / (LD)N;
  LL a = 1;
  
  vector<LL> C;
  for (LL i = 1; i <= sqrt(M); i++) {
    if (M % i == 0) {
      C.push_back(i);
      C.push_back(M/i);
    }
  }
  //PRINTSP(C);

  LL a_max = 1;
  //for (LL i = 1; i <= MD; i++) {
  for(auto i : C){
    //cerr << i << endl;
    if (i <= (M / (LD)N)) {
      a_max = max(a_max, i);
    }
  }
  cout << a_max;

}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
 
 
void dfs(int &ans, int n, long long x, bool three, bool five, bool seven){
    if(x>n) return;
    if(three&&five&&seven) ans++;
    dfs(ans, n, 10*x + 3, true, five, seven);
    dfs(ans, n, 10*x + 5, three, true, seven);
    dfs(ans, n, 10*x + 7, three, five, true);
}
 
int main(){
    int n;
    cin >> n;
    int ans = 0;
    dfs(ans, n, 0, false, false, false);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next()); 
        String str = sc.next();
        String[] arr = new String[str.length()];
        arr = str.split("",0);
        List<Integer> arrx = new ArrayList<>();
        
        int count = 0;
        arrx.add(0);
        
        for(int i = 0; i < str.length();i++){
            
            if(arr[i].equals("I")){
                count = count +1; 
            }else{
                count = count -1;
            }
            arrx.add(count);
        }  
        
        int max = arrx.get(0);
	int v = 0;
        
        for( int i = 0 ; i < arrx.size() ; i++){
            v = arrx.get(i);
	if( v > max ){
		max = v;
		}
	}
        
        System.out.println(max);
    }
    
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());
        String[] params = in.nextLine().split(" ");

        double parent = 0;
        for( int i = 0 ; i < n ; i++ ){
            parent += 1 / Double.parseDouble(params[i]);
        }

        System.out.println( 1/parent );

    }

}


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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define endl "\n"
//cout << fixed << setprecision(2);


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<int> v(n);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i += 2){
        if(v[i] % 2 != 0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3628
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()
    val d = sc.nextLong()
    val e = sc.nextLong()
    println(problem123c(n, a, b, c, d, e))
}

fun problem123c(n: Long, a: Long, b: Long, c: Long, d: Long, e: Long): Long {
    return n / listOf(a, b, c, d, e).min()!! + (if (n % listOf(a, b, c, d, e).min()!! != 0L) 1 else 0) + 4
}

Measured memory_bytes: 35920
#include <iostream>
#include <unordered_map>

using namespace std;


int main() {
  int n;
  cin >> n;
  int sum = 0;
  unordered_map<int, bool> mp;

  for(int i=0;i<n;i++) {
    int d;
    cin >> d;
    if (!mp[d]) {
      sum+=1;
      mp[d] = true;
    }
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b) {
		printf("a < b\n");
	} else if (a > b) {
		printf("a > b\n");
	} else if (a == b) {
		printf("a == b\n");
	}
	return 0;
}

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

int main(){

int N,wa=0,seki=0;
  cin >> N;
  
  int a[N];
  for (int i=0;i<N;i++){
  	cin >> a[i];
  }
  for (int j=0;j<N;j++){
  	 for (int i=j;i<N-1;i++){
  		seki=a[j]*a[i+1];
       	wa += seki;
  	}
  }
  
  cout << wa << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 300010
#define LL long long
#define MOD 998244353
int fac[M], inv[M];
inline int C(int n, int m) {
	return 1ll * fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
int main() {
	int n, A, B;
	LL K;
	scanf("%d%d%d%lld", &n, &A, &B, &K);
	fac[0] = 1;
	for(int i = 1; i <= n; ++ i) fac[i] = 1ll * fac[i - 1] * i % MOD;
	inv[0] = inv[1] = 1;
	for(int i = 2; i <= n; ++ i) inv[i] = 1ll * inv[MOD % i] * (MOD - MOD / i) % MOD;
	for(int i = 2; i <= n; ++ i) inv[i] = 1ll * inv[i - 1] * inv[i] % MOD;
	int Ans = 0;
	for(int i = 0; i <= n; ++ i) {
		if(K - 1ll * A * i >= 0 && (K - 1ll * A * i) % B == 0 && (K - 1ll * A * i) / B <= n) {
			Ans += 1ll * C(n, i) * C(n, (K - 1ll * A * i) / B) % MOD;
			if(Ans >= MOD) Ans -= MOD;
		}
	}
	printf("%d\n", Ans);
}

Measured memory_bytes: 2560
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#define INF 1000000;

using namespace std;

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

    if(s[2]==s[3]&&s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
 
int main() {
  ll a;
  ci(a);
  ll d=a;
  ll b=0;
  for(i,0,10){
    b+=a%10;
    a=a/10;
    //co(b);
    if(a==0)
      break;
  }
  string c="No";
  if(d%b==0)
    c="Yes";
  co(c);
}

Measured memory_bytes: 256
import itertools
from sys import exit

N = int(input())
S = input()
if N < 3:
    print(0)
    exit()

d = {'R': 0, 'G': 1, 'B': 2}
rgb = {'R', 'G', 'B'}

table = [[0] * N for _ in range(3)]
for i, s in enumerate(S):
    table[d[s]][i] = 1

for x in range(3):
    table[x] = tuple(itertools.accumulate(table[x]))

ans = 0
for k in range(2, N):
    for j in range(1, k):
        if S[j] != S[k] :
            x = (rgb - {S[j], S[k]}).pop()
            ans += table[d[x]][j - 1]
            if 2 * j - k >= 0 and S[2 * j - k] == x:
                ans -= 1
print(ans)

Measured memory_bytes: 68968
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


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


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


def solve():
    N, K = map(int, input().split())
    P = list(sorted(list(map(int, input().split()))))

    ans = 0
    for i in range(K):
        ans += P[i]
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n';
int lim=1e6;
int inf=1e9+7;
vector<vector<int> > v;
ll solve(vector<vector<ll> > &dp,int d,int n,int prev){
	if(d>=n){
		return 0;
	}
	if(d==0){
		ll t1=solve(dp,d+1,n,0);
		ll t2=solve(dp,d+1,n,1);
		ll t3=solve(dp,d+1,n,2);
		t1+=v[d][0];
		t2+=v[d][1];t3+=v[d][2];
		ll ans=max(max(t1,t2),t3);
		dp[d][0]=ans;
		return ans;
	}
	else if(dp[d][prev]!=-1){
		return dp[d][prev];
	}else{
		vector<ll> v1;vector<ll> v2;
		for(int i=0;i<3;i++){
			if(i!=prev){
				v1.push_back(v[d][i]);
				v2.push_back(i);
			}
		}
		ll x1=solve(dp,d+1,n,v2[0]);
		ll x2=solve(dp,d+1,n,v2[1]);
		ll x3=0;
		if(v1.size()==3){
			x3=solve(dp,d+1,n,v2[2]);
		}
		ll ans=max((v1[0]+x1),(v1[1]+x2));
		if(v1.size()==3){
			ans=max(ans,v1[2]+x3);
		}
		//cout<<ans<<" "<<x1<<" "<<x2<<ln;
		dp[d][prev]=ans;
		return ans;
		}
}
int main()
{	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;cin>>n;
	v.resize(n);
	for(int i=0;i<n;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		v[i].push_back(a);v[i].push_back(b);v[i].push_back(c);
	}
	vector<vector<ll> > dp(n,vector<ll>(3,-1));
	cout<<solve(dp,0,n,-1)<<ln;
}

Measured memory_bytes: 33024
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> Ais;
    for (int i = 0; i < N; i++) {
        int Ai;
        cin >> Ai;
        Ais.push_back(Ai);
    }
    vector<int> maxs(N+1, numeric_limits<int>::min() / 2);
    int max_inc = numeric_limits<int>::min();
    for (int i = N-1; i >= 0; i--) {
        max_inc = max(max_inc, maxs[i+1] - Ais[i]);
        maxs[i] = max(maxs[i+1], Ais[i]);
    }
    int cnt = 0;
    int low_cnt = 0;
    int high_cnt = 0;
    int min_diff = 0;
    for (int i = 0; i < N; i++) {
        if (Ais[i] == maxs[i]) {
            high_cnt++;
        } else if (Ais[i] + max_inc == maxs[i]) {
            low_cnt++;
        }
        min_diff = min(min_diff, low_cnt - high_cnt);
        if (maxs[i+1] < maxs[i]) {
            cnt += min_diff + high_cnt;
            low_cnt = 0;
            high_cnt = 0;
            min_diff = 0;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1272
N, M, Q = [int(_) for _ in input().split()]
ABCD = [[int(_) for _ in input().split()] for i in range(Q)]

def gen(N, M, st=1):
    if N == 0:
        yield []
    else:
        for i in range(st, M + 1):
            for r in gen(N - 1, M, i):
                yield [i] + r

def calc(xs, abcd):
    return sum((xs[b - 1] - xs[a - 1] == c) * d for a, b, c, d in abcd)

result = 0

for x in gen(N, M):
    r = calc(x, ABCD)
    result = max(result, r)

print(result)


Measured memory_bytes: 9200
#include<stdio.h>

int main(void)
{
   int a, b, c, i, x=0;

   scanf("%d", &a);
   scanf("%d", &b);

   c = b - a;

   for(i=0;i<=c;i++)
      x += i;

   x = x - b;
   printf("%d\n", x);
   return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
maxn = -float("inf")
listy = []
for i in range(n):
    listy.append(list(map(int,input().split())))
for i in range(8):
    g = []
    for j in range(n):
        tmp=0
        for k in range(3):
            if(i&(1<<k)):
                tmp+=listy[j][k]
            else:
                tmp-=listy[j][k]
        g.append(tmp)
    g.sort(reverse=True)
    maxn = max(maxn,sum(g[:m]))
print(maxn)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int M = 1e5;
 
int n, m, mc, ans;
map<int, int> mcnt;
 
int taken[M];
map<int, int> uqt[M];
 
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (a % m) ++uqt[a % m][a];
        a %= m;
        if (!a) ++mc;
        else if (mcnt.find(m - a) != mcnt.end() && mcnt[m - a] > 0) {
            ++ans;
            --mcnt[m - a];
            ++taken[a], ++taken[m - a];
        } else ++mcnt[a];
    }
 
    rep(i, 1, m) {
        if (!sz(uqt[i])) continue;
        int buffer = 0, pairs = 0;
        for (auto j : uqt[i]) {
            if (j.second % 2) ++buffer;
            pairs += j.second / 2;
        }
        if (buffer >= taken[i]) ans += pairs;
        else {
            taken[i] -= buffer;
            pairs -= ceil(taken[i] / (double)2);
            ans += pairs;
        }
    }
 
 
    cout << ans + mc / 2;
}


Measured memory_bytes: 15720
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		int a = inint(), b = inint();
		out.println(a+b>=10 ? "error" : a+b);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 21844
from collections import deque
formula=input().split()
N=len(formula)

q=deque()
i=0

def calculation(operand):
    a=q.pop()
    b=q.pop()
    q.append(str(eval("".join([b,operand,a]))))

while i < N:
    char=formula[i]
    if char=="+" or char=="-" or char == "*":
        calculation(char)
    else:
        q.append(char)
    i += 1

print(q.pop())




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

const long long INF = 1e18;
const int N = 1e5;

const double PI = acos(-1);



int main() {
    string s[3] = {"Sunny", "Cloudy", "Rainy"};
    string t;
    cin >> t;
    cout << s[(find(s, s + 3, t) - s + 1) % 3];
}


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

using namespace std;
typedef long long ll;

#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forrn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define PYMOD(a, m) ((((a) % (m)) + (m)) % (m))
#define all(v) v.begin(), v.end()
#define mp make_pair
#define ff first
#define ss second

const int mod = 1e9 + 7;

int main() {
    // Code here:

    int n, k;
    cin >> n >> k;

    if (k == 0) {
        cout << 1ll * n * n << endl;
        return 0;
    }
    
    ll ans = 0;
    for (int b = k + 1; b <= n; b++) {
        for (int nga = b; nga < n + b; nga += b) {
            if (nga <= n) {
                ans += b - k;
                //cout << b << " " << nga << " " << b - k << endl;
            } else if (nga - b + k <= n) {
                ans += n - (nga - b + k) + 1;
                //cout << b << " " << nga << " " << n - (nga - b + k) + 1 << endl;
            }
        }
    }

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


Measured memory_bytes: 256
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
# sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


# endregion
class combination():
    def __init__(self, mod):
        '''
        modを指定して初期化
        '''
        self.mod = mod
        self.fac = [1, 1]  # 階乗テーブル
        self.ifac = [1, 1]  # 階乗の逆元テーブル
        self.inv = [0, 1]  # 逆元計算用

    def calc(self, n, k):
        '''
        nCk%modを計算する
        '''
        if k < 0 or n < k:
            return 0
        self.make_tables(n)  # テーブル作成
        k = min(k, n - k)
        return self.fac[n] * (self.ifac[k] * self.ifac[n - k] %
                              self.mod) % self.mod

    def make_tables(self, n):
        '''
        階乗テーブル・階乗の逆元テーブルを作成
        '''
        for i in range(len(self.fac), n + 1):
            self.fac.append((self.fac[-1] * i) % self.mod)
            self.inv.append(
                (-self.inv[self.mod % i] * (self.mod // i)) % self.mod)
            self.ifac.append((self.ifac[-1] * self.inv[-1]) % self.mod)


comb = combination(mod)
ans = 0
s = inp()
for i in range(s):  # i個の仕切り
    if s - 3 * (i + 1) < 0:
        break
    ans += comb.calc(s - 3 * (i + 1) + i, s - 3 * (i + 1))
    ans %= mod
print(ans)


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;
struct UnionFind {
  vector<pair<LL, LL>> memo;
  vector<LL> par;
  UnionFind(int n) {
    par = vector<LL>(n, -1);
  }
  LL root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  LL reversible_root(int x) {
    if (par[x] < 0) return x;
    return reversible_root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (par[x] < par[y]) swap(x, y);
      par[y] += par[x];
      par[x] = y;
    }
    return;
  }
  void reversible_unite(int x, int y) {
    x = reversible_root(x);
    y = reversible_root(y);
    if (x != y) {
      if (par[x] < par[y]) swap(x, y);
      memo.emplace_back(x, par[x]);
      memo.emplace_back(y, par[y]);
      par[y] += par[x];
      par[x] = y;
    }
    return;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  LL size(int x) {
    return -par[root(x)];
  }
  LL reversible_size(int x) {
    return -par[reversible_root(x)];
  }
  void revert_all() {
    for (int i = memo.size() - 1; i >= 0; --i) {
      par[memo[i].first] = memo[i].second;
    }
    memo.clear();
  }
  void revert(int i) {
    par[memo[i].first] = memo[i].second;
  }
};

class Solver2 {
 public:
  int n, m;
  UnionFind uf;
  vector<pair<pair<int, int>, pair<LL, int>>> edges;
  Solver2(LL n, LL m) : n(n),
                        m(m),
                        uf(n){};

  void solve() {
    //UFに頂点の重みを持たせる
    for (int i = 0; i < n; ++i) {
      int tmp;
      cin >> tmp;
      uf.par[i] = -tmp;
    }

    for (int i = 0; i < m; ++i) {
      int a, b, y;
      cin >> a >> b >> y;
      --a;
      --b;
      edges.push_back({{a, b}, {y, -1}});
    }
    sort(edges.begin(), edges.end(), [&](auto xx, auto yy) { return xx.second.first < yy.second.first; });

    //軽い辺から連結成分を繋いで、uniteしたらメモする
    for (int i = 0; i < m; ++i) {
      int a = edges[i].first.first;
      int b = edges[i].first.second;
      if (uf.reversible_root(a) != uf.reversible_root(b)) {
        edges[i].second.second = uf.memo.size();
        uf.reversible_unite(a, b);
      }
    }

    //条件に違反する辺を削除して、uniteを巻き戻す
    int ans = 0;
    for (int i = m - 1; i >= 0; --i) {
      if (uf.reversible_size(edges[i].first.first) < edges[i].second.first) {
        ans++;
        if (edges[i].second.second != -1) {
          uf.revert(edges[i].second.second);
          uf.revert(edges[i].second.second + 1);
        }
      }
    }
    cout << ans << endl;
  }
};  // namespace Problem
}  // namespace Problem

signed main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}


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

namespace ITP1
{
    class ITP1_6_B
    {
        static void Main(string[] args)
        {
            int n;
            List<string> cardSet = new List<string>();

            n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                cardSet.Add(Console.ReadLine());
            }

            for (int i = 1; i < 14; i++)
            {
                if (!(cardSet.Contains("S " + i)))
                {
                    Console.WriteLine("S " + i);
                }
            }
            for (int i = 1; i < 14; i++)
            {
                if (!(cardSet.Contains("H " + i)))
                {
                    Console.WriteLine("H " + i);
                }
            }
            for (int i = 1; i < 14; i++)
            {
                if (!(cardSet.Contains("C " + i)))
                {
                    Console.WriteLine("C " + i);
                }
            }
            for (int i = 1; i < 14; i++)
            {
                if (!(cardSet.Contains("D " + i)))
                {
                    Console.WriteLine("D " + i);
                }
            }
        }
    }
}


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

main(){
	int m,d,ans;
	
	cin>>m>>d;
	ans = 0;
	
	for(int i=4;i<=m;i++){
		for(int j=22;j<=d;j++){
			if(j%10 < 2)	continue;
			if((j/10) * (j%10) == i)
				ans++;
		}
	}
	cout<<ans<<endl;
} 

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

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    char C[6];
    rep(i, 6){
        cin >> C[i];
    }

    if(C[0] == C[5] && C[1] == C[4] && C[2] == C[3]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

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

int main()
{
	long double a,b,c;
//	long double qa,qb,qc;
	cin>>a>>b>>c;
	
	if(a+b+2.0*sqrt(a*b)<c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define ll long long
#define ss second
#define ff first
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define w(x) ll x; cin>>x; while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define fo(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define re(i, j) fo(i, 0, j, 1)
#define pi 3.1415926535897932384626433832795
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define lo lower_bound
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    #ifndef ONLINE_JUDGE  
    freopen("input.txt", "r", stdin);  
    freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int main()
{
    //cp();
    //w(x)
        de(a);
        de(b);
        cout<<(a*b)/gcd(a,b);
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  string S;
  cin >> S;

  vector<string> SS;

  SS.push_back("R");
  for (int ii=1; ii<S.size(); ++ii) {
    if (S[ii-1]=='L'&&S[ii]=='R')
      SS.push_back("");
    SS.back().push_back(S[ii]);
  }

  for (string s : SS) {
    unsigned numL = 0, numR = 0;
    for (char c : s) {
      if (c=='L')
	++numL;
      else
	++numR;
    }
    for (int n=0; n<numR-1; ++n)
      cout << 0 << ' ';
    cout << (numR+1)/2 + numL/2 << ' ';
    cout << numR/2 + (numL+1)/2 << ' ';
    for (int n=0; n<numL-1; ++n)
      cout << 0 << ' ';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3320
n = int(input())
tmp = list(map(int, input().split()))
V, W = {}, {}
for i in range(n):
    key = tmp[i]
    if i%2 == 0:
        if key not in V:
            V[key] = 0
        V[key] += 1
    else:  # if i%2 == 1
        if key not in W:
            W[key] = 0
        W[key] += 1
# 奇数列または偶数列に含まれる，要素keyの個数valが，
# 最も大きいものと２番めに大きいものの組[key, val]
V = sorted(V.items(), key=lambda x: -x[1])
W = sorted(W.items(), key=lambda x: -x[1])
if V[0][0] != W[0][0]:
    # (n/2 - V[0][1]) + (n/2 - W[0][1])
    print(n - V[0][1] - W[0][1])
# if V[0][0] == W[0][0]
elif len(V) == 1 and len(W) == 1:
    print(n//2)
else:
    print(min(n - V[1][1] - W[0][1], n - V[0][1] - W[1][1]))

Measured memory_bytes: 17652
a="-.,!? -abc-def-ghi-jkl-mno-pqrs-tuv-wxyz".split("-")
gets
while s=gets
puts s.gsub("0"," ").split.map{|i|b=i[0].to_i;a[b][(i.size-1)%a[b].size]}.join
end

Measured memory_bytes: 6116
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
signed main()
{
    fast;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int nn = s.size();
    for(int i=0;i<nn;i++)
    {
        int ans = s[i]+n;
        if(ans>90)
        {
            ans = ans-90;
            ans = 64+ans;
        }
        cout<<(char)(ans);
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk = new StringTokenizer(br.readLine());
        
        int dummyNum = Integer.parseInt(tk.nextToken());
        int dummyNum2 = Integer.parseInt(tk.nextToken());
        
        Calc calc = (numInput,num2Input) -> {return numInput * num2Input;};
        System.out.print(calc.calcArea(dummyNum,dummyNum2));
        
        Calc2 calc2 = (numInput,num2Input) -> {return 2*(numInput + num2Input);};
        System.out.println(" "+calc2.calcSquereLength(dummyNum,dummyNum2));
    }
}

interface Calc{
    int calcArea(int num1, int num2);
}
interface Calc2{
    int calcSquereLength(int num1, int num2);
}


Measured memory_bytes: 30380
#include<iostream>
 
int main(){
    int a,b,c,temp;
    std::cin>>a>>b>>c;
    if(a>b){
	temp=b;
	b=a;
	a=temp;
	}
    if(b>c){
	temp=c;
	c=b;
	b=temp;
    	    }
    if(a>b){
	temp=b;
	b=a;
	a=temp;
	}
    std::cout << a << " " << b << " " << c << std::endl;
    return 0;
    }

Measured memory_bytes: 1164
H, W = map(int, input().split())
li = []
for i in range(H):
	x = input()
	if "#" in x:
		li.append(x)

H = len(li)
W = len(li[0])

removelist = []
for i in range(W):
	for j in range(H):
		if li[j][i] == "#":
			break
	else:
		removelist.append(i)

for i in reversed(removelist):
	for j in range(H):
		li[j] = li[j][:i] + li[j][i+1:]

for i in range(H):
	print(li[i])


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

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
ll lcm(ll a, ll b){
    ll ret = (a * b)/gcd(a,b);
    return ret;
}

int main(){
    ll N;
    cin >> N;
    ll a; cin >> a;
    ll ans = a;
    rep(i, 0, N-1){
        cin >> a;
        ans = gcd(ans, a);
    }
    cout << ans << endl;
    return 0;
}

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

L = list(map(int,input().split()))

L.sort()

def bisect(L,num,l,r):
    while r-l>1:
        if L[(r+l)//2] < num:
            l = (r+l)//2
        else:
            r = (r+l)//2
    return l

ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        num = L[i]+L[j]
        if L[j+1]<num:
            if L[N-1]<num:
                ans+=N-1-j
            else:
                l = bisect(L,num,j+1,N-1)
                ans += l-j

print(ans)

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

int n, m, q;
vector<int> a, b, c, d;

void dfs(vector<int>& A, int& ans) {
	int tmp = 0;
	if (A.size() == n + 1) {
		for (int i = 0; i < q; i++) {
			if (A[b.at(i)] - A[a.at(i)] == c.at(i)) tmp += d.at(i);			
		}
		ans = max(ans, tmp);
		return;
	}
	for (int i = A.back(); i <= m; i++) {
		A.push_back(i);
		dfs(A, ans);
		A.pop_back();
	}
	return;
}

int main() {

	cin >> n >> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	for (int i = 0; i < q; i++) {	
		cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
	}
	int ans = 0;
	vector<int> A = { 1 };
	dfs(A, ans);
	cout << ans << endl;
	return 0;
}

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

int main() {
	int n;

	cin >> n ;

	set<int> s;
	
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		s.insert(num);
	}

	cout << s.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    ll ans=0;
    ll i=357;
    while(i<=n){
        bool tj=false,fj=false,sj=false,ej=false;
        ll copy=i;
        if(i%10==3||i%10==5){
            while(copy>0){
                if(copy%10==3){
                    tj=true;
                }
                else if(copy%10==5){
                    fj=true;
                }
                else if(copy%10==7){
                    sj=true;
                }
                else {
                    ej=true;
                    break;
                }
                copy/=10;
            }
            if(tj&&fj&&sj&&(!ej)) ans++;
            if(ej){
                i+=10;
                continue;
            }
            i+=2;
        }
        else if(i%10==7){
            while(copy>0){
                if(copy%10==3){
                    tj=true;
                }
                else if(copy%10==5){
                    fj=true;
                }
                else if(copy%10==7){
                    sj=true;
                }
                else {
                    ej=true;
                    break;
                }
                copy/=10;
            }
            if(tj&&fj&&sj&&(!ej)) ans++;
            i+=16;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void) {
    int x[5];
    for(int i = 1; i <= 5; i++) {
        scanf("%d", &x[i]);
    }

    for(int i = 1; i <= 5; i++) {
        if(x[i] == 0) {
            printf("%d\n", i);
        }
    }
    return 0;
}

Measured memory_bytes: 2152
#include <stdio.h>

int main(void)
{
	int h,w;
	int i,j;

	do{
		scanf("%d%d",&h,&w);
		if(h == 0	&&	w == 0)
		     break;
		
		for(i = 0;	h > i;	i++){
		      for(j = 0;	w > j;	j++)
		      	    printf("#");
		      puts("");
		}
		puts("");
	}while(1);
	
	return(0);
}

Measured memory_bytes: 1016
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

	cout << (1000 - n % 1000) % 1000 << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
    long long int n ,t ,time,sum=0;
    cin >> n >> t;
    while(t--)
    {
        cin >> time;
        sum=sum+time;
    }
    n=n-sum;
    if(n<0)
        n=-1;
    cout << n <<endl;
    return 0;
}


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

int main() {
  long long N, A, B;
  long long Q;
  long long result;
  cin >> N >> A >> B;

  Q = N / (A+B);
  N -= Q * (A+B);
  result = Q * A;

  if(N >= A){
    result += A;
  }else if(N > 0){
    result += N;
  }

  cout << result << endl;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<bitset>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std; 
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// ÉÏ ×ó ÏÂ ÓÒ
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
char a1,b1,c1,d1;
int a,b,c,d;
int main(){
	cin>>a1>>b1>>c1>>d1;
	a=a1-'0';
	b=b1-'0';
	c=c1-'0';
	d=d1-'0';
	for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
			{
				int sum=a;
				if(i)
					sum+=b;
				else 
					sum-=b;
				if(j) 
					sum+=c;
				else
					sum-=c;
				if(k)
					sum+=d;
				else
					sum-=d;
				if(sum==7)
				{
					cout<<a<<(i?'+':'-')<<b<<(j?'+':'-')<<c<<(k?'+':'-')<<d<<"=7";
					return 0; 
				}
			} 
	return 0;
}


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll K, A, B;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  cin >> K;
  cin >> A >> B;
  for (ll i=A ; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3568
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String line = br.readLine();
	    while(line!=null){
    	    int n = Integer.parseInt(line);
    	    int ans = 0;
    	    for(int i=0;i<=9;i++)
    	    for(int j=0;j<=9;j++)
    	    for(int k=0;k<=9;k++)
    	    for(int l=0;l<=9;l++)
    	    if(n==i+j+k+l)  ans++;
    	    
    		System.out.println(ans);
	        line = br.readLine();
	    }
	}
}

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

long int all_sum(long int S, long int keta, long int sum){
    if(S / keta == 0) return S + sum;

    long int wakeru, wakenai;
    wakeru  = all_sum(S / keta, 10       , sum + (S % keta));
    wakenai = all_sum(S       , keta * 10, sum             );

    return wakeru + wakenai;
}

int main() {
    long int S;
    cin >> S;

    long int answer;

    answer = all_sum(S, 10, 0);

    cout << answer << endl;
}


Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    int ans = a + b;
    if(ans < 10)
        cout << ans << endl;
    else
        cout << "error" << endl;

    return 0;
}


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

int main() {
    int K;
    string S;
    cin >> K;
    cin >> S;
    
    if((int)S.length()<=K) {
        cout << S << endl;
    }else{
        cout << S.substr(0,K) << "..." << endl;
    }
}

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

int main(){
  int n; cin >>n;
  vector<int> h(n);
  rep(i,n) cin >>h[i];
  int ans = 0, sum = 0;
  rep(i,n){
    if(sum<h[i]){
      ans += (h[i]-sum);
      sum = h[i];
    }
    else sum = h[i];
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <stdio.h>
#include <sstream>


using namespace std;
void swap(int &a, int &b);

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

	string sTaro, sHanako;
	int Tscore = 0, Hscore = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> sTaro;
		cin >> sHanako;

		if (sTaro > sHanako)
			Tscore += 3;
		else if (sHanako > sTaro)
			Hscore += 3;
		else
		{
			Tscore += 1;
			Hscore += 1;
		}

	}
	cout << Tscore << " " << Hscore << endl;

	return 0;
}





Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	char a[4];
	scanf("%s",&a);
	if(strlen(a)==2)
	{
		cout<<a;
	}
	else
	{
		cout<<a[2]<<a[1]<<a[0];
	}
	return 0;
}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc111

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

int main() {
    string n;
    cin >> n;
    for (int i = 0; i < n.length(); ++i) {
        if (n[i] == '1') n[i] = '9';
        else n[i] = '1';
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n, q; cin >> n;
  map <ll,ll> ser;
  ll ans = 0;
  vll a(n); rep(i, n) { cin >> a[i]; if(ser.count(a[i]))ser[a[i]]++; else ser[a[i]] = 1; ans += a[i];}
  cin >> q;
  vll b(q), c(q); rep(i, q) cin >> b[i] >> c[i];
  rep(i, q)
  {
    ser[c[i]] += ser[b[i]];
    ans += ser[b[i]] * c[i];
    ans -= ser[b[i]] * b[i];
    ser[b[i]] = 0;
    cout << ans << endl;
  }
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

Measured memory_bytes: 11260
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  // input
  int n;cin >> n;
  vector<int> a(n);
  vector<int> x(n);
  
  for(int i = 0;i < n; i++) {
        cin >> a[i];
  }

  x[0]= 1;
  

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

  
  // output  
  cout << ans << endl;
  
}

Measured memory_bytes: 4056
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  map<int, deque<int>> m;
  for (int i = 0; i < N; ++i) {
    int A, B;
    cin >> A >> B;
    m[A].push_back(B);
  }
  int ans = 0;
  priority_queue<int> que;
  for (int i = 1; i <= M; ++i) {
    if (m.find(i) != m.end())
      for (auto& v : m[i])
        que.push(v);
    if (que.empty())continue;
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
}


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

int main(){
    string s;
    while(getline(cin,s)){
        if(s == "0")    break;

        int sum = 0;
        int one = 0;

        stringstream ss(s);
        int c;
        while(ss >> c){
            if(c == 1)  one++;
            if(c > 10)  c = 10;
            sum += c;
        }

        if(sum > 21){
            sum = 0;
        }else if(one > 0){
            while(one > 0 && sum+10 <= 21){
                sum += 10;
                one--;
            }
        }

        cout << sum << endl;
    }
    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int K;
  cin>>K;
  for(int i(0);i<K;i++){
    cout << "ACL";
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
cout << fixed << setprecision(10);
int n;
cin>>n;
double a;
if(n%2==0){
a=0.5000000;
cout<<a<<endl;}
else{
a=(n+1)/2;
cout<<a/n<<endl;}}


Measured memory_bytes: 3756
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final long H = Long.parseLong(sc.next());
        out.println(ans(H));
        
        out.flush();
    }
    
    static long ans(long x) {
        if (x == 1) return 1;
        return 2 * ans(x / 2) + 1;
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

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

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

int cnt[200020];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    REP(i, 0, n - 1) {
        int a;
        cin, a;
        a--;
        cnt[a]++;
    }
    REP(i, 0, n) {
        cout << cnt[i] << endl;
    }
    return 0;
}


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

const ll MOD = 1000000007LL;

// DP[y][x] : 上からy番目の行で、左から x 番目の縦棒に、1からスタートしてたどり着く組み合わせの数
ll dp[102][9];

int main() {
  int H,W,K;
  cin >> H >> W >> K;
  ll f[10];
  f[0] = 1;
  f[1] = 2;
  for(int i=2;i<10;i++) f[i] = f[i-1] + f[i-2];

  dp[0][0] = 1;
  for(int y=1;y<H+1;++y)
    REP(x,W) {
      // まっすぐ
      dp[y][x] += (dp[y-1][x] * f[ max(x-1,0) ] * f[ max(W-x-2,0) ]) % MOD;
      // 左から
      if (x > 0)
        dp[y][x] += (dp[y-1][x-1] * f[ max(x-2,0) ] * f[ max(W-x-2,0) ]) % MOD;
      // 右から
      if (x < W-1)
        dp[y][x] += (dp[y-1][x+1] * f[ max(x-1,0) ] * f[ max(W-x-3,0) ]) % MOD;
    }
  cout << (dp[H][K-1] % MOD) << endl;
}


Measured memory_bytes: 256