akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int value = sc.nextInt();
	
		System.out.println(value*value*3);



	}
	
	static boolean isvail(long num,int n,int[] a,int[] food,long k){
		long sum = 0;
		for(int i = 0;i < n;i++){
			long dif = num/food[i];
			sum += Math.max(0, a[i]-dif);
		}
		return sum <= k;
	}


	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 21844
while True:
    h,w=map(int,input().split())
    if h == 0 and w == 0:break
    for x in range(h):
        for y in range(w):
            if x == 0 or y == 0 or x == h-1 or y == w-1:
                print("#",end="")
            else:
                print(".", end="")
        print()
    print()
        


Measured memory_bytes: 7008
#include<iostream>
#define mod 998244353

using namespace std;

long long dp[3005][3005];

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[a][b]=1;
    for(int i=a; i<=c;++i){
        for(int j=b; j<=d;++j){
            if(i!=a||j!=b){
                dp[i][j]=dp[i-1][j]*j%mod;
                dp[i][j]+=(dp[i][j-1]*i)%mod;
                dp[i][j]-=(dp[i-1][j-1])*(i-1)*(j-1)%mod;
              	dp[i][j]=(dp[i][j]+mod)%mod;
            }
        }
    }
    cout<<dp[c][d]<<endl;
    return 0;
}

Measured memory_bytes: 73996
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

signed main() {
	int a,b;
	cin >> a >> b;
	int now=1;
	int ans=0;
	while(now<b){
		now--;
		now+=a;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

a, b, c = na()

print(max(a * 10 + b + c, b * 10 + a + c, c * 10 + a + b))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
class mint{
    public:
        long long x;
 
    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};
vector<mint> matmul(vector<mint> &dp,vector<vector<mint>> &mt){
    int m=dp.size();
    vector<mint> ret(m);
    REP(i,m){
        REP(j,m){
            ret[i]+=mt[i][j]*dp[j];
        }
    }
    return ret;
}
vector<vector<mint>> update(vector<vector<mint>> &mt){
    int m=mt.size();
    vector<vector<mint>> ret(m,vector<mint>(m));
    REP(i,m){
        REP(j,m){
            REP(l,m){
                ret[i][j]+=mt[i][l]*mt[l][j];
            }
        }
    }
    return ret;
}
void matpow(vector<mint> &dp,vector<vector<mint>> &mt,ll k){
    while(k){
        if(k&1){
            dp=matmul(dp,mt);
        }
        mt=update(mt);
        k/=2;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin >> n >> k;
    vector<vector<mint>> a(n,vector<mint>(n));
    vector<mint> dp(n,1);
    REP(i,n){
        REP(j,n){
            int p;cin >> p;
            a[i][j]=p;
        }
    }
    matpow(dp,a,k);
    mint ans=0;
    REP(i,n){
        ans+=dp[i];
    }
    cout << ans << endl;
}

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

vector<unsigned long long> next_p_mod(unsigned N, long long mod) { //next_permutation
  vector<unsigned long long> Next_p(N);
  unsigned long long Next_p_buff = 1;
  for (int i = 0; i < N; i++)
  {
    Next_p_buff *= (i + 1) % mod;
    Next_p.at(i) = Next_p_buff % mod;
  }
  return Next_p;
}
unsigned long long modpow(unsigned long long a, unsigned long long n, unsigned long long mod) {
   unsigned long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void comb(vector<vector <long long int> > &v,unsigned long long mod) {
  //vector<入れたい型> v(配列の個数(x),vector<入れたい型> (配列の個数,初期値));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int k = 1; k < v.size(); k++) {
    for (int j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%mod;
    }
  }
}
// a^{-1} mod を計算する
unsigned long long modinv(unsigned long long a, unsigned long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
int A,B;
  cin>>A>>B;
  int buff;
  buff=A+B;
  if(buff%2==0){
    cout<<buff/2<<endl;
  }else{
  cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}

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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int N = 18;
const int INF = (int)1e9;

int n;
ii dat[N+2];
int dp[N+2][(1<<N)+5];
int cost[N+2][(1<<N)+5];

int DP(int last, int mask) {
	if (__builtin_popcount(mask) == n) return 0;
	int& ret = dp[last][mask];
	if (ret != -1) return ret;
	int order = __builtin_popcount(mask) - 1;
	int faceup;
	if (order % 2 == last % 2) faceup = dat[last].fi;
	else faceup = dat[last].se;
	// printf("order = %d, last = %d, mask = %d, faceup = %d\n", order, last, mask, faceup);
	ret = INF;
	for (int nxt = 0; nxt < n; nxt++) {
		if (mask & (1 << nxt)) continue;
		int nxtFaceup;
		if ((order+1)%2 == nxt%2) nxtFaceup = dat[nxt].fi;
		else nxtFaceup = dat[nxt].se;
		if (nxtFaceup < faceup) continue;
		ret = min(ret, cost[nxt][mask] + DP(nxt, mask | (1<<nxt)));
	}
	// printf("dp[%d][%d] = %d\n", last, mask, ret);
	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &dat[i].fi);
	for (int i = 0; i < n; i++) scanf("%d", &dat[i].se);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < (1<<n); j++) {
			for (int k = 0; k < i; k++) {
				if (!(j & (1 << k))) cost[i][j]++;
			}
		}
	}
	reset(dp,-1);
	int ans = INF;
	for (int i = 0; i < n; i++) ans = min(ans, i + DP(i, 1<<i));
	if (ans == INF) printf("-1\n");
	else printf("%d\n", ans);
	return 0;
}

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll  a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;
 ll count;
signed main(){
string L;
 cin >>  L;

 reverse(L.begin(),L.end());

i=L.size();
for(i;i>0;){
	if(L[0]=='m'&&L[1]=='a'&&L[2]=='e'&&L[3]=='r'&&L[4]=='d'){
		i=i-5;
		for(t=0;i>t;t++) L[t]=L[t+5];
	}
    if(L[0]=='e'&&L[1]=='s'&&L[2]=='a'&&L[3]=='r'&&L[4]=='e'){
    	i=i-5;
    	for(t=0;i>t;t++) L[t]=L[t+5];
    }
    if(L[0]=='r'&&L[1]=='e'&&L[2]=='s'&&L[3]=='a'&&L[4]=='r'&&L[5]=='e'){
    	i=i-6;
    	for(t=0;i>t;t++) L[t]=L[t+6];
    }
    if(L[0]=='r'&&L[1]=='e'&&L[2]=='m'&&L[3]=='a'&&L[4]=='e'&&L[5]=='r'&&L[6]=='d'){
    	i=i-7;
    	for(t=0;i>t;t++) L[t]=L[t+7];
    }
    if(!(L[0]=='m'&&L[1]=='a'&&L[2]=='e'&&L[3]=='r'&&L[4]=='d')
    &&!(L[0]=='e'&&L[1]=='s'&&L[2]=='a'&&L[3]=='r'&&L[4]=='e')
    &&!(L[0]=='r'&&L[1]=='e'&&L[2]=='s'&&L[3]=='a'&&L[4]=='r'&&L[5]=='e')
    &&!(L[0]=='r'&&L[1]=='e'&&L[2]=='m'&&L[3]=='a'&&L[4]=='e'&&L[5]=='r'&&L[6]=='d')
    || (0<i&&i<5)){
    	cout<<"NO";
    return 0;
    }
}
 cout<<  "YES"  <<endl;
  
 return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
string s, t, u;
int A, B;


int main(void) {
    cin >> s >> t;
    scanf("%d %d", &A, &B);
    cin >> u;

   if (s == u) A--;
   else B--;

  
    printf("%d %d\n", A, B);

	return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if i < j < k:
                if L[i] != L[j] and L[j] != L[k]:
                    if L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[j]+L[k]>L[i]:
                        count += 1
print(count)


Measured memory_bytes: 68152
def conbination(dct):
    for i in range(len(dct)-2):
        for j in range(i+1,len(dct)-1):
            for k in range(j+1,len(dct)):
                v_lst = list(dct.values())
                k_lst = list(dct.keys())
                l = [ int(k_lst[i]), int(k_lst[j]), int(k_lst[k]) ]
                l_sorted = sorted(l)
                if l_sorted[2] < l_sorted[0] + l_sorted[1]:
                    global cnt 
                    cnt += v_lst[i]*v_lst[j]*v_lst[k]
    return cnt

N = int(input())
L = input().split()
D = dict()
cnt = 0
for i in range(len(L)):
    if L[i] in D.keys():
        D[L[i]] += 1
    elif not L[i] in D.keys():
        D[L[i]] = 1
if len(D) < 3:
    print(0)
elif len(D) >= 3:
    print(conbination(D))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;


int32_t main()
{
    simplify
    int arr[5];
    for(int i=0;i<5;i++){
        cin>>arr[i];    
        if(arr[i]==0){
            cout<<i+1;
            return 0;
        }
    }


    return 0;
}


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

const int maxn=300;
int a,b,d[maxn][maxn],w[maxn][maxn];

int main(){
	cin>>a>>b;
	for(int x=1;x<=a;++x)
		for(int y=1;y<=b;++y){
			cin>>d[x][y];
			for(int i=0;i<=100;++i)
				for(int j=0;j<=100;++j)
					if(w[i][j]<d[x][y]-i*x-j*y)
						w[i][j]=d[x][y]-i*x-j*y;
		}
	for(int x=1;x<=a;++x)
		for(int y=1;y<=b;++y){
			int dis=1e9;
			for(int i=0;i<=100;++i)
				for(int j=0;j<=100;++j)
					if(dis>i*x+j*y+w[i][j])
						dis=i*x+j*y+w[i][j];
			if(dis!=d[x][y]){
				puts("Impossible");
				return 0;
			}
		}
	puts("Possible");
	printf("%d %d\n",202,2*100+101*101);
	for(int i=1;i<=100;++i)
		printf("%d %d X\n",i,i+1);
	for(int i=1;i<=100;++i)
		printf("%d %d Y\n",i+102,i+101);
	for(int i=0;i<=100;++i)
		for(int j=0;j<=100;++j)
			printf("%d %d %d\n",i+1,j+102,w[i][j]);
	puts("1 102");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll n,t,dp[3010][6010];
pair< ll , ll > a[3010];
bool use[3010][6010];

ll fn( ll pos , ll time ){
    if( time >= t || pos>=n ) return 0LL;
    if( use[pos][time] ) return dp[pos][time];
    use[pos][time] = true;
    return dp[pos][time] = max( fn( pos+1 , time ) , a[pos].se+fn( pos+1 ,time+a[pos].fi ) );
}

int main()
{

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

    cin >> n >> t;
    for(ll i=0; i<n; i++) cin >> a[i].fi >> a[i].se;

    sort( a , a+n );

    cout << fn( 0 , 0 );

    return 0;
}


Measured memory_bytes: 158208
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = 0;

		for(int i = 0; i < n; i++) {
			sum += Math.abs(sc.nextInt() - sc.nextInt()) + 1;
		}
		System.out.println(sum);
		sc.close();
	}
}


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

namespace Atcoder_procpn_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] t_input = new int[2];
            int[] a = new int[3];
            int[] b = new int[3];
            string result = "YES";
            int[] cnt = new int[4];

            for (int j = 0; j < 3; j++)
            {
                t_input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
                a[j] = t_input[0];
                b[j] = t_input[1];
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 1; j <= 4; j++)
                {
                    if (a[i] == j) cnt[j-1]++;
                    if (b[i] == j) cnt[j-1]++;
                }
            }

            for (int i = 0; i <= 3; i++)
            {
                if (cnt[i] > 2 || cnt[i] == 0) result = "NO";
            }


            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

void printM(vector<vector<long> > &vec, long height, long width){
    F(i, 0, height){
        F(j, 0, width){
            cout << vec[i][j] << space;
        }
        cout << endl;
    }
}

ll flo(ull a, ull b, ull x){
    ull first = a*x;
    first = first/b;
    ull second = x/b;
    second = second * a;
    ll hoge = first  - second;
    return hoge;
}

#define TST 0
int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n,k;
    cin >> n>> k;
    vector<int> sunuke(n);
    sunuke.assign(n, -1);
    int d;
    F(i, 0, k){
        cin >> d;
        int a;
        F(l, 0, d){
            cin >> a;
            a = a-1;
            sunuke[a] = 1;
        }
    }
    int ans = 0;
    F(i, 0, n){
        if(sunuke[i] == -1)ans++;
    }
    cout << ans << endl;


#if TST==1

#endif
}


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

int main() {
    int N;
    string S, T;
    cin >> N >> S >> T;
    rep(i, N) {
        cout << S[i] << T[i];
    }
    cout << endl;
    return 0;
}

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

typedef long long ll;

using namespace std;
int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int S1 = A * B;
    int S2 = C * D; 
    int ans = 0;
    if (S1 >= S2) {
    	ans = S1;
    } 
    else {
    	ans = S2;
    }

    cout << ans;
}


Measured memory_bytes: 256
void main(){
	

	auto K = readLine!()()[0];
	auto AB = readLine!()();
	
	foreach( i ; 1..1000 ){
		if( AB[0] <= K*i  && K*i <= AB[1] ){
			writeln("OK");
			return;
		}
		if( K*i > 1001 ){break;}
	}
	writeln("NG");
	return;
}


import std.stdio, std.string, std.conv;
import std.math, std.algorithm, std.array;
import std.regex;

T[] readLine( T = size_t )( string sp = " " ){
	T[] ol;
	foreach( string elm ; readln().chomp().split(sp) ){
		ol ~= elm.to!T();
	}
	return ol;
}

Measured memory_bytes: 3176
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;

int main(void) {
  int n;
  int m;
  cin>>n>>m;
  vector<ll> v(n+1);
  vector<int> a(n+1);
  for(int i=0; i<n+1; i++) {
    v[i]=0;
    a[i]=0;
  }
  
  int prev;
  for(int i=0; i<m; i++) {
    int x;
    cin>>x;
    // if(i>0) {
    //   if(prev + 1 == x)
    // 	return 0;
    //   prev = x;
    // }
    a[x]=1;
  }
  v[0]=1;
  for(int i=0; i<n; i++) {
    if(a[i]==0) {
      v[i+1] = (v[i+1] % 1000000007 + v[i] % 1000000007) % 1000000007;
      if(i+2 <= n)
	v[i+2] = (v[i+2] % 1000000007 + v[i] % 1000000007) % 1000000007;
    }
    //std::cout << "---" << i << "---"<< std::endl;
    //std::cout << v << std::endl;
  }
  std::cout << v[n] << std::endl;
  return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define repd(i,start,lim) for(long long (i)=(start);i>=(lim);i--)
#define present(c,x) (find(all(c),x) != (c).end())
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#ifdef WIN32
#define getchar_unlocked getchar
#endif
#define gc getchar
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define N 1000006
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long int ll;
typedef vector<long long int> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T sqr(T x){return x*x;}
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T>void read(T &x) { register T c = gc(); x = 0; int t = 0; if (c == '-') t = 1, c = gc(); for (; (c < 48 || c>57); c = gc()); for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; }if (t) x = -x; }
template<typename T> T pow(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y%2==1) ans=(ans*x)%m;y/=2;x=(x*x)%m;}return ans%m;} //using this instead of inbuilt pow due to precision issues in that
template<typename T> ll roundp(T x){ll ans=x;if(x-floor(x)<=0.001) ans=floor(x);else if(ceil(x)-x<=0.001) ans=ceil(x);return ans;}
vvi g;
int ans,glob;
void dfs(int n,vi vis,int ct){
	if(vis[n]) return;
	vis[n]=1;
	++ct;
//	trace2(n,ct);
	if(ct==glob) ++ans;
	tcf(g[n],i){
		dfs(i,vis,ct);
	}
}
int main(){
	int n,m,x,y;
	 cin>>n>>m; glob=n;g.resize(n);
	rep(i,0,m){
		cin>>x>>y; --x; --y; g[x].eb(y); g[y].eb(x);
	}
	vi vis; vis.resize(n); fill(all(vis),0);
	dfs(0,vis,0);
	cout<<ans<<endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> N;
    vector<ll> vec(N);
    REP(i, N)
        cin >> vec.at(i);

    vector<ll> cost(N);

    cost.at(0) = 0;
    cost.at(1) = max(vec.at(0), vec.at(1)) - min(vec.at(0), vec.at(1));

    for (ll i = 2; i < N; i++) {
        ll tmp1 = cost.at(i - 1) + max(vec.at(i - 1), vec.at(i)) - min(vec.at(i - 1), vec.at(i));
        ll tmp2 = cost.at(i - 2) + max(vec.at(i - 2), vec.at(i)) - min(vec.at(i - 2), vec.at(i));

        cost.at(i) = min(tmp1, tmp2);
    }
    cout << cost.at(N-1) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {

    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for(int i = 0; i < N; i++) cin >> P.at(i);
    for(int i = 0; i < N; i++) cin >> Q.at(i);

    vector<int> num(N);
    iota(num.begin(), num.end(), 1);

    int count = 1, a = 0, b = 0;
    do {
        if(a == 0 && num == P) a = count;
        if(b == 0 && num == Q) b = count;
        count++;
    } while (next_permutation(num.begin(), num.end()));

    cout << abs(a - b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n';
const ll nmax = 1000000000;

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

	ll count = 0, t = 0;
	for(ll i=1; i<n; i++){
		count += ((n-1)/i);
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n, k, s, i;
    vector <int> v;
    
    scanf("%d %d %d", &n, &k, &s);
    
    for (i = 0; i < k; i++) v.push_back(s);
    
    for (; i < n; i++) {
        if (s == 1e9) {
            v.push_back(1);
        } else {
            v.push_back(1e9);
        }
    }
    
    for (i = 0; i < n; i++) {
        if (i > 0) putchar(' ');
        printf("%d", v[i]);
    }
    puts("");
    
    return 0;
}


Measured memory_bytes: 1912
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pb push_back
const double INF = 1e7;
const double eps = 1e-6;
const int maxn = 2e5 + 7;
const int maxm = (1 << 10) + 7;
const int mod = 1e9 + 7;
#define IO                        \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);
int a[maxn];
map<int,int>num;
int main()
{
	IO;
	int n;
	cin>>n;
	for (int i=0;i<n;++i)
	cin>>a[i],num[a[i]]++;
	int flag=0;
	for (auto it:num)
	if (it.second>1) flag=1;
	cout<<(flag?"NO":"YES")<<endl;
	return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();i++){
	int k = s[i]-'A';
	cout<<(char)('A'+(k+n)%26);
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
const int N=1e6;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
struct P{ double x,y; }q[N];
inline P operator + (const P &a,const P &b) { return (P){a.x+b.x,a.y+b.y}; }
inline P operator - (const P &a,const P &b) { return (P){a.x-b.x,a.y-b.y}; }
inline P operator * (const P &a,const double &b) { return (P){a.x*b,a.y*b}; }
int main()
{
	int n=gi(),m=gi(),i,T,V,l=n,r=n-1;P sum={},p,v;
	for (i=1;i<=n;i++) {
		T=gi(),V=gi();
		p=(P){(double)V,(double)V*T};
		sum=sum+p;
		while (sum.x>m) {
			v=q[r--];
			sum=sum-v;
			if (sum.x<m) {
				v=v*((m-sum.x)/v.x);
				sum=sum+v;
				q[++r]=v;
				break;
			}
		}
		while (l<=r&&p.y/p.x<=q[l].y/q[l].x) p=p+q[l++];
		q[--l]=p;
		printf("%.8lf\n",sum.y/sum.x);
	}
	return 0;
}


Measured memory_bytes: 17664
#include<stdio.h>

int main(){
	
	int n;
	
	scanf("%d",&n);
	
	int count = 0;
	for(int i=1;i<=n;i++){
		if( i % 2 !=0){
			count++;
		}
	}
	
	double total = (double) count / n;
	
	printf("%.6lf\n",total);
	
}

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

class Cube {
public:
  int f[6];
  Cube(void){}
  void roll_z(void) {
    roll(1,2,4,3);
  }
  void roll_y(void) {
    roll(0,2,5,3);
  }
  void roll_x(void) {
    roll(0,1,5,4);
  }
  void roll(int i,int j,int k,int l) {
    int t = f[i];
    f[i] = f[j];
    f[j] = f[k];
    f[k] = f[l];
    f[l] = t;
  }
};

bool eq(Cube c1,Cube c2) {
  for (int i=0; i<6; i++) {
    if (c1.f[i]!=c2.f[i]) {
      return false;
    }
  }
  return true;
}

bool equal(Cube c1,Cube c2) {
  for (int i=0; i<6; i++) {
    for (int j=0; j<4; j++) {
      if (eq(c1,c2)) {
        return true;
      }
      c1.roll_z();
    }
    if (i%2==0) {
      c1.roll_y();
    } else {
      c1.roll_x();
    }
  }
  return false;
}

Cube C[100]; int n;

bool check(void) {
  for (int i=0; i<n-1; i++)
    for (int j=i+1; j<n; j++) {
      if (equal(C[i],C[j])) {
        return false;
      }
    }
  return true;
}

int main(void) {
  cin >> n;
  for (int j=0; j<n; j++) {
    for (int i=0; i<6; i++) {
      cin >> C[j].f[i];
    }
  }
  if (check()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3108
import queue
n = int(input())


#ab = [[]*(n)]
ab = [[] for _ in range(n+1)]
#print(ab)

li = []

for i in range(n-1):
    a,b = map(int,input().split())
    ab[a].append([b,i])
    ab[b].append([a,i])
    #li.append([a,b])

#ab_color = [[None for _ in range(n+1)] for _ in range(n+1)]
ans = [0] * (n-1)

q = queue.Queue()
check = [0] * (n+1)
#check[1] == 1
check_color = [0] * (n+1)

q.put(1)
color_num = 1
#mae_color = 0

while not q.empty():
    tmp_color = 0
    tmp = q.get()
    #print(tmp)
    #tmp_color = mae_color
    mae_color = check_color[tmp]
    for i in range(len(ab[tmp])):
        if check[ab[tmp][i][0]] == 1:
            #print(i,tmp)
            continue
        else:
            #print(mae_color,tmp_color,tmp,i)
            tmp_color += 1
            q.put(ab[tmp][i][0])
            if tmp_color == mae_color:
                tmp_color += 1
            check_color[ab[tmp][i][0]] = tmp_color
            ans[ab[tmp][i][1]] = tmp_color
            #ab_color[ab[tmp][i]][tmp] = tmp_color
            #ab_color[tmp][ab[tmp][i]] = tmp_color
            check[tmp] = 1
            if color_num < tmp_color:
                color_num = tmp_color
            #color_num = max(color_num,tmp_color)
            #print(check,i)

print(color_num)
for i in range(len(ans)):
    print(ans[i])


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

def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

S = num_divisors_table(N)

ans = 0

for i in range(1,N+1):
    ans += i*S[i]
    
print(ans)

Measured memory_bytes: 145800
#include<iostream>
#include<cstdio>
#include<queue>
const int N=205;
int dis[N],n;
char s[N][N];
int bfs(int u) {
    std::queue<int> q;
    for(int i=1;i<=n;i++) dis[i]=N;
    dis[u]=1;
    q.push(u);
    while(!q.empty()) {
        u=q.front();q.pop();
        for(int j=1;j<=n;j++) {
            if(u==j||s[u][j]!='1') continue;
            if(dis[j]>dis[u]+1) {
                dis[j]=dis[u]+1;
                q.push(j);
            }
        }
    }
    int res=1;
    for(int i=1;i<=n;i++) res=std::max(res,dis[i]);
    for(int i=1;i<n;i++) for(int j=i+1;j<=n;j++) {
        if(s[i][j]=='0') continue;
        if((dis[i]+1!=dis[j])&&dis[j]+1!=dis[i]) {
            res=-1;
        }
    }
    return res;
}
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    int ans=-1;
    for(int i=1;i<=n;i++) ans=std::max(ans,bfs(i));
    printf("%d",ans);
    return 0;
}


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

#define NIL NULL

typedef struct node{
  int key;
  struct node *right,*left,*p;
} Node;

Node *root;

void insert(int);
void prep(Node *);
void inp(Node *);
int find(int);
void delete(int);
Node * mini(Node *);
Node * suc(Node *);

int main(){
  char c[20];
  int n,i,j,x;


  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",c);


    if(c[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }

    else if(c[0] == 'p'){
      inp(root);
      printf("\n");
      prep(root);
      printf("\n");
    }
  
    else if(c[0] == 'f'){
      scanf("%d",&x);
      if( find(x))printf("yes\n");
      else printf("no\n");
    }

    else if(c[0] == 'd'){
      scanf("%d",&x);
      delete(x);
    }
  }
  return 0;
}


void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z->key < x->key) x = x->left;

    else x = x->right;
  }

  z->p = y;

  if(y == NIL)root = z;

  else{
    if(z->key < y->key) y->left = z;

    else y->right = z;
  }
}


void prep(Node *p){
  if(p == NIL) return;
  printf(" %d",p->key);
  prep(p->left);
  prep(p->right);
}

void inp(Node *p){
  if(p == NIL) return;
  inp(p->left);
  printf(" %d",p->key);
  inp(p->right);
}

int find(int k){
  Node *x = root;
  Node *y = NIL;
  
  while(x != NIL){
    y = x;
    if(y->key == k)return 1;

    if(k < x->key) x=x->left;

    else x = x->right;
  }

  return 0;
}

Node * mini(Node *x){
  while(x->left != NIL){   
    x = x->left;
  }

  return x;
}

Node * suc(Node * x){
  Node *y;
  
  if(x->right != NIL){
    return mini(x->right);
  }
  
  y = x->p;
  
  while(y != NIL && y->right == x){
    x = y;
    y = y->p;
  }
  return y;
}
  
  
void delete(int k){
  Node *x = root;
  Node *y = NIL;
  Node *z;
  Node *w;
  Node *r;
  
  while(x != NIL){
    y = x;
    if(y->key == k) z = y; 
                      
    if(k < x->key) x=x->left;

    else x = x->right;
  }

  if(z->right == NIL || z->left == NIL) w = z;
 
  else  w = suc(z);

  if(w->left != NIL) r = w->left;

  else r = w->right;

  if(r != NIL) r->p = w->p;

  if(w->p == NIL) root = x;

  else{
    if(w == w->p->left) w->p->left = r;

    else w->p->right = r;
  }
  
  if(w != z) z->key = w->key;

  free(w);
}



Measured memory_bytes: 20520
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long T = sc.nextInt();
        long A = sc.nextInt();
        for (int i=0;i<N-1;i++) {
            long t = sc.nextInt();
            long a = sc.nextInt();
            long tmp = Math.max((T+t-1)/t, (A+a-1)/a);
            T = t*tmp;
            A = a*tmp;
        }
        System.out.println(T+A);
    }
}

Measured memory_bytes: 25320
n = int(input())
city = []
nums = []
result = []
 
for i in range(n):
  s,p = input().split()
  p = int(p)
  city.append(s)
  nums.append(p)
  result.append([s,p,i+1])
 
for i in sorted(set(city)):
  for j in sorted(set(nums), reverse = True):
    for k in result:
      if k[0] == i and k[1] == j:
        print(k[2])

Measured memory_bytes: 9204
h,n=map(int,input().split())
A=[]
B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

dp=[10**10 for i in range(h+1)]

dp[h]=0

for i in reversed(range(1,h+1)):
    for j in range(n):
        if i-A[j]>=0:
            dp[i-A[j]]=min(dp[i-A[j]],dp[i]+B[j])
        else:
            dp[0]=min(dp[0],dp[i]+B[j])

print(dp[0])

Measured memory_bytes: 41708
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	int[int] m;
	auto A = readAs!(int[]);
	auto kind = A.sort().uniq.array.length.to!long;
	foreach(v; A) m[v]++;
	auto arr = m.values.sort();
	if(kind - K <= 0) writeln(0);
	else arr[0..kind-K].sum.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int A = read();

  if (A < 1200)
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
 using namespace std ;
 int main()
{
short int a,b,c,d;

cin>>a;
cin>>b;
cin>>c;
cin>>d;
if((abs(c-a))<=d) cout<< "Yes";
else
 if((abs(c-b)<=d)&& ( abs(b-a)<=d) ) cout<< "Yes";
else
cout<< "No";




}

Measured memory_bytes: 3632
S=input()

mod=2019
D={}
S=S[::-1]
now=0

for i in range(len(S)):
    if (int(S[i])*pow(10,i,mod)+now)%mod not in D:
        D[(int(S[i])*pow(10,i,mod)+now)%mod]=1
    else:
        D[(int(S[i])*pow(10,i,mod)+now)%mod]+=1
    now=(int(S[i])*pow(10,i,mod)+now)%mod
#print(D)
ans=0
for k,v in D.items():
    if k==0:
        v+=1
    ans+=v*(v-1)//2
print(ans)

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

public class Main {
    public static void main(String arg[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        int arr[] = new int[2*N];
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=0;i<N;i++){
            arr[2*i] = Integer.parseInt(st.nextToken());
            arr[2*i+1] = Integer.parseInt(st.nextToken());
        }
        Arrays.sort(arr);
        int total = 0;
        for(int i=0;i<N;i++){
            total += arr[2*i];
        }
        System.out.println(total);
    } 
}

Measured memory_bytes: 8272
n = int(input())
p = []
for i in range(n):
    a, b = input().split()
    p.append((int(a), int(b)))

from itertools import permutations

a = (permutations(p))

from math import sqrt

def dis(a):
    sum = 0
    for i in range(n-1):
        sum += sqrt( (a[i][0]-a[i+1][0]) ** 2 + (a[i][1]-a[i+1][1]) ** 2 )
    return sum

b = map(dis, a)

from statistics import mean

print(mean(b))


Measured memory_bytes: 6940
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int n, z, w; cin >> n >> z >> w;
    int a[n+1]; a[0] = w; for (int i = 1; i <= n; i++) cin >> a[i];
    int maxsc[n+1], minsc[n+1];
    for (int i = n; i >= 1; i--) {
        maxsc[i] = abs(a[i-1]-a[n]); minsc[i] = abs(a[i-1]-a[n]);
        for (int j = i+1; j <= n; j++) maxsc[i] = max(maxsc[i], minsc[j]);
        for (int j = i+1; j <= n; j++) minsc[i] = min(minsc[i], maxsc[j]);
    }
    cout << maxsc[1] << endl;
}


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

const int INF = 1 << 29;

int N, M, b[15], p[15], bb[15];

int calc(int c) {
    for (int j = 0; j < N; ++j) b[j] = bb[j];

    int swaps = 0;

    int idx = 0;
    for (int j = 0; j < M; ++j) {
        for (int k = 0; k < p[j]; ++k) {
            int kk = idx+k;
            while (kk < N && b[kk] != c) ++kk;
            if (kk == N) return INF;

            swaps += kk-(idx+k);
            for (int m = kk; m > idx+k; --m) {
                swap(b[m], b[m-1]);
            }
        }
        c = 1-c;
        idx += p[j];
    }

    return swaps;
}

int main() {
    cin >> N >> M;
    for (int j = 0; j < N; ++j) { cin >> b[j]; bb[j] = b[j]; }
    for (int j = 0; j < M; ++j) { cin >> p[j]; }

    cout << min(calc(0), calc(1)) << endl;
    return 0;
}

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

int main(){
  int X,A,B;
  cin >> X >> A >> B;
  if(A>=B){
    cout << "delicious" << endl;
  }
  else if(X+A<B){
    cout << "dangerous" << endl;
  }
  else{
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 256
import math
a,b,h,m = map(int,input().split())
hun = h*60+m
ad = hun*0.5
bd = m*6

if abs(ad-bd) < 180:
    dg = abs(ad-bd)
    cos = math.cos(math.radians(dg))
    cc = a**2+b**2-2*a*b*cos
    print(math.sqrt(cc))
elif abs(ad-bd) == 180:
    print(a+b)
else:
    dg = 360-abs(ad-bd)
    cos = math.cos(math.radians(dg))
    cc = a**2+b**2-2*a*b*cos
    print(math.sqrt(cc))



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



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	ll n; cin >> n;
	
	vector<int> pf; // Prime Factor

	for(ll i = 2; i*i <= n; i++){
		int x = 0; // 割れた回数
		while(n%i == 0){
			n /= i;
			x++; 
		}
		pf.emplace_back(x);
	}
	if(n != 1) pf.emplace_back(1);

	int ans = 0;

	rep(i, pf.size()){
		int p = pf[i];
		int c = 1;

		while(p >= c){
			p -= c;
			c++;
			ans ++;
		}

	}

	cout << ans << endl;

	
	return 0;
}


Measured memory_bytes: 7380
#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;
string s,t;
int n;
int main(){
    cin>>n>>s>>t;
    rep(i,n)cout<<s[i]<<t[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll>pairs;
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,l,c,f;
	long double k;
	cin>>i>>k;
	cout<<(ll)(i*k);

	return 0;
}


Measured memory_bytes: 3728
#include<stdio.h>
#include<string.h>
int main()
{
	int n,i,c=0;
	char m[7];

	scanf("%d",&n);	
	for(i=1;i<=n;i++){
		sprintf(m,"%d",i);
		if(strlen(m)%2==1)
			c++;
	}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int add(int n, int m, int x);
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    int c = 0;
    for(int i=0; i<10; i++){
      if(m >= i){c+=add(n-1,m-i,i);}
    }
    cout <<c<<endl;
  }
  return 0;
}
int add(int n, int m, int x){
  int c = 0;
  if(!n && !m){return 1;}
  else if(n>0){
    for(int i=x+1; i<10; i++){
      if(m >= i){c+=add(n-1,m-i,i);}
    }
  }
  return c;
}

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

int main() {
    int X;
    cin >> X;
    int cnt = 0;
    for(int i = 1; i <= X; i++) {
        cnt += i;
        if(X <= cnt) {
            cout << i << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char O[50];
    char E[50];
    scanf("%s",&O);
    scanf("%s",&E);
    char ans[strlen(O)+strlen(E)];
  	int j= strlen(O)-strlen(E);
    for(int i=0;i<strlen(O)+strlen(E)-abs(j);i++){
        if(i%2==0){
            ans[i]=O[i/2];
        }else{
            ans[i]=E[i/2];
        }
    }
  	int count=0;
  	if(j>0){
      	for(int i=strlen(O)+strlen(E)-abs(j);i<strlen(O)+strlen(E);i++)
        {
       	    ans[i]=O[(strlen(O)+strlen(E)-abs(j))/2+count];
    		count++;
        }
    }else if(j<0){
        for(int i=strlen(O)+strlen(E)-abs(j);i<strlen(O)+strlen(E);i++)
        {
          ans[i]=E[(strlen(O)+strlen(E)-abs(j))/2+count];
          count++;
        }
    }
    printf("%s",ans);
    return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    tasks = [tuple(map(int, input().split())) for _ in range(N)]
    tasks = sorted(tasks, key=lambda x: x[1])
    ct = 0
    for t in tasks:
        if ct+t[0] > t[1]:
            return False
        ct += t[0]
    return True

if __name__ == '__main__':
    if main():
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 33408