akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
	int N;
	cin >> N;
	
	int H[N], i;
	for(i=0; i<N; i++){
		cin >> H[i];
	}
	
	int max=H[0], ans=1;
	for(i=1; i<N; i++){
		if(max<=H[i]){
			max = H[i];
			ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

int main()
{
  int n; cin >> n;
  vector<string> s(n);
  map<string, int> mp;
  rep(i, n) {
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
    mp[s[i]]++;
  }
  ll ans = 0;
  rep(i, n) {
    mp[s[i]]--;
    ans += mp[s[i]];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18176
#include<bits//stdc++.h>
using namespace std;
int main(){
	int a;
	while(cin>>a&&a!=-1){
		long double x1=a/2,x2;
		int i=1;
		if(a==1){
			cout<<"1.00000000000000"<<endl;
		}
		else{
			while(true){  
				x2=x1-(x1*x1*x1-a)/(3*x1*x1);
				if(abs(x2*x2*x2-a)<0.00001*a) 
				{
					printf("%.15Lf\n",x2);
					break;
				}
				x1=x2-(x2*x2*x2-a)/(3*x2*x2);
				if(abs(x1*x1*x1-a)<0.00001*a) 
				{
					printf("%.15Lf\n",x1);
					break;
				}
				i++; 
			}
		}

	}
	return 0;
}

Measured memory_bytes: 3108
import math

a, b = map(int, input().split())
c1 = a / 0.08
c2 = b / 0.1
kouho = []
for i in range(10):
  if math.floor((c2 + i) * 0.08) == a: 
    print(int(c2 + i))
    exit()
print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

typedef long long int llint;
static const double PI = 3.14159265358979323846;

int main(void){

  double a, b, h, m;
  std::cin >> a >> b >> h >> m;

  double a_x = a * std::sin(2*PI*(h/12 + m/720));
  double a_y = a * std::cos(2*PI*(h/12 + m/720));
  double b_x = b * std::sin(2*PI/60*m);
  double b_y = b * std::cos(2*PI/60*m);

  double diff_x = std::abs(a_x - b_x);
  double diff_y = std::abs(a_y - b_y);

  double sq = diff_x * diff_x + diff_y * diff_y;
  double ret = std::sqrt(sq);
  //std::cout << a_x << "  "<< a_y << " " << b_x << " " << b_y << std::endl;

  std::printf("%.16lf\n", ret);

  return 0;
}


Measured memory_bytes: 4128
n=input()
a=[map(int,raw_input().split()) for _ in xrange(n)]
t=1<<n
q=[0]*t
for m in xrange(t):
    s=0
    for i in xrange(n):
        if (m>>i)&1:
            for j in xrange(i):
                if (m>>j)&1:
                    q[m]+=a[i][j]
z=[-(1<<64)]*t
for m in xrange(t):
    z[m]=q[m]
    s=m
    while s:
        z[m]=max(z[m],z[s]+q[s^m])
        s=(s-1)&m
print z[-1]

Measured memory_bytes: 85044
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 100000
using namespace std;
ll v[LIM];
int main() {
  string s;
  cin >> s;
  ll cnt = 0;
  for (int i = 0; i < s.length()-1; i++) {
    if (s[i] != s[i+1]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 512
void main(){
	string[] label = _scanln!string();
	int[] balls = _scanln();
	int[string] ball_boxed;
	ball_boxed[ label[0] ] = balls[0];
	ball_boxed[ label[1] ] = balls[1];
	ball_boxed[ _scan!string() ] --;
	writefln("%d %d", ball_boxed[label[0]], ball_boxed[label[1]]);
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2860
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
const int N = 2e5 + 10;
vector<int>g[N];
int n, m, cnt;
int deep[N];
int fa[N];
int d[N];
int in[N];
int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 1 ; i < n + m ; i ++)
    {
        int x ,y;
        scanf("%d %d", &x, &y);
        g[x].push_back(y);
        in[y] ++;
    }
    for (int i = 1; i <= n ; i ++)
        if (!in[i]){
            int l = 0, r = 1;
            d[1] = i;
            while (l != r)
             {
                ++l;
                 for (auto v:g[d[l]])
                 if (deep[v] < deep[d[l]] + 1){
                     deep[v] = deep[d[l]] + 1;
                     fa[v] = d[l];
                     if (!(--in[v]))
                         d[++r] = v;
                 }
             }
        }
    for (int i = 1; i <= n ;  i++)
        printf("%d\n", fa[i]);
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct Combinatorics {
  using int64 = long long;
  const int64 mod = 1e9+7;
  int64 fact[202020];
  int64 invfact[202020];
  Combinatorics() {
    fact[0] = invfact[0] = 1;
    for(int i = 1; i < 202020; ++i) {
      fact[i] = fact[i-1]*i%mod;
      invfact[i] = minv(fact[i]);
    }
  }
  int64 mpow(int64 x, int64 n) const {
    int64 res = 1;
    while(n > 0) {
      if(n&1) res = res*x%mod;
      x = x*x%mod;
      n >>= 1;
    }
    return res;
  }
  int64 minv(int64 x) const {
    return mpow(x, mod-2);
  }
  int64 mfact(int64 x) const {
    return fact[x];
  }
  int64 C(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[r]%mod*invfact[n-r]%mod;
  }
  int64 P(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[n-r]%mod;
  }
}C;

int dp[17][1<<16];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m;
  cin >> n >> m;
  vint a(m);
  rep(i, m) cin >> a[i];
  reverse(all(a));

  dp[0][0] = 1;
  rep(i, m) rep(bit, 1<<n) {
    dp[i+1][bit] += dp[i][bit];
    dp[i+1][bit] %= mod;
    int l = (1<<n)-a[i];
    rep(j, n) if((bit>>j)&1) l -= (1<<j);
    rep(j, n) if(!((bit>>j)&1)) {
      dp[i+1][bit|(1<<j)] += dp[i][bit]*C.C(l, (1<<j)-1)%mod;
      dp[i+1][bit|(1<<j)] %= mod;
    }
  }

  int ans = 0;
  rep(bit, 1<<n) {
    int l = (1<<n)-1;
    rep(i, n) if((bit>>i)&1) l -= (1<<i);

    int tmp = dp[m][bit];
    rep(i, n) if(!((bit>>i)&1)) {
      tmp = tmp*C.C(l, 1<<i)%mod;
      l -= 1<<i;
    }

    if(__builtin_popcount(bit)&1) ans = (ans-tmp+mod)%mod;
    else ans = (ans+tmp)%mod;
  }

  rep(i, n) ans = ans*C.mfact(1<<i)%mod;

  cout << ans*(1<<n)%mod << endl;

  return 0;
}


Measured memory_bytes: 11648
# B
n,l = map(int,input().split())
ans=0
for i in range(1,n+1):
    ans+=(l+i-1)
if l+n-1 < 0:
    print(ans-(l+n-1))
elif l+n-1 >= 0 and l <= 0:
    print(ans)
else:
    print(ans-l)

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

using namespace std;
#define rep(i, N) for(int i=0;i<int(N);++i)
#define rep1(i, N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

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

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    map<ll, int> map;
    ll ans = 0;
    rep(i,N){
        ans += map[(i+1)-A[i]];
        map[A[i]+(i+1)]++;
    }
    cout << ans << endl;
}

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

int main(){
	int N;
	while(cin>>N,N){
		int dp[31] = {}; dp[0] = 1;
		for(int i=0;i<N;i++){
			for(int j=1;j<=3;j++) if(i+j<=N) dp[i+j] += dp[i];
		}
		printf("%d\n",((dp[N]-1)/10)/365+1);
	}
	return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

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


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

    int d, l;
    cin >> d >> l;

    int dp[10001];
    fill(dp, dp + d + 1, IINF);
    dp[0] = 0;

    rep(i, d){
        chmin(dp[i + 1], dp[i] + 1);
        if(i + l <= d){
            chmin(dp[i + l], dp[i] + 1);
        }
    }

    cout << dp[d] << endl;

    return 0;
}


Measured memory_bytes: 3176
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
    string s;
    int flg=0;
    cin >> s;
    (int)(s.size());
    int n=(s.size());
    rep(i,n){
        if(i%2==0){
            if(s[i]=='L'){
                flg=1;
            }
        }else{
            if(s[i]=='R'){
                flg=1;
            }
        }
    }
    if(flg==1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#pragma comment(linker, "/STACK: 20000000005")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

const int N = 3e5 + 5, MOD = 1e9 + 7;

string S;
int n;
ll x;
ll ans;

int main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin >> S;
    n = (int)S.size();
    S = "#" + S;
    for (int i = 1; i + 1 <= n; i++){
        //cout << i << " " << x << " " << ans << endl;
        if (S[i] == 'A'){
            x++;
            continue;
        }
        if (S[i] == 'C'){
            x = 0;
            continue;
        }
        if (S[i + 1] == 'C'){
            i++;
            ans += x;
        }
        else
            x = 0;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  if (N * A < B){
    cout << N * A << endl;
  }
  else if (N * A == B){
    cout << B << endl;
  }
  else {
    cout << B << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
char c[100005];
int num[100005][5],a[100005];
int main(){
	n=read();
	scanf("%s",c+1);
	for(register int i=1;i<=n;i++){
		for(register int j=1;j<=3;j++)num[i][j]=num[i-1][j];
		if(c[i]=='R'){a[i]=1;num[i][1]++;}
		if(c[i]=='G'){a[i]=2;num[i][2]++;}
		if(c[i]=='B'){a[i]=3;num[i][3]++;}
	}
	long long ans=0;
	for(register int now=2;now<n;now++){
		for(register int i=1;i<now;i++){
			if(a[i]==a[now])continue;
			int x=6-a[now]-a[i];
			ans+=num[n][x]-num[now][x];
			if(a[now+now-i]==x)ans--;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

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


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

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

    int K, R=0;
    cin>>K;
    for(int I = 1; I<=K; I++)
    {
        for(int J = 1; J<=K; J++)
        {
            for(int L = 1; L<=K; L++)
            {
                R+=__gcd(I, __gcd(J, L));
            }
        }
    }
    cout<<R<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9 + 7;
const ll LINF = 1LL << 60;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

ll dp[20100][256];

ll add(const ll &a) {
  if(a > 255) return 255;
  else if(a < 0) return 0;
  else return a;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  for(;;) {
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    vector<int> c(m), x(n);
    rep(i,m) cin >> c[i];
    rep(i,n) cin >> x[i];
    rep(i,20100) rep(j,256) dp[i][j] = LINF;
    dp[0][128] = 0;
    rep(i,n) rep(j,256) {
      if(dp[i][j] == LINF) continue;
      rep(k,m) {
        chmin(dp[i+1][add(j+c[k])], dp[i][j]+(add(j+c[k])-x[i])*(add(j+c[k])-x[i]));
      }
    }
    ll ans = LINF;
    rep(j,256) chmin(ans, dp[n][j]);
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 43452
#include <stdio.h>

int a, b, c;

int main()
{
  scanf("%d%d%d", &a, &b, &c);
  if(a==b && b==c && c==a) printf("1\n");
  else if(a==b || b==c || c==a) printf("2\n");
  else printf("3\n");
}

Measured memory_bytes: 128
import sys
from heapq import *
input = sys.stdin.readline
N, K = map(int, input().split())
D, H, var, res, L = [], [], set(), 0, N.bit_length()+2
for _ in range(N):
    t,d = map(int, input().split())
    D.append((d<<L)+t)
D.sort(reverse=True)
for z in D[:K]:
    d, t = z>>L, z%(1<<L)
    if t not in var: var.add(t)
    else: heappush(H, d)
    res += d
x = len(var)
res += x**2
tmp = res
for z in D[K:]:
    d, t = z>>L, z%(1<<L)
    if H and t not in var:
        tmp += d-heappop(H)+2*x+1
        x += 1
        var.add(t)
        res = max(res,tmp)
print(res)

Measured memory_bytes: 80248
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
int main()
{
  ll n,d;
  cin>>n>>d;
  ll x,y;
  ll count = 0;
  while(n--)
  {
    cin>>x>>y;
    if(x*x + y*y <= d*d)
      count++;
  }
  cout<<count<<"\n";
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cassert>


using namespace std;
int getIndex(char c){
  if(c >= 'a' && c <= 'z')return c - 'a';
  else return c - 'A' + 26;
}
int main(){
  int n;
  vector<int> key;
  string offset="";
  for(int i = 0; i < 26; i++){
    offset += 'a' + i;
  } 
  for(int i = 0; i < 26; i++){
    offset += 'A' + i;
  }
  while( cin >> n, n){
    key.clear();    
    while(n--){
      int k;
      cin >> k;
      key.push_back(k);
    }
    string s;
    cin >> s;
    for(int i = 0; i < (int)s.size();i++) {
      cout << offset[ (getIndex(s[i])+52-key[i%key.size()]) % 52];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
import sys
readline = sys.stdin.readline
#非再帰
import sys
def scc(Edge):
    N = len(Edge)
    Edgeinv = [[] for _ in range(N)]
    for vn in range(N):
        for vf in Edge[vn]:
            Edgeinv[vf].append(vn)
    
    used = [0]*N
    order = []
    for st in range(N):
        if used[st]:
            continue
        stack = [~st, st]
        while stack:
            vn = stack.pop()
            if vn >= 0:
                if used[vn]:
                    continue
                used[vn] = 1
                for vf in Edge[vn]:
                    if used[vf]:
                        continue
                    stack.append(~vf)
                    stack.append(vf)
            else:
                if used[~vn] != 2:
                    used[~vn] = 2
                    order.append(~vn)


    res = [None]*N
    used = [False]*N
    cnt = -1
    for st in order[::-1]:
        if not used[st]:
            cnt += 1
            stack = [st]
            res[st] = cnt
            used[st] = True
            while stack:
                vn = stack.pop()
                for vf in Edgeinv[vn]:
                    if not used[vf]:
                        used[vf] = True
                        res[vf] = cnt
                        stack.append(vf)
    M = cnt+1
    components = [[] for _ in range(M)]
    for i in range(N):
        components[res[i]].append(i)
    """
    tEdge = [[] for _ in range(M)]
    teset = set()
    for vn in range(N):
        tn = res[vn]
        for vf in Edge[vn]:
            tf = res[vf]
            if tn != tf and tn*M + tf not in teset:
                teset.add(tn*M + tf)
                tEdge[tn].append(tf)
    """
    return res, components


        
N, M = map(int, readline().split())
Edge = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, readline().split())
    Edge[a].append(b)

R, comp = scc(Edge)
Ans = [str(len(comp))]

for c in comp:
    Ans.append(f'{len(c)} ' + ' '.join(map(str, c)))

print('\n'.join(Ans))






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


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];
            char[] ss = sc.chararr;

            foreach(var s in ss)
            {
                if(s == 'Y')
                {
                    wr.wri("Four");
                    return;
                }
            }
            wr.wri("Three");
            return;
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  vector<int> x(n), y(n), a(n);
  rep(i,n) cin >> x[i] >> y[i] >> a[i];
  vector<vector<int>> table(h, vector<int>(w,1));
  rep(i,n) {
    if(a[i] == 1) {
      rep(j,h) {
        rep(k,x[i]) table[j][k] = 0;
      }
    }
    if(a[i] == 2) {
      rep(j,h) {
        rep(k,w - x[i]) table[j][k + x[i]] = 0;
      }
    }
    if(a[i] == 3) {
      rep(j,y[i]) {
        rep(k,w) table[j][k] = 0;
      }
    }
    if(a[i] == 4) {
      rep(j,h - y[i]) {
        rep(k,w) table[j+y[i]][k] = 0;
      }
    }
  }
  int ans = 0;
  rep(i,h) {
    rep(j,w) {
      ans += table[i][j];
    }
  }
  cout << ans << endl;
}

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

int main(){
  int i,j;
  int N,D,X,A;
  int count=0;
  cin>>N>>D>>X;
  for(i=0;i<N;i++){
    cin>>A;

    for(j=1;j<=D;j+=A){
      count++;
    }
  }

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


Measured memory_bytes: 256
#include "stdio.h"


int main()
{
	int n, i,a, max = -1000000, min = 1000000;
	long long sum=0;

	scanf("%d\n", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d ", &a);
		if (a > max) max = a;
		if (a < min) min = a;
		sum = sum + a;
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
	
}


Measured memory_bytes: 2088
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	int i,j;

	for (i = 1; i <= 9; ++i){
		for (j = 1; j <= 9; ++j){
			cout << i << 'x' << j << '=' << i*j << endl;
		} // end for
	} // end for
		
	return 0;
}

Measured memory_bytes: 0
# ??±????????????????????????????????????
L = [] # ???????????????????????????????´?
v = {} # ?¨???????????????????????????????(true????´?)
def visit(node, visited)
  unless visited[node]
    visited[node] = true
    $result[node].each do |x|
      visit(x, visited)
    end
    L << node
  end
end

#???????????°???????????°??\???
n_teams = gets.to_i
games   = gets.to_i

#???????????????hash???????????§??????
$result = {}
(1..n_teams).each{ |team| $result[team] = [] }
games.times do
  win,lose = gets.split.map(&:to_i)
  $result[win] << lose
end

# p ObjectSpace.memsize_of()
(1..n_teams).each do |team|
  visit(team, v)
end
L.reverse!

exist = L.each_cons(2).all? do |x,y|
    $result[x].include?(y)
  end

puts L
case exist
when true  then puts 0
when false then puts 1
end

Measured memory_bytes: 15628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int i,b,u;
    char s[1000];
    while(gets(s))
    {
        b=0;
        u=strlen(s);
        for(i=0;i<u;i++)
        {
            if(s[i]=='+')
                b++;
                else if(s[i]=='-')
                    b--;
        }
        printf("%d\n",b);

    }
}


Measured memory_bytes: 128
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;
const int MOD = 1000000007;

int nNode;
vector<int> g[100000+10];
int parentOf[100000+10];
int memo[100000+10][2];

void go1(int u, int p) {
  for(int v : g[u]) {
    if(v != p) {
      parentOf[v] = u;
      go1(v, u);
    }
  }
}
int solve(int u, int c) {
  int &res = memo[u][c];
  if(res < 0) {
    int p = parentOf[u];
    if(c == 0) { // B
      ll cur = 1;
      for(int v : g[u]) {
        if(v == p) {
          continue;
        }
        int tmp = solve(v, 1);
        cur = cur * tmp % MOD;
      }
      res = cur;
    } else { // W
      ll cur = 1;
      for(int v : g[u]) {
        if(v == p) {
          continue;
        }
        int tmp = solve(v, 0) + solve(v, 1);
        tmp %= MOD;
        cur = cur * tmp % MOD;
      }
      res = cur;
    }
  }
  return res;
}

int main(void) {
  scanf("%d", &nNode);
  REP(i, nNode-1) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  go1(0, 0);
  memset(memo, -1, sizeof memo);
  int res = solve(0, 0) + solve(0, 1);
  cout << res % MOD << endl;
  return 0;
}


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

#define MAX_N 101
#define MAX_E 1001

struct Edge {
  int u, v, cost;
};
int par[MAX_N], rank[MAX_N];
Edge es[MAX_E];

int V, E;

void init_union_find() {
  for(int i=0; i<V; i++) {
    par[i] = i;
    rank[i] = 0;
  }
}

int p_find(int x) {
  if(par[x] == x) return x;
  return par[x] = p_find(par[x]);
}

bool issame(int x, int y) {
  return p_find(x) == p_find(y);
}

void unite(int x, int y) {
  x = p_find(x);
  y = p_find(y);
  if(x == y) return;
  
  if(rank[x] < rank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if(rank[x] == rank[y]) {
      rank[x] ++;
    }
  }
}

bool comp(const Edge &e1, const Edge &e2) {
  return e1.cost < e2.cost;
}

int kruskal() {
  sort(es, es+E, comp);
  init_union_find();
  int res = 0;
  for(int i=0; i<E; i++) {
    Edge e = es[i];
    if(!issame(e.u, e.v)) {
      unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

int main() {
  while(cin >> V >> E && V+E) {
    for(int i=0; i<E; i++) {
      cin >> es[i].u >> es[i].v >> es[i].cost;
    }
    cout << kruskal() << endl;
  }
  
  return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[1] == 'B') s[1] = 'R'; else s[1] = 'B';
	cout << s;
	return 0;
}

Measured memory_bytes: 3612
#include <map>
#include <stdio.h>
#include <iostream>
using namespace std;
#define MAXN 500005

long long M,N;
long long L;
char c1[MAXN];
char c2[MAXN];
map <long long,char>m;

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

int main(void)
{
	cin >> N >> M;
	for(long long i=1;i<=N;i++)	cin >> c1[i];
	for(long long i=1;i<=M;i++)	cin >> c2[i];
	L = (long long)N*M/gcd(M,N);
	if(c1[1] != c2[1])
	{
		cout << "-1";
		return 0;
	}
	m[1] = c1[1];
	for(long long i=1;i<N && i*L/N+1<=L;i++)
		m[i*L/N+1] = c1[i+1];
	for(long long i=1;i<M && i*L/M+1<=L;i++)
		if(m[i*L/M+1]!='\0' && m[i*L/M+1]!=c2[i+1])
		{
			cout << "-1";
			return 0;
		}
	cout << L;
	return 0;
}

Measured memory_bytes: 10880
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M;
  cin>>N>>M;
  vector<int> P(M),Y(M);
  vector<vector <int> > data(N+1);
  for(int i=0;i<M;i++){
    cin>>P[i]>>Y[i];
    data[P[i]].push_back(Y[i]);
  }
  for(int i=0;i<N+1;i++){
    sort(data[i].begin(),data[i].end());
  }

  for(int i=0;i<M;i++){
    vector<int> &d = data[P[i]];
    int k=lower_bound(d.begin(),d.end(),Y[i])-d.begin();
    printf("%06d%06d\n", P[i], k+1);
  }
}


Measured memory_bytes: 7808
N, M = map(int,input().split())
AB = list()
good = [0]*N
count = 0
H = list(map(int,input().split()))
for _ in range(M):
  ab = list(map(int,input().split()))
  AB.append(ab)
for i in range(M):
  if H[AB[i][0]-1] > H[AB[i][1]-1]:
    good[AB[i][1]-1] = -1
  elif H[AB[i][0]-1] < H[AB[i][1]-1]:
    good[AB[i][0]-1] = -1
  elif H[AB[i][0]-1] == H[AB[i][1]-1]:
    good[AB[i][0]-1] = -1
    good[AB[i][1]-1] = -1
for i in range(N):
  if good[i]==0:
    count = count + 1
print(count)

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

int main()
{
    int i,j;
    char s[101],t[101];
    char tmp[101];
    scanf("%s",s);
    scanf("%s",t);

    for(i=strlen(s)-1;i>=0;i--){
        strcpy(tmp,s);
        s[0] = tmp[strlen(s)-1];
        for(j=1;j<strlen(s);j++){
            s[j] = tmp[j-1];
        }
        if( strcmp(s,t) == 0 ){
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");

    return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int left = a+b;
  int right = c+d;
  if(left > right){
    cout << "Left" << endl;
  }else if(left == right){
    cout << "Balanced" << endl;
  }else if(left < right){
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string S;
  cin>>S;
  ll N=S.size();
  ll P=2019;
  //桁数のMOD用意
  vector<int> X(N,0);
  X[0]=1%P;
  for(int i=1; i<N; i++){
    X[i]=X[i-1]*10;
    X[i]=X[i]%P;
  }
  //1桁目からN桁目までのあまりを用意
  vector<int> Y(N,0);
  Y[0]=(S[N-1]-'0')*X[0];
  Y[0]=Y[0]%P;
  for(int i=1; i<N; i++){
    Y[i]=(S[N-1-i]-'0')*X[i]+Y[i-1];
    Y[i]=Y[i]%P;
  }
  //1桁目からN桁目まで、都度和をとる
  ll ans=0;
  if(P==2 || P==5){
    for(int i=0; i<N; i++){
      if((S[N-1-i]-'0')%P==0)
        ans+=N-i;
    }
  }
  else{
    unordered_map<int,int> mp;
    mp[0]=1;
    for(int i=0; i<N; i++){
      ll tmp=mp[Y[i]];
      mp[Y[i]]=tmp+1;
      ans+=tmp;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5244
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    string s; cin >> s;
    int ans=0;
    if(s[0] == 'R') ans = 1;
    if(s[1]=='R') ans+=1;
    if(s[2]=='R' && s[1]=='R') ans+=1;
    if(s == "SSR") ans=1;
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int gcd(int a, int b) {
  int temp;
  if(a < b) { temp = a; a = b; b = temp; }
  while(b != 0) {
    a %= b;
    temp = a; a = b; b = temp;
  }
  return a;
}
    

int main()
{
  int a, b, k, max;
  scanf("%d %d %d", &a, &b, &k);
  max = gcd(a, b);
  while( max > 0 && k > 0) {
    if( a%max == 0 && b%max == 0) { 
      --k; if(k == 0) break; }
    --max;
  }
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <boost/integer/common_factor_rt.hpp> // gcd, lcm

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

int64_t N, X; cin >> N >> X;
VI Xx(N); 
rep(i, 0, N) {
    int64_t x; cin >> x;
    Xx[i] = abs(X - x);
}

int64_t GCD = Xx[0];
rep(i, 1, N) GCD = boost::integer::gcd(GCD, Xx[i]);
cout << GCD << endl;


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');

        var e = long.Parse(input[0]);
        var o = long.Parse(input[1]);

        long score1 = 0;
        long score2 = 0;

        if (e > 1) 
        {
            score1 = e * (e - 1) / 2;
        }

        if(o > 1)
        {
            score2 = o * (o - 1) / 2;
        }

        Console.WriteLine(score1 + score2);
        Console.ReadLine();
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};


LL dp[200][4][2];
int K;
string s;

LL rec(int t,int k, bool f){
    if(k >= 4) return 0;
    if(t == s.length()){
        if(k == K) return 1;
        else return 0;
    }
    if(~dp[t][k][f]) return dp[t][k][f];
    int mx = 9;
    if(f) mx = s[t] - '0';
    LL ret = 0;
    for (int i = 0; i <= mx; i++) {
        ret = ret + rec(t+1,k+(i!=0),f&i==mx);
    }
    return dp[t][k][f] = ret;
}


int main(){
    memset(dp,-1,sizeof(dp));
    cin >> s >> K;
    cout << rec(0,0,1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    vector<int> r(999);
    r.at(0) = 1;
    for (int i = 1; i < 999; i++) {
        r.at(i) += r.at(i - 1) + i + 1;
    }
    int dif = b - a;
    int ans = r.at(dif - 2) - a;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,mx,c,x,ls;
int main() {
	cin >> n;
	for(int i=1; i<=n; i++) {
		scanf("%d", &x);
		if(x <= ls) c++;
		else c = 1;
		ls = x;
		mx = max(mx,c);
	}
	cout << mx-1 << endl;
    return 0;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int h, w;
  cin >> h >> w;
  for (int i = 1; i <= h; i++)
  for (int j = 1; j <= w; j++) {
    string s; cin >> s;
    if (s == "snuke") {
      cout << char(j + 'A' - 1) << i << '\n';
      return;
    }
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  // ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '+') {
      ans++;
    } else {
      ans--;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

long long int a[100005], a_sum;
int m[100], n;

long long int digit2(long long int x) {
    int digit = 0;
    while (x > 1) {
        digit++;
        x = x / 2;
    }
    return digit;
}

long long int solve(long long int x){
    if (x == 0) return a_sum;

    long long int x_digit = digit2(x);
    //printf("%lld %lld\n", x, x_digit);
    long long int a = solve(x - ((long long int)1<<x_digit));
    a += ((long long int)1<<x_digit) * max(0, (n-m[x_digit]) - m[x_digit]);

    long long int b = a_sum;
    for (int i = 0; i < x_digit; i++) {
        b += ((long long int)1<<i) * max(0, (n-m[i]) - m[i]);
    }

    //printf("%lld %lld %lld\n", x, a, b);
    return max(a, b);
}
int main() {
    long long int k;

    scanf("%d%lld", &n, &k);
    long long int k_digit = digit2(k);


    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        a_sum += a[i];
        for (int j = 0; j <= k_digit; j++) m[j] += (a[i]>>j) & 1;
    }
    //printf("%lld\n", a_sum);

    //for (int j = 0; j <= k_digit; j++) printf("%d ", m[j]);
    //printf("\n");

    //printf("%lld, %lld\n", k_digit, (long long int)1 << k_digit);

    printf("%lld\n", solve(k));

    return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(s=="SUN") cout <<7;
  else if(s=="SAT") cout <<1;
  else if(s=="FRI") cout <<2;
  else if(s=="THU") cout <<3;
  else if(s=="WED") cout <<4;
  else if(s=="TUE") cout <<5;
  else if(s=="MON") cout <<6;
}
  


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int po[4000]; 
  while(1)
    {
      cin >> n;
      if(n == 0)break;
      int k;
      for(k=0;k<n;k++)
	{
	  cin >> po[k];
	}
      sort(po,po+k,greater<int>());
      int ans=0;
      for(int i=1;i<k-1;i++)
	{      
	  ans+=po[i];
	}
      cout << floor(ans/(k-2)) << endl;
    }
}

Measured memory_bytes: 0
n=int(input())
a=[]
for i in range(0,n):
    t=input()
    a.append(t)
print(f"AC x {a.count('AC')}")
print(f"WA x {a.count('WA')}")
print(f"TLE x {a.count('TLE')}")
print(f"RE x {a.count('RE')}")


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

int main() {
	int N; cin >> N;
	vector<int>A(N);
	int ans = 0;
	for (int i = 0; i < N; i++) cin >> A.at(i);
	for (int i = 0; i < N; i++) {
		if (A.at(A.at(i) - 1) == i + 1) ans++;
	}
	cout << ans / 2<< endl;
}

Measured memory_bytes: 640
def main():
    n = int(input())
    uu = [input() for _ in range(n)]
    m = int(input())
    is_closed = True
    for _ in range(m):
        t = input()
        if t in uu:
            if is_closed:
                print("Opened by", t)
            else:
                print("Closed by", t)
            is_closed = not is_closed
        else:
            print("Unknown", t)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int main(){
    int K;
    string s;
    cin >> s;
    cin >> K;
    int N = s.length();
    set<string> ss;
    for(int i=1; i<=K; i++){
        for(int j=0; j<N-i+1; j++){
            ss.insert(s.substr(j, i));
        }
    }
    auto itr = ss.begin();
    for(int i=0; i<K-1; i++){
        ++itr;
    }
    cout << * itr << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
const int N = 1e7+1;
using namespace std;
int p[N];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++){
        p[i] = 1;
    }
    for(int i=2;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            p[j]++;
        }
    }
    for(int i=1;i<=n;i++){
        sum = (sum+1ll*p[i]*i);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 42676
#%%
n = int(input())
a = 10**15


x = int(n**0.5)
x += 1
for i in range(x, 1, -1):
    if n%i == 0:
        a = i
        b = n//i
        break
#print(a, b)

if a == 10**15:
    print(n-1)
else:
    print(a+b-2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int MAX = 10005;
typedef long long ll;
vector<int> vec;
int n, m;
int arr[MAX];
map<int, int>mp;
int main(){
//	freopen("aa.txt","r",stdin);
	cin >> n;
	int ans = 0;
//	memset(arr, 0, sizeof(arr));
	int a;
	for(int i = 0; i < n; i++){
		cin >> a;
		if(mp.find(a) != mp.end()){
			mp[a]++;
			if(mp[a] == 1) ans++;
			else {
				mp[a] = 0;
				ans--;
			}
		}else{
			mp[a] = 1;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int t = ceil(n/1000.0) * 1000;
    cout<<t - n;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;

int selectionSort(int A[], int N) {
	int i, j, minj,sw;
	sw = 0;
	for (int i = 0; i<N-1; i++) {
		minj = i;
		for (int j = i + 1; j < N; j++) {
			if (A[minj] > A[j]) {
				minj = j;
			}
		}
		if (minj != i) {
			swap(A[minj], A[i]);
			sw++;
		}
		}
	return sw;
	}

int main() {
	int N, A[100],sw;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sw = selectionSort(A,N);

	for (int i = 0; i < N; i++) {
		if (i) {
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=3e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll book[maxn];
int pre[61];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n;
	cin>>n;
	rep(i,1,n)
	{
		cin>>book[i];
		rep(j,0,60)
		{
			ll tmp=1;
			tmp<<=j;
			if(tmp&book[i]) pre[j]++;
		}
	}
	ll ans=0;
	rep(i,1,n)
	{
		rep(j,0,60)
		{
			ll tmp=1;
			tmp<<=j;
			if(tmp&book[i])
			{
				pre[j]--;
				ans+=tmp%mod*(n-i-pre[j]);
				ans%=mod;
			}
			else
			{
				ans=(ans+tmp%mod*pre[j])%mod;
			}
		}
	}
	cout<<ans<<'\n';
    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    VI A(N);
    REP(i,N) cin >> A[i];
    LL ans = 1;
    VI B(3); //照準
    REP(i,N){
        int t = A[i];
        int cnt = 0;
        REP(j,3){
            if(B[j] == A[i]) cnt++;
        }
        ans *= cnt;
        ans %= MOD;
        REP(j,3){
            if(B[j] == A[i]){
                B[j]++;
                sort(B.begin(),B.end());
                break;
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 640
#include<stdio.h>

int main(void) {
	
	int a[4][3][10] = {0};
	int b, c, d, e, n, m, l, o, p;

	scanf("%d", &n);

	for (m = 0; m < n; m++) {
		scanf("%*c%d %d %d %d", &b, &c, &d, &p);
		for (e = 0; e < 4; e++) {
			for (l = 0; l < 3; l++) {
				for (o = 0; o < 10; o++) {
					if (e == b - 1 && l == c - 1 && o == d - 1) {
						a[b - 1][l][o] += p;
					}
				}
			}
		}
	}
		
	for (m = 0; m < 4; m++) {
		for (l = 0; l < 3; l++) {
			for (o = 0; o < 10; o++) {
				printf(" %d", a[m][l][o]);
			}
			printf("\n");
		}
		if(m != 3) printf("####################\n");
	}
	
	return 0;
}

Measured memory_bytes: 1856
w,h,n = map(int,input().split())
lo = [0,0]
hi = [w,h]
for i in range(n):
    a,b,x = map(int,input().split())
    if x == 1:
        if a >= lo[0]:
            lo[0] = a
    if x == 2:
        if a <= hi[0]:
            hi[0] = a

    if x == 3:
        if b >= lo[1]:
            lo[1] = b

    if x == 4:
        if b <= hi[1]:
            hi[1] = b
if hi[0] >= lo[0] and hi[1] >= lo[1]:
    print( (hi[0] - lo[0])*(hi[1] - lo[1]) )
else:
    print(0)    


Measured memory_bytes: 3064
/**
 * Created by hiramekun at 20:44 on 2019-12-08.
 */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll h, w;
    cin >> h >> w;
//    vector<vector<ll>> a(h, vector<ll>(w)), b(h, vector<ll>(w));
    int a[h][w], b[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) cin >> b[i][j];

    ll max_diff = 2 * 80 * 160;
//    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(max_diff)));
    bool dp[h][w][max_diff];
    rep(i, h) rep(j, w) rep(l, max_diff) dp[i][j][l] = false;

    ll mid = max_diff / 2;
    dp[0][0][b[0][0] - a[0][0] + mid] = true;
    dp[0][0][-b[0][0] + a[0][0] + mid] = true;

    rep(i, h) {
        rep(j, w) {
            rep(l, max_diff) {
                if (!dp[i][j][l]) continue;
                if (i + 1 <= h - 1) {
                    assert(l - b[i + 1][j] + a[i + 1][j] >= 0);
                    assert(l + b[i + 1][j] - a[i + 1][j] >= 0);
                    dp[i + 1][j][l + b[i + 1][j] - a[i + 1][j]] = true;
                    dp[i + 1][j][l - b[i + 1][j] + a[i + 1][j]] = true;
                }
                if (j + 1 <= w - 1) {
                    dp[i][j + 1][l + b[i][j + 1] - a[i][j + 1]] = true;
                    dp[i][j + 1][l - b[i][j + 1] + a[i][j + 1]] = true;
                }
            }
        }
    }
    ll ans = 1e18;
    rep(i, max_diff) {
        if (dp[h - 1][w - 1][i]) ans = min(ans, abs(i - mid));
    }
    cout << ans << '\n';
}

Measured memory_bytes: 160256
import math

def f(n):
    x = 0
    for ai in a:
        x += math.ceil(ai/n)-1
    return x <= k

def solve(ng,ok):
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        flag = f(mid)
        if flag:
            ok = mid
        else:
            ng = mid
    return ok

n,k = map(int,input().split())
a = list(map(int,input().split()))
print(solve(0,max(a)))

Measured memory_bytes: 31076
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	char z[11],x[21];
	scanf("%s",z);
	a=strlen(z);
	scanf("%d",&s);
	f=0;
	for(i=0;i<s;i++){
		scanf("%s",x);
		for(j=0;j<10;j++){
			x[j+10]=x[j];
		}
		for(j=0;j<20;j++){
			f=1;
			for(d=0;d<a;d++){
				if(j+d>=20||x[j+d]!=z[d]){
					f=0;
				}
			}
			if(f==1){
				g++;
				break;
			}
		}
	}
	printf("%d\n",g);
	return 0;
}

Measured memory_bytes: 1024