akhauriyash/Code-Regression huggingface dataset:
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

n=int(input())
A=[list(map(int,input().split())) for i in range(n-1)]
for i in range(n):
    if i==n-1:print(0);exit()
    now=0
    for l in A[i:]:
        c,s,f =l 
        now=max(now,s)
        for plus in range(0,101):
            if (now+plus)% f==0:
                now+=plus
                break
        now+=c
    print(now)



Measured memory_bytes: 79256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
#include <memory>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

struct Combinations {

    long long mod;
    vector< long long > inv;
    vector< long long > fact;
    vector< long long > inv_fact;

    Combinations (int n, int m) : inv(n), fact(n), inv_fact(n), mod(m) {
        inv[1] = 1;
        for (long long i = 2; i < n; i++) {
            inv[i] = inv[mod%i] * (mod - mod / i) % mod;
        }
        fact[0] = inv_fact[0] = 1;
        for (long long i = 1; i < n; i++) {
            fact[i] = (fact[i-1] * i) % mod;
            inv_fact[i] = (inv_fact[i-1] * inv[i]) % mod;
        }
    }

    long long nPr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return fact[n] * inv_fact[n-r] % mod;
    }

    long long nCr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return nPr(n,r) * inv_fact[r] % mod;
    }

    long long nHr(long long n, long long r) {
        return nCr(n+r-1,r);
    }

};

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

    const ll MOD = 1e9 + 7;

    Combinations inst(300000, MOD);

    ll ans = 0;
    for (ll i = 0; i <= min(n, k); i++) {
        ll anst = 1LL;
        anst *= inst.nCr(n, n - i);
        anst %= MOD;
        anst *= inst.nHr(n - i, i);
        anst %= MOD;
        ans += anst;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7296
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=1000*1007;

int n;

int wyn=1e9;

int ile(int v)
{
	if (!v)
		return 0;
	return (v%10)+ile(v/10);
}

int main()
{
	scanf("%d", &n);
	for (int i=1; i<n; i++)
		wyn=min(wyn, ile(i)+ile(n-i));
	printf("%d\n", wyn);
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
ll pow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res*=a;
		b/=2;
		a*=a;
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	ll h[n], dp[n];
	for(int i = 0; i < n; i++) {
		cin >> h[i];
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= k && i+j < n; j++){
			dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
		}
	}
	cout << dp[n-1] << "\n";
	return 0;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOf(listOf(0), listOfInt(), listOf(0)).flatMap { it }.toIntArray()
    var D = 0; for (n in 0 .. N) D += Math.abs(A[n] - A[n + 1])
    val ans = Array(N) { val n = it + 1
        D - Math.abs(A[n - 1] - A[n]) - Math.abs(A[n] - A[n + 1]) + Math.abs(A[n - 1] - A[n + 1])
    }
    println(ans.joinToString("\n"))
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }


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

bool comp(const tuple<int,string,int>& a,const tuple<int,string,int>& b)
{
	if (get<1>(a) < get<1>(b))
		return true;
	else if(get<1>(a) == get<1>(b))
		return (get<2>(a) > get<2>(b));
	else
		return false;
} 

int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif*/

	int n;
	cin>>n;
	vector<tuple<int,string,int>> v;
	string name;int score;
	for(int i=0;i<n;i++)
	{
		cin>>name>>score;
		v.push_back(make_tuple(i,name,score));
	}
	sort(v.begin(),v.end(),comp);
	for(int i=0;i<v.size();i++)
	{
		cout<<(get<0>(v[i]))+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int r = (x[1] + x[0]) * 2;
            int r1 = x[0] * x[1];
            Console.WriteLine(r1 + " " + r);

        }
    }
}

Measured memory_bytes: 9588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  map<int,int>mp;
  rep(i,n)mp[a[i]]++;
  ll ans=1;
  bool ng=false;
  if(n%2==0){
    rep(i,n){
      if(i%2==0){
        if(mp[i]>0)ng=true;
      }
      else {
        if(mp[i]!=2)ng=true;
        else ans*=2,ans%=mod;
      }
    }
  }
  else {
    rep(i,n){
      if(i%2==0&&i!=0){
        if(mp[i]!=2)ng=true;
        else ans*=2,ans%=mod;
      }
      else if(i==0){
        if(mp[0]!=1)ng=true;
      }
      else {
        if(mp[i]>0)ng=true;
      }
    }
  }
  if(ng)ans=0;
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 5376
def calc(n):
	a = 1000 - n
	y = [500, 100, 50, 10, 5, 1]
	ans = 0
	for i in y:
		ans += a // i
		a %= i
		if a == 0:
			return ans
def resolve():
	while True:
		v = int(input())
		if v == 0:
			return
		print(calc(v))
resolve()


Measured memory_bytes: 4652
class TN(object):
	def __init__(self):
		self.h = {}
		self.count = 0
		self.need = collections.Counter()


ais = [raw_input() for _ in range(int(raw_input()))]
ais.sort(key = len)
import collections
cc = collections.Counter()

ans = 0
root = TN()
for w in ais:
	
	###COUNT
	cur =  root
	for j in range(len(w)-1, -1, -1):
		for k in cur.need:
			if k in w[:j+1]:
				ans += cur.need[k]
		if w[j] in cur.h:
			cur = cur.h[w[j]]
		else:
			break
	###UPDATE
	cur = root
	for j in range(len(w) - 1, 0, -1):
		if w[j] not in cur.h:
			cur.h[w[j]] = TN()
		cur = cur.h[w[j]]
	cur.need[w[0]] += 1

print ans

Measured memory_bytes: 477676
#include<stdio.h>

int main(){
    int n;
    int total=0, maior=0, min=0;
    scanf("%d", &n);
    int x[n];
    for (int i=0; i<n; ++i){
        scanf("%d", &x[i]);
        if (x[i]>maior){
            maior=x[i];
        }
    }
    for (int i=0; i<=maior; ++i){
        total=0;
        for (int j=0; j<n; ++j){
            total+=((x[j]-i)*(x[j]-i));
        }
        if (min==0){
            min=total;
        }
        if (total<min){
            min=total;
        }
    }
    printf("%d\n", min);
    return 0;
}

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

int main(){
    ll x,y;
    cin>>x>>y;
    int cnt=0;
    for(ll i=x;i<=y;i*=2){
        cnt+=1;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    let v = input_vector::<usize>();
    let mut a = 0;
    let mut w_count = 0;
    for z in v {
        a += 1;
        if z != a {
            w_count += 1;
        }
    }
    if w_count > 2 {
        println!("NO");
    } else {
        println!("YES");
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int l=nxt();
    double x=l;
    x/=3;
    cout<<setprecision(10)<<x*x*x<<endl;

    return 0;   
}


 
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i,n-1) cin >> b[i];

    int sum = b[0] + b[n-2];
    rep(i,n-2)
        sum += min(b[i],b[i+1]);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = a * b;
        int z = (a + b) * 2;
        System.out.println(x +" "+ z);
        sc.close();
    }
}



Measured memory_bytes: 25936
#include <bits/stdc++.h>
#include <algorithm>
using namespace std; 
  
typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<string> vs;
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
int INF = 100005; 
long long int mod=1000000007;
long long TES=1000007;
long long INFF = 1000000000000000005LL; 
double PI = acos(-1); 
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 }; 
  
#ifdef TESTING 
#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#else 
#define DEBUG 
#define VALUE(x) 
#define debug(...) 
#endif 
  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a)) 
#define FOREACH(a, b) for (auto&(a) : (b)) 
#define rep(i, n) FOR(i, 0, n) 
#define repn(i, n) FORN(i, 1, n) 
#define MAX(a, b) a = max(a, b) 
#define MIN(a, b) a = min(a, b) 
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define TC(t) while (t--)


void solve()
{
  int n;
  cin>>n;
  n=n%1000;
  if(n==0)
  cout<<"0\n";
  else
  cout<<1000-n<<endl;
  return;
}
int main()
{
    IOS();
  
    solve();
    return 0;
}





Measured memory_bytes: 3636
import collections

if __name__ == '__main__':
    N = int(input())
    kv = collections.defaultdict(int)
    max_cnt = 0
    res = []
    for _ in range(N):
        word = input()
        kv[word] += 1
        if kv[word] == max_cnt:
            res.append(word)
        elif kv[word] > max_cnt:
            res = [word]
            max_cnt = kv[word]
    for s in sorted(res):
        print(s)

Measured memory_bytes: 33680
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

ll p2[50] = {};

ll power(int n){
  if(n == 0) return 1;
  if(p2[n] != 0) return p2[n];
  ll temp = power(n / 2);
  if(n & 1) return p2[n] = 2 * temp * temp;
  return p2[n] = temp * temp;
}

ll f(int l, ll x){
  if(x == 0) return 0;
  if(x == power(l + 2) - 3) return power(l + 1) - 1;
  if(x > (power(l + 2) - 4) / 2){
    x = power(l + 2) - 3 - x;
    return power(l + 1) - 1 - f(l, x);
  }
  return f(l - 1, x - 1);
}

int
main(int argc, char *argv[])
{
  int n; ll x;
  scanf("%d %lld", &n, &x);
  printf("%lld\n", f(n, x));

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#define INF 1e9 + 1
using namespace std;

struct item {
    int wt;
    int val;
};

// Bottom Up Approach
int knapsackBottomUp(vector<item> arr, int n, int W) {
    int maxVal = (n * 1000);
    long long int dp[n + 1][maxVal + 1];
    // Base Cases
    for(int val = 0; val <= maxVal; val++) dp[1][val] = INF;
    dp[1][0] = 0;
    dp[1][arr[1].val] = arr[1].wt;
    // Iteratively Calculating Other Cases In Bottom Up Fashion
    for(int i = 2; i <= n; i++) {
        for(int v = 0; v <= maxVal; v++) {
            dp[i][v] = dp[i - 1][v];
            if(arr[i].val > v) continue;
            dp[i][v] = min(dp[i][v], (arr[i].wt + dp[i - 1][v - arr[i].val]));
        }
    }
    int ans = 0;
    for(int x = 0; x <= maxVal; x++) {
        if(dp[n][x] <= W) ans = x;
    }
    return ans;
}

int main() {
    int n, w;
    cin >> n >> w;
    vector<item> arr(n + 1);
    for(int i = 1; i <= n; i++) cin >> arr[i].wt >> arr[i].val;
    cout << knapsackBottomUp(arr, n, w) << endl;
    return 0;
}

Measured memory_bytes: 81712
#include<bits/stdc++.h>
using namespace std;
#define I_O		ios::sync_with_stdio(false),cin.tie(0)
#define ll		long long
#define ff		first
#define ss		second
#define mod 		1000000007
#define rep(i,n)	for(ll i=1;i<=n;i++)
#define repv(i,a,n)	for(ll i=a;i<=n;i++)
#define pb 		push_back
#define newl		'\n'
#define deb(x)		cout<<x<<" "
int ac = 0,wa  = 0,tle = 0,re = 0;
int main() 
{  
	I_O;
	int _;	cin>>_;
	string s;
	while(_--)
	{
		cin>>s;
		if(s == "AC")	ac++;
		else if(s == "TLE")	tle++;
		else if(s == "WA")	wa++;
		else				re++;
	}
	cout<<"AC x "<<ac<<newl;
	cout<<"WA x "<<wa<<newl;
	cout<<"TLE x "<<tle<<newl;
	cout<<"RE x "<<re<<newl;
} 


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

void chmin(int& a, int b){
    a = min(a, b);
}

int main(){
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i] >> B[i];

    vector<int> dp(100000, 1e9);
    dp[0] = 0;
    for(int h=0; h<H; h++) for(int i=0; i<N; i++){
        chmin(dp[min(h+A[i], H)], dp[h] + B[i]);
    }
    cout << dp[H] << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  bool chk = false;
  if(c<d)chk = true;
  else{
    for(int i=b-1;i<=d-1;i++){
      if(s[i]=='.' && s[i-1]=='.' && s[i+1]=='.')chk = true;
    }
  }
  for(int i=a-1;i<c-1;i++){
    if(s[i] == '#' && s[i+1]=='#')chk = false;
  }
  for(int i=b-1;i<d-1;i++){
    if(s[i] == '#' && s[i+1]=='#')chk = false;
  }
  if(chk)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 640
n = input()
N = int(n)
P = []
counter = 0
input_string = input()
P = input_string.split()

for i in range(int(N)):
    for j in range(N):
        if N == int(P[i]):
            counter = counter + 1
            if N != 1:
                N = N - 1
                break
            else: 
                break
        elif N < int(P[i]):
            break
        else:
            if N != 1:
                N = N - 1   

print(counter)


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, a, b; cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    }
    else {
        cout << "B" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

set<long long> prime_factor(long long n) {
	set<long long> res;
	res.insert(1);
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			res.insert(i);
			n /= i;
			// cout << i << " " << n << endl;
		}
	}
	if (n != 1) res.insert(n);
	return res;
}

long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}

void solve(long long A, long long B){
	ll x, y, g;
	g = extgcd(A, B, x, y);
	cout << prime_factor(g).size() << endl;
}

int main(){	
	long long B;
	long long A;
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(A, B);
	return 0;
}



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

int n, y;

int main(){
    cin >> n >> y;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n - i; j++){
            if(10000 * i + 5000 * j + 1000 * (n - i - j) == y){
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
            } 
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;
int n,m,lmx=0,rmn=100000;

int main(){
    cin >> n >> m;
    int tmpl, tmpr;
    for(int i=0;i<m;i++){
        cin >> tmpl >> tmpr;
        lmx = max(lmx, tmpl);
        rmn = min(rmn, tmpr);
    }

    cout << max(0, rmn-lmx+1) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD1    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define scd second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

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

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main(int argc, char *argv[]) {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, d; cin >> n >> d;
    vector<Vi> x(n, Vi(d));
    rep(i, n){
        rep(j, d){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    rep(i, n-1){
        for(int j = i+1; j < n; ++j){
            int sum = 0;
            rep(k, d){
                sum += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            reps(q, 130){
                if(sum == q*q) ++ans;
            }
        }
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3652
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  ll N,A,B; cin>>N>>A>>B;

  ll br = N/(A+B);
  ll tail = N%(A+B);

  ll  ans = A*br + min(A, tail);

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;

  if (a==b) {
    cout << c << endl;;
  } else if (a==c) {
    cout << b << endl;
  } else {
    cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
// typedef pair<int,int> P;
const int MAX = 1000000;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> p(n);
    rep(i,n-1){
        int x;
        cin >> x;
        --x;
        p[x].push_back(1); 
    }
    rep(i,n){
        cout<<p[i].size()<<endl;
    }
    return 0;


}

Measured memory_bytes: 13956
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	string S;
	cin >> S;

	string s;
	for(int i = 0; i < S.size(); i++){
		if(S[i] == '0'){
			s += '0';
		}
		else if(S[i] == '1'){
			s += '1';
		}
		else{
			if(s.size()) s.pop_back();
		}
		
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <math.h>
#include <cctype>
#include <algorithm>
#include <sstream>
using namespace std;
const float PI = 3.14;

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


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans=1e18;
    
    rep(i,max(x,y)+1){//セット買う個数
        ll ans1=0;
        ans1+=2*c*i;
        if(x-i>0) ans1+=  (x-i)*a;
        if(y-i>0) ans1+=  (y-i)*b;
        ans=min(ans,ans1);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        System.out.println(func(H));
    }

    public static long func(long hp){
        if(hp == 1){return 1;}
        return func(hp/2)*2+1;
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  for(ll i=0;i<k;i++) {
    if(i%2) {
      b-=b%2;
      a+=b/2;
      b/=2;
    }
    else {
      a-=a%2;
      b+=a/2;
      a/=2;
    }
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    
    bool flag = true;
    if(A < B) {
        if(A + T * V >= B + T*W) flag = false;
    } else {
        if(B - T*W >= A - T*V) flag = false;
    }

    if(!flag) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<int, ll> mil;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"
#define sqr(a)((a) *(a))
#define jor(a) !(a & 1)	// jor means EVEN number
#define bjor(a)(a & 1)	// bjor means ODD number
#define all(a) a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr))	//memset only for -1 and 0
//fill(a, a+n, 5)	//fill for any value
#define for0(i, b) for (int i = 0; i < (b); i++)
#define for1(i, b) for (int i = 1; i <= (b); i++)
#define forab(i, a, b) for (int i = (a); i <= (b); i++)
#define forba(i, b, a) for (int i = (b); i >= (a); i--)
#define rep(i, a, b, c) for (int i = (a); i != (b); i += (c))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define fileRead freopen("input.txt", "r", stdin);

void print(int a[], int n)
{
	// for testing or debugging
	for (int i = 0; i < n; i++) cout << a[i] << " ";
	cout << endl;
}

//______________________________________________________\\

int main()
{
    IOS;
    //fileRead;
    int x,y;
    cin>>x>>y;
    int t=(y - x*2);
    if(jor(t) and t >= 0 and t/2 <= x) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    long long int n; cin >> n;
    long long int min=1000000000000;
    long long int i,j,k;
    for (k=1; k<=sqrt(n); k++){
        if (n%k==0) { 
            i = k; j = n/k;
            if ((i+j-2)<min) min = i+j-2;
        }
    }
    cout << min << endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s, t;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> k ;
	x = k/50;
	y = k%50;

	ll a = 49 + x;
	cout<<50;newl;
	for(ll i=0;i<50-y;i++) cout<<a-y<<" ";
	for(ll i=0;i<y;i++) cout<<a+51-y<<" ";
	newl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3636
s = input()
op = ["+", "-"]


def caliculation(sum, operator, _input):
    if op[operator] == "+":
        sum += _input
    elif op[operator] == "-":
        sum -= _input
    return sum


for i in range(2):
    for j in range(2):
        for k in range(2):
            sum = int(s[0])
            sum = caliculation(sum, i, int(s[1]))
            sum = caliculation(sum, j, int(s[2]))
            sum = caliculation(sum, k, int(s[3]))
            if sum == 7:
                print("{}{}{}{}{}{}{}{}".format(s[0], op[i], s[1], op[j], s[2], op[k], s[3], "=7"))
                exit()

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int MAX=1000010;
int p[MAX];
void sieve(){
	for(int i=2; i<MAX; i++){
		if(p[i]==0){
			for(int j=(i<<1); j<MAX; j+=i) p[j]=i;
		}
	}
}
int cnt[MAX];
int main()
{
    int n; cin>>n;
    int a[1000010];
    for(int i=0; i<n; i++) cin>>a[i];
    int g=a[0];
    for(int i=1; i<n; i++) g=gcd(g, a[i]);
    if(g>1){
        cout<<"not coprime"<<endl;
        return 0;
    }
    sieve();
    for(int i=0;i<n; i++){
        unordered_map<int, int> mp;
        int x=a[i];
        while(p[x]>0){
            mp[p[x]]++;
            x/=p[x];
        }
        mp[x]++;
        for(auto q:mp){
            cnt[q.first]++;
        }
    }
    for(int i=2; i<MAX; i++){
        if(cnt[i]>1){
            cout<<"setwise coprime"<<endl;
            return 0;
        }
    }
    cout<<"pairwise coprime"<<endl;
    return 0;
}

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


public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		
	    int a= scan.nextInt();
	    int b=scan.nextInt();
	    numbers num = new numbers(a,b);
	    num.comp();
		
	}
}

class numbers{
	int a;
	int b;
	public numbers(int x, int y){
		a=x;
		b=y;
	}
	public void comp(){
		if(a>b)
		System.out.println("a > b");
		else if(a<b)
		System.out.println("a < b");
		else
		System.out.println("a == b");
	}
	
}

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

public class Main {
  private static int solve(int n, int k) {
    int answer = Integer.MAX_VALUE;
    for (int i = 0; i <= n; i++) {
      answer = Math.min(answer, (1 << i) + (n - i) * k);
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int k = reader.nextInt();
    out.println(solve(n, k));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21332
/*input
cabacc
abc
*/

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

int main() {
    string s, t;
    cin >> s >> t;
    int sl = s.size(), tl = t.size();
    int match = 0;
    rep(i, sl-tl+1) {
        int tmp = 0;
        rep(j, tl) {
            tmp += s[i+j] == t[j];
        }
        match = max(match, tmp);
    }
    cout << tl-match << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())
#define REP(i,a,b) for(int i =a;i<b;i++)
typedef vector <ii> vii;

int main(){
	int N;
  cin >> N;
  bool ans =false;
  REP(i,1,10){
    REP(l,1,10){
      if(l*i==N){
        ans=true;
      }
    }
  }
  if(ans){
    cout << "Yes" << "\n";
  }
  else{
    cout << "No" << "\n";
  }
	
	
		return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
vector<int> book[10];
int mem[10][2000], N, K;

int value(int k, int n)
{
  if(n == 0)
    return 0;
  int v = 0;
  for(int i = 0; i < n; i++)
    v += book[k][i];
  return v + (n - 1) * n;
}

int dfs(int k, int n){
  if(k == 10)
    return 0;
  if(mem[k][n] != -1)
    return mem[k][n];
  int ans = 0;
  for(int i = 0; i <= book[k].size(); i++)
  {
    if(n + i > K)
      break;
    ans = max(ans, dfs(k + 1, n + i) + value(k, i));
  }
  mem[k][n] = ans;
  return ans;
}

int main()
{
  for(int i = 0; i < 10; i++)
    for(int j = 0; j < 2000; j++)
      mem[i][j] = -1;
  cin >> N >> K;
  for(int i = 0; i < N; i++)
  {
    int c, g;
    cin >> c >> g;
    book[g - 1].push_back(c);
  }
  for(int i = 0; i < 10; i++)
    sort(book[i].begin(), book[i].end(), greater<int>());

  cout << dfs(0, 0) << endl;
}

Measured memory_bytes: 1312
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


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

	vector<ld> x(n);
	vector<ld> y(n);
	vector<ld> d(n);
	rep(i, n)  cin >> x[i] >> y[i];
	rep(i, n) d[i] = sqrt(x[i] * x[i] + y[i] * y[i]);

	int ans = 0;
	rep(i, n) {
		if (d[i] <= D) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 12716
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
  cin>>n;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];
  ll sum = 0;
  rep(i, n) sum += a[i];
  ll res = 1e12;
  ll s = 0;
  rep(i, n-1){
    s += a[i];
    res = min(res, abs(sum-2*s));
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1792
player_card = dict()
for x in ("a","b","c"):
    player_card[x] = list(input())

loop = True
turn = "a"

while loop:
    
    if "a" == turn:
        if len(player_card["a"]) == 0:
            winner = "A"
            loop = False
        else:
            turn = player_card["a"].pop(0)
        
        
    elif "b" == turn:
        if len(player_card["b"]) == 0:
            winner = "B"
            loop = False
        else:
            turn = player_card["b"].pop(0)
    
    
    elif "c" == turn:
        if len(player_card["c"]) == 0:
            winner = "C"
            loop = False
        else:
            turn = player_card["c"].pop(0)
    
    
print(winner)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

main(){
    int n,p[30];
    int cnt = 0;

    cin >> n;
    for(int i=0;i<n;i++) cin >> p[i];

    for(int i=1;i<n-1;i++)
    {
        if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i+1] < p[i] && p[i] < p[i-1])) cnt++;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256