akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;

vector<int> ra(MX,0);
vector<int> par(MX,0);
using P = pair<int, int>;
using ll = long long;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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(ra[x]<ra[y]) {
        par[x] = y;
    }else {
        par[y] = x;
        if(ra[x]==ra[y]) {
            ra[x]++;
            
        }
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int a[MX];
int c[10][1000];
signed main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = inf;
    rep(div, 1<<h) {
        int g = 0;
        vector<int> id(h);
        rep(i, h) {
            id[i] = g;
            if(div>>i & 1) ++g;
        }
        ++g;
        rep(i,g) rep(j,w) c[i][j] = 0;
        rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j]-'0');

        int num = g - 1;
        vector<int> now(g);
        auto add = [&](int j) {
            rep(i,g) now[i] += c[i][j];
            rep(i,g) if(now[i]> k) return false;
            return true;
        };
        rep(j,w) {
            if(!add(j)) {
                num++;
                now = vector<int>(g);
                if(!add(j)) {
                    num = inf;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;

}



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

const int maxn = 1e5 + 5;
int a[maxn];

int main()
{
	int n, k;	cin >> n >> k;
	for(int i = 0; i < n; i ++)	cin >> a[i];
	int l = 0, r = k - 1;
	int ans = min(abs(a[l]), abs(a[r])) + a[r] - a[l];
	l ++;	r ++;
	while(r < n)
	{
		int tmp = min(abs(a[l]), abs(a[r])) + a[r] - a[l];
		ans = min(ans, tmp);
		l ++;	r ++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    ll l, r;
    cin >> l >> r;
    if (r - l + 1 >= 2019)
    {
        cout << 0 << endl;
        return 0;
    }
    vector<int> v;
    rep(i, l, r + 1)
    {
        v.push_back(i % 2019);
    }
    int ans = 2020;
    rep(i, v.size())
    {
        rep(j, i + 1, v.size())
        {

            ans = min(ans, (v[i] * v[j]) % 2019);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
S=input()
N=len(S)
ans=0
for i in range(2**(N-1)):
    Bit = list(i+1 for i in range(N-1))
    for j in range(N-1):
        if (i >> j) & 1:
            Bit[j] = 0
    Bit=[b for b in Bit if b>0]
    L=0
    for b in Bit:
        ans+=int(S[L:b])
        L=b
    ans+=int(S[L:])
print(ans)

Measured memory_bytes: 9144
#include<bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
int k, x, m, n, h, r, w; ll sum = 0,d = 0,c; string s;
int main() {
    cin >> m;
    rep(i, m) {
        cin >> k >> c;
        sum += k * c; d += c;
    }d--; sum--;
    cout << d + sum / 9 << endl;
}

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

int beki2(int n){
  if(n == 0) return 1;
  return 2*beki2(n-1);
}
int main(){
  int N,K; cin >> N >> K;
  
  double ans = 0;
  
  for(int i = 1; i <= N; i++){
    int n = i;
    int m = 0;
    while(n < K){
      n *= 2;
      m++;
    }
    ans +=  1 / (double)(beki2(m) * N);
  }
  cout << setprecision(12) << ans; // "3.1"
}

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

#define MAX_N 100
int par[MAX_N];
int rank[MAX_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;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	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);
}
struct Edge{
	int a,b,c;
	Edge(){}
	Edge(int a,int b,int c):a(a),b(b),c(c){}
	bool operator<(const Edge &e)const{return c<e.c;}
};

int main(){
	int n,m;
	vector<Edge> edge;
	while(cin>>n&&n){
		edge.clear();
		cin>>m;
		for(int i=0;i<m;i++){
			int a,b,c;
			char _;
			cin>>a>>_>>b>>_>>c;
			edge.push_back(Edge(a,b,c/100-1));
		}
		init(n);
		sort(edge.begin(),edge.end());
		int ans=0;
		for(int i=0;i<m;i++){
			Edge &e=edge[i];
			if(!same(e.a,e.b)){
				unite(e.a,e.b);
				ans+=e.c;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1328
def return_binary(n, s):
    t = bin(n)[2:]
    while s > len(t):
        t = '0' + t
    t = t + '1'
    return t


def add_up(n, b):
    temp = ''
    total = 0
    for x in range(len(n)):
        temp = temp + n[x]
        if b[x] == '1':
            total = total + int(temp)
            temp = ''
    return total


raw_input = input()
length = len(raw_input)
tot = 0

if length == 1:
    print(raw_input)
else:
    for i in range(2**(length-1)):
        binary = return_binary(i, length-1)
        tot = tot + add_up(raw_input, binary)
    print(tot)


Measured memory_bytes: 3064
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut counts: HashMap<usize, usize> = HashMap::new();
    for _ in 0..n {
        let ai: usize = iterator.next().unwrap().parse().unwrap();
        *counts.entry(ai).or_insert(0) += 1;
    }

    let mut keys: Vec<&usize> = counts.keys().collect::<Vec<_>>();
    keys.sort();

    let mut edge1: usize = 0;
    for &&key in keys.iter().rev() {
        if edge1 == 0 {
            if counts[&key] >= 4 {
                return format!("{}", key * key);
            } else if counts[&key] >= 2 {
                edge1 = key;
            }
        } else {
            if counts[&key] >= 2 {
                return format!("{}", edge1 * key);
            }
        }
    }

    return "0".into();
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    long long int MA = max(A, max(B, C));
    long long int ans = MA * pow(2, K);
    ans += (A + B + C);
    ans -= MA;
    cout << ans << endl;
}

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

int main(){
    int n,v;
    scanf("%d",&n);
    vector<int> cnt(n,0);
    for(int i=1;i<n;i++) {
        scanf("%d", &v);
        cnt[v-1]++;
    }
    for(auto& c : cnt) printf("%d\n", c);
}


Measured memory_bytes: 4080
"""

https://atcoder.jp/contests/agc010/tasks/agc010_c

似たような問題を最近やらなかったっけ…？
→Complete Compressか

部分木に注目してみる

部分木から飛び出すパスの個数をXとしてみよう
余ったパスは上に投げるしかない
→部分木から飛び出すパスの本数の最小をYとすると、Y[根] == 0 が答え
根は葉でない頂点を適当に選ぶ

飛び出すパスの本数の最小はどう計算するか？
最大と最小を受け取る
いい感じにつなげて最小と最大を導出したい

まず、最大・最小間はすべて作れるのか？
2本飛び出している奴を接続すると、飛び出しは2減り、1余るので飛び出しが1ふえる…？
→もしかして飛び出し本数の候補はより少ない？

容量が X で、子が全部葉、 a,bとする
n組繋げたとすると、 a+b-2n 本飛び出す
X = n + (a+b-2n) = a+b-n
なので、nは一定値になる n = a+b-X
nは、最小は0、最大は過半数でなければa+b+…　にでき、そうでなければ最大値以外の和の範囲を取れる
nがその条件を満たしているかを調べればいい

"""

from sys import stdin
import sys
sys.setrecursionlimit(200000)

def dfs(v,p):
    if len(lis[v]) == 1:
        return A[v]

    chlis = []
    for nex in lis[v]:
        if nex != p:
            chlis.append(dfs(nex,v))
    chlis.sort()
    chsum = sum(chlis)

    n = chsum - A[v]
    if chlis[-1] * 2 <= chsum:
        if 0 <= n <= chsum//2:
            pass
        else:
            print ("NO")
            sys.exit()
    else:
        if 0 <= n <= chsum-chlis[-1]:
            pass
        else:
            print ("NO")
            sys.exit()
    return chsum - 2 * n

N = int(stdin.readline())

A = list(map(int,stdin.readline().split()))
if N == 2:
    if A[0] == A[1]:
        print ("YES")
    else:
        print ("NO")
    sys.exit()

lis = [ [] for i in range(N)]

for loop in range(N-1):
    u,v = map(int,stdin.readline().split())
    u -= 1
    v -= 1
    lis[u].append(v)
    lis[v].append(u)

root = None
for i in range(N):
    if len(lis[i]) > 1:
        root = i
        break

ret = dfs(root,root)
if ret == 0:
    print ("YES")
else:
    print ("NO")



Measured memory_bytes: 219960
#include<stdio.h>

#define MAX 10000
#define NIL -1

typedef struct{
	int a;
	int b;
	int c;
}Node;

Node T[MAX];
int n , D[MAX] , H[MAX];

void setDepth( int u , int d ){
	
	if( u == NIL ){
		return;
	}
	D[u] = d;
	setDepth( T[u].b , d+1 );
	setDepth( T[u].c , d+1 );
}

int setHeight( int u ){
	
	int h1 = 0 , h2 = 0;
	
	if( T[u].b != NIL ){
		h1 = setHeight( T[u].b ) +1;
	}
	if( T[u].c != NIL ){
		h2 = setHeight( T[u].c ) + 1;
	}
	return H[u] = ( h1 > h2 ? h1 : h2 );
}

int getSibling( int u ){
	
	if( T[u].a == NIL ){
		return NIL; 
	}
	if( T[T[u].a].b != u && T[T[u].a].b != NIL ){
		return T[T[u].a].b;
	}
	if( T[T[u].a].c != u && T[T[u].a].c != NIL ){
		return T[T[u].a].c;
	}
	return NIL;
	
}

void print( int u ){
	
	printf( "node %d: " , u );
	printf( "parent = %d, " , T[u].a );
	printf( "sibling = %d, " , getSibling(u) );
	
	int deg = 0;
	
	if( T[u].b != NIL ){
		deg++;
	}
	if( T[u].c != NIL ){
		deg++;
	}
	printf( "degree = %d, " , deg );
	printf( "depth = %d, " , D[u] );
	printf( "height = %d, " , H[u] );
	
	
	if( T[u].a == NIL ){
		printf( "root\n" );
	}else if( T[u].b == NIL && T[u].c == NIL ){
		printf( "leaf\n" );
	}else{
		printf( "internal node\n" );
	}
}

int main( void ){
	
	int v , l , r , root = 0;
	
	scanf( "%d" , &n );
	
	for( int i = 0; i < n; i++ ){
		T[i].a = NIL;
	}
	
	for( int i = 0; i < n; i++ ){
		scanf( "%d" , &v );
		scanf( "%d" , &l );
		scanf( "%d" , &r );
		T[v].b = l;
		T[v].c = r;
		if( l != NIL ){
			T[l].a = v;
		}
		if( r != NIL ){
			T[r].a = v;
		}
	}
	
	for( int i = 0; i < n; i++ ){
		if( T[i].a == NIL ){
			root = i;
		}
	}
	
	setDepth( root , 0 );
	setHeight( root );
	
	for( int i = 0; i < n; i++ ){
		print( i );
	}
	
	return 0;
}



Measured memory_bytes: 2048
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    N=str(input())
    sum1=0
    for i in N:
        sum1 += int(i)
    
    if sum1%9 ==0:
        print("Yes")
        sys.exit()
    print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
a, b = list(map(int, input().split()))

white = "."
black = "#"
wb = white+black
wremaining = a - 1
bremaining = b - 1

print("100 100")
for i in range(25):
    if bremaining >= 50:
        print(wb*50)
        bremaining -=50
    elif bremaining > 0:
        s = wb*bremaining + white*(50-bremaining)*2
        print(s)
        bremaining = 0
    else:
        print(white*100)
    print(white*100)

for i in range(25):
    print(black*100)
    if wremaining >= 50:
        print(wb*50)
        wremaining -= 50
    elif wremaining > 0:
        s = wb*wremaining + black*(50-wremaining)*2
        print(s)
        wremaining = 0
    else:
        print(black*100)

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

int main(void)
{
    int n, d;
    cin >> n >> d;
    int x[11][11];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) cin >> x[i][j];
    }
    bool sq[100010] = {};
    for (int i = 0; i < 200; i++) sq[i*i] = 1;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            int s = 0;
            for (int k = 0; k < d; k++) {
                s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            if(sq[s]) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
  int main(void){

  int x,y,z;
  scanf("%d %d",&x,&y);

  if(x<y){
    z = x;
    x = y;
    y = z;
  }

  for(;;){
    if(y==0)
      break;
    z = x%y;
    x = y;
    y = z;
  }

  printf("%d\n",x);

  return 0;
}


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

int main()
{
    int n, R, maxv = INT_MIN, minv;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> R;
        if (i == 0) {
            minv = R;
        } else {
            if (maxv < R - minv)
                maxv = R - minv;
            if (minv > R)
                minv = R;
        }
    }
    cout << maxv << endl;
}


Measured memory_bytes: 3116
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int T = Integer.parseInt(sc.next());

		double c = (T+0.5)/A * B;
		int a =(int) c /B;
		System.out.println(a*B);

	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
int main()
{
	lli h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	lli diff=(h2-h1)*60+(m2-m1);
	cout<<diff-k;
}



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

using namespace std;
typedef long long ll ;
ll arr[5001] , score [5001] , vis[5001];
ll n  , k ;
const ll OO =-1e18;
ll mx;
ll cycleLen(ll idx)
{
    if(vis[idx])
        return 0;
    vis[idx]++;
    ll cnt=cycleLen(arr[idx])+1;
    return cnt;
}
ll cycleVal( ll idx , ll num , ll scsofar , ll MX)
{
    if(vis[idx])
        return 0;
    vis[idx]++;
    scsofar+=score[arr[idx]];
    num++;
    if(num<=MX)mx=max(mx , scsofar);
    ll ans=cycleVal(arr[idx] , num , scsofar , MX)+score[arr[idx]];
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k ;
    cin >> n >>k ;
    for(int i = 1 ; i <=n ;i++)
    {
        cin >> arr[i];
    }
    for(int i = 1 ; i <=n ;i++)
    {
        cin >> score[i];
    }
    ll ans=OO , len , cyc;
    pair<int,int>p;
    for(int i = 1 ; i <=n ; i++)
    {
        memset(vis , 0 , sizeof vis);
        mx=OO;
        len=cycleLen(i);
        memset(vis , 0 , sizeof vis);
        cyc=cycleVal(i , 0 , 0 , k%len );
        ll x= k/len ;
        ans=max(ans , cyc*(x)+mx);
        memset(vis , 0 , sizeof vis);
        mx=OO;
        cyc=cycleVal(i , 0 , 0 , min(k,len) );
        ans=max(ans , cyc*max(x-1 , (long long)0)+mx);
        ans=max(ans , mx);
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 3880
def main():
    s = input()
    k = int(input())
    ss = set()
    sss = sorted(s)
    for i in range(len(s)):
        for j in range(i+1, i+6):
            ss |= {s[i:j]}
    print(sorted(ss)[k-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 4588
program main
  implicit none
  integer A,B,T,i,sumkukki
  sumkukki = 0
  read(*, *) A, B, T
  do i = 1,T
    if (mod(i,A) == 0) then
      sumkukki = sumkukki + B
    end if
  end do 

  write(* ,'(i0)') sumkukki
end program main


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int k,n;
    cin >> k >> n;
    vector<int> a;
    for(int i=0; i<n; i++){
      int test;
      cin >> test;
      a.push_back(test);
    }
    
    int testPointNum = a[0] + k;
    a.push_back(testPointNum);
    
    int maxLong = 0;
    int sumLong = 0;
    for(int i=0; i<n; i++){
      int PtoPlong = abs(a[i] - a[i+1]);
      if(PtoPlong > maxLong){
        maxLong = PtoPlong;
      }
      sumLong += PtoPlong;
    }
    cout << sumLong - maxLong << endl;
    return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	static final long MOD = 1000000007;
	static long modpow(long n, long y){
		if(y == 0){
			return 1;
		}else if(y == 1){
			return n % MOD;
		}else{
			if(y % 2 == 0){
				long r = modpow(n , y / 2);
				return (r * r) % MOD;
			}else{
				long r = modpow(n , y / 2);
				long r2 = (r * r) % MOD;
				return (r2 * n) % MOD;				
			}
		}
	}
	static long modinv(long n){
		return modpow(n , MOD - 2);
	}
	static long comb(int N , int R, long fact[]){
		long ret = fact[N];
		ret = (ret * modinv(fact[R])) % MOD;
		ret = (ret * modinv(fact[N - R])) % MOD;
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		long all = modpow(26, K + S.length());
		long fact[] = new long[K + S.length() + 1];
		fact[0] = 1;
		fact[1] = 1;
		for(int i = 2 ; i < fact.length; ++i){
			fact[i] = (i * fact[i - 1]) % MOD;
		}
		long sum = 0;
		for(int i = 0 ; i < S.length() ; ++i){
			long res = K + S.length() - i;
			long pat = modpow(25, res);
			pat = (pat * comb(K + S.length() , i , fact)) % MOD;
			sum = (sum + pat) % MOD;
		}
		long ret = (all - sum + MOD) % MOD;
		System.out.println(ret);
	}
}


Measured memory_bytes: 57760
// nomura2020_b
#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 <atomic>
#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 <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string t;
  cin >> t;
  ll t_size = (int)t.size();
  for (int i = 0; i < t_size; ++i) {
    if (t[i] == '?') {
      t[i]='D';
    }
  }

  cout << t << endl;
  return 0;
}


Measured memory_bytes: 3736
N, M = list(map(int,input().split()))
s = []
c = []
for i in range(M):
    in1, in2 = list(map(int,input().split()))
    s.append(in1 - 1)
    c.append(in2)
    
def solve():
    
    res = [-1 for _ in range(N)]

    for i in range(M):
        if res[s[i]] != -1 and res[s[i]] != c[i]:
            print(-1)
            return
        if s[i] == 0 and c[i] == 0 and N != 1:
            print(-1)
            return
        res[s[i]] = c[i] 

    ans = ""
    
    if N == 1:
        if res[0] == -1:
            print(0)
        else:
            print(res[0])
        return
    
    for i in range(N):
        if res[i] == -1:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
        else:
            ans += str(res[i])
    print(ans)

solve()

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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    int count = 0;
    int ans = 101;
    while (count < K)
    {
        ans--;
        if (A % ans == 0 && B % ans == 0)
        {
            count++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define NAME 10
#define NUM 100000

int head = 0, tail = 0;
typedef struct {
    char name[NAME+1];
    int  time;// if structure variable name is 'res', this variable 'time' means end time. 
}Info;
Info data[NUM+1];
void enqueue( Info );
Info dequeue( void );

int main(){
    int n, quantum, total_time = 0;
    int i, cnt = 0;
    Info tmp, res[NUM];

    //input area
    scanf("%d%d", &n, &quantum);
    for (i = 0; i<n; i++)
	scanf("%s%d", data[i].name, &data[i].time);

    //processing area
    for (tail = n-1;;){
	//when job time is larger than quantum.
	if (data[head].time > quantum){
	    tmp = dequeue();
	    total_time += quantum;
	    tmp.time -= quantum;
	    enqueue(tmp);
	}else {//when job time is smaller than or equal to quantum.
	    tmp = dequeue();
	    total_time += tmp.time;
	    tmp.time = total_time;//update job-time into finished time
	    res[cnt] = tmp;//resister the result
	    cnt++;
	}
	//check the data exist or not	
	if (head == tail+1) break;
    }

    //display area
    for (i = 0; i<n; i++)
	printf("%s %d\n", res[i].name, res[i].time);

    return 0;
}


void enqueue( Info x ){
    //when the tail reached the end of queue.
    if (tail == NUM){
	tail = 0;
	data[tail] = x;
    }else {
	tail++;
	data[tail] = x;
    }
    return ;
}

Info dequeue( void ){
    //when the head reached the end of queue.
    if (head == NUM){
	head = 0;
	return data[NUM];
    }else {
	head++;
	return data[head-1];
    }
}



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

S = [1] * (n + 1)
for _ in range(m):
    a = int(input())
    S[a] = 0

i = -3
for _ in range(n - 1):
    if S[i] != 0:
        S[i] = S[i + 1] + S[i + 2]
    i -= 1

ans = S[0] % (10**9 + 7)
print(ans)


Measured memory_bytes: 460020
#include "bits/stdc++.h"
using namespace std;

int K, A, B;

int main()
{
  cin >> K;
  cin >> A >> B;

  if (K * (B / K) >= A)
  {
    cout << "OK" << endl;
  }
  else
  {
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
int N, A[5], B[5], dp[5010], dp2[25000010];
void solve()
{
    int ans = 0;
    int t = 0;

    t = N;
    FOR(i, 0, N + 1)
    {
        dp[i] = N;
        bool a[5];
        FOR(j, 0, 3)
        {
            if (i >= A[j]) {
                a[j] = true;
            } else {
                a[j] = false;
            }
        }
        FOR(j, 0, 3)
        {
            if (a[j]) {
                dp[i] = max(dp[i], dp[i - A[j]] + B[j] - A[j]);
                t = max(t, dp[i]);
            }
        }
    }
    ans = t;
    FOR(i, 0, t + 1)
    {
        dp2[i] = t;
        bool b[5];
        FOR(j, 0, 3)
        {
            if (i >= B[j]) {
                b[j] = true;
            } else {
                b[j] = false;
            }
        }
        FOR(j, 0, 3)
        {
            if (b[j]) {
                dp2[i] = max(dp2[i], dp2[i - B[j]] + A[j] - B[j]);
                ans = max(ans, dp2[i]);
            }
        }
    }

    cout << ans << endl;
}


signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, 3)
    cin >> A[i];
    FOR(i, 0, 3)
    cin >> B[i];
    solve();
    return 0;
}


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

void kyori(string s[50], int d[50][50], int i, int j, int h, int w) {
	if (i < h - 1 && s[i + 1][j] == '.' && d[i][j] + 1 < d[i + 1][j] ) {
		d[i + 1][j] = d[i][j] + 1;
		kyori(s, d, i + 1, j, h, w);
	}

	if (i > 0 && s[i - 1][j] == '.' && d[i][j] + 1 < d[i - 1][j]) {
		d[i - 1][j] = d[i][j] + 1;
		kyori(s, d, i - 1, j, h, w);
	}

	if (j < w - 1 && s[i][j + 1] == '.' && d[i][j] + 1 < d[i][j + 1]) {
		d[i][j + 1] = d[i][j] + 1;
		kyori(s, d, i, j + 1, h, w);
	}

	if (j > 0 && s[i][j - 1] == '.' && d[i][j] + 1 < d[i][j - 1]) {
		d[i][j - 1] = d[i][j] + 1;
		kyori(s, d, i, j - 1, h, w);
	}
}

int main() {
	int h, w;
	int count;
	string s[50];
	int d[50][50];

	cin >> h >> w;

	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 50; j++) {
			d[i][j] = 9999;
		}
	}
	d[0][0] = 0;

	if (s[0][0] == '#' || s[h - 1][w - 1] == '#') {
		cout << "-1" << endl;
	}
	else {
		kyori(s, d, 0, 0, h, w);

		count = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '#') {
					count++;
				}
			}
		}

		if (d[h - 1][w - 1] == 9999) {
			cout << "-1" << endl;
		}
		else {
			cout << h * w - count - (d[h - 1][w - 1] + 1) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string s,t,u;
  cin >> s >> t >> u;
  cout << s[0]<< t[0] << u[0] << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int d, n;
    cin >> d >> n;
    int ans, cnt = 1;

    if (d == 0) {
        if (n != 100) ans = n;
        else ans = 101;
    }
    else if (d == 1) {
        if (n != 100) ans = n * 100;
        else ans = (n + 1) * 100;
    } else {
        if (n != 100) ans = n * 10000;
        else ans = (n + 1) * 10000;
    }
    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll fact[2005];

void prepare(){
  ll now=1;
  reps(i,2000){
    now*=i;
    now%=MOD;
    fact[i]=now;
  }
}

long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll x(n);
  rep(i,n) cin>>x[i];
  vll d(n-1);
  rep(i,n-1) d[i]=x[i+1]-x[i];
  
  ll c=0, ans=0;
  rep(i,n-1){
    c=(c+modinv(i+1,MOD))%MOD;
    ans=(ans+c*d[i])%MOD;
  }
  reps(i,n-1) ans=ans*i%MOD;
  
  cout<<ans<<endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,0,n) cin >> a[i];

    int maxi=2*1e5;
    //vector<vector<long double>> dp(n,vector<long double>(maxi,infll));
    //rep(i,1,maxi) dp[0][i]=(long double)(abs(a[0]-i))/a[0];
    vector<long double> curr(maxi,infll),next(maxi,infll);
    rep(i,1,maxi) curr[i]=(long double)(abs(a[0]-i))/a[0];
    rep(i,0,n-1){
        rep(j,1,maxi){
            for(int k=j; k<maxi; k+=j){
                next[k]=min(next[k],max(curr[j],(long double)(abs(a[i+1]-k))/a[i+1]));
            }
        }
        swap(curr,next);
        fill(next.begin(),next.end(),infll);
    }
    cout << *min_element(curr.begin(),curr.end()) << endl;
}

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

Measured memory_bytes: 9184
use std::io;

fn main() {
    let mut input_line:String = String::new();
    io::stdin().read_line(&mut input_line).expect("err");

//    let inputs: Vec<&str> = input_line.split_whitespace().collect();
    let inputs: Vec<&str> = input_line.split(",").collect();
    
    print!("{} {} {}",inputs[0], inputs[1], inputs[2])    
}


Measured memory_bytes: 2100
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int vx[12]={0,1,2,2,2,1,0,-1,-2,-2,-2,-1};
    int vy[12]={2,2,1,0,-1,-2,-2,-2,-1,0,1,2};
    for(;;){
        int sx,sy;
        scanf("%d%d",&sx,&sy);
        if(sx==0&&sy==0) break;
        int n;
        scanf("%d",&n);
        int xs[10],ys[10];
        for(int i=0;i<n;i++){
            scanf("%d%d",&xs[i],&ys[i]);
        }
        queue<P> que;
        que.push(P(sx,sy));
        for(int i=0;i<n;i++){
            int sz=que.size();
            bool isre[10][10];
            for(int j=0;j<10;j++){
                for(int k=0;k<10;k++){
                    isre[j][k]=false;
                }
            }
            for(int j=0;j<sz;j++){
                P now=que.front();
                que.pop();
                int nx=now.first,ny=now.second;
                for(int v=0;v<12;v++){
                    int nex=nx+vx[v],ney=ny+vy[v];
                    if(0<=nex && nex<10 && 0<=ney && ney<10 && abs(nex-xs[i])<=1 && abs(ney-ys[i])<=1 && !isre[nex][ney]){
                        isre[nex][ney]=true;
                        que.push(P(nex,ney));
                    }
                }
            }
            if(i==n-1){
                if(que.empty()) printf("NA\n");
                else printf("OK\n");
            }
        }
    }
}

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

int main() {
  int n, y;
  cin >> n >> y;
  for (int a=0; a<n+1; a++) {
    for (int b=0; b<(n+1)-a; b++) {
      for (int c=0; c<(n+1)-a-b; c++) {
        if ((a+b+c == n) && (a*10000 + b*5000 + c*1000 == y)) {
          cout << a << " " << b << " " << c << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}

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

int main(){
    int R,C,P;
    cin >> R >> C >> P;
    vector<int> v(P);
    for(int i=0;i<P;i++){
        int x,y;
        cin >> x >> y;
        v[i] = {R-x+1+(y<=C? C-y+1:y-C)};
    }
    sort(v.begin(),v.end(),greater<int>());
    int ans = 0;
    for(int i=0;i<P;i++){
        ans = max(ans,v[i]+i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4588
#include<stdio.h>
int main(void)
{
    double a;

    while(scanf("%lf",&a)!=EOF){
        if(a <= 48.0) printf("light fly\n");
        else if(a > 48.0 && a <= 51.0) printf("fly\n");
        else if(a > 51.0 && a <= 54.0) printf("bantam\n");
        else if(a > 54.0 && a <= 57.0) printf("feather\n");
        else if(a > 57.0 && a <= 60.0) printf("light\n");
        else if(a > 60.0 && a <= 64.0) printf("light welter\n");
        else if(a > 64.0 && a <= 69.0) printf("welter\n");
        else if(a > 69.0 && a <= 75.0) printf("light middle\n");
        else if(a > 75.0 && a <= 81.0) printf("middle\n");
        else if(a > 81.0 && a <= 91.0) printf("light heavy\n");
        else printf("heavy\n");
    }
    return 0;
}

Measured memory_bytes: 604
#include <stdio.h>

int main(void){
	int n,i,sum;
	char str[100];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		sscanf(str,"%d",&n);
		sum=0;
		for(i=0;i<600;i+=n){
			sum+=n*i*i;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  string S;
  cin>>S;
  int ten=1;
  int count[2019];
  for(int i=0;i<2019;i++){
    count[i]=0;
  }
  int k=0;
  for(int i=S.size()-1;i>=0;i--){
    k=(k+(S[i]-48)*ten)%2019;
    ten=(ten*10)%2019;
    count[k]++;
  }
  long long answer=count[0];
  for(int i=0;i<2019;i++){
    answer=answer+(count[i]*(count[i]-1))/2;
  }
  cout<<answer<<endl;
  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    string s; cin>>s;
    cout<<"ABC"+s<<endl;
}

Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	int k;
	cin >> k;
	int sum = 0;
	int n = k / 2;
	int ans = n*(n + 1);
	if (k % 2 == 0)ans -= k / 2;
	cout << ans << endl;
	return 0;
}





Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main(){
int N;
ll K,S;
cin>>N>>K>>S;
if(S==1e9){
    rep(i,N){
        if(i!=N-1){
           if(i<K){
            cout<<(ll)powl(10,9)<<" ";
           }
           else{
            cout<<1<<" ";
           }
        }
        else{
            if(i<K){
            cout<<(ll)powl(10,9)<<endl;
            }
            else{
            cout<<1<<endl;
            }

        }
    }
}
else{
    rep(i,N){
        if(i!=N-1){
           if(i<K){
            cout<<S<<" ";
           }
           else{
            cout<<(ll)powl(10,9)<<" ";
           }
        }
        else{
            if(i<K){
            cout<<S<<endl;
            }
            else{
            cout<<(ll)powl(10,9)<<endl;
            }

        }
    }

}
return 0;
}

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

int main() {
    int n; cin >> n;
    vector<char> s(n);
    for (auto &si: s) cin >> si;
    cout << (count(begin(s), end(s), 'Y') ? "Four" : "Three") << endl;
    return 0;
}


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

int main(){
	int a,b,c,d,n;
	int num=0;
	
	while(cin >> n){
	
	for(a=0;a<10;a++){
		for(b=0;b<10;b++){
			for(c=0;c<10;c++){
				for(d=0;d<10;d++){
					if(a+b+c+d ==n)	num++;
				}
			}
		}
	}
	cout << num << endl;
	num = 0;
	}

}

Measured memory_bytes: 1160
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}



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

    int n;
    cin>>n;
    array<ll,2> a[n];
    for(int i=0;i<n;i++){
        cin>>a[i][0];
        a[i][1] = i+1;
    }
    sort(a,a+n);
    ll ans = 0;
    ll dp[n+2][n+2]={};
    for(int d=0;d<n;d++){
        for(int l=1;l+d<=n;l++){
            int r = l+d;
            chmax(dp[l][r], dp[l+1][r] + abs(l-a[d][1]) * a[d][0]);
            chmax(dp[l][r], dp[l][r-1] + abs(r-a[d][1]) * a[d][0]);
            chmax(ans,dp[l][r]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 34992
#include <vector>
#include <iostream>

using namespace std;

int main()
{
	int x1, x2;
	while (cin >> x1 >> x2)
	{
		if (x1 < x2) swap(x1, x2);

		while (x2 > 0)
		{
			int tmp = x1 % x2;
			x1 = x2;
			x2 = tmp;
		}
		cout << x1 << endl;
	}
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	int a,b;
	ll c;
	vector<vector<pair<int,ll>>>path(n);
	rep(i,n-1){
		cin>>a>>b>>c;
		a--;
		b--;
		path[a].emplace_back(b,c);
		path[b].emplace_back(a,c);
	}
	int q,k;
	int x,y;
	cin>>q>>k;
	vector<ll>dis(n,-1LL);
	queue<int>Q;
	int at;
	Q.push(k-1);
	dis[k-1]=0LL;
	while(!Q.empty()){
		at=Q.front();
		Q.pop();
		repi(itr,path[at]){
			if(dis[itr->F]==-1LL){

			Q.push(itr->F);
			dis[itr->F]=dis[at]+(itr->S);
			}
		}
	}
	rep(i,n){
		clog<<" ("<<dis[i]<<endl;
	}
	rep(i,q){
		cin>>x>>y;
		x--;
		y--;

		cout << dis[x]+dis[y] << endl;
	}
	
}

Measured memory_bytes: 9984
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int compare_string(const void *left, const void *right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;
    
    return strcmp(left_char,right_char);
    
}


int main(){
    int i,n,count=1;
    char names[200001][11];
    scanf("%d",&n);
    for(i = 0; i < n; i++) scanf("%s",names[i]);
    qsort(names, n, sizeof *names, compare_string);
    
    for(i = 1; i < n; i++){
        if(strcmp(names[i-1],names[i]) != 0) count++;
    }
//    for(i = 0; i < n; i++) printf("%s\n",names[i]);
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 5700
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = get!(usize);
    let s: Vec<char> = util::line().chars().collect();
    let t: Vec<char> = util::line().chars().collect();

    let ans = (0..n + 1)
        .filter_map(|i| {
            let q = s[0..i]
                .iter()
                .chain(t.iter())
                .cloned()
                .collect::<Vec<char>>();

            if &q[..n] == &s[..] && &q[q.len() - n..] == &t[..] {
                Some(q.len())
            } else {
                None
            }
        })
        .nth(0)
        .unwrap();

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


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    string s; cin >> s;
    int ans = 0;
    rep(i,0,3){
        if(s[i] == 'R') ans++;
    }


    if(ans == 2 && s[1] == 'S') cout << "1\n";
    else cout << ans << "\n";
}

Measured memory_bytes: 3588