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

using namespace std;

// typedef
typedef long long ll;

// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

// repetition
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define REP(i,n) FOR(i,0,n)

//constant
const double    EPS     = 1e-10;
const double    PI      = acos(-1.0);
const int       INFTY   = (1<<21);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
    cin.sync_with_stdio(false);
    for(;;){
        int N;
        cin>>N;
        if(N==0) break;
        vector<vector<bool>> m(21, vector<bool> (21, false));
        REP(i,N){
            int x,y;
            cin>>x>>y;
            m[x][y] = true;
        }
        int M,x=10,y=10;
        int ans=0;
        cin>>M;
        REP(i,M){
            char d;
            int l;
            cin>>d>>l;
            REP(ii,l){
                switch(d){
                    case 'N':
                        y++;
                        break;
                    case 'S':
                        y--;
                        break;
                    case 'W':
                        x--;
                        break;
                    case 'E':
                        x++;
                        break;
                }
                if(m[x][y]){
                    m[x][y] = false;
                    ans += 1;
                }
            }
        }
        cout<<(ans==N?"Yes":"No")<<endl;
    }
    return 0;
}


Measured memory_bytes: 3136
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

n =int(input())

s = list(input())
num =[]
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in range(1,n,1):
    x = []
    y = []
    for j in range(0,i,1):
        x.append(s[j])
    for j in range(i,n,1):
        y.append(s[j])
    answer = 0
    for a in alphabet:
        if (a in x) and (a in y):
            answer += 1
    num.append(answer)
#    print(x,y)

print(max(num))
#print(num)


Measured memory_bytes: 12764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp(a, b) make_pair(a, b)
const int maxn = 1e6 + 10; 
const ll mod = 1e9 + 7;
ll fac[maxn], inv[maxn], facinv[maxn], bin[maxn];
ll pow8[maxn];
ll ans;
void pre()
{
	fac[0] = 1; for(int i = 1; i < maxn; ++i) fac[i] = fac[i - 1] * i % mod;
	inv[1] = 1; for(int i = 2; i < maxn; ++i) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	facinv[0] = 1; for(int i = 1; i < maxn; ++i) facinv[i] = facinv[i - 1] * inv[i] % mod;
	bin[0] = 1; for(int i = 1; i < maxn; ++i) bin[i] = bin[i - 1] * 2 % mod;
	pow8[0] = 1; for(int i = 1; i < maxn; ++i) pow8[i] = pow8[i - 1] * 8 % mod;
}
ll C(int n, int m) { return n < m ? 0 : fac[n] * facinv[m] % mod * facinv[n - m] % mod;}
int main()
{
	pre();
	int n;
	cin >> n;
	for(int i = 2; i <= n; ++i)
	{
		ll tmp = C(n, i) * (bin[i] - 2 + mod) % mod * pow8[n - i] % mod;
		ans = (ans + tmp) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 42692
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
using namespace std;
const int maxn=100100;
const int INF=0x3f3f3f3f;

int a[maxn],b[maxn],c[maxn],d[maxn];
int s[maxn],n;
int sa[maxn],h[maxn],rk[maxn];
int sum[maxn];
char str[maxn];
bool cmp(int r[],int a,int b,int k) {
    return r[a]==r[b]&&r[a+k]==r[b+k];
}
void build_sa(int r[],int sa[],int n,int m) {
    int i,j,p,*x=a,*y=b;
    for(i=0; i<m; c[i++]=0);
    for(i=0; i<n; c[x[i++]=r[i-1]]++);
    for(i=0; i<m; c[++i]+=c[i-1]);
    for(i=n-1; i>=0; sa[--c[x[i]]]=i--);
    for(j=1,p=1; p<n; j<<=1,m=p) {
        for(p=0,i=n-j; i<n; y[p++]=i++);
        for(i=0; i<n; i++)if(sa[i]>=j)y[p++]=sa[i]-j;
        for(i=0; i<n; d[i++]=x[y[i-1]]);
        for(i=0; i<m; c[i++]=0);
        for(i=0; i<n; c[d[i++]]++);
        for(i=0; i<m; c[++i]+=c[i-1]);
        for(i=n-1; i>=0; sa[--c[d[i--]]]=y[i+1]);
        for(swap(x,y),p=1,x[sa[0]]=0,i=1; i<n; i++)
            x[sa[i]]=cmp(y,sa[i-1],sa[i],j)?p-1:p++;
    }
}
void calh(int r[],int sa[],int n) {
    int i,j,k=0;
    for(i=1; i<=n; rk[sa[i++]]=i-1);
    for(i=0; i<n; h[rk[i++]]=k)
        for(k?k--:0,j=sa[rk[i]-1]; r[i+k]==r[j+k]; k++);
}
int main() {
    int Q;
    scanf("%s",str);
    n=strlen(str);
    for(int i=0; i<n; i++)s[i]=(int)str[i];
    s[n]=0;
    build_sa(s,sa,n+1,256);
    calh(s,sa,n);

    int tot=0;
    for(int i=1; i<=n; i++) {
        sum[i] = n-sa[i]-h[i];
        tot+=sum[i];
    }
    for(int i=2; i<=n; i++)
        sum[i]+=sum[i-1];
    int kth,ans;

    cin>>kth;
    if(kth>tot)kth%=tot;
    int L=0,R=n,mid;
    while(L<=R) {
        mid=(L+R)>>1;
        if(sum[mid]>=kth) {
            ans=mid;
            R=mid-1;
        } else L=mid+1;
    }
    int s=sa[ans];
    int t=s+kth-sum[ans-1]+h[ans]-1;
    for(int i=s; i<=t; i++)cout<<str[i];
    cout<<endl;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if(a < 6)
    cout << 0 << endl;
  else if(a < 13)
    cout << b / 2 << endl;
  else
    cout << b << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
typedef long double lld;
const ll INF = 1e18;
const ll mod = 1e9+7;
 
ll fastpowMOD(ll a, ll p,ll MOD);
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; a %= MOD; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
 
ll lcm(ll a,ll b){
	return (a*b)/__gcd(a,b);
}

void solve(){
	ll n;
	cin>>n;
	vector<ll> a(n,0);
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	int f = 0;
	ll yen = 1000, stocks = 0, i = 0;
	while(i<n){
		if(f==0){
			ll lmin = a[i];
			while(i+1<n && a[i+1]<=a[i]){
				lmin = min(a[i+1],lmin);
				i++;
			}	
			if(i<n-1){
				stocks += yen/a[i];
				yen -= (yen/a[i])*a[i];
				i++;
			}
			else{
				break;
			}
			f = 1;
		}
		else{
			ll lmax = a[i];
			while(i+1<n && a[i+1]>=a[i]){
				lmax = max(a[i+1],lmax);
				i++;
			}	
			yen += (stocks*lmax);
			stocks = 0;
			i++;
			f = 0;
		}
		
	}
	cout<<yen<<"\n";
	
	
}

int main(){
    fastio;
    ll t=1;//cin>>t;
    for(ll i=1;i<=t;i++){
    	solve();
	}	
}




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

int main()
{
    int N;
    cin >> N;
    int ac=0, wa=0, tle=0, re = 0;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        if (s == "AC")++ac;
        else if (s == "WA")++wa;
        else if (s == "TLE")++tle;
        else if (s == "RE")++re;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<unordered_set>
#include<vector>
#include<math.h>
#include<iomanip>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    double l;
    cin >> l;
    cout << setprecision(9) << (l/3) * (l/3) * (l/3);
}

Measured memory_bytes: 256
n, p = map(int, input().split())
s = input()
a = []
c = 0
if p == 2:
    b = [0]*n
    for i in range(n):
        if int(s[i])%2 == 0:
            b[i] += 1
    for i in range(n):
        if b[i] == 1:
            c += i+1
elif p == 5:
    b = [0]*n
    for i in range(n):
        if int(s[i])%5 == 0:
            b[i] += 1
    for i in range(n):
        if b[i] == 1:
            c += i+1
else:
    b = [0]*p
    b[0] = 1
    d = [1]
    a.append(int(s[-1])%p)
    for i in range(n-1):
        d.append(d[-1]*10%p)
    for i in range(1, n):
        a.append((int(s[-i-1])*d[i]+a[i-1])%p)
    for i in range(n):
        b[a[i]] += 1
    for i in range(p):
        c += int(b[i]*(b[i]-1)/2)
print(c)

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

typedef long long ll;
ll res[10000], a[20];

inline int S(ll k) {
	int res = 0;
	while(k) res += k % 10, k /= 10;
	return res;
}

int main() {
	int cnt = 0;
	ll val = 1;
	do {
		res[cnt++] = val;
		val++;
		long long tmp = val, t = 1, c = 0;
		for(c = 0; tmp; c++, tmp /= 10, t *= 10) {
			a[c] = tmp * t + t - 1;
		}
		val = a[0];
		for(int i = 0; i < c; i++)
			if(val * S(a[i]) > a[i] * S(val)) val = a[i];
	} while(val < 10000000000000000ll);
int k; scanf("%d", &k);
for(int i = 0; i< k; i++) printf("%lld\n", res[i]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define bigint int64_t
#define vll vector<ll>
#define pll ar<ll,2>
#define vpll vector<pll>
#define pb push_back
#define MOD 1000000007
#define sz(x) (ll)(x).size()
#define ff first
#define ss second
#define en cout<<"\n"
#define LCM(a,b) (a*(b/__gcd(a,b)))
#define all(v) v.begin(),v.end()
#define maxqueue    priority_queue<int>
#define minqueue    priority_queue<int,vector<int>,greater<int> >
#define lb(v,val)  (lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (upper_bound(v.begin(),v.end(),val)-v.begin())
#define INF (ll)(1e18)
#define ini(a,b) memset(a,b,sizeof(a))
#define vvll vector<vector<ll>>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define prec(n) fixed<<setprecision(n)
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define forn(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define deb1(x)                cerr<<#x<<": "<<x<<endl
#define deb2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define GET5(a, b, c, d, e, ...) e
#define D_EBC(...) GET5(__VA_ARGS__, deb4, deb3, deb2, deb1)
#define deb(...) D_EBC(__VA_ARGS__)(__VA_ARGS__)
#define each(x, a) for (auto& x: a)

using namespace std;

template <typename T>
void read(T &x) {
    cin >> x;
}
template <typename T , typename T0>
void read(T &x, T0 &y) {
    cin >> x >> y;
}

template <typename T , typename T0 , typename T1>
void read(T &x, T0 &y, T1 &z) {
    cin >> x >> y >> z;
}

template <typename T , typename T0 , typename T1 , typename T2>
void read(T &x, T0 &y, T1 &z, T2 &w) {
    cin >> x >> y >> z >> w;
}

template <typename T>
void read(vector< T > &oneD, ll n) {
    for (ll i = 0; i < n; i++) {
        read(oneD[i]);
    }

}

template <typename T>
void read(T oneD[] , ll n) {
    for (ll i = 0; i < n; i++) {
        read(oneD[i]);
    }
}

const ll N=1e5;
ll dp[N+1];
void solve(){
    ll n;
    read(n);
    ll arr[n];
    read(arr,n);
    dp[0]=0;
    forn(i,1,n){
        dp[i]=MOD;
        if(i)
            dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
        if(i-1>=0){
            dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i]);
        }
    }
    cout<<dp[n-1];
}

int main() {
    fast;
    int t=1;
    // read(t);
    forn(t) {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b-1); i >= (a); i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

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

  if (a>=3200) {
    cout << s << endl;
  }
  else {
    cout << "red" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a == b) return cout << "0\n", 0;
    int cost = 0;
    if (abs(a) > abs(b)) a=-a, b=-b, swap(a, b);
    if (a<0) cost++, a=-a;
    if (b<0) cost++, b=-b;
    cost += b-a;
    cout << cost << '\n';
}


Measured memory_bytes: 256
//ABC136A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

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

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int N,ans;
	static int[]num;
	static long[][]dp;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		N=cin.nextInt();
		num=new int[N-1];
		ans=0;
		dp=new long[N-1][21];
		for(int i=0;i<N-1;i++){
			num[i]=cin.nextInt();
			Arrays.fill(dp[i], -1);
		}
		ans=cin.nextInt();
		System.out.println(search(0,0));
	}
	static long search(int a,int b){
		if(b>20||b<0)return 0;
		if(a==N-1){
			if(b==ans){
				return 1;
			}
			return 0;
		}
		if(dp[a][b]!=-1)return dp[a][b];
		long res=0;
		if(a==0&&num[a]==0){
			res+=search(a+1,b+num[a]);	
		}
		else{
			res+=search(a+1,b+num[a]);
			res+=search(a+1,b-num[a]);
		}
		return dp[a][b]=res;
	}
}

Measured memory_bytes: 18108
import heapq

def Sigle_Source_Shortest_Path_2(adj_list, Cost, Color):

    Cost[0] = 0
    H = list()
    heapq.heappush(H, [0, 0])

    while len(H) != 0:
        _, u = heapq.heappop(H)
        Color[u] = "B"

        for i in range(len(adj_list[u])):

            c = adj_list[u][i][0]
            v = adj_list[u][i][1]
           
            if Color[v] != "B":
                if Cost[v] > Cost[u] + c:
                    Cost[v] = Cost[u] + c
                    Color[v] = "G"
                    heapq.heappush(H, [Cost[v], v])

def Main():
    N = int(input())
    adj_list = [list() for n in range(N)]
    Cost = [1000000 for n in range(N)]
    Color = ["W" for n in range(N)]

    for n in range(N):
        u, K, *p = map(int, input().split())

        if K > 0:
            for k in range(K):
                v, c = p[2*k], p[2*k + 1]
                adj_list[u].append([c, v])

    Sigle_Source_Shortest_Path_2(adj_list, Cost, Color)

    for i in range(N):
        print("{} {}".format(i, Cost[i]))

Main()


Measured memory_bytes: 76628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k;
  int64_t x,y;
  cin>>k;
  x=floor(log10(k)+1);
  y=7*(pow(10,x)-1)/9;
  if(k%2==0){
    cout<<-1<<endl;
  }
  else{
    if(y%k==0){
      cout<<x<<endl;
    }
    else{
      for(int i=x+1;i<k+1;i++){
        y=(y%k)*10+7;
        if(y%k==0){
          cout<<i<<endl;
          break;
        }
        else if(i==k){
          cout<<-1<<endl;
        }
      }
    }


  }
}

Measured memory_bytes: 4068
//In the name of God
#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n;
 cin>>n;
 set<string>s1;
 while(n--)
 {string s;
  cin>>s;
  s1.insert(s);
 }
 cout<<s1.size();}
  

Measured memory_bytes: 19204
#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <string.h>


int main() {
	char str[27];
	memset(str, '\0', 27);
	scanf("%s", str);
	int temp;
	for (int i = 0; ; i++) {
		if (str[i] == '\0') {
			temp = i;
			break;
		}
	}
	for (int i = 0; i < temp; i++) {
		for (int j = i + 1; j < temp; j++) {
			if (str[i] == str[j]) {
				printf("no\n");
				return 0;
			}
		}
	}
	printf("yes\n");
	return 0;
}

Measured memory_bytes: 128
n,m= map(int, input().split())
vs = [0] * (n + 1)
for _ in range(m):
    a,b= map(int, input().split())
    vs[a] += 1
    vs[b] += 1
ans = "YES"
for i in range(n + 1):
    if vs[i] % 2 == 1:
        ans = "NO"
print(ans)

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,D;

int main(){
    cin>>N>>D;

    int ans=ceil(N/(2.0*D+1.0));

    cout<<ans<<endl;
}

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

template<typename T, typename E> class SegmentTree {
public:
  typedef function<T (T, T)> Operator;
  typedef function<T (T, E)> Apply;

  vector<T> data;
  ll n;
  T e;
  Operator op;
  Apply apply;

  SegmentTree(ll _n, T e, Operator op, Apply apply): e(e), op(op), apply(apply) {
    for(n = 1; n < _n; n *= 2);
    data.resize(n * 2 - 1, e);
  }

  SegmentTree(const vector<T> &vec, T e, Operator op, Apply apply): e(e), op(op), apply(apply) {
    for(n = 1; n < vec.size(); n *= 2);
    data.resize(n * 2 - 1, e);
    REP(i, 0, vec.size()) data[i + n - 1] = vec[i];
    for(ll i = n - 2; i >= 0; i--) data[i] = op(data[i * 2 + 1], data[i * 2 + 2]);
  }

  T query(ll a, ll b) { return query(a, b, 0, 0, n); }
  T query(ll a, ll b, ll k, ll l, ll r) {
    if(r <= a || b <= l) return e;
    if(a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }

  void update(ll k, E x) {
    k += n - 1;
    data[k] = apply(data[k], x);
    while(k > 0) {
      k = (k - 1) / 2;
      data[k] = op(data[k * 2 + 1], data[k * 2 + 2]);
    }
  }
};

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

int main(void) {
  ll N, Q;
  cin >> N >> Q;
  vector<ll> P(N);
  REP(i, 0, N) cin >> P[i], P[i]--;
  vector<ll> L(Q), R(Q);
  REP(i, 0, Q) cin >> L[i] >> R[i], L[i]--;

  vector<ll> x(N), t(N, -1), sum(N, 0);
  REP(i, 0, N) x[i] = i;
  REP(k, 1, 41) {
    REP(i, 0, N) {
      x[i] = P[x[i]];
      if(t[i] == -1) {
        if(x[i] == i) t[i] = k;
        sum[i] += x[i] + 1;
      }
    }
  }

  const ll MOD = 1000000007;
  SegmentTree<ll, ll>::Operator lcm = [](ll a, ll b) { return a * (b / gcd(a, b)); };
  SegmentTree<ll, ll>::Operator add = [](ll a, ll b) { return (a + b) % MOD; };
  SegmentTree<ll, ll>::Apply apply = [](ll a, ll x) { return x; };
  SegmentTree<ll, ll> segtree_lcm(t, 1, lcm, apply);
  vector<SegmentTree<ll, ll>> segtree_add(41, SegmentTree<ll, ll>(N, 0, add, apply));
  REP(i, 0, N) segtree_add[t[i]].update(i, sum[i]);

  REP(i, 0, Q) {
    ll m = segtree_lcm.query(L[i], R[i]);
    ll ans = 0;
    REP(j, 1, 41) if(m % j == 0) {
      ll x = m / j % MOD;
      ans += segtree_add[j].query(L[i], R[i]) * x % MOD;
      ans %= MOD;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 94516
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (h, w) = get!(i64, i64);
    let n = get!(usize);
    let v = get!([i64]);
    let mut field = vec![vec![0; w as usize]; h as usize];
    let mut idx = 0;
    let mut counter = v[idx];
    for i in 0..h {
        for j in 0..w {
            if i % 2 == 0 {
                //left to right
                field[i as usize][j as usize] = idx + 1;
                counter -= 1;
            } else {
                //right to left
                field[i as usize][(w - 1 - j) as usize] = idx + 1;
                counter -= 1;
            }
            if counter == 0 {
                idx += 1;
                if idx == n {
                    break;
                }
                counter = v[idx];
            }
        }
    }
    for i in 0..field.len() {
        let mut s = String::new();
        for j in 0..field[i as usize].len() {
            s.push_str(&field[i][j].to_string());
            if j != field[i as usize].len() - 1 {
                s.push_str(" ");
            }
        }
        println!("{}", s);
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            var n = long.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            long sum_odd = 0;
            long count_odd = 0;
            for(var i=0;i<n;i++){
                sum_odd += a[i];
                if(i%2==1&&sum_odd<=0){
                    count_odd += 1-sum_odd;
                    sum_odd = 1;
                }else if(i%2==0&&sum_odd>=0){
                    count_odd += sum_odd+1;
                    sum_odd = -1;
                }
            }
            long sum_even = 0;
            long count_even = 0;
            for(var i=0;i<n;i++){
                sum_even += a[i];
                if(i%2==0&&sum_even<=0){
                    count_even += 1-sum_even;
                    sum_even = 1;
                }else if(i%2==1&&sum_even>=0){
                    count_even += sum_even+1;
                    sum_even = -1;
                }
            }
            Console.WriteLine(Math.Min(count_odd,count_even));
        }
    }
}


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

int main(){
    int n, d, x[10][10];
    cin >> n >> d;
    for(int i=0;i<n;++i){
        for(int j=0;j<d;++j) cin >> x[i][j];
    }

    int ans = 0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            int64_t d2 = 0;
            for(int k=0;k<d;++k) d2 += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            int l=0, r=d2+1;
            while(r-l > 1){
                int64_t m = (l+r) / 2;
                if(m*m <= d2) l = m;
                else r = m;
            }
            if(l*l == d2) ++ans;
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

int main() {
    char ch;
    int cnt[26] = {};
    while(cin >> ch){
        ch = tolower(ch);
        if (isalpha(ch)){
            cnt[ch-'a']++;
        }

    }
    for (int i = 0; i < 26; i++){
        printf("%c : %d\n",i+'a',cnt[i]);
    }

    return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int p = a[0];
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (p > a[i]) {
			ans += p - a[i];
		} else {
			p = a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3992
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]

ans = 1010101010

for i in range(h):
    for j in range(w):
        now = 0
        for k in range(h):
            for l in range(w):
                now += min(abs(i - k), abs(j - l)) * a[k][l]
        
        ans = min(ans, now)

print(ans)


Measured memory_bytes: 5608
w, h, n = gets.split.map(&:to_i)
x = []
y = []
a = []
0.upto(n-1) do |i|
  x[i], y[i], a[i] = gets.split.map(&:to_i)
end
w0 = h0 = 0
0.upto(n-1) do |i|
  if a[i] == 1
    w0 = x[i] if w0 < x[i]
  elsif a[i] == 2
    w = x[i] if w > x[i]
  elsif a[i] == 3
    h0 = y[i] if h0 < y[i]
  elsif a[i] == 4
    h = y[i] if h > y[i]
  end
end
if w - w0 <= 0 || h - h0 <= 0
  puts 0
else
  puts (w - w0) * (h - h0)
end

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define rsort_v(v) std::sort(v.rbegin(), v.rend())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //

int main() {
	in(ll, K, A, B);
	ll ans = 0, C = 1, CK = 1 + K;
	//売り買いすると損
	//買えずに終わる
	if (B - A < 2 || A - 1 - 2 > K) {
		out(CK);
		return 0;
	}
	ll bc = K - (A - 1);
	C += (A - 1);
	C += (bc/2) * (B - A);
	C += bc % 2;
	out(max<ll>(C, CK));
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const ll MOD = 1000000007;

//vector< vector<int> > v (size1, vector<int>(size2) );

vector<ll> p(1005); //素因数の数を格納

//ここ速くしたい
void prime(ll n){
    FOR(i,2,1005){
        while(n%i==0){
            n/=i;
            p[i]++;
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    ll ans=1;
    ll a;
    
    FOR(i,0,1005){
        p[i]=0;
    }

    FOR(i,2,N+1){
        prime(i);
    }

    FOR(i,2,1005){
        ans*=p[i]+1;
        ans%=MOD;
    }
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 256
def fnt(arr,n): 
  
     
     
     
    count = 0
  
     
    for i in range(0,n-2): 
  
         
        k = i + 2
  
        # Fix the second element 
        for j in range(i+1,n): 
  
             
            while (k < n and arr[i] + arr[j] > arr[k]): 
                k += 1
  
             
            if(k>j): 
                count += k - j - 1
  
    return count


n=int(input())
arr=input()
arr=arr.split()
arr=list(map(int,arr))
arr.sort()
print(fnt(arr,n))



Measured memory_bytes: 3188
/* #include <iostream> */
/* using namespace std; */
#include <stdio.h>

typedef struct {
  int fst, snd;
} tuple;

int main() {
  int i,j,k,n,m,score;
  char c;
  tuple gems[20], robot, prog;
  
  while(1) {
    scanf("%d", &n); if(n==0) break;
    for(i=0;i<n;i++)
      scanf("%d %d", &gems[i].fst, &gems[i].snd);

    robot.fst = 10; robot.snd = 10; score = 0;
    
    scanf("%d", &m);
    for(i=0;i<m;i++){
      /* cin >> c >> prog.snd; */
      scanf("%*c%c %d", &c, &prog.snd);
      prog.fst = (int)(c);
      for(j=0;j<n;j++) if(robot.fst==gems[j].fst && robot.snd==gems[j].snd) score++;
      for(k=0;k<prog.snd;k++){
	switch(prog.fst) {
	case 'N': robot.snd++; break;
	case 'E': robot.fst++; break;
	case 'S': robot.snd--; break;
	case 'W': robot.fst--; break;
	default : printf("error!\n");
	}
	for(j=0;j<n;j++)
	  if(robot.fst==gems[j].fst && robot.snd==gems[j].snd) {
	    score++;
	    gems[j].fst = -1;
	    gems[j].snd = -1;
	  }
	/* printf("robot:%d,%d,(%d,%d)\n",robot.fst,robot.snd,gems[0].fst,gems[0].snd); */
      }
    }
    if(score==n)
      printf("Yes\n");
    else
      printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 584
from itertools import product
n = input()
p = []
for i in range(len(n)):
	p += list(product(["7","5","3"], repeat = i+1))
a = []
for i in p:
	if ("7" not in i) or ("5" not in i) or ("3" not in i):
		continue
	else:
		if int("".join(i)) <= int(n):
			a.append(int("".join(i)))
print (len(a))


Measured memory_bytes: 7872
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <iomanip>
          
using namespace std;
          
int main() {
double r;
cin >> r;

cout << fixed;
cout << setprecision(5);
cout << M_PI*r*r << " " << 2*M_PI*r << endl;
}


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

const int N = 1e5 + 7;

int a[N], pnt[N];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
/*	if (n % 2 == 1) {
		cout << "0";
		return 0;
	}*/
	for (int i = 1; i <= n; i++)
		pnt[i] = i;
	sort(pnt + 1, pnt + n + 1, [](int x, int y) {return a[x] < a[y]; });
/*	for (int i = 1; i <= n; i++)	
	cout << pnt[i] << " " << i << endl;*/
	int res = 0;
	for (int i = 1; i <= n; i ++) {
		if (pnt[i] % 2 != i % 2)
			res++;
	}	
	cout << res / 2;
}

Measured memory_bytes: 1024
S = input()
N = len(S)
is_s_0 = (S == S[::-1])
s1 = S[0:((N-1)//2)]
is_s_1 = (s1 == s1[::-1])
s2 = S[((N+3)//2)-1:]
is_s_2 = (s2 == s2[::-1])
if is_s_0 and is_s_1 and is_s_2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}

	q := partition(a, 0, n-1)

	for i, v := range a {
		if i != 0 {
			fmt.Printf(" ")
		}
		if i == q {
			fmt.Printf("[%d]", v)
		} else {
			fmt.Printf("%d", v)
		}
	}
	fmt.Println("")
}

func partition(a []int, p, r int) int {
	x := a[r]
	i := p
	for j := p; j < r; j++ {
		if a[j] <= x {
			a[i], a[j] = a[j], a[i]
			i++
		}
	}
	a[i], a[r] = a[r], a[i]
	return i
}

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

typedef long long ll;
const int NMAX = 2e5 + 10;
char s[NMAX],t[NMAX];
bool ispath()
{
	int len = strlen(s);
	for(register int i = 0;i < len;i++)
		if(s[i] != t[i])
			return false;
	return true;
}
int main(int argc, char const *argv[])
{

	scanf("%s%s",s,t);
	puts(ispath()?"Yes":"No");
	return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <vector>
#define rep(i,n) for(inti = 0; i < (n); ++i)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(10);
    s[0] = "pon";
    s[1] = "pon";
    s[2] = "hon";
    s[3] = "bon";
    s[4] = "hon";
    s[5] = "hon";
    s[6] = "pon";
    s[7] = "hon";
    s[8] = "pon";
    s[9] = "hon";
    cout << s[n % 10] << endl;
    return 0;
}

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

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

const int mod = 1e9+7;
const int Max = 2e8;
const double eps = 1e-4;

int main(){
    int n;
    scanf("%d",&n);
    string s;
    map<string,int>ch;
    string l[] = {"AC", "WA", "TLE", "RE"};
    for(int i=0;i<n;i++){
        cin>>s;
        ch[s]++;
    }
    for(auto it: l){
        cout<<it<< " x "<<ch[it]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3700
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()
	a := make([]int, 6000)

	for i := 0; i < 6; i++ {
		for j := 0; j < 1000; j++ {
			index := i*1000 + j
			a[index] = (100 + i) * (j + 1)
		}
	}
	sort.Ints(a)

	dp := make([][]bool, 6010)
	for i := 0; i < 6010; i++ {
		dp[i] = make([]bool, 100010)
	}
	dp[0][0] = true

	for i := 0; i < 6000; i++ {
		for j := 0; j <= x; j++ {
			if j >= a[i] {
				dp[i+1][j] = dp[i][j] || dp[i][j-a[i]]
			} else {
				dp[i+1][j] = dp[i][j]
			}
		}
	}
	if dp[6000][x] {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 647552
import math
#####sorting a dictionary#####
def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
flag=[0]*1000002
def seive_primes():
    flag[0]=flag[1]=1
    i=2
    while i*i<=1000000:
        if flag[i]==0:
            j=i*i
            while j<=1000000:
                flag[j]=1
                j+=i
        i+=1
def sqr(n):
    return n*n
def inp():
    ls=list(map(int,input().split()))
    return ls
N=int(input())
ls=inp()
if 0 in ls:
    print(0)
    exit(0)
ans=1
for i in ls:
    ans*=i
    if ans>1000000000000000000:
        print(-1)
        exit(0)
print(ans)


Measured memory_bytes: 30380
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c,n;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
bool dfs(int u,int p)
{
	int flag=0;
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p)
		{
			bool k=dfs(V[i],u);
			if(k==1)
			{
				flag++;
				if(flag>1)
				{
					printf("First\n");
					exit(0);
				}
			}
		}
	if(flag==0) return 1;
	else if(flag==1) return 0;
}
int du[MAXN];
bool check()
{
	for(int i=1;i<=n;i++)
		if(du[i]>2) return 0;
	return 1;
}
int main()
{
	int u,v;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		du[u]++,du[v]++;
		AddEdge(u,v);
		AddEdge(v,u);
	}
	if(check())
	{
		if(n&1) printf("First\n");
		else printf("Second\n");
		return 0;
	}
	bool ans=dfs(1,0);
	if(ans) printf("First\n");
	else printf("Second\n");
}

Measured memory_bytes: 2560
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		boolean p[] = new boolean[12345];
		Arrays.fill(p, true);
		p[0] = false;
		p[1] = false;

		int count = 0;

		for (int i = 0; i < 123; i++) {
			if (p[i]) {
				for (int j = i + i; j < 12345; j += i){
					p[j] = false;
				}
			}
		}

		for (int i = 0; i < 10001; i++) {
			if (p[i]) {
				count++;
			}
		}

		int pt[] = new int[count + 1];

		int cnt = 1;
		pt[0] = 0;
		for (int i = 0; i < 10001; i++) {
			if (p[i]) {
				pt[cnt] = i + pt[cnt - 1];
				cnt++;
			}
		}
//		System.out.println(Arrays.toString(pt));
		int dp[] = new int[12345];
		for (int s = 0; s < count+1; s++) {
			for (int e = s + 1; e < count+1; e++) {
				if(pt[e]-pt[s] > 10000){
					break;
				}
				dp[pt[e] - pt[s]]++;
			}
		}

		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}

			System.out.println(dp[n]);
		}
	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int a;
string s;
int main(){
	cin>>a;
	cin>>s;
	if(a>=3200){
		cout<<s<<endl;
	}else{
		cout<<"red"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
// #pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll a,b,i;
    cin>>a>>b;
    for(i=1;i<=3;i++)
    {
        if(i!=a && i!=b)
            break;
    }
    cout<<i;


}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,C,X;
    scanf("%d%d%d%d",&A,&B,&C,&X);
    int i,j,k;
    int way=0;
    for(i=0;i<=A;i++)
    {
        for(j=0;j<=B;j++)
        {
            for(k=0;k<=C;k++)
                if((i*500+j*100+k*50)==X)
                way+=1;
        }
    }
    printf("%d",way);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
ans = 0
pr = [[] for i in range(n)]
for i in range(n):
    for j in range(int(input())):
        xy = list(map(int, input().split()))
        pr[i].append(xy)

# print(pr)

for i in range(2 ** n):
    tflist = [0]*n  # 全員嘘つきと仮定　0＝嘘つき
    for j in range(n):
        if ((i >> j) & 1):
            tflist[j] = 1
    # print(tflist)
    mujun = False
    for k in range(n):
        if (tflist[k] == 1):
            # print(k)
            for m in pr[k]:
                # print(m)
                #print(tflist[m[0] - 1], m[1])
                if (tflist[m[0] - 1] != m[1]):
                    # print("mujun")
                    mujun = True
                    break
    if (not (mujun)):
        ans = max(ans, tflist.count(1))
        # print("anschange")

    # print()

print(ans)


Measured memory_bytes: 3064
N=int(input())
#N=m*k+k
#N=k(m+1)
#N%(m+1)==0 and
s=0
for t in range(1,1+int((N-1)**0.5)):
  if N%t==0:
    m=N//t-1
    if N<m*(m+1):
      s+=m
print(s)

Measured memory_bytes: 3060
N,A,B = map(int,input().split())
student = input()
passp = 0
passb = 0
ab = (A+B)
for s in student:
	if s == "a":
		if passp < ab:
			passp += 1
			print("Yes")
		else:
			print("No")
	elif s == "b":
		if passp < ab and passb < B:
			passp += 1
			passb += 1
			print("Yes")
		else:
			print("No")
	else:
		print("No")

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

int main() {
    int n;

    while (true) {
        int n; cin >> n;
        if (n == 0) break;

        vector<int> a(n);

        rep(i, n) cin >> a.at(i);
        sort(a.begin(), a.end());

        int ans = a.at(1) - a.at(0);
        for (int i = 1; i < n; i++) {
            ans = min(ans, a.at(i) - a.at(i-1));
        }
        cout << ans << endl;
    }
}


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

int main() {
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    int prev = 0; long long ans = 0;
    for (int i = 0; i < n; i++) {
        int t = prev + 1;
        int s = v[i] - t;
        if (s > 0) {
            ans += (s + t-1) / t;
            v[i] = 1;
        }
        prev = max(v[i], prev);
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void dfs(ll n, vl &ans) {
  if(n > 3234566667) return;
  ans.push_back(n);
  int l = n % 10;
  if(l != 0) dfs(n*10+l-1, ans);
  if(l != 9) dfs(n*10+l+1, ans);
  dfs(n*10+l, ans);
}

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

  int k;
  cin >> k;
  vl ans;
  REP(i,10) {
    dfs(i,ans);
  }
  sort(all(ans));
  //rep(i,k) cout << ans[i] << ' ';
  cout << ans[k-1] << endl;
}

Measured memory_bytes: 1400
import sys
input = sys.stdin.readline

def main():
  N,K = map(int,input().split())
  A = sorted(list(map(int,input().split())))
  
  # AM:Aのうち負のもの
  # AP:Aのうち正のもの
  AM = []
  AP = []
  for a in A:
    if a > 0:
      AP.append(a)
    elif a < 0:
      AM.append(a)

  INF = 10**18+1
  l = -INF
  r = INF
  while(l+1 < r):
    # 積がc未満となるペアの個数xを求める。
    # K番目の積は、それより小さい積の個数がK未満である積のうち最大のもの。
    c = (l+r)//2
    x = 0
    if c > 0:
      # cが正の場合
      # まず、正×正または負×負のペアのうち、c未満となるペアの個数を求める。
      i = len(AP)-1
      for j in range(len(AP)):
        if j >= i:
          break
        while(j < i and AP[i]*AP[j] >= c):
          i -= 1
        x += i-j
      i = 0
      for j in range(len(AM)-1,-1,-1):
        if j <= i:
          break
        while (i < j and AM[i]*AM[j] >= c):
          i += 1
        x += j-i
      # さらに、正×負のペアは必ずc未満となるので、そのペアの個数も加算する。
      x += len(AP)*len(AM)
      # さらにさらに、0と任意のaとのペアも必ずc未満となるので、そのペアの個数も加算する。
      x += (len(AP)+len(AM))*(N-len(AP)-len(AM))
      if N-len(AP)-len(AM) > 1:
        x += (N-len(AP)-len(AM))*(N-len(AP)-len(AM)-1)//2
    elif c == 0:
      # cが0の場合
      # 正×負のペアがc未満となるペアになるので、その個数を求める。
      x += len(AP)*len(AM)
    else:
      # cが負の場合
      # 正×負のペアのうち、c未満となるペアの数を求める。
      i = 0
      for j in range(len(AM)):
        while(i < len(AP) and AP[i]*AM[j] >= c):
          i += 1
        x += len(AP)-i

    #print(l,r,c,x)
    if x < K:
      l = c
    else:
      r = c
  print(l)

if __name__ == '__main__':
  main()


Measured memory_bytes: 89172
S = input()
Q = int(input())
reverse = False
front = ""
end = ""
 
for i in range(Q):
    inp = input().split()
    if inp[0] == "1":
        reverse = not reverse
    else:
        if (inp[1] == "1") ^ reverse:
            front = front+inp[2]
        else:
            end = end+inp[2]
 
if reverse:
    print(end[::-1]+S[::-1]+front)
else:
    print(front[::-1]+S+end)


Measured memory_bytes: 4468
def inWall(x,y,x1,y1,r):
	return True if ((x-x1)**2+(y-y1)**2)**0.5 <= r + 1e-9 else False

def isHide(x,y,r,a,b,c):
	D = abs(a*x+b*y+c)/(a**2+b**2)**0.5
	return True if D <= r + 1e-9 else False

def isBetween(x,y,tx,ty,sx,sy):
	a,b,c = (x-tx)**2+(y-ty)**2,(x-sx)**2+(y-sy)**2,(sx-tx)**2+(sy-ty)**2
	if c > b and c > a: return True
	a,b,c = sorted([a,b,c])
	return True if c-a-b <= 0 else False

while 1:
	n = input()
	if n == 0: break
	wall = [map(int,raw_input().split()) for i in range(n)]
	for i in range(input()):
		tx,ty,sx,sy = map(int,raw_input().split())
		a,b,c = -(ty-sy),tx-sx,sx*ty-sy*tx
		for x,y,r in wall:
			t_in,s_in = inWall(x,y,tx,ty,r),inWall(x,y,sx,sy,r)
			if t_in != s_in or (not t_in and isBetween(x,y,tx,ty,sx,sy) and isHide(x,y,r,a,b,c)):
				print "Safe"
				break
		else:
			print "Danger"

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

int main(){
  int n, m, t;
  cin >> n;
  map<int, int> ca;
  rep(i, n) {
    int x;
    cin >> x;
    ca[x]++;
  }
  cin >> m;
  while(m --){
    cin >> t;
    if(ca[t]){
      ca[t]--;
    } else{
      cout << "NO";
      return 0;
    }
  }
cout <<"YES";
}


Measured memory_bytes: 12968
#include<stdio.h>

int main(void){
	int N, M;
	scanf("%d %d", &N, &M);
	int A[1000];
	int count = 0;
	for(int i = 0; i < N; i++){
		scanf("%d", &A[i]);
		count += A[i];
	}
	double limit = (double)count / (double)(4 * M);
	int num = 0;
	for(int i = 0; i < N; i++){
		if(A[i] >= limit) num++;
	}
	
	if(num >= M) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128