akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define x first
#define y second

typedef long long ll;
typedef std::pair<ll,ll> pii;

const int N=201000;

ll A[N];
int n;

int main()
{
	scanf("%d",&n);

	for(int i=1;i<=n;i++)
		scanf("%lld",A+i);
	for(int i=1;i<=n;i++)
		A[i]+=A[i-1];


	ll ans=1009000000000000000ll;

	int l=1,r=3;

	for(int i=2;i<=n-2;i++)
	{
		if(r<=i)r=i+1;

		while(l<i-1)
		{
			ll a=A[l],b=A[i]-A[l];
			ll c=A[l+1],d=A[i]-A[l+1];

			if(std::abs(a-b)>std::abs(c-d))l++;
			else break;
		}
		while(r<n-1)
		{
			ll a=A[r]-A[i],b=A[n]-A[r];
			ll c=A[r+1]-A[i],d=A[n]-A[r+1];

			if(std::abs(a-b)>std::abs(c-d))r++;
			else break;
		}


//		printf("%d - %d - %d\n",l,i,r);

		ll a=A[l],b=A[i]-A[l],c=A[r]-A[i],d=A[n]-A[r];

//		printf("%lld %lld %lld %lld\n",a,b,c,d);
//		printf("--------------\n");

		ll mx=std::max(std::max(a,b),std::max(c,d));
		ll mn=std::min(std::min(a,b),std::min(c,d));

		ans=std::min(ans,mx-mn);
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  vector<int> a(n);
  for(int i=0;i<n;i++){
    scanf("%d",&(a[i]));
  }
  sort(a.begin(),a.end());
  bool ans;
  if(n%3!=0){
    ans=(a[n-1]==0);
  }
  else{
    ans=(a[0]==a[n/3-1]&&a[n/3]==a[n/3*2-1]&&a[n/3*2]==a[n-1]&&(a[0]^a[n/3]^a[n/3*2])==0);
  }
  puts(ans?"Yes":"No");
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll N;
    cin >> N;
    if (N/10 == 9 | N % 10 == 9) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
    return 0;
}


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

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n; cin >> n;
	cout << arr[n - 1] << endl;
}

Measured memory_bytes: 256
void main()
{
    long n = rdElem;
    long[] l = rdRow;

    l.sort!"a > b";

    writeln(l[0] < l[1..$].sum ? "Yes" : "No");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

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

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    int x,a,b;cin >>x>>a>>b;
    if(abs(a-x)<abs(b-x))puts("A");
    else puts("B");
    return 0;
}

Measured memory_bytes: 3632
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

signed main(){
/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/
  int N;
  cin >> N;

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

  long long money = 1000;
  for (int i = 0; i < N - 1; i++) {
    long long stocks = 0;
    if (A[i] < A[i + 1]) stocks = money / A[i];
    money += (A[i + 1] - A[i]) * stocks;
  }
  cout << money << endl;

  return 0;
}

Measured memory_bytes: 3208
#include <stdio.h>

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

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcountll
#define setbitcnt __builtin_ctz
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define roundup(a,b)  std::cout << std::fixed;std::cout << std::setprecision(b); std::cout << a
const int siz = (1e6 + 10);
const int logi = 21;
const double epsilon = 1e-6;
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}



signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	int val = 0;
	while(t--)
	{
		int d,t,s;
		cin>>d>>t>>s;

		if(t*s >= d)
		{
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
	}
}

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

public class Main {
	public static void main(String[] args) {
		FastScanner br = new FastScanner();
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
		int n1 = br.ni();
		int n2 = br.ni();
		System.out.println((int)(n2*Math.pow((n2-1),n1-1)));
		pw.close();
	}
}

class FastScanner {
	BufferedReader br;
	StringTokenizer st;

	public FastScanner(String s) {
		try {
			br = new BufferedReader(new FileReader(s));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public FastScanner() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	ArrayList<Integer>[] ng(int n, int e) {
		ArrayList<Integer>[] adj = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			adj[i] = new ArrayList<Integer>();
		}
		for (int i = 0; i < e; i++) {
			int a = ni() - 1;
			int b = ni() - 1;
			adj[a].add(b);
			adj[b].add(a);
		}
		return adj;
	}

	Integer[] nIa(int n) {
		Integer[] arr = new Integer[n];
		for (int i = 0; i < n; i++) {
			arr[i] = ni();
		}
		return arr;
	}

	int[] nia(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = ni();
		}
		return arr;
	}

	Long[] nLa(int n) {
		Long[] arr = new Long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nl();
		}
		return arr;
	}

	long[] nla(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nl();
		}
		return arr;
	}

	String[] nsa(int n) {
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nt();
		}
		return arr;
	}

	String nt() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int ni() {
		return Integer.parseInt(nt());
	}

	long nl() {
		return Long.parseLong(nt());
	}

	double nd() {
		return Double.parseDouble(nt());
	}

}

Measured memory_bytes: 21204
n=int(input())
d=[0]*4
for i in range(n):
    s=input()
    if s=="AC":
        d[0]+=1
    elif s=="WA":
        d[1]+=1
    elif s=="TLE":
        d[2]+=1
    elif s=="RE":
        d[3]+=1
print("AC x "+str(d[0]))
print("WA x "+str(d[1]))
print("TLE x "+str(d[2]))
print("RE x "+str(d[3]))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(v) ((v).begin()), ((v).end())
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int n;
    cin >> n;
    vector<int> dp(2005, 0);
    dp[3] = 1;
    dp[4] = 1;
    dp[5] = 1;
    int M = 1e9+7;
    rep(i, 6, n+1)
    {
        dp[i] = 1;
        rep(j, 3, i-2)
            dp[i] = (dp[i] + dp[j])%M;
    }
    cout << (dp[n]+M)%M;
    return 0;
}

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

int main(){
  int N,M;
  int s[11][11] = {0};
  int p[11];

  cin >>N>>M;

  for(int i = 0; i < M;i++){
      int k = 0;
      cin >>k;
      for(int j = 0;j < k;j++){
          cin >>s[i][j];
      }
  }
  for(int i = 0; i < M;i++){
      cin >>p[i];
  }

  int ans = 0;
  
  for (int i = 0;i < pow(2,N);i++){
      int verNum = 0;
      bitset<10>sw(i);
      for(int j = 0;j < M;j++){
          int k = 0;
          int a = 0;
          while (s[j][k] != 0){
              if(sw[s[j][k]-1])a++;
              k++;
          }
          if(a%2 == p[j]){
              verNum++;
          }
      }
      if(verNum == M)ans++;

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int a=1;
	while (s.length()) {
		if (s.substr(s.length()-5,5)=="dream") for (int i=0;i<5;i++) s.pop_back();
		else if (s.substr(s.length()-5,5)=="erase") for (int i=0;i<5;i++) s.pop_back();
		else if (s.substr(s.length()-6,6)=="eraser") for (int i=0;i<6;i++) s.pop_back();
		else if (s.substr(s.length()-7,7)=="dreamer") for (int i=0;i<7;i++) s.pop_back();
		else {
          cout << "NO\n";
          a=0;
          break;
        }
	}
	if (a) cout << "YES\n"; 
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    if(abs(a-c)<=d||(abs(a-b)<=d&&abs(c-b)<=d)){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }

}

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

void solve() {
    ll AMAX = 2e5 + 1;
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    vector<ll> pos(AMAX, -1);
    for ( int i = N - 1; i >= 0; i-- ) {
        pos[A[i]] = i;
    }
    vector<ll> offset(N);
    for ( int i = N - 1; i >= 0; i-- ) {
        ll b = pos[A[i]] - i;
        if ( b <= 0 ) b += N;
        offset[i] = b;
        pos[A[i]] = i;
    }
    vector<ll> last(N + 3, -1);  // (k+1)周目で最後に全消しになるp
    ll k = 0;
    ll p = 0; 
    for(;;) {
        p += offset[p];
        if ( p >= N ) {
            p -= N;
            k++;
        }
        last[k] = p;
        if ( p >= N-1 ) {
            break;
        }
        p++;
    }
    ll kt = k + 1;
    K %= kt;

    if ( K == 0 ) {
        cout << "\n";
        return;
    } else {
        vector<int> X;
        set<int> S;
        k = K - 1;
        while ( last[k] == -1 && k > 0 ) k--;
        p = last[k] + 1;
        for(; k <= K - 1; k++ ) {
            for( ; p < N; p++ ) {
                ll a = A[p];
                if ( S.find(a) == S.end() ) {
                    S.insert(a);
                    X.push_back(a);
                } else {
                    for ( int j = X.size() - 1; j >= 0 ; j-- ) {
                        ll xx = X.back();
                        S.erase(xx);
                        X.pop_back();
                        if ( xx == a ) {
                            break;
                        }
                    }
                }
            }
            p = 0;
        }
        for ( int i = 0; i < X.size(); i++ ) {
            cout << X[i] << " ";
        }
        cout << "\n";
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 17908
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#ALDS1_1_C

import math

def isprime(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i += 2
    return True

n = int(input())
count = 0
for _ in range(n):
    if isprime(int(input())):
        count += 1
print(count)



Measured memory_bytes: 5676
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

template <typename T>
using vec = vector<T>;

template <typename T>
using vec2 = vector<vector<T>>;

template <typename T>
using vec3 = vector<vector<vector<T>>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    int n, l;
    cin >> n >> l;
    vec<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    sort(s.begin(), s.end());

    for (int i = 0; i < n - 1; i++) {
        cout << s[i];
    }
    cout << s[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

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

    int tmp[N+1];
    int black = 0;
    int white = 0;
    int cnt = 0;

    tmp[0] = 0;
    for(int i = 0; i < N; i++){
        if( S[i] == '.' ) ++cnt;
        tmp[i+1] = cnt;
    }

    int ans = 2000000;
    for(int i = 0; i < N+1; i++){
        black = tmp[N] - tmp[i];
        white = i - tmp[i];

        ans = min( ans, black+white);
    }

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


Measured memory_bytes: 1412
#include <iostream>
#include <cmath>
#include <math.h>
#include <iomanip>

int main(){
    int a = 0;
    int b = 0;
    int h = 0;
    int m = 0;
    double hdeg = 0.0;
    double mdeg = 0.0;
    double diff = 0.0;
    double length = 0.0;

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

    hdeg = h * 30 + m * 0.5;
    mdeg = m * 6;
    diff = std::abs(hdeg - mdeg);

    if(diff > 180){
        diff = 360 - diff;
    }

    if(diff == 0){
        length = std::abs(a - b);
        std::cout << std::fixed << std::setprecision(20) << length << std::endl;
    }
    else if(diff == 180){
        length = a + b;
        std::cout << std::fixed << std::setprecision(20) << length << std::endl;
    }
    else{
        length = sqrt(a*a + b*b - 2*a*b*std::cos(diff*M_PI/180));
        std::cout << std::fixed << std::setprecision(20) << length << std::endl;
    }

    return 0;
}

Measured memory_bytes: 4204
n, x = (int(_) for _ in input().split())
if x == 1 or x == 2 * n - 1:
    print('No')
    exit()
print('Yes')
if n == 2:
    print('1 2 3')
    exit()
s = set()
for i in range(1, 2 * n):
    s.add(i)
a = [-1 for i in range(1, 2 * n)]
a[n - 1] = x
if x == 2:
    a[n - 2] = 1
    a[n] = 3
    a[n - 3] = 4
else:
    a[n - 2] = x + 1
    a[n] = x - 1
    a[n - 3] = x - 2
for i in a:
    s.discard(i)

for i in range(len(a)):
    if a[i] == -1:
        a[i] = s.pop()        
print(' '.join(str(_) for _ in a))


Measured memory_bytes: 33124
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = 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 same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int n;
	cin >> n;
	cout << (n+1)*n/2 << endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input){
  var inputs = input.split("\n"); 
  var age = inputs[0];
  var A = parseInt(inputs[1],10);
  var B = parseInt(inputs[2],10);
  if(age == "1"){
    console.log("Hello World");
  }else if(age =="2"){
    console.log(A+B);
  }
}
    Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064
#include <stdio.h>
#include <string.h>
int main()
{
   int N=0,count=0;
   char S[100];

   scanf("%d",&N);
   scanf("%s",&S);



   for(int i=0; i<N; i++)
   {
       if(S[i]=='A')
       {
           if(S[i+1]=='B')
           {
               if(S[i+2]=='C')
                   count++;

           }
       }

   }
   printf("%d\n",count);


}



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

// 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)
int main()
{
    int ab = 0, bc = 0, ca = 0;
    cin >> ab >> bc >> ca;

    cout << (double)(ab * bc / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $X);
$ans = 1;
$maxx = floor(sqrt(1000));

for ($i = 2; $i <= $maxx; $i++) {
    $t = $i;
    while(true) {
        $t *= $i;
        if ($t <= $X) {
            $ans = max($ans, $t);
        } else {
            break;
        }
    }
}

echo $ans, "\n";


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	for (int i = n; i > 0; i--)
	{
		int temp = i;
		int sum = 0;
		while (temp != 0)
		{
			sum += temp % 10;
			temp /= 10;
		}
		if (a <= sum && sum <= b)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}

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


int main()
{
	int n;
	int bit[19];
	int *t, t_n;
	int x, tmp;
	int size;
	int flag;
	int i, j, k;

	scanf("%d", &n);

	scanf("%d", &t_n);

	t = (int *)malloc(sizeof(int) * t_n);
	for(i = 0; i < t_n; i++)
		scanf("%d", &t[i]);

	for(i = 0; i < pow(2, n); i++){
		x = i;
		j = k = 0;
		while( (tmp = x / 2) >= 1){
			if(x % 2)
				bit[k++] = j;
			x = tmp;
			j++;
		}
		if(x)
			bit[k] = j;

		size = k;

		if(i > 0){
			flag = 1;
			for(j = 0; j < t_n; j++){
				for(k = 0; k <= size; k++)
					if(t[j] == bit[k])
						break;
				if(k == size + 1){
					flag = 0;
					break;
				}
			}

			if(flag){
				printf("%d:", i);
				for(j = 0; j <= size; j++)
					printf(" %d", bit[j]);
				printf("\n");
			}
		}else if(i == 0 && t_n == 0)
			printf("0:\n");
	}

	return 0;
}



Measured memory_bytes: 2084
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 200000+19;
int mod[max_n]; //each digit

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

    map<int,int> dic;
    int m = 2019;
    int x = 1;
    int cur = 0;
    dic[0] = 1;
    for(int i = s.size()-1;i >= 0;i--) {
        int num = s[i] - '0';
        cur = (cur + num*x)%m;
        x = (x*10)%m;
        dic[cur]++;
    }

    Int ans = 0;
    for(auto u:dic) {
        ans += u.second*(u.second-1)/2;
    }

    cout<<ans<<endl;

    return 0;
}



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


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

    sort(a, a+n, greater<int>());
    int alice =0;
    int bob=0;
    for(int i=0;i<n;i++){
        if(i % 2 ==0){
            alice += a[i];

        }
        else{
            bob += a[i];
        }
    }
    cout << alice-bob <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000000
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fast_exp(ll x, ll n, ll m)
{
    ll res = 1;
    while(n>0)
    {
        if(n%2==1)
            res = (res * x) % m;
        x = (x * x) % m;
        n/=2;
    }
    return res%m;
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    ll x;
    cin>>x;
    cout<<((x/500LL)*1000LL) + (((x%500LL)/5LL)*5LL)<<endl;

    //End();
    return 0;
}


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

using namespace std;

using ll = long long;

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

    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<int> cnt(n + 1);
    for (int i = 2; i <= n; ++i) {
        if (s[i - 2] == 'A' && s[i - 1] == 'C') ++cnt[i];
        cnt[i] += cnt[i - 1];
    }

    for (int i = 0, l, r; i < q; ++i) {
        cin >> l >> r;
        int res = cnt[r] - cnt[l - 1];
        if (l != 1 && s[l - 2] == 'A' && s[l - 1] == 'C') --res;
        cout << res << '\n';
    }

    return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

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

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

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

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

  int k, a, b; cin >> k >> a >> b;
  bool ok = false;
  FOR(i, a, b+1) {
    ok |= i % k == 0;
  }
  cout << (ok ? "OK" : "NG") << endl;

}
























Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int count{};
    for(int i=0;i<n-2;i++)
    {
        if(arr[i+1]>arr[i] && arr[i+2]>arr[i+1])
            count++;
        if(arr[i+1]<arr[i] && arr[i+2]<arr[i+1])
            count++;
    }
    cout<<count;
	return 0;
}

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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<long> h(N);
	for (int i = 0; i < N; i++)
		cin >> h[i];
	sort(h.begin(), h.end());
	long ans = 1e9;
	for (int i = 0; i+K-1 < N; i++)
	{
		ans = min(ans, h[i + K - 1] - h[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
p=[list(map(int,input().split())) for _ in [0]*(n-1)]
g=[[] for _ in [0]*n]

[g[a-1].append(b-1) for a,b in p]
[g[b-1].append(a-1) for a,b in p]

memo=[False for _ in [0]*n]
q=[0]
memo[0]=True
last=0

while(q):
	qq=[]
	for i in q:
		for j in g[i]:
			if memo[j]==False:
				memo[j]=True
				last=j
				qq.append(j)
	q=qq

memo=[False for _ in [0]*n]

q=[last]
memo[last]=True
cnt=0
while(q):
	cnt+=1
	qq=[]
	for i in q:
		for j in g[i]:
			if memo[j]==False:
				memo[j]=True
				qq.append(j)
	q=qq
	
if cnt%3==2:
	print('Second')
else:
	print('First')

Measured memory_bytes: 90364
import collections
k = int(input())
count = 0
queue = collections.deque(['1','2','3','4','5','6','7','8','9'])
if k <= 12:
    print(k)
else:
    for i in range(k):
        t = queue.popleft()
        s = int(t[-1])
        if(s == 0):
            queue.extend([t + str(s),t + str(s + 1)])
            count+=1
        elif(s == 9):
            queue.extend([t + str(s-1),t + str(s)])
        else:
            queue.extend([t + str(s-1),t + str(s),t + str(s+1)])
            count += 1
    print(int(t))

Measured memory_bytes: 90572
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int r;
    cin>>r;
    LD e=1.;
    cout<<setprecision(10)<< e*2*pi*r;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/








int H, W, D, A[303][303], Q;
pair<int, int> idx[90101];
//---------------------------------------------------------------------------------------------------
int memo[90101];
int f(int x) {
    if (0 < memo[x]) return memo[x];
    if (x < D) return 0;

    int y = x - D;
    int cost = abs(idx[x].first - idx[y].first) + abs(idx[x].second - idx[y].second);
    int res = cost + f(y);
    return memo[x] = res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> W >> D;
    rep(y, 0, H) rep(x, 0, W) {
        cin >> A[y][x];
        A[y][x]--;
        idx[A[y][x]] = make_pair(x, y);
    }
    cin >> Q;
    rep(q, 0, Q) {
        int L, R; cin >> L >> R;
        L--; R--;
        int ans = f(R) - f(L);
        printf("%d\n", ans);
    }
}

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

int main(){
    string S;
    cin >> S;
    int judge = 0;

    if(S[0]==S[1]){
        if(S[0] != S[2] && S[2] == S[3]){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else if(S[0]==S[2]){
        if(S[0] != S[1] && S[1] == S[3]){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else if(S[0]==S[3]){
        if(S[0] != S[1] && S[1] == S[2]){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K = 0;
  cin >> N;
  vector<int> a(N),b(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> b.at(i);
    if (a.at(i) > b.at(i)){
      K = K + a.at(i)- b.at(i);
    }
  }
  cout << K << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
from collections import Counter
a = Counter(A)

T = 0
for k in a.keys():
    c = a[k]
    T += (c * (c-1)) // 2

for i in A:
    t = 0
    c = a[i]
    t = T
    t -= (c * (c-1)) // 2
    c -= 1
    t += (c * (c-1)) // 2
    print(t)

Measured memory_bytes: 26268
n = gets.chomp.to_i
blue_card = Hash.new(){0}
n.times do
  blue_card[gets.chomp] += 1
end

m = gets.chomp.to_i
red_card = Hash.new(){0}
m.times do
  red_card[gets.chomp] -= 1
end

blue_card.merge!(red_card){|key, selfv, otherv| selfv + otherv}
maxv = blue_card.values.max
puts maxv > 0 ? maxv : "0"

Measured memory_bytes: 1916
n = int(input())
a = list(map(int,input().split()))
num4 = 0;num2 = 0
for i in range(n):
    if a[i] % 4 == 0:
        num4 += 1
        continue
    elif a[i] % 2 == 0:
        num2 += 1
num2 = num2 // 2
if n // 2 <= num4 + num2:print('Yes')
else:print('No')

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

int main(){
  string s,t;
  int ans=0,Max=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'||s.at(i)=='T'||s.at(i)=='C'||s.at(i)=='G'){
      ans++;
      Max=max(Max,ans);
    }else{
      ans=0;
    }
  }
  cout<<Max<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include<math.h>
//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = 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 same(int x, int y) {
	return find(x) == find(y);
}
/************************************************************************************/
//int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
/**************/
int n;
ll a[int(1e5)], b[int(1e5)], c[int(1e5)];

ll adp[int(1e5)+2], bdp[int(1e5)+2], cdp[int(1e5)+2];
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	for (int i = 0; i < n; i++) {
		adp[i + 1] = max(bdp[i], cdp[i]);
		adp[i + 1] += a[i];
		bdp[i + 1] = max(adp[i], cdp[i]);
		bdp[i + 1] += b[i];
		cdp[i + 1] = max(adp[i], bdp[i]);
		cdp[i + 1] += c[i];
		

	}
	cout << max(max(adp[n], bdp[n]),cdp[n])<<endl;


}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
int main()
{
	map<string,int> m;
	int n;
	char s[15];
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%s",s);
		m[s]=1;
	}
	printf("%d",m.size());
}

Measured memory_bytes: 19328
/*"You can do anything you set your mind to,man" - Eminem*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define l_b(a,val) min((int)a.size()-1, (int)(lower_bound(a.begin(),a.end(),val)-a.begin()))
#define f first
#define up(a,b) max(a,b)
#define s second
#define INF 9223372036854775807
const  int mod = 1000000007;
template <typename T> T add(T& a, T b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
template <typename T> T sub(T& a, T b){a-=b;while(a<0)a+=mod;while(a>=mod)a-=mod;}
template <typename T> T mul(T& a, T b){a*=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
template <typename T> T up_self(T& a, T b){a = up(a,b);}
template <typename T> T min_self(T& a, T b){a = min(a,b);}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int msb(ll n){int ans;for(int i = 0 ; i < 64;  i++)if(n&(1LL<<i))ans = i+1;return ans;}
/*All the macros below are copied from nik_y(OG)*/
#define fl(i,a,b) for(int i = a; i < b; i++)
#define test() int t; cin>>t; while(t--)
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define all(c) c.begin(),c.end()
#define endl "\n"
#define get(a,n) fl(i,0,n)  cin>>a[i];
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;

int main()
{
	Shazam;
	int n,k; cin>>n>>k;
	vector<int> a(n);
	get(a,n);
	vector<int> dp(k+1); //dp[i] is the number of ways to distribute i candies
	dp[0] = 1;
	for(int i = 0 ; i < n ;i++){
		int up_to = a[i];
		vector<int> fake(k+1);
		for(int used = k; used>=0; used--){
			int temp = dp[used];
			int l = used +1;
			int r = used+ min(up_to, k-used);
			if(l<=r){
				add(fake[l],temp);
				if(r+1<=k)
					sub(fake[r+1],temp);
			}
		}
		int pref = 0;
		for(int j = 0; j < k+1; j++){
			add(pref,fake[j]);
			add(dp[j],pref);
		}
	}
	cout<<dp[k]<<endl;
  	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n)  for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

// 約数を数える
int countDiv(const int& n) {
    int c = 0;
    for(int i = 1; i*i <= n; ++i) {
        // 約数なら加え入れる
        if(n % i == 0) {
            c++;
            // 大きい約数も同時に入れていく
            if(i * i != n) {
                c++;
            }
        }
    }
    return c;
}

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

    int ans = 0;

    for(int i = 1; i <= n; ++i) if((i % 2 == 1) && (countDiv(i) == 8)) ++ans;

    cout << ans;
}

Measured memory_bytes: 256
use std::io::{self, BufRead};
use std::error::Error;

fn main() {
    run().unwrap()
}

fn run() -> Result<(), Box<Error>> {
    let stdin = io::stdin();
    let mut stdin = stdin.lock().lines();
    let line = stdin.next().unwrap()?;
    
    let mut value = 700;
    for c in line.chars() {
        value += match c {
            'o' => 100,
            _ => 0,
        };
    }
    println!("{}", value);

    Ok(())
}


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

int main() {
  int N;
  cin >> N;
  bool isFour = false;

  for (int i = 0; i < N; i++){
    string C;
    cin >> C;
    
    if (C == "Y"){
      isFour = true;      
    }    
  }
    
   if(isFour){
    cout << "Four" << endl;
   } else {
     cout << "Three" << endl;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
const int MAXN = 1e4 + 10;
const int MAXD = 1e2 + 10;
const int MOD = 1e9 + 7;
 
vector<int> digitos;
string s;
int N,D;
ll dp[MAXN][2][MAXD];
 
ll solve(int pos,int flag,int resto){
 
	if(pos == N) return (resto == 0);
	if(dp[pos][flag][resto] != -1) return dp[pos][flag][resto];
 
	ll tot = 0;
	int limit = (flag) ? (digitos[pos]) : (9);
	for(int i = 0;i<=limit;i++){
		tot += solve(pos+1,flag && (i == limit), (resto + i) % D );
	}
 
	return dp[pos][flag][resto] = tot % MOD;
 
}
 
int main(){
 
	cin >> s;
	cin >> D;
	N = (int)s.size();
	for(int i = 0;i<N;i++){
		digitos.push_back(s[i] - '0');
	}
	memset(dp,-1,sizeof(dp));
 
	ll ans = solve(0,1,0) - 1;
	if(ans < 0) ans += MOD;
	cout << ans << endl;
 
 
	return 0;
 
}

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

int m, n;
int data[101];

bool func( int num ) {
  int sum = 0, cnt = 1;
  for(int i=0; i<n; i++) {
    if( sum + data[i] <= num ) {
      sum += data[i];
    } else {
      if( data[i] > num ) return false;
      sum = data[i];
      cnt++;
    }
  }

  if( cnt <= m ) return true;
  else return false;
}


int main() 
{
  while( cin >> m >> n, m+n ) {
    for(int i=0; i<n; i++) {
      cin >> data[i];
    }
    
    int l = 0, r = 1500000;
    int now;
    while( l != r ) {
      now = (l + r) / 2;
      if( func( now ) ) {
	r = now;
      } else {
	l = now+1;
      }
    }
    
    cout << l << endl;
  }
  
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a,b,k,i,c;
  cin>>a>>b>>k;
  for(i=min(a,b);i>=1;i--){
    if(a%i==0&&b%i==0){
      c++;
      if(c==k){
        cout<<i<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3616
import java.util.HashSet;
import java.util.Scanner;

class Main {

	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String order="";
		String str="";
		 HashSet<String> dic = new HashSet<String>();

		for (int i = 0; i < n; i++) {
			order=in.next();
			str=in.next();
			if(order.equals("insert")) {
				dic.add(str);
			}else if(order.equals("find")) {
				if(dic.contains(str)) {
					System.out.println("yes");
				}else {
					System.out.println("no");
				}
			}

		}

		in.close();
	}

}



Measured memory_bytes: 252512
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
	int n, x;cin>>n>>x;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a.begin(), a.end());
	int ans=0;
	for(int i=0;i<n;i++){
	  x-=a[i];
	  if(x<0)break;
	  ans++;
	}
	cout << ans - (x>0) << endl;
}

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

long long int dp[100005][14]= {0}, arr[100005] ={0};

long long int parade(int i, int n, int sum){
    if(i==n) return (sum==5);
    
    if(dp[i][sum]!=-1) return dp[i][sum];
    
    long long int ans = 0;
    if(arr[i]!=-1){
        ans = ((ans%mod) + (parade(i+1, n, (sum*10+arr[i])%13)%mod))%mod;
        return dp[i][sum] = ans%mod;
    }

    for(int j = 0; j < 10; j++){
        ans = ((ans%mod) + (parade(i+1, n, (sum*10+j)%13)%mod))%mod;
    }
    return dp[i][sum] = ans%mod;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin >> s;
    
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='?') arr[i] = -1;
        else arr[i] = s[i] -'0';
    }
    memset(dp, -1, sizeof(dp));
    cout << parade(0, s.size(), 0)%mod;
    return 0;
}

Measured memory_bytes: 23272
n = gets.chomp
rates = gets.chomp.split.map(&:to_i)

colors = Array.new(9) { Array.new }
rates.each do |rate|
    x = rate / 400
    case x
        when 0..7
            colors[x] << rate
        else
            colors[8] << rate
    end
end

count = 0
8.times do |i|
    next if colors[i].empty?
    count += 1
end

answer = []
if colors[8].empty?
    answer << count << count
elsif count == 0
    answer << 1 << (count + colors[8].size)
else
    answer << count << (count + colors[8].size)
end
puts answer.join(" ")


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int toZero = 0;
        int toN = 0;
        Integer a[] = new Integer[m];
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            if (a[i] < x) {
                toZero++;
            } else {
                toN++;
            }
        }
        System.out.println(Math.min(toZero, toN));
    }
}


Measured memory_bytes: 22868
def get_divisors(n):
    div = []
    append = div.append
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            append(i)
            if i != n // i:
                append(n // i)
    div.sort()
    return div


# input
N = int(input())

# check
cnt = 0
for n in range(1, N + 1, 2):
    div = get_divisors(n)
    if len(div) == 8:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
	int A, B, C;


	cin >> A >> B >> C;

	int five_num = 0;
	int seven_num = 0;

	auto check = [&](int tmp)
	{
		if (tmp == 5)
		{
			five_num++;
		}
		else if (tmp == 7)
		{
			seven_num++;
		}
	};

	check(A);
	check(B);
	check(C);

	if (five_num == 2 && seven_num == 1)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}

	return 0;
}

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= b) {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
		cout << endl;
	}
}

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

int main() {
  int A,B,ans;
  char op;
  cin >> A >> op >> B;

  if(op == '+') {
    ans = A + B;
  }
  else if(op == '-') {
    ans = A - B;
  }

  cout << ans << endl;
}


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

int main() {
  long long a, b, x;
  scanf("%lld%lld%lld", &a, &b, &x);

  long long ans = 0;
  if (a % x == 0) ans++;

  ans += b / x;
  ans -= a / x;

  printf("%lld", ans);
}

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

signed main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  int aa=a-1;
  cout<<b-aa-((b/c-aa/c)+(b/d-aa/d)-(b/(c*d/__gcd(c,d))-aa/(c*d/__gcd(c,d))))<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
#define ll long long 
ll ans=0;
ll gcdgcd(ll x, ll n) {
    if(n % x == 0)
        return n * 2 - x;
    ans = n / x * x * 2 + gcdgcd(n % x, x);
    return ans;
}
int main() {
	ll n,x;
	cin>>n>>x;
	cout<<gcdgcd(x,n-x)+n;
}

Measured memory_bytes: 256