akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] ac = new int[n];
		int[] penalty = new int[n];
		int acCnt = 0;
		int penaltyCnt = 0;
		for(int i = 0; i < m; i++){
		    int p = sc.nextInt() - 1;
		    String s = sc.next();
		    if(ac[p] == 1) continue;
		    if(s.equals("AC")){
		        ac[p] = 1;
		        acCnt++;
		        penaltyCnt += penalty[p];
		    }else{
		        penalty[p]++;
		    }
		}
		
		// 計算
		
		
		// 出力
		System.out.println(acCnt + " " + penaltyCnt);
	}
	
}




Measured memory_bytes: 63340
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
        int c = a+b;
        int d = b-a;
		System.out.println(b%a==0?c:d);
	}
}

Measured memory_bytes: 22740
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    int sum = 0;
    for (int i = 0; i < 3; i++)
    {
        int a; cin >> a;
        sum += a;
    }
    if (sum >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static int mod = 1000000007;

	
	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		long []b = new long [n];
		int []gcd = new int [1000001];
 		
		for(int i = 0 ; i < n ;i++) {
			a[i] = Integer.parseInt(sc.next());
			b[i] = Modpow(a[i], mod-2);
		}
				
		for(int i = 0 ; i < n ;i++) {
			if(a[i] == 1) continue;
			
			int temp = a[i];
			for(int j = 2 ; j * j <= a[i] ;j++) {
				int cnt = 0;
				if(temp % j == 0) {
					while(temp % j == 0) {
						temp = temp / j;
						cnt++;
					}
					gcd[j] = Math.max(cnt, gcd[j]);
				} 
			}
			if(temp != 1 && prime(temp)) {
				gcd[temp] = Math.max(1, gcd[temp]);
			}
		}
		
		
		long lcm = 1L;
		
		for(int i = 0 ; i <= 1000000 ;i++) { 
			if(gcd[i] > 0) {
				lcm = (Modpow(i, gcd[i]) * lcm) % mod;
			}
		}
				
		long ans = 0 ;
		
	
		for(int i = 0 ;i < n ; i++) {
			long q = (lcm * b[i]);
			ans = (ans + q)% mod;
		}
		
		System.out.println(ans);
		
	}
	
	//a^n mod
		static long Modpow(long a, long n) {
			long res = 1;
			while(n > 0) {
				if((n & 1) == 1) {
					res = res * a % mod;
				}
				a = a * a % mod;
				n >>= 1;
			}
			return res;
		}
		
	static boolean prime(int m) {
		if(m == 1) {
			return false;
		}
		
		for(int i = 2 ; i * i <= m ;i++) {
			if(m % i == 0) {
				return false;
			}
		}
		return true;
	}
}


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

int main() {
	string s;
	int g = 0, p = 0, ans;
	cin >> s;
	for (unsigned i = 0; i < s.size(); i++) {
		if (s[i] == 'g')g++;
		else p++;
	}
	if (s.size() % 2 == 0) {
		ans = s.size() / 2 - p;
	}
	else {
		ans = (s.size() - 1) / 2 - p;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
map<int,int>ma;
#define ss second
#define ff first
int main(){
	int n,m,x,y;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",&x,&y),ma[x]+=y;
	long long ans=0;
	int less=m;
	for(auto i:ma)
	if(i.ss<less)less-=i.ss,ans+=1ll*i.ff*i.ss;
	else{
		ans+=1ll*i.ff*less;
		break;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4992
#[derive(Debug)]
enum Query {
    Reverse,
    Add(i64, String),
}

fn main() {
    let mut s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let s1 = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let q = {
        let mut ws = s1.split_whitespace();
        let q: i64 = ws.next().unwrap().parse().unwrap();
        q
    };

    let mut query_list = vec![];
    for _ in 0..q as usize {
        let s1 = {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            s.trim_right().to_owned()
        };
        let query = {
            let mut ws = s1.split_whitespace();
            let q: i64 = ws.next().unwrap().parse().unwrap();
            if q == 1 {
                Query::Reverse
            } else {
                let f: i64 = ws.next().unwrap().parse().unwrap();
                let c: String = ws.next().unwrap().to_owned();
                Query::Add(f, c)
            }
        };
        query_list.push(query);
    }

    let mut s2 = String::new();
    let mut is_reverse = false;
    for query in query_list {
        match query {
            Query::Reverse => {
                is_reverse ^= true;
            }
            Query::Add(i, mut s1) => {
                if is_reverse && i == 1 || !is_reverse && i == 2 {
                    s.push_str(&s1);
                } else {
                    s2.push_str(&s1);
                }
            }
        }
    }

    if is_reverse {
        let mut result = s.chars().rev().collect::<String>();
        result.push_str(&s2);
        println!("{}", result);
    } else {
        let mut result = s2.chars().rev().collect::<String>();
        result.push_str(&s);
        println!("{}", result);
    }
}

//


Measured memory_bytes: 14328
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 998244353;
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;}
// combination mod prime
struct Combination {
  vector<mint> fact, ifact;
  Combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n,m,k;
  cin >> n >> m >> k;

  Combination c(n);
  mint ans;
  rep(i,k+1){
    ans += c(n-1,i) * m * mint(m-1).pow(n-1-i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6348
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string S;
  cin >> S;
  bool isOK = true;
  if (S.front() != 'A')
    isOK = false;
  int cnt = 0;
  for (int i = 2; i < S.size() - 1; i++)
  {
    if (S[i] == 'C')
      cnt++;
  }
  if (cnt != 1)
    isOK = false;
  cnt = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] < 'a')
      cnt++;
  }
  if (cnt != 2)
    isOK = false;
  if (isOK)
  {
    cout << "AC" << endl;
  }
  else
  {
    cout << "WA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else if(a==b){
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
// Author: pankaj_m05

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define f_in(file) freopen(file, "r", stdin)
#define f_out(file) freopen(file, "w", stdout)
#define sz(a) int((a).size())
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) c.begin(), c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())  // Set and Maps
#define cpresent(c,x) (find(allc,x) != c.end()) // Vectors
using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef long long ll;

const int mod = 1e9 + 7;
const int mxN = 100;
int n, x;
bool a[mxN + 2];

void testcase() {
	cin >> x >> n;
	if (n == 0) {
		cout << x << '\n';
		return;
	}
	for (int i=0;i<n;i++) {
		int t;
		cin >> t;
		a[t] = 1;
	}
	int l=0, r=101;
	for (int i=x; i>0; --i) {
		if(a[i])
			continue;
		l = i;
		break;	
	}
	for (int i=x; i<101; ++i) {
		if(a[i])
			continue;
		r = i;
		break;	
	}
	cout << (x-l<=r-x?l:r) << '\n';
}

int main(void) { 
	fast
	testcase();
	return 0;
}                                          

Measured memory_bytes: 3612
n, k = list(map(int, input().split()))
xs = list(map(int, input().split()))
from collections import deque
def slide_max(k, l):
    rs, rrs = [], set()
    dq = deque()
    for i, x in enumerate(l):
        while True:
            if not len(dq):
                dq.append(i)
                break
            lxi = dq[-1]
            if x < l[lxi]:
                dq.append(i)
                break
            dq.pop()
        if i+1 < k:
            continue
        sxi = dq[0]
        rs.append(l[sxi])
        if sxi == (i + 1 - k):
            dq.popleft()
    return rs

def slide_min(k, l):
    rs = []
    rrs = set()
    dq = deque()
    for i, x in enumerate(l):
        while True:
            if not len(dq):
                dq.append(i)
                break
            lxi = dq[-1]
            if x > l[lxi]:
                dq.append(i)
                break
            dq.pop()
        if i+1 < k:
            continue
        if len(dq) == k:
            rrs.add(i+1-k)
        sxi = dq[0]
        rs.append(l[sxi])
        if sxi == (i + 1 - k):
            dq.popleft()
    return rs, rrs

maxs, (mins, ns) = slide_max(k, xs), slide_min(k, xs)
r = 1
for i, (s, x) in enumerate(zip(xs, xs[k:])):
    if (x != maxs[i+1] or s != mins[i]) and (i+1 not in ns): 
        r+=1
if (0 not in ns) and (len(ns) > 0):
    r += 1
print(r)


Measured memory_bytes: 106020
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    string t;
    cin >> t;
    string ans;
    rep(i, t.size()) {
        if (t[i] == 'P') {
            ans += 'P';
        }
        else if (t[i] == 'D') {
            ans += 'D';
        }
        else {
            ans += 'D';
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3872
var n,x,demp,dem,i:integer;a:array[1..8] of boolean;
{procedure       mo;
begin
        assign(input,'test.inp');reset(input);
        assign(output,'test.out');rewrite(output);
end;
procedure       dong;
begin
        close(input);close(output);
end;}
procedure       nhap;
begin
        readln(n);
        for i:=1 to n do
                begin
                read(x);
                case x of
                        1..399: if A[1]=true then
                                begin
                                A[1]:=false;
                                inc(dem);
                                end;
                        400..799:if A[2]=true then
                                begin
                                A[2]:=false;
                                inc(dem);
                                end;
                        800..1199:if A[3]=true then
                                begin
                                A[3]:=false;
                                inc(dem);
                                end;
                        1200..1599:if A[4]=true then
                                begin
                                A[4]:=false;
                                inc(dem);
                                end;
                        1600..1999:if A[5]=true then
                                begin
                                A[5]:=false;
                                inc(dem);
                                end;
                        2000..2399:if A[6]=true then
                                begin
                                A[6]:=false;
                                inc(dem);
                                end;
                        2400..2799:if A[7]=true then
                                begin
                                A[7]:=false;
                                inc(dem);
                                end;
                        2800..3199:if A[8]=true then
                                begin
                                A[8]:=false;
                                inc(dem);
                                end;
                        3200..4800:inc(demp);
                end;
                end;
end;
procedure       xuli;
begin
        fillchar(a,sizeof(A),true);
        nhap;
        if dem=0 then write(1,' ') else write(dem,' ');
        //if demp<=(8-dem) then write(demp+dem) else write(8);
        write(demp+dem);
end;
begin
        //mo;
        xuli;
        //dong;
end.


Measured memory_bytes: 128
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
static const int MOD = 10000007;
static const int MAX = 100005;

string s;
int N;


int gcd(int a, int b) {
  if ( b > a ) swap(a, b);
  int r = 1;
  while (r > 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main() {
  cin >> N;
  vector<int> A(N, 0);
  rep(i, N) {
    cin >> A[i];
  }
  int minv = A[0];
  rep(i, N-1){
    minv = min(gcd(minv, A[i+1]), minv);
  }
  cout << minv << endl;
}


Measured memory_bytes: 640
S = input()
N = len(S)
MOD = 10**9 + 7
DP = [[1] * 4 for _ in range(N + 1)]
# initialize
DP[N][3] = 1
DP[N][0] = 0
DP[N][1] = 0
DP[N][2] = 0

for i in range(N-1, -1, -1):
    for j in range(3, -1, -1):
        DP[i][j] = DP[i+1][j] * (3 if S[i]=='?' else 1)
        if j<3:
            DP[i][j] += DP[i + 1][j + 1] * (1 if (S[i]=='ABC'[j] or S[i]=='?') else 0)
        DP[i][j] %= MOD

ans = DP[0][0]
print(ans)
            


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

int main() {
	unsigned long N;
	cin >> N;
	int sum = 0;
	unsigned long M = N;
	while (M > 0) {
		sum += M % 10;
		M /= 10;
	}
	if (N % sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B, X;
    cin >> A >> B >> X;
    cout << ( X - A <= B && A <= X ? "YES" : "NO" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<bool> list(n+1);
  int t;
  for(int i=0; i<m; i++) {
    cin >> t;
    list.at(t) = true;
  }
  int a=0,b=0;
  for(int i=x; i<=n; i++) {
    if(list.at(i)) {
      a += 1;
    }
  }
  for(int i=x; i>=0; i--) {
    if(list.at(i)) {
      b += 1;
    }
  }
  cout << min(a,b) << endl;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
aa = list(map(int, input().split()))

h = [-a for a in aa]
heapq.heapify(h)
for _ in range(m):
    x = h[0]
    heapq.heapreplace(h, -(-x // 2))

print(sum([-hh for hh in h]))

Measured memory_bytes: 15044
using System;
using System.Linq;
using System.Text.RegularExpressions;

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static int[] ToInt(this string[] strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ToLong(this string[] strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] SpInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long[] SpLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int Diff(int a, int b) => (int)Diff(a, (long)b);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Sign(this int i) => Math.Sign(i);
    public static bool IsEven(this int i) => i % 2 == 0;
    public static int[] dx = new int[] { 0, -1, 0, 1 };
    public static int[] dy = new int[] { -1, 0, 1, 0 };
    public static int Gcd(int a, int b) => (int)Gcd(a, (long)b);
    public static long Gcd(long a, long b)
    {
        if (b == 0)
        {
            return a;
        }

        return Gcd(b, a % b);
    }                       //最大公約数
    public static int Lcm(int a, int b) => (int)Lcm(a, (long)b);
    public static long Lcm(long a, long b) => a / Gcd(a, b) * b;    //最小公倍数
    //テンプレここまで
}

public static partial class Program
{
    public static void Main()
    {
        var s = CRL();
        var pattern = "[ACGT]+";
        var maxLength = 0;
        for (int i = 0; i < s.Length; i++)
        {
            var str = s.Substring(i);
            maxLength = Math.Max(maxLength, Regex.Match(str, pattern).Length);
        }

        CWL(maxLength);
    }
}


Measured memory_bytes: 15956
n, z, w = map(int, input().split())
cards = list(map(int, input().split()))
#print(getX(z, w, cards, 0))
if(abs(cards[len(cards)-1]-w)>abs(cards[len(cards)-1]-cards[len(cards)-2])):
    print(abs(cards[len(cards)-1]-w))
else:
    print(abs(cards[len(cards)-1]-cards[len(cards)-2]))

Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
int N;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	FOR(i,1,10)FOR(j,1,10){
		if(i*j==N){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

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

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

int main(){
  int64_t x;
  cin >> x;

  int64_t gohyaku = 0;
  gohyaku = x/500;

  int64_t go = 0;
  go = (x - gohyaku*500)/5;

  cout << gohyaku*1000 + go*5;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int isPrime(int n){
    for(int i=2;i*i<=n;i++) if(n%i==0) return 0;
    return 1;
}
int main(){
    int isp[200000]={};
    for(int i=2;i<200000;i++) isp[i]=isPrime(i);
    int n,p;
    while(cin>>n>>p){
        if(n==-1 && p==-1) break;
        int k=n;
        int c=0;
        int tmp[100]={};
        while(c<100){
            k++;
            if(isp[k]==1){
                tmp[c]=k;
                c++;
            }
        }
        vector<int> vec;
        for(int i=0;i<100;i++){
            for(int j=i;j<100;j++){
                vec.push_back(tmp[i]+tmp[j]);
            }
        }
        sort(vec.begin(),vec.end());
        cout<<vec[p-1]<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3968
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toLong)
    val aAccum = mutableListOf(aList[0])
    for (i in 1 until n) {
        aAccum.add(aAccum[i - 1] + aList[i])
    }
    val aSum = aAccum[aAccum.size - 1]
    var min = Long.MAX_VALUE
    for (i in 0 until (n - 1)) {
        val tempMin = Math.abs(aAccum[i] - (aSum - aAccum[i]))
        min = Math.min(min, tempMin)
    }
    println(min)
}

Measured memory_bytes: 82852
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    static final long MOD = 1000000007;
    static int n;
    static int m;
    static int[] b;
    static long[] dp;

    private static long rec(int current) {
        if (current == n) return 1;
        if (current > n) return 0;
        if (b[current] == 1) return 0;
        if (dp[current] == MOD) {
            dp[current] = (rec(current + 1) + rec(current + 2)) % MOD;
        }
        return dp[current];
    }

    public static void main(String[] args) {
        java.util.Scanner input = new Scanner(System.in);
        n = input.nextInt();
        m = input.nextInt();
        b = new int[n];
        dp = new long[n];
        for (int i = 0; i < n; i++) dp[i] = MOD;
        for (int i = 0; i < m; i++) b[input.nextInt()] = 1;
        long r = rec(0);
        System.out.println(r);
    }
}


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

void solve(){

	int n ;
	cin>>n ;

	vector<int> v(n) ;

	rep(i,n){
		cin>>v[i] ;
	}

	vector<int> ans ;

	for(int i=n-1;i>=0;i=i-2){
		ans.push_back(v[i]) ;
	}

	for(int i=((n%2!=0)?1:0);i<n;i=i+2){
		ans.push_back(v[i]) ;
	}

	rep(i,n){
		cout<<ans[i]<<" " ;
	}

}


int main(){

		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

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

#define rep(i,N) repv(i,0,N)
#define reps(i,N) repvs(i,0,N)
#define repv(i,a,b) for(int i=a;i<b;i++)
#define repvs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define debug(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define debug2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define debug3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define debug4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define debugarr(arr,N){if(isDebugMode){ rep(i,N+1)\
	{if(arr[i]==INF)printf("INF ");\
		else cout<<arr[i]<<" ";} cout<<endl;}}
#define debugarr2(arr,N,M){if(isDebugMode) rep(i,N+1){rep(j,M+1)\
	{if(arr[i][j]==INF)printf(" INF");\
		else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define show(a) cout<<a<<endl;

auto chmax =[](int &a,int b){a=max(a,b);};
auto chmin =[](int &a,int b){a=min(a,b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int MOD = 100000007;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};

bool isDebugMode=0;
//--------------------------------------//
int n,m;
bool r[100001];
int c[100001];
void solve(){
	reps(i,n) c[i]=1;
	r[1]=true;
	rep(i,m){
		int from,to;
		cin>>from>>to;
		if(r[from]) r[to]=true;
		if(--c[from]==0) r[from]=false;
		c[to]++;
		debugarr(c,n);
	}
	int ans=0;
	reps(i,n) if(r[i]) ans++;
	show(ans);
}

int main(){
	cin>>n>>m;
	solve();
	return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		float aka = (float)h * 30 + (float)m * 1/2;
		float bka = (float)m * 6;
		
		float saka;
		if(aka < bka) {
			saka = bka - aka;
		}else {
			saka = aka -bka;
		}
		if(saka > 180) {
			saka = 360 - saka;
		}
		
		System.out.println(String.format("%.20f",Math.pow((double)a*(double)a + (double)b*(double)b - 2 * (double)a * (double)b * Math.cos(Math.toRadians((double)saka)),1.0/2.0)));
		
	}
	
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    vector<bool> dp(k+1,0);
    for(int i=1;i<=k;i++)
    {
        for(int x:a) if(i>=x&&dp[i-x]==0) dp[i]=1;
    }
    if(dp[k]==1) cout << "First\n";
    else cout << "Second\n";
    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline

n = int(input())
a = [0]*5
for i in range(n):
    s = input().strip()
    c = s[0]
    if c == "M":
        a[0] += 1
    elif c == "A":
        a[1] += 1
    elif c == "R":
        a[2] += 1
    elif c == "C":
        a[3] += 1
    elif c == "H":
        a[4] += 1
#print(a)

ans = 0
for i in range(0, len(a)-2):
    for j in range(i+1, len(a)):
        for k in range(j+1, len(a)):
#            print(i,j,k, a[i]*a[j]*a[k])
            ans += a[i]*a[j]*a[k]
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define inf (int)(3e18)
#define all(v) v.begin(),v.end()
#define mod (int)(1e9+7)

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}


signed main() {
	string s;cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    A=LI()
    for i in range(M):
        N-=A[i]
        
    print(max(N,-1))

main()


Measured memory_bytes: 67948
#include <iostream>

using namespace std;
int main (){
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    bool flag=true;
    for (int i = 0; i < n; i++){
        if(a[i]%2==0&&(a[i]%5!=0 && a[i]%3!=0)) flag=false;
    }
    if(flag) cout << "APPROVED\n";
    else cout << "DENIED\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h1,h2,h3;
	scanf("%d%d%d",&h1,&h2,&h3);
	if((h3>=h1&&h3<=h2)||(h3>=h2&&h3<=h1))puts("Yes");
	else puts("No");
}

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

int main()
{
  int N, L;
  cin >> N >> L;
  vector<int> aji(N+1);
  for(int i=1; i<=N; ++i)
    aji[i] = L+i-1;

  int before=0, ans=INT_MAX, tmp=INT_MAX;
  for(int i=1; i<=N; ++i) {
    before += aji[i];
  }
  for(int i=1; i<=N; ++i) {
    int after = 0;
    for(int j=1; j<=N; ++j)
    {
      if(i != j)
        after += aji[j];
    }
    if(abs(before-after) < tmp){
      tmp = abs(before-after);
      ans = after;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int X,A,B; cin >> X >> A >> B;
  if ( A >= B ) cout << "delicious" << endl;
  else if ( B-A <=X ) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
      Scanner stdIn = new Scanner(System.in);
      int a = stdIn.nextInt();
      int b = stdIn.nextInt();
      if((a*b)%2 == 0){
        System.out.println("Even");
      }else{
        System.out.println("Odd");
      }
    }
}

Measured memory_bytes: 21588
S = input()

ans = False

if S[:7] == "keyence":
    ans = True

if S.find("k") != -1:
    if S.find("keyenc")== 0and S[-1] == "e":
            ans = True
    if S.find("keyen")== 0 and S[-2:] == "ce":
        ans = True
    if S.find("keye")== 0 and S[-3:] == "nce":
        ans = True
    if S.find("key")== 0and S[-4:] == "ence":
        ans = True
    if S.find("ke")== 0 and S[-5:] == "yence":
        ans = True
    if S.find("k")== 0 and S[-6:] == "eyence":
        ans = True

else:
    if S[-7:] == "keyence":
        ans = True

if ans:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
constexpr long long int MOD = 1000000007;
#define int long long int

enum {
  SINGLE = 0,
  DOUBLE = 1,
};

vector<int> dist(100001, -1);
vector<vector<pair<int, int>>> E(100001);

void dfs(int pos) {
  for (pair<int, int> &p : E[pos]) {
    if (dist[p.first] >= 0) {
      continue;
    }

    dist[p.first] = dist[pos] + p.second;
    dfs(p.first);
  }
}

void solve() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  int ans, i, prev;
  if (S[0] == S[1]) {
    ans = 6;
    i = 2;
    prev = DOUBLE;
  } else {
    ans = 3;
    i = 1;
    prev = SINGLE;
  }

  while (i < S.size()) {
    if (i + 1 == S.size() || S[i] != S[i + 1]) {
      if (prev == SINGLE) {
        ans = (ans * 2) % MOD;
      } else {
        // ans = ans * 1
      }

      prev = SINGLE;
      i++;
    } else {
      if (prev == SINGLE) {
        ans = (ans * 2) % MOD;
      } else {
        ans = (ans * 3) % MOD;
      }
      prev = DOUBLE;
      i += 2;
    }
  }

  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

priority_queue< P, vector<P>, greater<P> > pq;

bool ishaiku(int x, int y, int z){
	return ((x == 5) && (y == 7) && (z == 5));
}

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s[51];
int alph[50][26] = {};
int alph_cnt[26] = {};

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

    for(int i=0; i<N; i++){
        int j = 0;
        while(s[i][j] != '\0'){
            int k = s[i][j] - 'a';
            alph[i][k]++;
            j++;
        }
    }

    for(int i=0; i<26 ;i++){
        int min_cnt = 50;
        for(int j=0; j<N;j++){
            min_cnt = min(min_cnt, alph[j][i]);
        }
        alph_cnt[i] = min_cnt;
    }

    for(int i=0; i<26; i++)
        while(alph_cnt[i]){
            char c = 'a' + i;
            cout << c;
            alph_cnt[i]--;
        }
    cout << '\n';
}


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

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

Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        String ans;
        if(r < 1200) ans = "ABC";
        else if(r < 2800) ans = "ARC";
        else ans = "AGC";
        System.out.println(ans);
    }
}

Measured memory_bytes: 22100
import itertools

n, m = [int(x) for x in input().split()]
lst = []
for _ in range(m):
    a = [int(x) for x in input().split()]
    lst.append(a)
p = tuple([int(x) for x in input().split()])

sta = [0,1]
cnt = 0

for v in itertools.product(sta, repeat=n):
    for i in range(m):
        if sum(v[x - 1] for x in lst[i][1:]) % 2 != p[i]:
            break 
    else:
        cnt += 1

print(cnt)

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

int main(void) {
	int W, a, b;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	W = atoi(ch);
	ch = strtok(NULL, " ");
	a = atoi(ch);
	ch = strtok(NULL, " ");
	b = atoi(ch);

	if(a + W < b) {
		printf("%d\n", b - a - W);
	} else if(b + W < a) {
		printf("%d\n", a - b - W);
	} else {
		printf("%d\n", 0);
	}

	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 3000 + 7;

int n;
double coins[maxn];

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> coins[i];
    }

    map<int,double> mp; mp.clear();
    mp[0] = 1.0;

    for (int i = 0; i < n; i++) {
        map<int,double> mp2; mp2.clear();
        for (auto p: mp) {
            mp2[p.first+1] += coins[i]*p.second;
            mp2[p.first-1] += (1.0-coins[i])*p.second;
        }
        swap(mp,mp2);
    }

    double ans = 0.0;
    for (auto p: mp) {
        if (p.first > 0) ans += p.second;
    }

    cout << fixed << setprecision(12) << ans << "\n";
    
    
    return 0;
}


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define prll(v) for (auto i: v) cout << i << " ";

int main() {
    fast
	ll n;
	cin >> n;
	vvi mat(n, vi(n));
	string x;
	REP(i, 0, n) {
		cin >> x;
		REP(j, 0, n)
			mat[i][j] = x[j] - '0';
	}
	queue<ll> q;
	vi col(n, -1);
	q.push(0);
	col[0] = 0;
	ll p = 0;
	while (!q.empty()) {
		ll c = q.front();
		q.pop();
		REP(i, 0, n) {
			if (mat[c][i] == 0)
				continue;
			if (col[i] == col[c]) {
				p = 1;
				break;
			}
			else if (col[i] == -1) {
				col[i] = !col[c];
				q.push(i);
			}
		}
	}
	//cerr << p << "";
	if (p)
		cout << -1 << endl;
	else {
		ll ans = 0;
		REP(i, 0, n)
			REP(j, 0, n)
				if (mat[i][j] == 0 && i != j)
					mat[i][j] = INT_MAX;
		REP(i, 0, n) {
			auto tmp = mat;
			REP(j , 0, n)
				REP(k, 0, n)
					tmp[j][k] = min(mat[j][i] + mat[i][k], mat[j][k]);
			mat = tmp;
		}
		REP(i, 0, n)
			REP(j, 0, n)
				ans = max(ans, mat[i][j]);
		cout << ans + 1 << endl;
	}
}


Measured memory_bytes: 960
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 N, K, i;
  cin >> N >> K;
  vi H(N);
  REP(0, N, i) {
    cin >> H[i];
  }
  i64 ans = 0;
  if(sz(H) > K) {
    sort(all(H), greater<i64>());
    REP(K, N, i) {
      ans += H[i];
    }
  }
  cout << ans << endl;  

  return 0;
}


Measured memory_bytes: 1792
n = int(input())

m = [[0 for _ in range(n+1)] for _ in range(n+1)]
#mm = [[] for _ in range(n+1)]

for _ in range(n):
	tmp = [int(x) for x in input().split()]
	u,k,l = tmp[0],tmp[1],tmp[2:]
	#mm[u] += tmp[2:]
	for x in l:
		m[u][x] = 1
		
dp = [float('inf') for _ in range(n+1)]
dp[1] = 0
queue = [1]

while queue:
	t = queue.pop(0)
	for i,x in enumerate(m[t]):
		if x == 1:
			if dp[i] > dp[t] + 1:
				dp[i] = dp[t] + 1
				queue.append(i)
			else:
				pass
		else:
			pass
			
for i,x in enumerate(dp):
	if i == 0:
		pass
	else:
		if x == float('inf'):
			print(i, -1)
		else:
			print(i, x)
			

	


Measured memory_bytes: 5724
'use strict';
function Main(input) {
	input = input.trim().split("");  

  	let n = input.length;
  	let l = (n - 1) / 2;
  	let r = (n + 3) / 2;
  	let left = [];
  	let right = [];
  
  	for(let i = 0 ; i < Math.floor(input.length/2); i++){
      let e = input.length-1-i;
      if(input[i] !== input[e]){
        console.log('No');
        return;
      }
    }
  
  
  	for(let i = 0; i < l; i++){
      left.push(input[i])
    }
  	for(let i = r-1; i < n; i++){
      right.push(input[i])
    }
  	
	for(let i = 0 ; i < Math.floor(left.length/2); i++){
      let e = left.length-1-i;
      if(left[i] !== left[e]){
        console.log('No');
        return;
      }
    }
  	for(let i = 0 ; i < Math.floor(right.length/2); i++){
      let e = right.length-1-i;
	  if(right[i] !== right[e]){
        console.log('No');
        return;
      }
    }
  	console.log('Yes');
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29564
#include<bits/stdc++.h>
using namespace std;
int main() {
    int Taka_Health, Taka_Damage, Enemy_Health, Enemy_Damage;
    cin >> Taka_Health >> Taka_Damage >> Enemy_Health >> Enemy_Damage;
    while (true) {
        if (Enemy_Health<=0){
            cout << "Yes";
            break;
        }
        if (Taka_Health<=0){ 
            cout << "No";
            break;
        }
        Taka_Health = Taka_Health - Enemy_Damage;
        Enemy_Health = Enemy_Health - Taka_Damage;
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int a[5],n,m,s,c;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) a[i]=-1;
	for(int i=1;i<=m;i++)
	{
		cin>>s>>c;
		if(a[s]!=-1&&a[s]!=c) {cout<<-1;return 0;}
		else a[s]=c;
	}
	if(n>1&&a[1]==0) cout<<-1;
	else if(n==1)
	{
		if(a[1]==-1) cout<<0;
		else cout<<a[1];
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			if(i==1&&a[i]==-1) cout<<1;
			else if(a[i]==-1) cout<<0;
			else cout<<a[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char map[114][514];
int h, w, ans;
void dfs(int i, int j) {
	ans++;
	map[i][j] = '#';
	if (map[i - 1][j] == '.')dfs(i - 1, j);
	if (map[i + 1][j] == '.')dfs(i + 1, j);
	if (map[i][j - 1] == '.')dfs(i, j - 1);
	if (map[i][j + 1] == '.')dfs(i, j + 1);
	return;
}
int main() {
	while (cin >> h >> w, h, w) {
		ans = 0;
		int x, y;
		for (int i = 0; i < 30; i++)for (int j = 0; j < 30; j++)map[i][j] = '#';
		for (int i = 1; i <= w; i++)for (int j = 1; j <= h; j++) {
			cin >> map[i][j];
			if (map[i][j] == '@') { x = i; y = j; }
		}
		dfs(x, y);
		cout << ans << endl;
	}
}

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

int abs(int x){
  if(x<0){
    x=-x;
  }
  return x;
}

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


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int maxN = 10^^6;
    int[] f, f_odd;
    for(int n=1; ;n++) {
        f ~= func(n);
        if (f.back > maxN) break;
        if (f.back%2!=0) f_odd~= f.back;
    }
    int INF = 1<<30;

    int[] ary = new int[maxN+1];
    ary[] = INF;
    ary[0] = 0;
    foreach(int i; 0..maxN) {
        if (ary[i]<INF) {
            for(int n=0; n<f.length; n++) {
                if (i+f[n]<=maxN) {
                    ary[i+f[n]] = min(ary[i+f[n]], ary[i]+1);
                } else {
                    break;
                }
            }
        }
    }
    int[] _ary = new int[maxN+1];
    _ary[] = INF;
    _ary[0] = 0;
    foreach(int i; 0..maxN) {
        if (_ary[i]<INF) {
            for(int n=0; n<f_odd.length; n++) {
                if (i+f_odd[n]<=maxN) {
                    _ary[i+f_odd[n]] = min(_ary[i+f_odd[n]], _ary[i]+1);
                } else {
                    break;
                }
            }
        }
    }

    while(true) {
        int N = readln.chomp.to!int;
        if (N==0) break;
        writeln(ary[N], " ", _ary[N]);
    }
}
int func(int n) {
    return n*(n+1)*(n+2)/6;
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> e(n);
    vector<int> w(n);

    if(s[0]=='W')
        w[0]=1;
    for(int i=1; i<n; ++i){
        if(s[i]=='W')
            w[i] = w[i-1]+1;
        else
            w[i] = w[i-1];
    }


    if(s[n-1]=='E')
        e[n-1]=1;
    for(int i=n-2; i>=0; --i){
        if(s[i]=='E')
            e[i] = e[i+1]+1;
        else
            e[i] = e[i+1];
    }

    int ans = INT_MAX;
    for(int i=0; i<n; ++i){
        ans = min(ans, e[i]+w[i]-1);
    }
    cout << ans;
}

Measured memory_bytes: 6136
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int h,w,n;
	cin >> h >> w >> n;
	int cnt = 0;
    while(n > 0){
        cnt++;
        n -= max(h,w);
    }
    cout << cnt << endl;
	
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://keyence2020.contest.atcoder.jp/tasks/keyence2020_b

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<double,double,double> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    vector<tpl> ee(N);
    REP(i,N){
        double x,y; cin >> x >> y;
        double theta;
        if(x == 0 && y == 0) theta = 0;
        else theta = atan2(y,x);
        if(theta < 0) theta += 2*PI;
        get<0>(ee[i]) = theta;
        get<1>(ee[i]) = x;
        get<2>(ee[i]) = y;
    }
    SORT(ee);
    vector<tpl> e(2*N);
    REP(i,N){
        get<0>(e[i]) = get<0>(ee[i]);
        get<1>(e[i]) = get<1>(ee[i]);
        get<2>(e[i]) = get<2>(ee[i]);
        get<0>(e[i+N]) = get<0>(ee[i]) + 2*PI;
        get<1>(e[i+N]) = get<1>(ee[i]);
        get<2>(e[i+N]) = get<2>(ee[i]);
    }

    double ans = 0;
    REP(i,N)FOR(j,i,N){
        double x = 0, y = 0;
        FOR(k,i,j+1){
            x += get<1>(e[k]);
            y += get<2>(e[k]);
        }
        chmax(ans, sqrt(x*x+y*y));
        x = 0, y = 0;
        FOR(k,j+1,j+N-(j-i+1)){
            x += get<1>(e[k]);
            y += get<2>(e[k]);
        }
        chmax(ans, sqrt(x*x+y*y));
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	int i,k;
	int a,b;
	while(1){
		scanf("%d %d", &a, &b);
		if(a==0&&b==0){
			break;
		}
		for(i=0; i<a; i++){
			for(k=0; k<b; k++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(All(L));
    ll res = 0;
    rep(i, N) for(int j = i + 1; j < N; j++) {
        auto itr = lower_bound(All(L), L[i] + L[j]);
        ll ng = distance(itr, L.end());
        res += (N - 1 - j) - ng;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main()
{
  multiset<int> ms;
  int n;
  
  scanf("%d", &n);
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    auto it = ms.lower_bound(a);
    if (it == ms.begin()) {
      ans++;
    }
    else {
      --it;
      ms.erase(it);
    }
    ms.insert(a);
  }
  
  printf("%d\n", ans);
  
  return 0;
}

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

char com(char x){
  if(x=='?'){
    return 'a';
  }else{
    return x;
  }
}

bool eq(char x,char y){
  if(x=='?'){
    return true;
  }else if(x==y){
    return true;
  }else{
    return false;
  }
}

int main(){
  string S,T;
  cin >> S >> T;
  int N=S.size(),M=T.size();
  for(int i=N-M;0<=i;i--){
    bool part=true;
    for(int j=0;j<M;j++){
      if(!eq(S[i+j],T[j])){
        part=false;
        break;
      }
    }
    if(part){
      for(int j=0;j<M;j++){
        S[i+j]=T[j];
      }
      for(int j=0;j<N;j++){
        cout << com(S[j]);
      }
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256