akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    int n;
    int k;
    int q;
    cin >> n;
    cin >> k;
    cin >> q;
    vector<int> a(q);
    vector<int> b(n);
    vector<int> c(n);
    REP(i, q)
    cin >> a[i];

    for (int i = 0; i < n; i++)
    {
        b[i] = k - q;
        c[i] = 0;
    }

    for (int i = 0; i < q; i++)
    {
        c[a[i] - 1] += 1;
    }

    for (int j = 0; j < n; j++)
    {
        b[j] = b[j] + c[j];
    }

    for (int i = 0; i < n; i++)
    {
        if (b[i] <= 0)
        {
            printf("No\n");
        }
        else
            printf("Yes\n");
    }
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}


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

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

    vector<ll> v;
    for (int i = 1; i <= 9; ++i) {
        v.push_back(i);
    }

    while (1) {
        if (k <= v.size()) {
            cout << v[k-1] << endl;
            return 0;
        }
        k -= v.size();
        vector<ll> old;
        swap(old, v);

        for (ll o : old) {
            int t = o % 10;
            for (int i = -1; i <= 1; i++) {
                if ((t+i) < 0 || (t+i) > 9) {
                    continue;
                }
                v.push_back(o*10+(t+i));
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	sort(a.begin(),a.end());
	vector<pii> ans;
	for(int i=1;i<n-1;++i){
		if(a.at(i)>=0){
			ans.pb(mp(a.at(0),a.at(i)));
			a.at(0)-=a.at(i);
		}
		else{
			ans.pb(mp(a.at(n-1),a.at(i)));
			a.at(n-1)-=a.at(i);
		}
	}
	ans.pb(mp(a.at(n-1),a.at(0)));
	a.at(n-1)-=a.at(0);
	cout << a.at(n-1) << endl;
	rep(i,n-1) cout << ans.at(i).first << " " << ans.at(i).second << endl;
}


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}
struct list{
	int a;
	struct list *prev;
	struct list *next;
};
struct list *head,*tail;
struct list *make(int a){
	struct list *p;
	p=malloc(sizeof(struct list));
	p->a=a;
	p->prev=NULL;
	p->next=NULL;
	return p;
}

int g[8][8];
int mark[8];
int n;

int dfs(int i){
	int j,ret=0;
	mark[i]=1;
	rep(j,n)
		if(!mark[j])break;
	if(j==n)return 1;
	rep(j,n){
		if(g[i][j]&&!mark[j]){
			ret+=dfs(j);
			mark[j]=0;
		}
	}
	return ret;
}

int main(void){
	int m,i,a,b;
	n=in();
	m=in();
	rep(i,m){
		a=in();
		b=in();
		a--;
		b--;
		g[a][b]=g[b][a]=1;
	}
	print(dfs(0));
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const string YES = "Possible";
const string NO = "Impossible";

void solve(long long N, long long L, std::vector<long long> a) {
  ll sumMax = 0;
  ll sumMaxN = -1;
  rep(n, N - 1) {
    ll tmp = a[n] + a[n + 1];
    if (sumMax < tmp) {
      sumMax = tmp;
      sumMaxN = n;
    }
  }

  if (sumMax >= L) {
    print(YES);
    rep(n, sumMaxN) { print(n + 1); }
    for (ll n = N - 1; n > sumMaxN; n--) {
      print(n);
    }
  } else {
    print(NO);
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long L;
  scanf("%lld", &L);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, L, std::move(a));
  return 0;
}


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

using namespace std;

#define debug(x) cerr << "  - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << "  - " << #x << ": " << x << "         " << #y << ": " << y << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

typedef long long ll;
const ll mod = 1e9 + 7;


int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int d, n;
	cin >> d >> n;
	if(n == 100) {
		if(d == 0) cout << 101 << endl;
		if(d == 1) cout << 10100 << endl;
		if(d == 2) cout << 1010000 << endl;
		return 0;
	}
	int r = 1;
	for(int i = 0; i < d; i++) r *= 100;
	r *= n;
	cout << r << endl;
	return 0;
} /**/

Measured memory_bytes: 256
H, W = map(int, input().split())
A = []
for h in range(H):
    tmp = list(map(int, input().split()))
    if h % 2 == 0:
        r = range(W)
    else:
        r = range(W)[::-1]

    for w in r:
        A.append((h, w, tmp[w]))

ans = []
for i in range(len(A) - 1):
    if A[i][2] % 2 != 0:
        ans.append((A[i][0] + 1, A[i][1] + 1, A[i + 1][0] + 1, A[i + 1][1] + 1))
        A[i + 1] = (A[i + 1][0], A[i + 1][1], A[i + 1][2] + 1)
print(len(ans))
for x in ans:
    print(*x)


Measured memory_bytes: 47948
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::{fastout, input, marker::*};
//use std::collections::HashSet;
use std::collections::*;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;

#[fastout()]
fn main() {
    input! {
        N:usize, mut S:[String;N]
    }
    //S.sort();
    //println!("{:?}", S);
    let emptystring = "".to_string();
    let mut m = BTreeMap::new();
    let mut max = 0;
    for s in S {
        *m.entry(s.clone()).or_insert(0) += 1;
        let k = *m.get(&s).unwrap();
        max = std::cmp::max(max, k);
    }
    for (s, v) in m.iter() {
        if *v == max {
            println!("{}", s.to_string());
        }
    }
}


Measured memory_bytes: 26012
import java.util.Scanner;


	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			long n = sc.nextLong();
			long m = sc.nextLong();
			long ret = 0;
			
			if(n>=2&&m>=2) {
				ret = (n-2)*(m-2);
			}
			if(n==1||m==1) {
				ret = n*m-2;
			}
			
			if(n==1&&m==1) {
				ret = 1;
			}
			
			System.out.println(ret);
			
		}



	}


Measured memory_bytes: 21844
N=int(input())
A=list(map(int,input().split()))
A.sort()
cnt=0
ans=1
for i,a in enumerate(A):
  #print(cnt,ans,a)
  if cnt*2>=a:    
    ans+=1
  else:
    ans=1
  cnt+=a
print(ans)
    
  

Measured memory_bytes: 84796
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);

    ll k, s;
    ll c;
    cin >> k;

    if (k % 2 == 0 | k % 5 == 0) {
        cout << -1;
        return 0;
    }

    s = 0;
    c = 0;
    while (true) {
        s *= 10;
        s += 7;
        s %= k;
        c++;
        if (s == 0) {
            break;
        }
    }

    cout << c;

    return 0;
}


Measured memory_bytes: 3620
n,m=map(int,input().split())
sw=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

ans=0
for i in range(2**n):
    f=1
    for j in range(m):
        c=0
        for x in sw[j][1:]:
            x-=1
            c+=(i>>x)&1
        if c%2!=p[j]:
            f=0
    ans+=1 if f else 0
print(ans)


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int main() {
	int a, b, c; cin >> a >> b >> c;
	bool isCan = false;
	for(int i=0; i<b; i++) {
		if(1ll * a * i % b == c) isCan = true;
	}
	puts(isCan ? "YES" : "NO");
	return 0;
}


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

int main(){
  int a,b;
  char op;
  while(1){
  cin >> a >> op >> b;
  if(op=='?')
    break;
  if(op=='+')
    cout << a+b << endl;
  if(op=='-')
    cout << a-b << endl;
  if(op=='*')
    cout << a*b << endl;
  if(op=='/')
    cout << (int)a/b << endl;
  }
  }

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

using namespace std;

#define ll long long
#define ull unsigned long long

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

    int n;
    cin >> n;
    vector<int> cnt(n, 0);
    for (int i = 1, x; i < n; i++) {
        cin >> x;
        cnt[x - 1]++;
    }
    for (int i = 0; i < n; i++) cout << cnt[i] << '\n';
}


Measured memory_bytes: 3992
#include<stdio.h>
#include<iostream>
#include<cstdlib>
using namespace std;

int N;
long long int sum = 0,ans = 0;
int a[112345];
int main (){
    cin >> N;
    int cnt = 0;
    int zero = 0;
    int m = 1023456789;
    for(int i=0; i<N; i++) {
        cin >> a[i];
        int x = abs(a[i]);
        sum += x;
        if( a[i] < 0 ) cnt++;
        m = min( m,x);
    }
    cout << ( cnt % 2 ? sum - (m * 2) : sum) << endl;
    return 0;
}


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

int main(){
     int x;
     scanf("%d", &x);
     char str[1000000];
     sprintf(str,"%d", x);
     int a, soma = 0;
     for (int i = 0; i < strlen(str); ++i){
          soma += (int)str[i] - 48;

     }
     if (x%soma == 0){
          printf("Yes\n");
     } else {
          printf("No\n");
     }
     return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll unsigned long long 
#define MOD 1000000007
using namespace std;
ll a[2000005];
ll S[2000005];
ll add(ll a,ll b){
	return (a%MOD+b%MOD)%MOD;
}
ll mul(ll a,ll b){
	return (a%MOD*b%MOD)%MOD;
}
int main(){
	int n ;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	S[1] = a[1];
	for(int i=2;i<=n;i++){
		S[i] = add(S[i-1],a[i]);
	}
	ll ans = 0;
	for(int i=1;i<=n-1;i++){
		// 注意大整数取模的时候需要先加上MOd防止暴毙。 
		ans = add(ans,mul(a[i],(S[n]-S[i]+MOD)%MOD))%MOD;
	}
	cout<<ans;
//	
//	ull n,sum = 0;
//    cin >> n;
//    for(int i = 1;i <= n;i++) cin >> arr[i];
//    for(int i = 1;i <= n;i++) ans[i] = (arr[i]+ans[i-1]);
//    for(int i = 1;i <= n;i++) sum = ((sum + arr[i]*((ans[n]-ans[i])%mod))%mod)%mod;
//    cout << sum << endl;
} 

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    map<ll, int, greater<ll>> mp;
    mp[0] = 4;

    rep(i, n)
    {
        int a;
        cin >> a;
        if (!mp[a])
            mp[a] = 0;
        mp[a]++;
    }

    ll ans[2];
    int i = 0;

    for (auto e : mp)
    {
        if (e.second >= 2)
        {
            ans[i] = e.first;
            i++;
            if (e.second >= 4)
            {
                ans[i] = e.first;
                i++;
            }
        }
        if (i >= 2)
            break;
    }

    OP(ans[0] * ans[1]);

    return 0;
}

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

public class Program333
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());

        var xy = Console.ReadLine().Split(' ');
        var f = new Dictionary<int, int>();
        var s = new Dictionary<int, int>();
        for (int i = 0; i < n; i = i + 2)
        {
            var n1 = int.Parse(xy[i]);
            var n2 = int.Parse(xy[i + 1]);
            int tryGetResult, tryGetResult2;
            f[n1] = f.TryGetValue(n1, out tryGetResult) ? tryGetResult + 1 : 1;    // keyの値インクリメント
            s[n2] = s.TryGetValue(n2, out tryGetResult2) ? tryGetResult2 + 1 : 1;    // keyの値インクリメント
        }

        var second = new KeyValuePair<int, int>();
        foreach (var skv in s)
        {
            if (second.Value < skv.Value)
            {
                second = skv;
            }
        }

        var fsMaxCount = 0;
        foreach (var kv in f)
        {
            var sMaxCount = 0;
            if (kv.Key != second.Key)
            {
                sMaxCount = second.Value;
            }
            else
            {
                foreach (var skv in s)
                {
                    if (skv.Key != kv.Key)
                    {
                        sMaxCount = Math.Max(sMaxCount, skv.Value);
                    }
                }

            }

            fsMaxCount = Math.Max(fsMaxCount, kv.Value+sMaxCount);
        }


        var result = n - fsMaxCount;
        Console.WriteLine(result);


    } // Main
}     // Class





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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &x:a)cin>>x;
	a.erase(unique(a.begin(),a.end()),a.end());
	cout << a[0] ;
	for(int i=1;i<a.size();i++){
		cout << " " << a[i];
	}
	cout << endl;
}


Measured memory_bytes: 3092
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    var x = 1L
    var ans = Long.MAX_VALUE
    while (x * x <= n) {
        if (n % x == 0L) {
            val y = n / x
            ans = Math.min(ans, (x - 1) + (y - 1))
        }
        x++
    }
    println(ans)
}

Measured memory_bytes: 31392
import math

A, B, H, M = map(int, input().split())

jishin = 360 * (H + M/60) / 12
funshin = 360 * (M/60)

x_j = A * math.cos(math.radians(jishin))
y_j = A * math.sin(math.radians(jishin))

x_f = B * math.cos(math.radians(funshin))
y_f = B * math.sin(math.radians(funshin))

print(
  math.sqrt((x_j - x_f) ** 2 + (y_j - y_f) ** 2)
)

Measured memory_bytes: 9580
n,m = map(int, input().split())

lmin = 1
rmax = n
finish = False
for i in range(m):
    l, r = map(int, input().split())

    if l > lmin:
        lmin = l

    if r < rmax:
        rmax = r
    
    if rmax < lmin:
        finish = True
        

if finish:
    print(0)
else:
    print(rmax - lmin + 1) 

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 500001
int main(void) {
	int N, K;
	scanf("%d%d", &N, &K);
	printf("%d\n", N % K != 0);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef pair<int,int> P;

int H,W,dx[]={1,0,-1,0},dy[]={0,1,0,-1};
char c[100][100],sc;

int main(){
	while(cin>>H>>W){
		if(!H)return 0;
		for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>c[i][j];
		queue<P> q;
		int ans=0;
		for(int i=0;i<H;i++)for(int j=0;j<W;j++){
			if(c[i][j]!='.'){q.push(P(i,j));sc=c[i][j];ans++;}
			while(!q.empty()){
				int sy=q.front().first,sx=q.front().second;
				q.pop();
				c[sy][sx]='.';
				//cout<<"("<<sy<<","<<sx<<")"<<sc<<endl;
				for(int i=0;i<4;i++){
					int ty=sy+dy[i],tx=sx+dx[i];
					if(ty<0||ty>=H||tx<0||tx>=W||c[ty][tx]!=sc)continue;
					q.push(P(ty,tx));
					c[ty][tx]='.';
				}
				/*for(int i=0;i<H;i++){
					for(int j=0;j<W;j++)cout<<c[i][j];cout<<endl;
				}*/
			}
		}
		cout<<ans<<endl;
	}
}

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

using ll = long long;

#define vl vector<long long>
using pll = pair<long long, long long>;
#define __ <<'\n'
#define _ << ' '
#define all(x) (x).begin(), (x).end()

void error()
{
    cout << "-1";
    exit(0);
}

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

    vector<ll> a(4);
    for (auto i = 0; i < 4; i++)
        cin >> a[i];
    
    sort(all(a));
    if (a[0] == 1)
        if (a[1] == 4)
            if (a[2] == 7)
                if (a[3] == 9)
                {
                    cout << "YES";
                    return 0;
                }
    
    
    cout << "NO";
    return 0;
}

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

int main(){
    vector<int> ar(10);
    int i;
    for(i=0;i<10;i++) cin >> ar[i];
    sort(ar.begin(),ar.end());
    for(i=9;i>=7;i--) cout << ar[i] << endl;
    return 0;
}

Measured memory_bytes: 0
#import <stdio.h>
#import <stdlib.h>
#define ABS(a) ((a)>0?(a):(-(a)))
#define MIN(a,b) ((a)<(b)?(a):(b))

long minus(long a, long b, long c) {
    return (b-a)*(c-b)<0 ? 2*MIN(ABS(b-a),ABS(c-b)) : 0;
}

int main() {
    long N;
    scanf("%ld", &N);
    long *A = (long*)malloc(N * sizeof(long));
    long *MINUS = (long*)malloc(N * sizeof(long));

    A[0] = 0;
    long n;
    long i = 1;
    long SUM = 0;
    long current = 0;
    while (scanf("%ld", &n) != EOF) {
        A[i]=n;
        SUM += ABS(n-current);
        current = n;
        if (i>=2) {
            MINUS[i-1] = minus(A[i-2], A[i-1], A[i]);
        }
        i++;
    }
    SUM += ABS(current);
    MINUS[N] = minus(A[N-1],A[N],0);

    for (i=1;i<=N;i++) {
        printf("%ld\n", SUM-MINUS[i]);
    }
}


Measured memory_bytes: 10184
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, d; cin >> n >> d;
	vector<tuple<int,int,int>> v;
	rep(i, n){
		int x, y, z; cin >> x >> y >> z;
		v.emplace_back(z, x, y);
	}
	sort(all(v));
	map<int, int> xs, ys;
	ll ans = 0;
	
	for(int i = 0, j = 0; i < n; i++){
		while(j < n && get<0>(v[i]) + (ll)d >= get<0>(v[j])){
			xs[get<1>(v[j])]++;
			ys[get<2>(v[j])]++;
			j++;
		}
		if(xs.size() && ys.size()){
			auto l = xs.begin(), r = xs.end(); --r;
			auto L = ys.begin(), R = ys.end(); --R;
			ans = max(ans, (r->first - l->first) * (ll)(R->first - L->first));
		}
		if(--xs[get<1>(v[i])] == 0) xs.erase(get<1>(v[i]));
		if(--ys[get<2>(v[i])] == 0) ys.erase(get<2>(v[i]));
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 17044
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int m, d;
    cin >> m >> d;

    int count = 0;
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= d; j++)
        {
            const int d0 = j % 10;
            const int d10 = j / 10;
            if (d0 >= 2 && d10 >= 2 && d0 * d10 == i)
            {
                count++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, K: int):
    if K % 2 == 0:
        d = N // K
        dd = (N + K // 2) // K
        print(d ** 3 + dd ** 3)
    else:
        d = N // K
        print(d ** 3)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5944
#include<stdio.h>

int main(void){

	int n,a[200000];
	int i;
	int max;
	int next;

	scanf("%d",&n);

	max = 0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i] > max){
			next = max;
			max = a[i];
		}else if(a[i] > next){
			next = a[i];
		}
	}
	
	for(i=0;i<n;i++){
		if(max == a[i]){
			printf("%d\n",next);
		}else{
			printf("%d\n",max);
		}

	}

	return 0;
}

Measured memory_bytes: 2304
//abc171_f.cpp
//Sun Jun 21 20:54:45 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

//nCk を1000000007で割った余りの計算。
const ll MAX = 2000010;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mod_pow(ll x, ll n, ll mod){
	if (n==0){
		return 1;
	}
	ll res = mod_pow(x*x%mod,n/2,mod);
	if (n&1){
		res = res * x % mod; //nが奇数の場合はxを余分にかける。
	}
	return res;
}

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

	ll length = (ll)s.length();

	COMinit();
	ll ans = 0;
	for (ll i=length-1;i<length+k;i++){
		ll tmp = COM(i,length-1);
		tmp = tmp * mod_pow(25LL,i-length+1,MOD)%MOD;
		tmp = tmp * mod_pow(26LL,length+k-i-1,MOD)%MOD;
		ans = (ans + tmp)%MOD;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 51160
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

int main(){
    int N,K;cin>>N>>K;
    ll h;vec H;
    for(int i=0;i<N;i++){
        cin>>h;
        H.push_back(h);
    }
    sort(H.begin(),H.end());
    if(N-K<=0){
        cout<<0<<endl;
        return 0;
    }    
    ll ans=0;
    for(int i=0;i<N-K;i++){
        ans+=H[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3444
using System;
using System.Linq;

class prog{
  static void Main(){
    
    int[] i = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int[] s = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1};
    Console.WriteLine(Array.IndexOf(s, i[0]) > Array.IndexOf(s,i[1]) ? "Alice" : Array.IndexOf(s, i[0]) == Array.IndexOf(s, i[1]) ? "Draw" : "Bob");
    
  }
}

Measured memory_bytes: 13280
# -*- coding: utf-8 -*-
#ABC105C
import sys

s = input()
k = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

for i in range(0,k):
	if(s[i]!="1"):
		print(s[i])
		sys.exit()
print("1")

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, H, W;
  cin >> N >> H >> W;
  long ans = 0;
  rep (i, N) {
    long A, B;
    cin >> A >> B;
    if (A >= H and B >= W) ans++;
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
x1,y1,x2,y2=map(int,input().split())
d1=[x2-x1,y2-y1]
d2=[-d1[1],d1[0]]
r3=[x2+d2[0],y2+d2[1]]
r4=[r3[0]-d1[0],r3[1]-d1[1]]
print(str(r3[0])+' '+str(r3[1])+ ' '+str(r4[0])+ ' '+str(r4[1]))

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

int main()
{
	int n, x;
	cin >> n >> x;
	long long int ans = 0;
	int p = 0;
	for(auto i = 0; i < n; ++i){
		int a;
		cin >> a;
		int b = max(0, a + p - x);
		ans += b;
		p = a - b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<vector>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


class C{
	public:
	vector<int> num;
	vector<char> calc;
	
	bool emp(){
		bool nu = false;
		rep(i,calc.size())if(calc[i]=='*')nu=true;
		return !nu;
	}
	
	void docalc(int i)
	{
		if(calc[i]=='+'){
			num [i] = num[i]+num[i+1];
		}else{
			num[i] = num[i]*num[i+1];			
		}
		
		num.erase(num.begin()+i+1);
		calc.erase(calc.begin()+i);
	}
};


int calc2(C c){
	while(c.calc.size()!=0){
		
		c.docalc(0);
	}
	return c.num[0];
}
int calc1(C c){
	while(!c.emp()){
		
		rep(i,c.calc.size()){
			if(c.calc[i]=='*'){
				c.docalc(i);
				break;
			}
		}
	}
	
	return calc2(c);
}

int main(){
	string s;
	int n;
	
	cin>>s>>n;
	
	C c;
	rep(i,s.size()){
		if(i%2==0){
			c.num.push_back(s[i]-'0');
		}else{
			c.calc.push_back(s[i]);
		}
	}
	
	
	int n1 = calc1(c);
	int n2 = calc2(c);
	
	char ans = '*';
	if(n1==n && n2==n) ans = 'U';
	if(!(n1==n) && !(n2==n)) ans = 'I';
	if(n1==n && !(n2==n)) ans = 'M';
	if(!(n1==n) && n2==n) ans = 'L';
	
	printf("%c\n",ans);
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int MAX_N = 1 << 17;

class Bucket{
  public:
  vector<ll> buc,v;
  ll N,sqn,K;
  Bucket(){};
  Bucket(ll n){
    N = n;
    sqn = sqrt(N);
    K = (n + sqn - 1) /sqn;
    buc.resize(K);
    v.resize(K * sqn);
  }
  void add(int x,int y){
    v[x] += y;
    ll sum = 0;
    int k = x / sqn;
    for(int i = k * sqn; i < (k + 1) * sqn;++i){
      sum += v[i];
    }
    buc[k] = sum;
  }
  ll query(int x,int y){
    ll res = 0;
    for (int k = 0; k < K; ++k) {
      int l = k * sqn, r = (k + 1) * sqn;
      if (r <= x || y <= l)
        continue;
      if (x <= l && r <= y) {
        res += buc[k];
      } else {
        for (int i = max(x, l); i < min(y, r); ++i) {
          res += v[i];
        }
      }
    }
    return res;
  }
  void Debug(){
    for(int i = 0; i < N;++i){
      cout << buc[i/sqn] << ' ';
    }
    cout << endl;
    for(int i = 0; i < N;++i){
      cout << v[i] << ' ';
    }
    cout << endl;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,q;
  cin >> n >> q;
  Bucket buc(n+1);
  ll a,s,t,x;
  rep(i,q){
    cin >> s >> t >> x;
    if(s){
      cout << buc.query(t-1,x)<<endl;
    }
    else{
      buc.add(t-1,x);
    }
  }
  /* buc.Debug(); */
  return 0;
}

Measured memory_bytes: 3548
#include<iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  
  int H[N];
  for(int i=0; i<N; i++){
    cin >> H[i];
  }
  
  int count;
  count = 1; // added first mountain
  
  int max_H;
  max_H = H[0];
  
  for(int i=1; i<N; i++){
    if(H[i] >= max_H){
      count += 1;
      max_H = H[i];
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, m = i_map()
    num_list = i_row_list(m)

    num_list = sorted(num_list, key=lambda x: x[1])

    count = 0
    tmp = 0
    for num in num_list:
        if num[0] < tmp:
            continue
        tmp = num[1]
        count += 1

    print(count)
    
if __name__ == '__main__':
    main()


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

MOD = 1000000007  # type: int


def solve(N: int, K: int, A: "List[int]"):
    al = [0] * N
    bl = [0] * N
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            elif A[i] > A[j]:
                al[i] += 1
                if i < j:
                    bl[i] += 1

    ans = 0
    for i in range(N):
        ans += ((K*(K-1)//2)*al[i] + K*bl[i]) % MOD

    
    print(ans%MOD)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 1 - 0 + 1)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3308
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int ans = 1000000000;
  for (int i = -100; i <= 100; i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) {
      sum += (a[j] - i) * (a[j] - i);
    }
    ans = min(sum, ans);
  }

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

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

int main(){
  int n;
  cin >> n;
  long c[n-1];
  long s[n-1];
  long f[n-1];
  for(int i = 0; i < n-1; i++){
    cin >> c[i] >> s[i] >> f[i];
  }
  for(int i = 0; i < n-1; i++){
    long t = 0;
    for(int j = i; j < n-1; j++){
      if(s[j]>t){
        t = s[j];
      }else if(t%f[j]!=0){
        t = (t/f[j]+1)*f[j];
      }
      t += c[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------


int main(){
  vector<string> st = {"dream","dreamer","erase","eraser"};
  string S;
  cin >> S;
  for(int i=0; i<4; i++){
    reverse(st[i].begin(),st[i].end());
  }
  reverse(S.begin(),S.end());
  int i=0;
  while(1){
    bool changed = false;
    for(int j=0; j<4; j++){
      if(S.substr(i,st[j].size()) == st[j]){
        i += st[j].size();
        changed = true;
        break;
      }
    }
    if(!(changed) || i==S.size()){
      break;
    }
  }
  if(i == S.size()){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> A(M);
  rep(i,M) cin >> A[i];
  int l=0,r=0;
  rep(i,M){
    if(A[i]<X) r++;
    else l++;
  }
  cout << min(l,r) << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    

    let mut ans = "No";
    for c in s.chars() {
        if c == '7' {
            ans = "Yes";
            break;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2136
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
typedef unsigned long long ull;
typedef signed long long sll;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF
#define BIG_PRIME 1000000007


int main()
{
  ull i,j,k,l,N,K;
  cin >> N >> K;
  vector<vector<ull>> a_k1;
  vector<vector<ull>> a_k2;
  vector<vector<vector<ull>>> a_n;
  a_n.resize(60);
  a_k1.resize(N);
  a_k2.resize(N);
  for(k=0;k<60;++k)
  {
    a_n[k].resize(N);
  }
  for(i=0;i<N;++i)
  {
    a_k1[i].resize(N);
    a_k2[i].resize(N);
    for(k=0;k<60;++k)
    {
      a_n[k][i].resize(N);
    }
    for(j=0;j<N;++j)
    {
      cin >> a_n[0][i][j];
      a_k1[i][j]=(i==j);
    }
  }
  l=0;
  while(K)
  {
    if(K&1)
    {
      for(i=0;i<N;++i)
      {
        for(j=0;j<N;++j)
        {
          a_k2[i][j]=0;
          for(k=0;k<N;++k)
          {
            a_k2[i][j]=(a_k2[i][j]+a_k1[i][k]*a_n[l][k][j])%BIG_PRIME;
          }
        }
      }
      for(i=0;i<N;++i)
      {
        for(j=0;j<N;++j)
        {
          a_k1[i][j]=a_k2[i][j];
        }
      }
    }
    K>>=1;
    if(K)
    {
      for(i=0;i<N;++i)
      {
        for(j=0;j<N;++j)
        {
          a_n[l+1][i][j]=0;
          for(k=0;k<N;++k)
          {
            a_n[l+1][i][j]=(a_n[l+1][i][j]+a_n[l][i][k]*a_n[l][k][j])%BIG_PRIME;
          }
        }
      }
      ++l;
    }
  }
  ull walk=0;
  for(i=0;i<N;++i)
  {
    for(j=0;j<N;++j)
    {
      walk = (walk+a_k1[i][j])%BIG_PRIME;
    }
  }
  cout << walk;
  return 0;
}

Measured memory_bytes: 1536
for t in range(int(input())):
	a,b,c,d=map(int,input().split(' '))
	l,x,y,o=(a+b)//(min(a,b)+1),0,0,""
	if a*l<=b:y=a+b
	elif b*l<=a:x=a+b
	else:x,y=(a*l-b)//(l-1),(b*l-a)//(l-1)
	for i in range(c,d+1):o+="AB"[i%(l+1)==0] if i<=x else "BA"[(a+b-i+1)%(l+1)==0] if a+b-i+1<=y else "AB"[a-x+x//(l+1)-y//(l+1)==0]
	print(o)

Measured memory_bytes: 3188
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	var b bool
	for i := 0; i < N; i++ {
		w := ""
		fmt.Scan(&w)
		if w == "Y" {
			b = true
			break
		}
	}
	if b {
		fmt.Println("Four")
	} else {
		fmt.Println("Three")
	}

}

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

using namespace std;

int permutation( int n, int ar[]){
    int arr[n+1],k = 1;
    for (int i = 1; i <= n; i++)
    {
       arr[i-1] = i;
    }
    
    do{
        if(equal(arr,arr+n,ar)) break;
        k++;
    }
    while(next_permutation(arr,arr+n));
        
    
    return k;
    
}
int main(){
    
    int a;

    cin>>a;

    int vec1[a],vec2[a];
    for (int i = 0; i < a; i++)
    {
        cin>>vec1[i];
    }
    for (int i = 0; i < a; i++)
    {
        cin>>vec2[i];
    }
    
   
    cout<<abs(permutation(a,vec1) -permutation(a,vec2))<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pqM = priority_queue<int>;
using pqm = priority_queue<int,vector<int>,greater<int>>;
using q = queue<int>;

int main() {
   int n; ll k;
   cin >> n >> k;
   vector<int> a(n);
   rep(i,n) cin >> a[i];

   vector<int> s;
   vector<int> ord(n+1,-1);
   int c = 1,l = 0;
   {
       int v = 1;
       while (ord[v] == -1) {
           ord[v] = s.size();
           s.push_back(v);
           v = a[v - 1];
       }
       c = s.size() - ord[v];//周期
       l = ord[v];//例外
   }

    if(k < l) cout << s[k] << endl;
    else{
        k -= l;
        k %= c;
    cout << s[l+k] << endl;
    }
return 0;
}


Measured memory_bytes: 5824
A,B = map(int,input().split(" "))

def getXor(n):
    ret = 0
    i = 1
    while True:
        div,mod = divmod(n,i)
        flg = i * (div // 2)
        if div % 2 == 1:
            flg += (mod + 1)
        if flg % 2 == 1:
            ret += i
        i *= 2
        if i > n:
            break
    
    return ret

print(getXor(A-1) ^ getXor(B))

Measured memory_bytes: 38356
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main (){
  int N;

  while(cin >> N && N > 0){
    vector<int> score(N, 0);
    rep(i,N){
      cin >> score[i];
    }

    sort(ALL(score));

    int ave = accumulate(score.begin() + 1, score.end() - 1, 0)/ (N-2);

    cout << ave << endl;
  }

  return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;
struct Edge { int from, to; long long cost; };
using Graph = vector<vector<Edge>>;

template<typename T = long long>
T mod_pow(T a, T x, T md) {
    T res = 1;
    while(x) {
        if(x & 1) res = res * a % md;
        a = a * a % md;
        x >>= 1;
    }
    return res;
}

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

    ll m,n;
    cin>>m>>n;
    cout<<mod_pow(m,n,MOD)<<endl;
}


Measured memory_bytes: 3176
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    int N;
    Scanner scanner = new Scanner(System.in);
    Node[] nodes;
    long[] memo;

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

    void compute() {
        N = scanner.nextInt();
        nodes = new Node[N];
        memo = new long[N];
        for (int i = 0; i < N; i++) {
            nodes[i] = new Node(i);
        }
        for (int i = 0; i < N; i++) {
            memo[i] = -1;
        }
        for (int i = 0; i < N - 1; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            long c = scanner.nextLong();
            nodes[a - 1].add(nodes[b - 1], c);
            nodes[b - 1].add(nodes[a - 1], c);
        }
        int Q = scanner.nextInt();
        int K = scanner.nextInt();

        long[] costs = new long[N];
        for (int i = 0; i < N; i++) {
            costs[i] = cost(nodes[i], nodes[K - 1], null);
        }

        for (int i = 0; i < Q; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            System.out.println(costs[x - 1] + costs[y - 1]);
        }

    }

    long cost(Node x, Node y, Node prev) {
        if (memo[x.num] != -1) {
            return memo[x.num];
        }
        if (x == y) {
            memo[x.num] = 0;
            return 0;
        }
        for (int i = 0; i < x.nexts.size(); i++) {
            Node next = x.nexts.get(i);
            if (prev == next) {
                continue;
            }
            long nextCost = cost(next, y, x);
            if (nextCost != -1) {
                memo[x.num] = nextCost + x.distances.get(i);
                return nextCost + x.distances.get(i);
            }
        }
        return -1;
    }

    class Node {

        int num;
        List<Node> nexts = new ArrayList<>();
        List<Long> distances = new ArrayList<>();

        void add(Node next, long distance) {
            nexts.add(next);
            distances.add(distance);
        }

        Node(int num) {
            this.num = num;
        }
    }
}


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

int main() {
  int A[100], N, max1 = -1;

  cin >> N;

  for (int i = 0; i < N; i++)
    cin >> A[i];

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      max1 = max(abs(A[i] - A[j]), max1);
    }
  }

  cout << max1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll s,w;
int main(){FAST;
cin>>s>>w;
if(w>=s)cout<<"unsafe\n";
else cout<<"safe\n";
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


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

typedef long long ll;

int N_box[200001];

int main()
{
    int n;
    cin >> n;
    vector<int> a, b;
    for (int i = 0; i < n; i++)
    {
        int tmp; cin >> tmp;
        a.push_back(tmp);
    }

    // nから0を見ていく
    for (int i = n; i > 0; i--)
    {
        int tmp = 0;
        for (int j = i; j <= n; j+=i)
        {
            tmp += N_box[j];
        }
        //printf("[%d] a_left = %d a_right = %d \n", i, tmp, a[i-1]);
        if (tmp % 2 != a[i - 1]){
            N_box[i] = 1;
            b.push_back(i);
        } else {
            N_box[i] = 0;
        }
        
    }
    
    cout << b.size() << endl;
    for(auto i: b){
        cout << i << " ";
    }
    cout << endl;

}



Measured memory_bytes: 3444
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (N < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}
}


Measured memory_bytes: 3620