akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P;
typedef vector<int> Vi;
int const MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }

double dp[3001][3001];

int main(){
  cin.tie(0); ios::sync_with_stdio(false);
    
  int n; cin>>n; double a[n],ans=0;
  for (int i = 0; i < n; i++)cin>>a[i];
  dp[0][0]=1;
  for (int i = 0; i < n; i++){
    for (int j = 0; j <= n; j++){
      if(j)dp[i+1][j]+=dp[i][j-1]*a[i];
      dp[i+1][j]+=dp[i][j]*(1-a[i]);
    }
  }
  for (int i = n/2+1; i <= n; i++)ans+=dp[n][i];
  cout<<setprecision(11)<<ans<<'\n';
}

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

int main()
{
    int h,n;
    cin >> h >> n;
    vector<int> move;
    int a;
    int total=0;
    for(int i=0;i<n;i++) {
        cin >> a;
        h-=a;
    }
    if(h<=0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)
D = []
for i in range(min(K, X)):
    for j in range(min(K, Y)):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(min(K, Z)):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            else:

                D.append(A[i] + B[j] + C[k])

D.sort(reverse=True)
for i in range(K):
    print(D[i])

Measured memory_bytes: 47220
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int d;
	cin >> d;

	if (d == 25)
		cout << "Christmas";
	else if (d == 24)
		cout << "Christmas Eve";
	else if (d == 23)
		cout << "Christmas Eve Eve";
	else
		cout << "Christmas Eve Eve Eve";

	cout << endl;
			
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(long long i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

vector<ll> to[200005];
ll c[200005];
ll buka[200005];
vector<ll> dat[200005];
ll numcol[200005];
ll n;

void dfs(ll x, ll p) {
    if (to[x].size()==1 && to[x][0]==p) return;
    for (ll e: to[x]) {
        if (e==p) continue;
        dfs(e, x);
        buka[x] += (buka[e])+1;
    }
}

void dfs2(ll x, ll p) {
    ll color = c[x];
    int flg = dat[color].size();
    ll v;
    if (!flg) {
        dat[color].push_back(n);
    }
    
    v = dat[color][dat[color].size()-1];
    v -= (buka[x]+1);
    dat[color].erase(dat[color].end()-1);   
    
    //int id = dat[color].size()-1;
    for (ll e: to[x]) {
        if (e==p) continue;
        dat[color].push_back(buka[e]+1);
        //int v = dat[color][id];
        //dat[color].erase(dat[color].begin()+id);
        //dat[color].push_back(v);
        //id = dat[color].size()-1;
        dfs2(e, x);
    }
    
    dat[color].push_back(v);
    
}

int main(){
    cin >> n;
    
    
    rep(i, n) {
        cin >> c[i];
        c[i]--;
        numcol[c[i]]++;
    }
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        to[a].emplace_back(b);
        to[b].emplace_back(a);
    }

    dfs(0, -1);
    dfs2(0, -1);

    rep(i, n) {
        /*
        rep(j, dat[i].size()) {
            cout << dat[i][j] << " ";
        }
        */
        //cout << endl;
        if (dat[i].size()==0 && numcol[i]==0) {
            //ll ans2 = numcol[i]*(numcol[i]+1)/2;
            cout << "0" << endl;
            continue;
        }
        ll sum = 0;
        ll ans = 0;
        for (ll e: dat[i]) {
            ll x = e;
            sum += x;
            ans += x*(x+1)/2;
        }
        ll rem = n - sum - numcol[i];
        ans += rem*(rem+1)/2;
        ll res = n*(n+1)/2 - ans;
        cout << res << endl;
    }

    
    
    
    
    return 0;
}


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

public class AtCoderC
{
    private static int n;
    private static int m;
    private static int[,] lights;
    private static int[] conditions;
    static void Main()
    {
        {
            string line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            m = int.Parse(words[1]);
        }

        lights = new int[m, n];
        {
            for (int i = 0; i < m; i++)
            {
                string line = Console.ReadLine();
                var words = line.Split(' ');
                int num = int.Parse(words[0]);
                for (int j = 0; j < num; j++)
                {
                    int sw = int.Parse(words[j + 1]);
                    lights[i, sw - 1] = 1;
                }
            }
        }

        conditions = new int[m];
        {
            string line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < m; i++)
            {
                conditions[i] = int.Parse(words[i]);
            }
        }

        int[] array = new int[n];
        int answer = Progress(array, 0);

        Console.WriteLine(answer);
    }

    private static int Progress(int[] array, int index)
    {
        if (index == n)
        {
            for (int i = 0; i < m; i++)
            {
                int count = 0;
                for (int j = 0; j < n; j++)
                {
                    if (array[j] == 1)
                    {
                        if (lights[i, j] == 1)
                        {
                            count++;
                        }
                    }
                }
                if (count % 2 != conditions[i])
                {
                    return 0;
                }
            }
            return 1;
        }
        int[] newArray = (int[])array.Clone();
        newArray[index] = 1;
        return Progress(array, index + 1) + Progress(newArray, index + 1);
    }
}

Measured memory_bytes: 11220
{-# LANGUAGE ScopedTypeVariables,Rank2Types #-}


import Data.Array.ST
import Data.Array
import Data.STRef
import Control.Monad.ST
import Control.Monad

--head,tail,size,bodyArray
type Queue s a = (STRef s (Int,Int,Int),STArray s Int (Maybe a))

new_queue::Int->ST s (Queue s a)
new_queue size = do
  ar<-newArray (0,size-1) Nothing
  hts_pt<-newSTRef (0,0,size)
  return (hts_pt,ar)

is_empty::Queue s a -> ST s Bool
is_empty (hts_pt,ar) = do
  (h,t,s)<-readSTRef hts_pt
  return (if h==t then True else False)

is_full::Queue s a -> ST s Bool
is_full (hts_pt,ar) = do
  (h,t,s)<-readSTRef hts_pt
  return (if mod (t+1) s == h then True else False)

de_queue::Queue s a -> ST s a
de_queue (hts_pt,ar) = do
  (h,t,s)<-readSTRef hts_pt
  (Just v)<-readArray ar h
  writeArray ar h Nothing
  writeSTRef hts_pt (mod (h+1) s,t,s)
  return v

en_queue::a -> Queue s a -> ST s ()
en_queue v (hts_pt,ar) = do
  (h,t,s)<-readSTRef hts_pt
  writeArray ar t (Just v)
  writeSTRef hts_pt (h,mod (t+1) s,s)
  return ()

show_queue::Queue s a -> ST s (Maybe (Array Int (Maybe a)))
show_queue (hts_pt,ar) = do
  b<-is_empty (hts_pt,ar)
  if b then return Nothing else do
                              iar<-freeze ar
                              return (Just iar)

--キュー、プロセス単位、現在時、完了履歴
do_proc::Queue s (String,Int) -> Int -> Int ->ST s [(String,Int)]
do_proc queue quant now = do
  b<-is_empty queue
  if b then return []
       else do
         (p_name,p_time) <- de_queue queue
         if p_time <= quant then do
              rest<-do_proc queue quant (now+p_time)
              return ((p_name,now+p_time):rest)
                            else do
              en_queue (p_name,p_time-quant) queue
              rest<-do_proc queue quant (now+quant)
              return rest

make_schedule::Int->[(String,Int)]->ST s (Queue s (String,Int))
make_schedule n ls = do
  queue<-new_queue n
  forM_ ls (\ i -> en_queue i queue)
  return queue


n_get::Int->IO [(String,Int)]
n_get 0 = return []
n_get n =do
  ptc<-getLine
  let p=head (words ptc)
  let t=read (last (words ptc))
  rest<-n_get (n-1)
  return ((p,t):rest)

main::IO()
main=do
  nqc<-getLine
  let n:q:[] = map read (words nqc)
  dat<-n_get n
  let trace = runST $ do
                queue<-make_schedule 100000 dat
                tr<-do_proc queue q 0
                return tr
  forM_ trace print_ls

print_ls::(String,Int)->IO()
print_ls (p,t) = do
  putStr (p++" ")
  print t


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

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

	int H, W;
	char c[110][110];
	string s[110];
	cin >> H >> W;
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) {
		cin >> c[i][j];
		s[i].push_back(c[i][j]);
	}
	for (int i = 0; i < H; i++){
		cout << s[i] << endl << s[i] << endl;
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<long> A(N);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  long long ll_2x1 = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0) ll_2x1 += A.at(i);
    else ll_2x1 -= A.at(i);
  }
  long long ll_2xi = ll_2x1;
  for(int i = 0; i < N - 1; i++){
    cout << fixed;
    cout << setprecision(10) << ll_2xi << " ";
    ll_2xi = 2 * A.at(i) - ll_2xi;
  }
  cout << fixed;
  cout << setprecision(10) << ll_2xi << endl;
}

Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a=n/k;
    ll b=n%k;
    cout<<min(abs(b-k),b)<<endl;

    return 0;
}

Measured memory_bytes: 256
// Don't place your source in a package
import java.util.*;
import java.lang.*;
import java.io.*;

// Please name your class Main
public class Main {
  int n, m;
  ArrayList<Integer> gr[];
  
  int cnt[] = new int[2];
  int d[];
  
  Main() {
    n = nxtint(); m = nxtint();
    gr = new ArrayList[n + 10];
    for (int i = 0; i ++ < n; ) gr[i] = new ArrayList<>();
    for (int i = -1; ++ i < m; ) {
      int u = nxtint(), v = nxtint();
      gr[u].add(v);
      gr[v].add(u);
    }
    Queue<Integer> qu = new LinkedList<Integer>();
    d = new int[n + 10];
    Arrays.fill(d, -1);
    d[1] = 0;
    for (qu.add(1); qu.size() > 0; ) {
      int u = qu.remove();
      cnt[d[u] & 1]++;
      for (int v: gr[u]) {
        if (d[v] != -1) {
          if ((d[u] + d[v]) % 2 != 0) continue;
          out.println((long)n * (n - 1) / 2 - m);
          return;
        }
        d[v] = d[u] + 1;
        qu.add(v);
      }
    }
    
    long t = 0;
    for (int i = 0; i ++ < n; ) {
      t += cnt[~d[i] & 1];
    }
    t /= 2;
    t -= m;
    out.println(t);
  }
  
  //////////////////////////////////////////////////////////////////////////////////////
  public static void main(String args[]) { new Main().out.flush(); }
  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out), false);
  PrintStream err = System.err;
  
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  StringTokenizer st = null;
  String nxttok() {
    try { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());}
    catch (IOException e) { throw new RuntimeException(e); }
    return st.nextToken();
  }
  int nxtint() { return Integer.parseInt(nxttok()); }
  long nxtlong() { return Long.parseLong(nxttok()); }
  double nxtdouble() { return Double.parseDouble(nxttok()); }
  
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll inf=1e18;
const ll maxs = 100005;
const ll mod = 1e9+7;

#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

ll a[maxs];
ll n;
ll dp[3002][3002]; // just reduce size before run;

ll solve(ll l,ll r)
{
    if(dp[l][r]!=-1) 
        return dp[l][r];
  	if(l==r+1)
      	return max(a[l],a[r]);
  
    if(l==r)
    {
        return dp[l][r] = a[l];
    }
    ll left = a[l] - solve(l+1,r);
    ll right = a[r] - solve(l,r-1);
    
    return dp[l][r] = max(left,right);
}

int main(){
    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    memset(dp,-1,sizeof dp);
	cout<<solve(0,n-1);
	//cout<<dp[0][n-1];
	return 0;
}

Measured memory_bytes: 70912
/*****************************
Filename: dkljlkfd.cpp
Author: hbb
Create: 2020-04-05 13:36:56
 *****************************/
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = INT_MAX >> 1;
typedef long long int LL;

LL n;

int main(){
	scanf("%lld", &n);
	LL ans = (n / 500LL) * 1000LL;
	LL temp = n % 500LL;
	if(temp != 0)
	ans += (temp / 5LL) * 5LL;
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b;
    cin>>a>>b;
  
      if(a >=b)
      {
         for(int i=1;i<=a;i++)
            cout<<b;
      }
     else
     {
        for(int i=1;i<=b;i++)
          cout<<a;
     }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod (1e9+7)
#define inf (1e9+7)
#define nil -1
int timer;
void dfs(int u,int prev,vvi& A,vb& visit,vi& prenum,vi& parent,vi& lowest) {
	prenum[u]=lowest[u] = timer;
	timer++;
	visit[u] = true;
	int next;
	for (int i = 0; i < A[u].size(); i++)
	{
		next = A[u][i];
		if (!visit[next]) {
			parent[next] = u;
			dfs(next, u, A, visit, prenum, parent, lowest);
			lowest[u] = min(lowest[u],lowest[next]);
		}
		else if (next!=prev) {
			lowest[u] = min(lowest[u], prenum[next]);
		}
	}
}
int main() {
	int  V,E;
	cin >> V >> E;
	vvi A(V);
	for (int i = 0; i < E; i++)
	{
		int s, t;
		cin >> s >> t;
		A[s].push_back(t);
		A[t].push_back(s);
	}
	vi prenum(V);
	vi parent(V);
	vi lowest(V);
	vb visit(V, false);
	timer = 1;
	dfs(0,-1,A,visit,prenum,parent,lowest);
	set<int> kansetu;
	int np = 0;
	int rclen = 0;
	for (int i = 1; i < V; i++)
	{
		int p = parent[i];
		if (p==0) {
			rclen++;
		}
		else if(prenum[p]<=lowest[i]) {
			kansetu.insert(p);
		}
	}
	if (rclen>1) {
		kansetu.insert(0);
	}
	for (set<int>::iterator i = kansetu.begin(); i != kansetu.end(); i++)
	{
		cout<<*i<<endl;
	}
}


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

int main() {
  int N, M;
  cin >> N;
  if(N <= 111) {
    M = 111;
  }
  else if(N <= 222) {
    M = 222;
  }
  else if(N <= 333) {
    M = 333;
  }
  else if(N <= 444) {
    M = 444;
  }
  else if(N <= 555) {
    M = 555;
  }
  else if(N <= 666) {
    M = 666;
  }
  else if(N <= 777) {
    M = 777;
  }
  else if(N <= 888) {
    M = 888;
  }
  else if(N <= 999) {
    M = 999;
  }
  
  cout << M << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def calc(flag):
    s = res = 0
    for i in range(N):
        flag = flag * -1
        s += a[i]
        if flag == 1:
            if s <= 0:
                res += abs(s) + 1
                s = 1
        elif flag == -1:
            if s >= 0:
                res += abs(s) + 1
                s = -1
    return res

N = int(input())
a = list(map(int, input().split()))

ans = min(calc(1), calc(-1))
print(ans)


Measured memory_bytes: 20028
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n;
    cin>>n;

    string s_n = to_string(n);

    for(int i=0; i<s_n.size(); i++) {
        if(s_n[i]=='1') {
            s_n[i] = '9';
        } else if(s_n[i]=='9') {
            s_n[i] = '1';
        }
    }
  cout<<s_n<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<float.h>

int main (){
  int a,b,w,am;
  double f;
  scanf("%d%d",&a,&b);
  w = a / b;
  am = a % b;
  f = a*1.0 / b;
  printf("%d %d %f\n",w,am,f);
  return 0;
}

Measured memory_bytes: 636
# AOJ 0030 Sum of Integers

NUMS = (0..9).to_a
MAX_N = 10
MAX_SUM = 45

n_combinations = Array.new(MAX_N + 1) {Array.new(MAX_SUM + 1, 0)}

(1..MAX_N).each do |n|
  NUMS.combination(n).each do |c|
    n_combinations[n][c.reduce(0, :+)] += 1
  end
end

while line = gets
  n, s = line.split.map(&:to_i)
  break if n.zero? && s.zero?

  if 1 <= n && n <= 10 && 0 <= s && s <= 45
    puts n_combinations[n][s]
  else
    puts 0
  end
end

Measured memory_bytes: 6116
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

A, B = LI()
print(A*B)


Measured memory_bytes: 67424
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

struct pl {
    bool operator()(const pll &a, const pll &b) {
        return a.first * a.second < b.first * b.second;
    }
};

int main(void)
{
    IOS
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n),f(n);
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> f[i];
    sort(ALL(a));
    sort(RALL(f));

    auto isok = [&](ll &x){
        bool ret = true;
        ll k2 = k;
        REP(i,a.size()) {
            ll c = a[i] * f[i] - x;
            if (c > 0) {
                if (c % f[i] == 0) k2 -= c / f[i];
                else k2 -= c / f[i] + 1;

                if (k2 < 0) {
                    ret = false;
                    break;
                }
            }
        }
        return ret;
    };

    // めぐる式2分探索
    ll ng = -1, ok = a.back() * f.front()+1;
    while(abs(ok-ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isok(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
        // cerr << ng << " " << ok << endl;
    }
    
    cout << ok << endl;

    return 0;
}

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

int main() {

  while(1) {
    int n,a,b,c,x;
    cin >> n >> a >> b >> c >> x;
    if(!(n||a||b||c||x)) break;

    int y[20000] = {0};
    for(int i = 0; i < n; i++) cin >> y[i];

    int i = 0, f = 0;
    while(1) {
       if(x == y[i]) {
         i++;
         if(i == n) break;
       }
       x = (a*x+b)%c;
       f++;
       if(f > 10000) {
         f = -1;
         break;
       }
     }
     cout << f <<endl;
  }

	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n;
    cin >> n;
    int p = 0;
    int w = 0;
    int g = 0; 
    int y = 0;
    rep(i,n){
        char c;
        cin >> c;
        if(c == 'G')g++;
        else if(c == 'Y')y++;
        else if(c == 'P')p++;
        else w++;
    }
    if(y == 0)cout << "Three\n";
    else cout << "Four\n";
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
  if a[i]>=b[i]: ans+=b[i]
  else:
    ans+=min(b[i],a[i]+a[i+1])
    a[i+1] = max(0,a[i]+a[i+1]-b[i])
print(ans)

Measured memory_bytes: 18468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, a = -LLINF, b = LLINF, c = -LLINF, d = LLINF;
pi arr[200005];

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) {
		cin >> arr[i].f >> arr[i].s;
		a = max(a, arr[i].f + arr[i].s);
		b = min(b, arr[i].f + arr[i].s);
		c = max(c, arr[i].f - arr[i].s);
		d = min(d, arr[i].f - arr[i].s);
	}
	cout << max(a-b, c-d);
}


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

int main()
{
    int n,m,c;
    cin >> n >> m >> c;
    int b[m];
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j < m; j++){
            int x;
            cin >> x;
            sum += (b[j] * x);
        }
        if(sum + c > 0){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int n;
  cin >> n;
  const ll MOD = (ll)pow(10,9)+7;
  vector<ll> a(n);
  vector<ll> p(n);
  rep(i,n){
    cin >> a[i];
    if(i == 0) p[i] = a[i];
    else{
      p[i] = p[i-1] + a[i];
      p[i] %= MOD;
    }
  }
  ll ans = a[0]*a[1];
  ans %= MOD;
  for(int i=2;i<n;i++){
    ans += p[i-1]*a[i];
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6392
#include <cstdio>  
#include <iostream>  
#include <cstring>  
#include <string>  
#include <cmath>  
#include <algorithm>  
#include <cstdlib>  
#include <utility>  
#include <map>  
#include <stack>  
#include <set>  
#include <vector>  
#include <queue>  
#include <deque>  
#include <sstream>  
#include <bitset>   
#define x first  
#define y second  
#define mp make_pair  
#define pb push_back  
#define LL long long  
#define ld long double  
#define Pair pair<int,int>  
#define LOWBIT(x) x & (-x)  
using namespace std;  
  
const int INF=0x7ffffff;  
  
int ans=INF;  
int movee[5][3];  
bool visited[848][848];  
int r,c,k;  
int sx,sy;  
int a[848][848];  
char s[1000];  
queue<int> q;  
  
void bfs(int x,int y,int step)  
{  
    q.push(x);q.push(y);q.push(0);  
    int cur_ans,cx,cy,cd,xx,yy,dd;  
    visited[x][y]=true;  
    while (!q.empty())  
    {  
        cx=q.front();q.pop();  
        cy=q.front();q.pop();  
        cd=q.front();q.pop();  
        cur_ans=cx-1;  
        cur_ans=min(cur_ans,cy-1);  
        cur_ans=min(cur_ans,r-cx);  
        cur_ans=min(cur_ans,c-cy);  
        ans=min(ans,cur_ans);  
        if (cd==k) continue;  
        for (int i=1;i<=4;i++)  
        {  
            xx=cx+movee[i][1];yy=cy+movee[i][2];  
            if (xx<1 || xx>r || yy<1 || yy>c) continue;  
            if (a[xx][yy]==1 || visited[xx][yy]) continue;  
            visited[xx][yy]=true;q.push(xx);q.push(yy);q.push(cd+1);  
        }  
    }  
}  
  
int main ()  
{  
    int i,j;  
    movee[1][1]=1;movee[1][2]=0;  
    movee[2][1]=0;movee[2][2]=1;  
    movee[3][1]=-1;movee[3][2]=0;  
    movee[4][1]=0;movee[4][2]=-1;  
    cin>>r>>c>>k; 
    for (i=1;i<=r;i++)  
    {  
        cin>>s; 
        for (j=1;j<=c;j++)  
        {  
            if (s[j-1]=='#') a[i][j]=1;  
            if (s[j-1]=='.') a[i][j]=2;  
            if (s[j-1]=='S')  
            {  
                sx=i;sy=j;  
                a[i][j]=2;  
            }  
        }  
    }  
    bfs(sx,sy,0);  
    int fans=1+(ans+k-1)/k;  
    cout<<fans;  
    return 0;  
}  

Measured memory_bytes: 3584
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

ll solve(ll l, vector<ll> v, int k, int q) {

    vector<vector<ll>> segments = {{}};
    for (ll t : v) {
        if (t < l) segments.push_back({});
        else segments.back().push_back(t);
    }

    vector<ll> tmp;
    for (vector<ll> &u: segments) sort(u.rbegin(), u.rend());
    for (vector<ll> &u: segments) {
        while (u.size() >= k) {
            tmp.push_back(u.back());
            u.pop_back();
        }
    }

    if (tmp.size() < q) return INF;
    sort(tmp.begin(), tmp.end());
    ll a = tmp[q - 1];
    return a - l;

}

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

    ll ans = INF;
    for (ll l : v) cmin(ans, solve(l, v, k, q));

    cout << ans << endl;

}


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

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

	int ret = 2000;
	int sl = s.size();
	for (int i = 0; i < sl - 2; ++i) {
		for (int j = i; j < sl - 2; ++j)
		{
			string t = s.substr(j,3);
			int v = stoi(t);
			int diff = abs(v - 753);
			ret = min(ret,diff);
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
W,H,x,y = map(int,input().split())
#print(W,H,x,y)

ans = 0
flag = 0
if x == W/2 and y == H/2:
  ans = W*H / 2
  flag = 1
else:
  ans = ans = W*H / 2
  flag = 0
print(ans,flag)

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	lis = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
	k = INT()
	print(lis[k-1])



if __name__=='__main__':
	main()


Measured memory_bytes: 5732
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		String s = fs.next();
		
		int a_left = s.length()-1;
		int z_right = 0;
		
		
		for(int i = 0; i < s.length(); i++) {
			
			if(s.charAt(i) == 'A') {
				a_left = Math.min(a_left, i);
			}
			
			if(s.charAt(i) == 'Z') {
				z_right = Math.max(z_right, i);
			}
		}
		
		System.out.println(z_right - a_left + 1);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 36512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();
        System.out.println(500*K>=X?"Yes":"No");
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    if (s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3)) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
}

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

int main(){
	string a, b, s;
	cin >> a >> s >> b;
	if(a == "AtCoder" && b == "Contest") {
		cout << 'A' << s.at(0) << 'C' << "\n";
	}
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int count=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='U'||S.at(i)=='D'){
      count++;
    }
    if(i%2==0&&S.at(i)=='R'){
      count++;
    }
    if(i%2==1&&S.at(i)=='L'){
      count++;
    }
  }
  if(count==S.size()){
    cout <<"Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N, D, X, A;
	LL ans = 0;
	cin >> N >> D >> X;
	FOR(i, 0, N) {
		cin >> A;
		LL t = 1;
		while (t <= D) {
			ans++;
			t += A;
		}
	}
	ans += X;
	O(ans);

	return 0;
}

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

int main() {
	int a,b,c;
	cin >>a>>b>>c;
	if(a<=b && b<=c && a<=c){
		cout<< a << " " << b << " " << c <<endl;
	}
	else if(a<=c && c<=b && a<=b){
		cout<< a << " " << c << " " << b <<endl;
	}
	else if(b<=a && a<=c && b<=c){
		cout<< b << " " << a << " " << c <<endl;
	}
	else if(b<=c && c<=a && b<=a){
		cout<< b << " " << c << " " << a <<endl;
	}
	else if(c<=a && a<=b && c<=b){
		cout<< c << " " << a << " " << b <<endl;
	}
	else if(c<=b && b<=a && c<=a){
		cout<< c << " " << b << " " << a <<endl;
	}
}

Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>

struct point {
	int x, y;
};

int dist(struct point a, struct point b);

int main()
{
	int n, m;
	struct point stu[50];
	struct point cp[50];

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++) {
		scanf("%d %d", &stu[i].x, &stu[i].y);
	}

	for (int i = 0; i < m; i++ ) {
		scanf("%d %d", &cp[i].x, &cp[i].y);
	}

	for (int i = 0; i < n; i++) {
		int min_pos = 0;

		for (int j = 1; j < m; j++) {
			if (dist(stu[i], cp[min_pos]) > dist(stu[i], cp[j])) {
				min_pos = j;
			}
		}

		printf("%d\n", min_pos + 1);
	}
}

int dist(struct point a, struct point b)
{
	return abs(a.x - b.x) + abs(a.y - b.y);
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> tree(n);
	rep(i, n) {
		cin >> tree[i];
	}
	sort(tree.begin(), tree.end());
	int ans = inf;
	rep(i,n - m + 1) {
		ans = min(ans, tree[i + m - 1] - tree[i]);
	}
	cout << ans << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 640
#include <bits/stdc++.h>
 using namespace std;
 
int main(){
  string s;
  cin>>s;
  if (s[0]!='A'){
    cout << "WA" << endl;
    return 0;
  }
  int c=0;
  for(int i=2;i<=s.size()-2;i++){
    if (s[i]=='C'){
      c++;
      if (c==2){
        cout << "WA" <<endl;
        return 0;
      }
    }
  }
  for (int i=0;i<s.size();i++){
    if((s[i]!='C'  and s[i]!='A') and s[i]<='Z'){
      cout << "WA" <<endl;
      return 0;
    }
  }
  if(c==0){
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
  return 0;
 }


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>

using ll = long long;
using lli = long long int;

ll n, m, p, y;
std::map<ll, std::vector<ll>> ma;
std::map<ll, std::map<ll, ll>> m2;
std::vector<std::pair<ll, ll>> inputs;

int main() {
    std::cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        std::cin >> p >> y;
        ma[p].push_back(y);
        inputs.push_back(std::make_pair(p, y));
    }
    for (auto &x: ma) {
        std::sort(x.second.begin(), x.second.end());
        ll c = 1;
        for (ll i = 0; i < x.second.size(); i++) {
            m2[x.first][x.second[i]] = c;
            c++;
        }
    }
    for (auto &v: inputs) {
        ll create_num = m2[v.first][v.second];
        std::printf("%06d%06d\n", v.first, create_num);
    }
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	string ans;
	for(int i = 0; i < s.size(); i++)
	{
		if((i % 2) == 0)
		{
			ans.push_back(s[i]);
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

int main(){
    vector<int> vec(3);
    cin>>vec.at(0)>>vec.at(1)>>vec.at(2);
    sort(vec.begin(), vec.end());
    if (vec.at(0)==5&&vec.at(1)==5&&vec.at(2)==7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cin >> a.at(i).at(j);
        }
    }
    for(int i = 0;i < h + 2;i++){
        for(int j = 0;j < w + 2;j++){
            if(i == 0 || i == h + 1)cout << "#";
            else if(j == 0 || j == w + 1)cout << "#";
            else cout << a.at(i - 1).at(j - 1);
        }
        cout << endl;
    }
}

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

int main() {
  int a,i,e=0,now=1,next;
  cin>>a;
  vector<int>c(a);
  
  for(i=0;i<a;i++)
    cin>>c.at(i);
  //4 3412
  while(1){
    next=c.at(now-1);
    c.at(now-1)=0;
    now=next;
    e++;
    
    if(next==2){
    cout<<e<<endl;
    return 0;
    }
    if(next==0){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<e<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << a[0] + a[1] << endl;
	return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int main(){
	IO
	string s, t;
	cin >> s >> t;
	
	int n = (int)s.size(), m = (int)t.size();
	int S[n][m] = {0};
	
	if(s[0] == t[0]) S[0][0] = 1;
	for(int i = 1; i<m; ++i){
		if(t[i] == s[0]) 
			S[0][i] = 1;
		else 
			S[0][i] = S[0][i-1];
	}
	
	for(int i = 1; i<n; ++i){
		if(s[i] == t[0]) S[i][0] = 1;
		else S[i][0] = S[i-1][0];
		for(int j = 1; j<m; ++j){
			if(s[i] == t[j]) S[i][j] = S[i-1][j-1] + 1;
			else S[i][j] = max(S[i-1][j], S[i][j-1]);
		}
	}
	
	int i = n - 1 , j = m - 1;
	string ans;
	while(i>0 && j>0){
		if(s[i] == t[j]){
			ans.pb(s[i]);
			--i; --j;
		}
		else{
			if(S[i-1][j] >= S[i][j-1]) --i;
			else --j;
		}
	}
	bool f = false;
	while(i>0){
		if(s[i] == t[0]){
			ans.pb(s[i]);
			f = true;
			break;
		}
		--i;
	}
	while(j>0){
		if(s[0] == t[j]){
			ans.pb(s[0]);
			f = true;
			break;
		
		}
		--j;
	}
	if(s[0] == t[0] && !f) ans.pb(s[0]);
	
	reverse(all(ans));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35456
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#define ll long long
#define ull unsigned long long
#define FOR(m,s,n,u) for(int m=s; m<n; m+=u)
#define ROF(m,s,n,u) for(int m=n; m>=s; m-=u)
#define FORb(m,s,n,u,k) for(int m=s; m<n&&k; m+=u)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define PI 3.1415926535897932384626433832795028841971
#define INF 0x3f3f3f3f
#define EPS 1e-9
#define MOD(x) ((x%mod)+mod)%mod
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define vi vector<int>
#define pii pair<int,int>
using namespace std;

int main(){
sync;

int H,W; cin>>H>>W;
char matriz[H+1][W+1];

FOR(i,1,H+1,1)FOR(j,1,W+1,1)cin>>matriz[i][j];
ll caminos[H+1][W+1];
FOR(i,0,H+1,1)FOR(j,0,W+1,1)caminos[i][j]=0;

FOR(i,1,H+1,1)FOR(j,1,W+1,1){
    if(matriz[i][j]=='#')goto salta;
    caminos[i][j] = (i==1&&j==1)?1:MOD(caminos[i-1][j] + caminos[i][j-1]);
    salta :;
}

cout<<caminos[H][W]<<endl;
return 0;
}

Measured memory_bytes: 12256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct team{
	int tID;
	int pID;		//問題ID
	vector<int> p;	//誤答数
	int ansnum;		//正答数
	int penalty;	//ペナルティ
	int time;		//時間

	bool operator<( const team& right ) const {
        return ( ansnum == right.ansnum ? 
			( penalty == right.penalty ? tID > right.tID : penalty > right.penalty )  : ansnum < right.ansnum );
    }
};

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int T, P, R;
		cin >> T >> P >> R;
		if( T == 0 && P == 0 && R == 0 ) break; 

		//■■■■チームテーブル作成■■■■
		vector<team> teams;
		team newteam;
		for(int i = 0; i <= P; i++)
			newteam.p.push_back(0);

		for(int i = 0; i < T; i++) {
			newteam.tID = i + 1;
			newteam.ansnum = 0;
			newteam.penalty = 0;
			teams.push_back( newteam );
		}

		//■■■■レコード取得■■■■
		for(int i = 0; i < R; i++) {
			int tID, pID, time_i;
			char s[7];
			cin >> tID >> pID >> time_i;
			cin >> s;

			switch( s[0] ) {
				case 'C':
					teams.at(tID - 1).ansnum ++;
					teams.at(tID - 1).penalty += teams.at(tID-1).p.at(pID)*1200 + time_i;
					break;
				case 'W':
					teams.at(tID - 1).p.at(pID) ++;
					break;
			}

		}

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

		for(int i = teams.size() - 1; i >= 0 ; i--) {
			cout << teams.at(i).tID << " " << teams.at(i).ansnum << " " << teams.at(i).penalty << endl;
		}

	}

	//while(1){}

	return 0;
}

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

// Vasito
typedef long long ll;
typedef pair<int,int> pii;
#define fore(i,ii,iii)for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii)for(int i=iii-1;i>=ii;i--)
#define all(s) s.begin(),s.end()
#define sz(a) ((int)a.size())
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second
// Extra
#define OUT(a)cout<<a<<endl
#define ANS(a) OUT(res.size());for(auto i:a)cout<<i<<" ";ENDL
#define PRINT(a,init,end) FOR(i,init,end) cout<<a[i]<<" ";ENDL
#define PRINTV(a) for(auto i:a)cout<<i<<" ";ENDL

struct block {ll w,s,v;};
const ll N=1024,M=2e4+15,MOD=1e9+7,INF=1e18;
block a[N];
ll n,m,dp[N][M];
  
bool compare(const block &a,const block &b) {
  return (a.s+a.w)>(b.s+b.w);
}
/*
ll solve(int i,int j) {
  if(i==n) return 0;
  if(dp[i][j]!=-1) return dp[i][j];
  ll r = solve(i+1,j);
  if(a[i].s>=j) r=max(r,a[i].v+solve(i+1,j+a[i].w));
  return dp[i][j] = r;
}
*/
ll solve(int i,int j) {
  if(i==n) return 0;
  if(dp[i][j]!=-1) return dp[i][j];
  ll r = solve(i+1,j);
  if(a[i].w<=j) {
    r=max(r,a[i].v+solve(i+1,min(j-a[i].w,a[i].s)));
  }
  return dp[i][j] = r;
}
int main() {
  ios::sync_with_stdio(false);
  mset(dp,-1);
  cin>>n;
  fore(i,0,n)cin>>a[i].w>>a[i].s>>a[i].v;
  sort(a,a+n,compare);
  //cout<<"___________"<<endl;fore(i,0,n)cout<<i<<" "<<a[i].w<<" "<<a[i].s<<" "<<a[i].v<<endl;
  cout<<solve(0,M-1)<<endl;
}



Measured memory_bytes: 160512
package main

import (
	"fmt"
)

func main() {
	var h, n, a int
	fmt.Scan(&h, &n)

	ret := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		ret += a
	}
	if h <= ret {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) throws IOException {
  	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    
    long sum = 0L;
    for (int i = 1; i <= n; i++) {
      if (i % 3 != 0 && i % 5 != 0) {
      	sum += i;
      }
    }
    
    System.out.print(sum);
  }
}

Measured memory_bytes: 32664