akhauriyash/Code-Regression huggingface dataset:
n = input()
precise = 0
ok_over = 1
ok_prec = 0
for d in n:
    d = int(d)
    new_over = min(precise + d + 1, ok_over + d + 2, ok_over + 9 - d, ok_prec + d + 1)
    new_prec = min(ok_over + d + 1, ok_prec + d)
    precise += d
    ok_over = new_over
    ok_prec = new_prec
ok_over += 1
print(min(precise, ok_over, ok_prec))


Measured memory_bytes: 5492
use std::io;


fn main() {
    let n = read_one::<usize>();
    let (t, a) = {
        let i = read::<f64>();
        (i[0], i[1])
    };
    let hn = read::<f64>();
    let mut idx = 0;
    let mut min = 1000000000000.0;
    for i in 0..n {
        let _t = ((t - hn[i] * 0.006) - a).abs();
        if _t <= min {
            idx = i;
            min = _t;
        }
    }
    println!("{}", idx + 1);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
ans = 0

for n in range(N):
  P = 0
  A = list(map(int,input().split()))
  for a,b in zip(A,B):
    P += a*b
  if P+C>0:
    ans+=1
    
print(ans)

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

int main(){
  int K;
  cin >> K;
  if(K%2 == 0){
    cout << (K/2)*(K/2) << endl;
  }else{
    cout << (K/2+1)*(K/2) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i, n, q;
    char s[100000 + 1];
    int sum[100000 + 1] = {0};
    scanf("%d%d", &n, &q);
    scanf("%s", s);

    for (i = 0; i < n ; i++)
    {
        sum[i + 2] = sum[i + 1];
        if(s[i] == 'A' && s[i + 1] == 'C'){
            sum[i + 2]++;
        }
    }

    int l[q], r[q];
    for (i = 0; i < q; i++)
    {
        scanf("%d%d", &l[i], &r[i]);
    }

    for (i = 0; i < q; i++)
    {
        printf("%d\n", sum[r[i]] - sum[l[i]]);
    }

    return 0;
}

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

#define ll long long
#define eb emplace_back
#define nl '\n'
#define deb(x) cerr << #x" = " << x << nl
#define in() ( { int a ; scanf("%d", &a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;


int32_t main()
{
    int n = in();
    int ok = 1;
    while(n--){
        int k = in();
        if(k % 2 == 0){
            if(k % 3== 0 || k % 5 == 0);
            else ok = 0;
        }
    }
    if(ok) puts("APPROVED");
    else puts("DENIED");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	while(true){
	int H = sc.nextInt();
	int W = sc.nextInt();
	if(H == 0 && W ==0){
		break;
	}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				System.out.printf("#");
			}
			System.out.printf("\n");
		}
			System.out.printf("\n");



	}
	}	
}

Measured memory_bytes: 57852
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 1e7;
LL tau[N+1];
int main()
{
	memset(tau,0,sizeof tau);
	for(int d = 1; d <= N; d++)
		for(LL k = d; k <= N; k+=d)
			tau[k]++;

	int n; cin >> n;
	LL ans = 0;
	for(LL k = 1; k <= n; k++)
		ans += k*tau[k];
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 81752
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);

        int n=scan.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=scan.nextInt();
        }

        int bot=0;
        int cnt=1;
        while(true){
            if(a[bot]==2){
                break;
            }else{
                bot=a[bot]-1;
            }

            if(cnt>n){
                cnt=-1;
                break;
            }


            cnt++;
        }

        System.out.println(cnt);


    }
}

Measured memory_bytes: 51036
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<' '<<y<<endl
#define p3(x,y,z)               out<<x<<' '<<y<<' '<<z<<endl
#define p4(x,y,z,w)             out<<x<<' '<<y<<' '<<z<<' '<<w<<endl
#define pl(x)                   out<<x
#define pll(x)                  out<<x<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


void ssolve(std::istream& in, std::ostream& out){
    int n, x, t; s3(n, x, t);
    int ans = (n/x + (n%x?1:0)) * t;
    p(ans);
    return;
}

class ATakoyaki {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    ATakoyaki solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3648
using System;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int[] array = new int[s.Length];
        for(int i = 0;i < s.Length; i++)
        {
            array[i] = int.Parse(s[i]);
        }

        Sort sorter = new Sort();
        sorter.sorting(array);
        for(int i = 0;i < array.Length; i++)
        {
            if (i != 0)
                Console.Write(" " + array[i]);
            else
                Console.Write(array[i]);
        }
        Console.WriteLine();

    }
}
class Sort
{
    public void sorting(int[] a)
    {
        int count = 0;
        while(true)
        {
            count = 0;
            for (int i = 0;i + 1 < a.Length; i++)
            {
                if (a[i] > a[i + 1])
                {
                    int tmp = a[i];
                    a[i] = a[i + 1];
                    a[i + 1] = tmp;
                }
                else
                    count++;
            }
            if (count == a.Length - 1)
                break;
        }
    }
}

Measured memory_bytes: 9036
#include<cstdio>

int n;
int a[200000];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == sum + 1) sum++;
    }

    if (sum == 0) printf("-1\n");
    else printf("%d\n", n - sum);
    return 0;
}


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

int main() {
    int n;
    cin>>n;
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            if(i*4+j*7 == n){
                cout<<"Yes"; return 0;
            }
        }
    }
    cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
  int e, o;
  cin>>e>>o;
  int res = 0;
  if (e > 1) res += e*(e-1)/2;
  if (o > 1) res += o*(o-1)/2;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<utility>
#include<vector>
using namespace std;
const int maxn = 4008;
int ch[maxn],a[maxn],b[maxn];
int f[2012][2012];int n;
void add(int x)
{
	for(int i=x;i<=2*n;i+=i&(-i))
		ch[i]++;
	return ;
}
int query(int x)
{
	int sum = 0;
	for(int i=x;i;i-=i&(-i))
		sum += ch[i];
	return sum;
}
int cost(int x,int p)
{
	x += p-query(x);
	return x-p-1;
}
int main()
{
	cin>>n;getchar();
	for(int i=1;i<=2*n;i++)
	{
		char c = getchar();
		int x;scanf("%d",&x);
		if(c=='W')a[x] = i;
		else b[x] = i;
		getchar();
	}
/*	for(int i=1;i<=n;i++)
	cout<<a[i]<<" ";
	cout<<endl;
	for(int i=1;i<=n;i++)
	cout<<b[i]<<" ";
	cout<<endl;*/
	for(int i=0;i<=n;i++)
	for(int j=0;j<=n;j++)
	f[i][j] = 1<<30;
	f[0][0] = 0;
	for(int i=0;i<=n;i++)
	{
		memset(ch,0,sizeof(ch));
		for(int j=1;j<=i;j++)add(a[j]);
		for(int j=0;j<=n;j++)
		{
			if(i!=n)f[i+1][j] = min(f[i+1][j],f[i][j]+cost(a[i+1],i+j));
			if(j!=n)f[i][j+1] = min(f[i][j+1],f[i][j]+cost(b[j+1],i+j));
			if(j!=n)add(b[j+1]);
		}
	}
	cout << f[n][n] <<endl;
	return 0;
}

Measured memory_bytes: 16128
/*
***************************************************************************
 name  : ITP1_07_B.cpp
 title : How many ways?
 make  : 2018/08/22 tanabe
***************************************************************************
*/

// Library
#include <iostream> // standard input output object

main(void){
  int n,x;    // integers
  int a,b,c;  // index
  int num=0;  // number
  bool judge; //  parameters to determine

  // initialized judge = 0
  // continue judge == 0
  // num = 0 at loop update
  for(judge = 0;judge == 0;num = 0){
    std::cin >> n >> x; // input "n x"
    if(n == 0 && x == 0){
      judge++; // increment judge
    }
    else{
      // initialized a = 1
      // continue a <= n-2
      // increment a at loop update
      for(a = 1;a <= n-2;a++){
        // initialized b = a+1
        // continue b <= n-1
        // increment b at loop update
        for(b = a+1;b <= n-1;b++){
          // initialized c = b+1
          // continue c <= n
          // increment c at loop update
          for(c = b+1;c <= n;c++){
            if(x == a+b+c){
              num++; // increment num
            }
          }
        }
      }
      std::cout << num << std::endl; // output "num"
    }
  }

}



Measured memory_bytes: 3060
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
ll n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  std::vector<ll> v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  reverse(all(v));
  ll flg = 0;
  ll ans = 0;
  // cout<<v[0]<<endl;
  rep(i,n){
    if(v[i]==v[i+3]){
      if(flg==0) {
        cout<<v[i]*v[i]<<endl;
        return;
      } else {
        cout<<ans*v[i]<<endl;
        return;
      }
    } else if(v[i]==v[i+2] || v[i] == v[i+1]) {
      if(flg==0) {
        ans = v[i];
        flg++;
        if(v[i]==v[i+2]) i+=2;
        else i+=1;
      } else {
        cout<<ans*v[i]<<endl;
        return;
      }
    }
  }
  cout<<0<<endl;
}

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


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

int main (){
    int n;
    cin >> n;
    int k;
    cin >> k;
    int cost[n];
    int h;
    for(int i=0;i<n;i++){
        cin >> h;
        cost[i] = h;
    }

    int min_cost[n];
    min_cost[0] = 0;
    min_cost[1] = abs(cost[0]-cost[1]);

    for(int i=2;i<n;i++){
        int mini = abs(cost[i-1]-cost[i]) + min_cost[i-1];
        for(int j=1;j<=k;j++){
            if(i-j>=0){
                mini = min(mini,abs(cost[i-j]-cost[i]) + min_cost[i-j]);
            }
        }
        min_cost[i] = mini;
    }

    cout << min_cost[n-1] << endl;

    return 0;
}



Measured memory_bytes: 4288
n = int(input())
p = map(int, input().split())
p_list = []
for i in p:
        p_list.append(i)
count = 0
for i in range(1,len(p_list)-1):
        if p_list[i-1] < p_list[i] < p_list[i+1] or p_list[i+1] < p_list[i] < p_list[i-1]:
                count += 1
print(count)

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

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

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

	int left = 0, right = 1;
	long long ans = 0, sum = A[0];
	while(left < N){
		if(right == N){
			ans += right - left;
			++left;
		}else if((sum + A[right]) == (sum ^ A[right])){
			sum += A[right];
			++right;
		}else{
			ans += right - left;
			sum -= A[left];
			++left;
		}
	}

	cout << ans << endl;
}


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

//#include "hash.h"
class Hash {
private:
	static const long long MOD = 1046527;
	
	inline long long my_ctoi(char c) {
		if (c == 'A') return 1;
		if (c == 'C') return 2;
		if (c == 'G') return 3;
		if (c == 'T') return 4;
		return 0;
	}
	
	inline long long hash1(long long key) {
		return key % MOD;
	}
	
	inline long long hash2(long long key) {
		return 1 + (key % (MOD - 1));
	}
	
public:
	Hash() {}
	
	long long getKey(const string& str) {
		long long key = 0;
		size_t len = str.size();
		for (size_t i = 0; i < len; ++i) key = 10 * key + my_ctoi(str[i]);
		return key;
	}
	
	long long getHash(long long key, long long collision_count) {
		return (hash1(key) + collision_count * hash2(key)) % MOD;
	}
};

class Dictionary {
private:
	string NIL;
	vector< string > table;
	
	Hash hash;
	
public:
	Dictionary() {
		NIL = "#";
		table.assign(1046527, NIL);
	}
	
	void insert(string& str) {
		long long key = hash.getKey(str);
		int collision_count = 0;
		
		while (1) {
			int hs = hash.getHash(key, collision_count);
			
			if (table[hs] == NIL) {
				table[hs] = str;
				break;
			} else {
				++collision_count;
			}
		}
	}
	
	bool find(string& str) {
		long long key = hash.getKey(str);
		int collision_count = 0;
		
		while (1) {
			int hs = hash.getHash(key, collision_count);
			
			if (table[hs] == str) {
				return true;
			} else if (table[hs] == NIL) {
				return false;
			} else {
				++collision_count;
			}
		}
	}
};

int main() {
	Dictionary dict;
	
	int n;
	cin >> n;
	
	char buf1[128], buf2[128];
		
	for (int i = 0; i < n; ++i) {
		scanf("%s %s", buf1, buf2);
		
		string op(buf1), str(buf2);
		
		if (op == "insert") {
			dict.insert(str);
		}
		
		if (op == "find") {
			if (dict.find(str)) puts("yes");
			else puts("no");
		}
	}
}

Measured memory_bytes: 35916
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;
//using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
const long long INF = 1LL << 60;

int main(){
    int N, T;
    scanf("%d %d", &N, &T);
    unsigned prev_t, t;
    unsigned long long answer = T;
    scanf("%u", &prev_t);
    for (int i = 0; i < N - 1; ++i) {
        scanf("%u", &t);
        answer += (t >= prev_t + T)? T : t - prev_t;
        prev_t = t;
    }
    printf("%llu", answer);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int i, n, m, s=0, q=0;
  int a[1000];

  /*商品数nと選ぶ数m*/
  scanf("%d %d", &n, &m);

  /*得票数を羅列*/
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  for(i = 0; i < n; i++){
    s = s + a[i];
  }

  /*商品数mを選べるか*/
  for(i = 0; i < n; i=i+1){
    if(a[i]*4*m >= s){
      q++;
    }
  }

    if(q >= m){
      printf("Yes");
    }else{
    printf("No");
  }

  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

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

Measured memory_bytes: 384
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int prod = 1;
		for (int i = 0; i < 3; i++) {
			prod *= sc.nextInt();
		}
		//System.out.println(prod);
		if (prod == 175) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 9428
a, b, c = list(map(int, input().split(' ')))

if a % 2 == 0 and a == b == c:
    print(-1)
else:
    count = 0
    while True:
        if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
            print(count)
            break
        a, b, c, = (b + c) // 2, (c + a) // 2, (a + b) // 2
        count += 1


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define x first
#define y second
#define PII pair < int , int >
#define PLL pair < ll , ll >
#define MOD 1000000007

using namespace std;
int n, a[200100];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i=1; i<=n;i++) cin >> a[i];
    for (int i=n;i>=1;i-=2) cout << a[i] << " ";
    int i = 1;
    if (n & 1) i = 2;
    for (; i<=n; i+=2) cout << a[i] << " ";
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#define MOD_P 1000000007
#define ll long long
using namespace std;



int main()
{
	int n;
	cin >> n;
	int sum = 0;

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		if (tmp != i + 1) {
			sum++;
		}
	}

	if (sum == 2 || sum == 0) {
		printf("YES");
	} else {
		printf("NO");
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	string n;
	cin>>n;
	if(n[0]=='9'||n[1]=='9')
		cout<<"Yes";
	else
		cout<<"No";
	return 0; 
}

Measured memory_bytes: 256
s=list(input().split())
a=int(s[0])
b=int(s[1])
grA=[1,3,5,7,8,10,12]
grB=[4,6,9,11]
grC=[2]
if a in grA:
  if b in grA:
    print('Yes')
  else:
    print('No')
elif a in grB:
  if b in grB:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 38384
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

class UnionFindTree
    attr_accessor:par,:rank
    def initialize(n)
        @par=Array.new(n){|i| i}
        @rank=array(n,0)
    end

    def find(x)
        return x if @par[x]==x
        @par[x]=find(@par[x])
        return @par[x]
    end

    def union(x,y)
        x=find(x)
        y=find(y)
        return if x==y
        if @rank[x]<@rank[y]
            @par[x]=y
        else
            @par[y]=x
            @rank[x]+=1 if @rank[x]==@rank[y]
        end
    end

    def same?(x,y)
        return find(x)==find(y)
    end
end

N,M=get_i
e=array(M)
M.times do|i|
  e[i]=get_i
  e[i][0]-=1
  e[i][1]-=1
end
ans=0
M.times do|i|
    uft=UnionFindTree.new(N)
    M.times do|j|
      next if i==j
      uft.union(e[j][0],e[j][1])
    end
    ans+=1 unless uft.same?(e[i][0],e[i][1])
end
puts ans

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    
    sort(arr,arr+n);
    ll sum=0;
    if((n-k)>0)
    {
    for(int i=0;i<n-k;i++)
    {
        sum+=arr[i];
    }
    
    }
    cout<<sum<<" ";
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean[][] cards = new boolean[4][13];
		char[] suit = {'S', 'H', 'C', 'D'};
		int n = sc.nextInt();
		for (int i=0; i < n; i++) {
			char c = sc.next().charAt(0);
			int num = Integer.parseInt(sc.next());
			switch (c) {
			case 'S': cards[0][num-1] = true; break;
			case 'H': cards[1][num-1] = true; break;
			case 'C': cards[2][num-1] = true; break;
			case 'D': cards[3][num-1] = true; break;
			}
		}
		sc.close();
		for (int i=0; i < 4; i++) {
			for (int j=0; j < 13; j++) {
				if (!cards[i][j]) System.out.println(suit[i] + " " + (j + 1));
			}
		}
	}
}

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

using namespace std;

typedef long long ll;
const int MAX=1e9+7;
int a[200005],b[200005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        {scanf("%d",&a[i]);b[i]=a[i];}
        sort(b,b+n);
        int mid2=b[n/2],mid1=b[n/2-1];
//        printf("1==%d\n",mid1);
//        printf("2==%d\n",mid2);
    for(int i=0;i<n;i++)
    {
        if(a[i]<=mid1)
            printf("%d\n",mid2);
        else
            printf("%d\n",mid1);
    }

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
long int x,y,z;
int main(){
  cin >> x >> y >> z;
  cout << (x-z)/(y+z) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Programminng
{
    class AOJ_Volume0008
    {
        public static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                int count = 0;

                
                for(int i=0;i<10;i++)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        for (int k = 0; k < 10; k++)
                        {
                            for (int l = 0; l < 10; l++)
                            {
                                if (i + k + j + l == int.Parse(input)) count++;
                            }
                        }
                    }
                }
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 5596
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();
			int K = scan.nextInt();

			String S = scan.next();
			ArrayList<Character>chara = new ArrayList<Character>();
			ArrayList<Integer>inte = new ArrayList<Integer>();
			Runlength(S,chara,inte);



			long[]s = new long[chara.size()+1];
			for(int i = 0;i<chara.size();i++) {
				s[i+1] = inte.get(i)+s[i];
			}

			for(int i = 0;i<chara.size();i++) {
				//System.out.println(chara.get(i)+" "+inte.get(i));
			}

			long max = 0;
			int R = 0;
			int count =  K;
			int zero =  0;
			for(int L = 0;L<chara.size();L++) {
				if(chara.get(L)=='0')zero = 1;
				if(zero==1&&chara.get(L)=='1') {
					count++;zero=0;
				}
				while(R<chara.size()-1&&count>0) {
					if(chara.get(R)=='0') {
						count--;
						if(count==0) {
							R++;break;
						}
					}
					R++;
				}
				if(chara.get(L)=='1'||L==0||R==chara.size()-1) {
					long ma = s[R+1]-s[L];
					//System.out.println(ma);
					max = Math.max(ma, max);
				}

				//System.out.println(L+" "+R);


			}

			System.out.println(max);





		}


	}




		//ランレングス圧縮　
	//必ず２個配列用意するように。
	/*
	 * (例)
	 * String S = scan.next();
	 * ArrayList<Character>chara = new ArrayList<Character>();
	 * ArrayList<Integer>inte = new ArrayList<Integer>();
	 * Runlength(S,chara,inte)
	 *
	 * */

	private static void Runlength(String S,ArrayList<Character> chara,ArrayList<Integer>inte) {

		char[]s = S.toCharArray();
		char mem =s[0];
		int count = 0;
		for(int i = 0;i<s.length;i++) {
			if(s[i]==mem) {
				count++;
				if(i==s.length-1) {
					chara.add(s[i]);
					inte.add(count);
				}
			}else if(s[i]!=mem) {
				chara.add(s[i-1]);
				inte.add(count);
				mem=s[i];
				count = 1;
				if(i==s.length-1) {
					chara.add(s[i]);
					inte.add(count);
				}
			}
		}


	}




}


Measured memory_bytes: 43284
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int main(){
  int s,ans = 0;
  for(int i = 0 ; i < 4 ; i++ ) cin >> s , ans += s;
  cout << ans / 60 << endl << ans % 60 << endl;
}

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

long long h, n, p, m, k;
vector<long long> a;
vector<vector<vector<long double>>> dp;

long double solve();

int main() {
  cout << fixed << setprecision(10);
  cin >> h >> n >> p >> m >> k;
  --p;
  a.assign(h, -1);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    a[h - x] = y - 1;
  }
  cout << solve() << endl;
  return 0;
}
long double solve() {
  long double res = 0;
  dp.assign(h + 1,
            vector<vector<long double>>(k + 1, vector<long double>(n, 0)));
  dp[0][0][p] = 1;
  for (int i = 0; i < h; ++i)
    for (int j = 0; j <= k; ++j) {
      dp[i + 1][j] = dp[i][j];
      if (a[i] >= 0)
        swap(dp[i + 1][j][a[i]], dp[i + 1][j][a[i] + 1]);
      else if (j != 0) {
        for (int t = 0; t < n; ++t) {
          if (t != 0) dp[i + 1][j][t - 1] += dp[i][j - 1][t];
          dp[i + 1][j][t] +=
              dp[i][j - 1][t] * (n - 1 - (t != 0) - (t != n - 1));
          if (t != n - 1) dp[i + 1][j][t + 1] += dp[i][j - 1][t];
        }
      }
    }
  for (int i = 0; i < n; ++i) res = max(res, (long double)dp[h][k][i]);
  // res / ((h - m)Ck * (n-1)^k)
  for (int i = 0; i < k; ++i) {
    res *= (i + 1);
    res /= (n - 1) * (h - m - i);
  }
  return res;
}


Measured memory_bytes: 84300
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1e9+7;

int main(void)
{
	ll n;
	cin >> n;
	vector<string> grid(n);
	rep(i, n) cin >> grid[i];

	ll sum = 0;
	rep(i, n) {
		auto ss = i;
		bool ok = true;
		rep(j, n) {
			repi(k,j+1,n) {
				if (grid[j][(k + ss) % n] != grid[k][(j + ss) % n]) {
					ok = false;
					break;
				}
			}
			if (!ok) break;
		}
		if (ok) sum++;
	}
	cout << sum * n << endl;

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void) {
    int i,j,c,n,r=0,p[200];
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&p[i]);
    }
    for(i=1;i<=n;i++){
        c=0;
        for(j=1;j<=n;j++){
            if(p[j]>=i){c++;}
        }
        if(c>=i){
            r=i;
        }else{
            break;
        }
    }
    printf("%d\n",r);
    return 0;
}


Measured memory_bytes: 2052
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int h, w, a, b; cin>>h>>w>>a>>b;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if((i<b && j<a) || (i>=b && j>=a)) cout<<"0";
			else cout<<"1";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <stack>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,n) for(int i=0;i<(n);++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }


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

  vvi edge(N, vi());
  vi sorted;
  int in[N], dp[N];
  rep(i, N) in[i] = dp[i] = 0;
  rep(i, M) {
    int x, y; cin >> x >> y;
    --x, --y;
    edge[x].push_back(y);
    ++in[y];
  }

  stack<int> st;
  rep(i, N) {
    if (in[i] == 0)
      st.push(i);
  }

  while (!st.empty()) {
    int n = st.top(); st.pop();
    sorted.push_back(n);
    for (const auto& to : edge[n]) {
      --in[to];
      if (in[to] == 0) st.push(to);
    }
  }
  for (const auto& from : sorted) {
    for (const auto& to : edge[from])
      chmax(dp[to], dp[from] + 1);
  }
  int ans = 0;
  rep(i, N) {
    chmax(ans, dp[i]);
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc() {
	ll n, a, b;
	ll ans = 0;

	cin >> n >> a >> b;

	ans = (n / (a + b)) * a;
	n -= (n / (a + b)) * (a + b);
	ans += min(a, n);

	cout << ans << "\n";
}

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

	solve_abc();

	return 0;
}

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

using namespace std;

static const int len = 1000001;
int erat[len];

int main() {
	int n;
	{
		string s;
		getline(cin, s);
		sscanf(s.c_str(), "%d", &n);
	}

	int* a = new int[n];


	for (int i = 0; i < n; i++) {
		cin >> a[i];
		int x = a[i];
		if (erat[x] >= 1) {
			erat[x] = 2;
			continue;
		}
		while (true) {
			if (x >= len)
				break;
			erat[x]++;
			x += a[i];
		}
	}

	int count = 0;
	
	for (int i = 0; i < n; i++) {
		if (erat[a[i]] <= 1)
			count++;
	}
	
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 7952
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] S = sc.next().split("");
        int N = S.length;
        String ret = "Yes";
        for (int i = 0; i < N/2; i++) {
            if (!S[i].equals(S[N - i - 1])) {
                ret = "No";
                break;
            }
        }
      	for (int i = 0; i < N/4; i++) {
          if (!S[i].equals(S[N/2 -i -1])) {
            ret = "No";
            break;
          }
        }
        System.out.println(ret);
    }
}

Measured memory_bytes: 22996
-- ABC042 B - 文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition)

import Data.List
import Control.Monad

main ::IO()
main = do
    [n,len] <- map read . words <$> getLine
    sls <- replicateM n getLine
    putStrLn $ ketugou $ sort sls


ketugou :: [String] -> String
ketugou [] = ""
ketugou strls = head strls ++ ketugou (tail strls)




Measured memory_bytes: 1404
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <decimal/decimal>
using namespace std;
using namespace __gnu_pbds;

#define rep(i, s, t) for (int i = s; i < int(t); ++i)

#define sc	scanf
#define pr	printf
#define ff	first
#define ss	second
#define mp	make_pair
#define pb	push_back
#define eb	emplace_back
#define range(c)	c.begin(), c.end()
#define lowbit(x)	((x) & -(x))
#define pop_count	__builtin_popcount
#define pop_count_64	__builtin_popcountll
#define tail_count	__builtin_ctz
#define tail_count_64	__builtin_ctzll
#define lead_count	__builtin_clz
#define lead_count_64	__builtin_clzll

#define TEMP template<typename
#define CONST(type) constexpr type const

TEMP... Ts> struct is_con { static CONST(bool) value = false; };
TEMP... Ts> struct is_con<vector<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<list<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<deque<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<map<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_map<Ts...>> { static CONST(bool) value = true; };

TEMP T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> const& p) { return os << "<" << p.ff << "," << p.ss << ">"; }
TEMP T> typename enable_if<is_con<T>::value, ostream>::type& operator<<(ostream& os, T const& c) {
	os << "{";
	bool first = true;
	for (auto const& x : c) {
		if (first) first = false;
		else os << ",";
		os << " " << x;
	}
	return os << " }";
}

TEMP T, typename... Ts> void dbg(T h, Ts... t) { cerr << " " << h; dbg<Ts...>(t...); }
template<> void dbg<int>(int x) { cerr << endl; }

#ifdef LOCAL
#define debug(...) cerr << "[ "#__VA_ARGS__" ] :", dbg(__VA_ARGS__, 0)
#else
#define debug(...) 0
#endif

TEMP T, typename U> using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
TEMP T> using ordered_set = ordered_map<T, null_type>;

typedef long long i64;
typedef decimal::decimal128 i99;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<i64> vl;

TEMP T> T& minn(T& lhs, T const& rhs) { return lhs = min(lhs, rhs); }
TEMP T> T& maxx(T& lhs, T const& rhs) { return lhs = max(lhs, rhs); }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, ac = 0, wa = 0, tle = 0, re = 0;
	cin >> n;
	while (n--) {
		string s;
		cin >> s;
		ac += s == "AC";
		wa += s == "WA";
		tle += s == "TLE";
		re += s == "RE";
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void shortestPath(const Graph &g, int s, vector<Weight> &dist) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (dist[e.dst] < e.weight) continue;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}

int main() {
  int n,m;
  cin >> n >> m;
  Graph g(n);
  REP(i,m) {
    int a,b,c,d;
    scanf("%d,%d,%d,%d\n",&a,&b,&c,&d);
    a--;b--;
    g[a].push_back(Edge(a,b,c));
    g[b].push_back(Edge(b,a,d));
  }
  int s, d, y1, y2;
  scanf("%d,%d,%d,%d\n",&s,&d,&y1,&y2);
  s--;d--;
  vector<int> dist;
  int hoge;
  shortestPath(g, s, dist);
  hoge = dist[d];
  shortestPath(g,d,dist);
  hoge += dist[s];
  cout << y1 - y2 - hoge << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
         
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define endl "\n"
#define mod 1000000007  
#define mod2 998244353 
const int N = 100001; 



void solve(){
    string a,b;
    cin>>a>>b;
    int ans=0;
    int n=a.length();
    rep(i,0,n){
        if(a[i]!=b[i])ans++;
    }
    cout<<ans;
    return ;
}
         
signed main(){
        IOS;

        // vi f(2e6+1);
        // f[0]=0;f[1]=0;f[2]=0;f[3]=4;
        // rep(i,4,2e6+1){
        //     f[i]=(f[i-1]+2*f[i-2])%mod;
        //     if(i%3==0)f[i]=(f[i]+4)%mod;
        // }
        int t=1;
        // cin>>t;
        rep(i,0,t){
            solve();
            // int temp;cin>>temp;
            // cout<<f[temp];

            cout<<"\n";
        //   cout<<" * "<<t<<"\n";
        }
    //    return 0;
}

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

int main()
{
	int n; cin >> n;
	
	vector<char> s(n);
	bool f = false;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == 'Y') f = true;
	}

	string ans = "Three";

	if (f)ans = "Four";
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
       ll n,a,b; cin >> n >> a >> b;
       ll ans=0;
       ans +=a*(n/(a+b));
       ll temp = n%(a+b);
       ans  += min(a,temp);
       cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



int n;

bool IsPalNum(int n) {
    stringstream ss;
    ss << n;
    string s = ss.str();
    reverse(ALL(s));
    if (ss.str() == s) return true;
    else return false;
}

int main() {
    cin >> n;
    int Min = 100000, res = -1;
    for (int i = 1; i <= 11111; ++i) {
        if (IsPalNum(i) && Min > abs(i-n)) {
            Min = abs(i-n);
            res = i;
        }
    }
    cout << res << endl;
            
    return 0;
}


Measured memory_bytes: 1220
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;

template <typename T> void max_self(T& a,T b)
{
  a = max(a,b);
}

int main() 
{

//longest common subsequence between two strings

string a,b;
cin>>a>>b;

vector<vector<pair<int,pair<int,int>>>>dp(a.length()+1,vector<pair<int,pair<int,int>>>(b.length()+1));

for(int i=0;i<(int) a.length();i++)
{
  for(int j=0;j<(int) b.length();j++)
  {
    if(a[i]==b[j])
    {
      max_self(dp[i+1][j+1],make_pair(1+dp[i][j].first,make_pair(i,j)));
    }
    max_self(dp[i+1][j],make_pair(dp[i][j].first,make_pair(i,j)));
    max_self(dp[i][j+1],make_pair(dp[i][j].first,make_pair(i,j)));
  }
}
pair<int,pair<int,int>> ans;
for(int i=0;i<=(int) a.length();i++)
{
  for(int j=0;j<=(int) b.length();j++)
  {
    max_self(ans,make_pair(dp[i][j].first,make_pair(i,j)));
  }
}

string s;
auto curr = ans.second;
//cout<<ans.first<<endl;
while(1)
{
  int i = curr.first;
  int j = curr.second;
  if(i==0 || j==0)
  {
    break;
  }

  auto prev = dp[i][j].second;

  if(prev == make_pair(i-1,j-1))
  {
    if(a[i-1]==b[j-1])
    s+=a[i-1];
  }
curr = prev;

}
reverse(s.begin(),s.end());
cout<<s<<endl;

}


Measured memory_bytes: 105984
import sys
    
global status, d
status = {}
d=0

def mst(p1, GRAPH):
    global status
    
    edge={}
    total = 0
    mini = 0
    while True:
        status[p1]=True
        for p2 in range(len(status)):
            if status[p2]==False and GRAPH.has_key((p1,p2)):
                edge[(p1, p2)]=GRAPH[(p1, p2)]
        mini=1000000
        for key, value in edge.items():
            if status[key[1]]==True:
                del edge[key]
                continue
            if value <mini:
                key0 = key
                mini = value
        if mini!=1000000:
            total+=mini
            p1=key0[1]
        else:
            break
    
    return total

n = int(raw_input())
x = {}
for i in range(n):
    seq = map(int,raw_input().split())
    for j in range(n):
        tmp = seq[j]
        if tmp != -1:
            x[(i, j)]=tmp
    status[i] = False

print mst(0, x)

Measured memory_bytes: 6000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n,k; cin>>n>>k;
    long long front; cin>>front;
    vector<long long> a(n-1); rep(i,n-1) cin>>a[i];
    long long ans=LINF;
    for(long long i=0;i<(1<<(n-1));i++){
        vector<long long> b=a;
        int cnt=0;
        long long mini=front,sum=0;
        for(long long j=0;j<n-1;j++){
            if((i>>j)&1){
                sum+=max(mini+1-b[j],0LL);
                b[j]=max(b[j],mini+1);
            }
            if(b[j]>mini) cnt++;
            mini=max(mini,b[j]);
        }
        // cout<<sum<<endl;
        if(cnt>=k-1) ans=min(ans,sum);
    };
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// B - Small and Large Integers
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int A,B,K; cin>>A>>B>>K;
	rp(i, A, min(B, A+K-1)+1) cout<<i<<endl;
	rp(i, max(B-K+1, A+K), B+1) cout<<i<<endl;
}

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

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int x;
    cin >> x;
    int ans = 0;
    int i = 1;
    while (100 * i <= x)
    {
        if (100 * i <= x && x <= 105 * i)
            ans = 1;
        i++;
    }
    cout << ans << endl;
}

int main(void)
{
    solve();
}


Measured memory_bytes: 3624