akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=1000000007LL;
//ll MOD=1000000007LL;
const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
const ll mod=MOD;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n;cin>>n;
  ll s;cin>>s;
  vl a(n);
  rep(i,n)cin>>a[i];
  vvl dp(n+1,vl(s+1,0));
  ll ans=0;
  rep(i,n){
    dp[i][0]+=1;
    rep(j,s+1){
      dp[i+1][j]+=dp[i][j];
      dp[i+1][j]%=MOD;
      if(j>=a[i]){
        dp[i+1][j]+=dp[i][j-a[i]];
        dp[i+1][j]%=MOD;
      }
      ans+=dp[i+1][s];
      ans%=MOD;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")

#define name "combo"
#define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout);

typedef long long ll;

ll n, a, b;

int main() {
    file(name);
    cin >> n >> a >> b;
    cout << max(0ll, (((n - 1) * b) + a) - (((n - 1) * a) + b) + 1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int mod_pow(int x,int y){
	int res=1;
	while(y>0){
		if(y&1)res*=x;
		x*=x;
		res%=mod;x%=mod;
		y>>=1;
	}
	return res;
}
bool prime(int x){
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return false;
	}
	return x!=1;
}
int n,a[114514];
multiset<int>st;
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n){
		auto it=st.lower_bound(a[i]);
		if(it!=st.begin()){
			it--;
			st.erase(it);
		}
		st.insert(a[i]);
	}
	cout<<st.size()<<endl;
}


Measured memory_bytes: 5760
#include <stdio.h>

int main(){
    int w = 0;
    int i = 0;
    char s[1002] = {0};
    while((s[i] = getchar()) != '\n'){
        i++;
    }
//    scanf("%s", s);
    scanf("%d", &w);

    i = 0;

    while (s[i] != '\n') {
        if (i % w == 0) {
            printf("%c", s[i]);
        }
        i++;
    }
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = (0 until n).map { readLine()!!.toInt() }
    val (x1, x2) = xs.sortedDescending().take(2)
    xs.forEach { println(if (it == x1) x2 else x1) }
}


Measured memory_bytes: 61148
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
int map[110][110];
int x[110], y[110], a[110];

int main(void)
{
    int W,H,N;
    int x1, x2, y1, y2;

    cin >> W >> H >> N;
    REP(i, H) {
        REP(j, W) {
            map[i][j] = 0;
        }
    }
    REP(i, N) {
        cin >> x[i] >> y[i] >> a[i];
        x1 = 0; x2 = W; y1 = 0; y2 = H;
        switch(a[i]) {
            case 1:
            x2 = x[i];
            break;
            case 2:
            x1 = x[i];
            break;
            case 3:
            y2 = y[i];
            break;
            case 4:
            y1 = y[i];
            break;
        }
        for(int i = x1; i < x2; i++) {
            for(int j = y1; j < y2; j++) {
                map[j][i] = 1;
            }
        }
    }
    int s = 0;
    REP(i, W) {
        REP(j, H) {
            if(map[j][i] == 0) s ++;
        }
    }
    cout << s << endl;


    

}


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

void selection_s(char a[], int N);
void selection_l(char a[], int N);

int main(void)
{

  char s[105];
  char a[105];

  fgets(s, sizeof(s), stdin);
  fgets(a, sizeof(a), stdin);

  //選択整列法を使用
  //sを小さい順でソート
  selection_s(s, strlen(s)-2);
  selection_l(a, strlen(a)-2);

  int str_siz = strcmp(s, a);

  if (str_siz < 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }


  
  return 0;
}

void selection_s(char a[], int N)
{
  int min;
  char t;

  for (int i = 0; i < N; i++) {

    min = i;

    for (int j = i+1; j <= N; j++) {
      if (a[j] < a[min]) {min = j;}
    }

    t = a[min];
    a[min] = a[i];
    a[i] = t;

  }
}

void selection_l(char a[], int N)
{
  int min;
  char t;

  for (int i = 0; i < N; i++) {

    min = i;

    for (int j = i+1; j <= N; j++) {
      if (a[j] > a[min]) {min = j;}
    }

    t = a[min];
    a[min] = a[i];
    a[i] = t;

  }
}


Measured memory_bytes: 128
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

AB.sort()

price = 0
store = 0

while M > 0:
  if M - AB[store][1] < 0:
    price += AB[store][0]*M
    M = 0
  else:
    price += AB[store][0]*AB[store][1]
    M -= AB[store][1]
    store += 1

print(price)

Measured memory_bytes: 60760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc123C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var trans = Enumerable.Range(0, 5).Select(x => long.Parse(Console.ReadLine())).ToArray();
            long[] pos = new long[10];
            long minval = trans.Min();
            var time = (long)Math.Ceiling((double)n / minval) + 4;
            
            Console.WriteLine(Convert.ToString(time));
            Console.ReadKey();
        }
    }
}



Measured memory_bytes: 13396
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
start = time.clock()

def prime(n):
    l=[True for _ in range(n+1)]
    i=2
    while i**2<=n:
        if l[i]:
            j=i+i
            while j<=n:
                l[j]=False
                j+=i
        i+=1
    return l
#    lis=[i for i in range(n+1) if l[i] and i>=2]

for n in sys.stdin:
    print (prime(int(n))).count(True)-2

Measured memory_bytes: 50120
N, A, B = map(int,input().split())

if A > B:
    print(0)
else:
    if N == 1:
        if A == B:
            print(1)
        else:
            print(0)
    elif N == 2:
        print(B-A+1)
    else:
        print((N-2) * (B-A) + 1)

Measured memory_bytes: 3060
#include<stdio.h>
#include<ctype.h>

int main(void){
	char str[1000];
	int i;
	fgets(str,1000,stdin);
	i = 0;
	while(str[i] != '\0'){
		str[i] = toupper(str[i]);
		i++;
	}
	printf("%s",str);
	return 0;
}

Measured memory_bytes: 524
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	n := scanInt()
	p := make([]int, n)

	for i := 0; i < n; i++ {
		p[i] = scanInt()
	}
	
	ans := 0

	for i := 0; i < n-2; i++ {
		if (p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i] > p[i+1] && p[i+1] > p[i+2]) {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  scanf("%d", &N);
  
  vector<string> vs(N);
  for(int i=0;i<N;i++){
      cin >> vs[i];
  }

  map<string, int> mp;
  mp["AC"] = 0;
  mp["WA"] = 0;
  mp["TLE"] = 0;
  mp["RE"] = 0;
  
  for(int i=0;i<N;i++){
      mp[vs[i]]++;
  }

  cout << "AC x " << mp["AC"] << "\n";
  cout << "WA x " << mp["WA"] << "\n";
  cout << "TLE x " << mp["TLE"] << "\n";
  cout << "RE x " << mp["RE"] << "\n";

  return 0;
}

Measured memory_bytes: 6372
import java.util.*;

class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int X = sc.nextInt();
      	int M;
      	int m = 8;
      	if ((X>=400)&&(X<600)) {
          	M = m;
        } else if ((X>=600)&&(X<800)) {
          	M = m - 1;
        } else if ((X>=800)&&(X<1000)) {
          	M = m - 2;
        } else if ((X>=1000)&&(X<1200)) {
          	M = m - 3;
        } else if ((X>=1200)&&(X<1400)) {
          	M = m - 4;
        } else if ((X>=1400)&&(X<1600)) {
          	M = m - 5;
        } else if ((X>=1600)&&(X<1800)) {
          	M = m - 6;
        } else {M = m - 7;}
      
      	System.out.println(M);
	}
}

Measured memory_bytes: 35700
#include <cstdio>

int main( void )
{
    while ( 1 )
    {
        int h, w;
        scanf( "%d %d", &h, &w );
        if ( ( h == 0 ) && ( w == 0 ) ) break;

        for ( int i = 0; i < h; i++ )
        {
            for ( int j = 0; j < w; j++ )
            {
                if ( ( i + j ) % 2 == 0 )
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }

        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2544
// Copyright 2017 wu_qing
#include <stdint.h>
#include <cstdio>
const int N = 2e5 + 10, mod = 1e9 + 7;
int h, w, a, b;
int64_t jie[N], inv[N], ans;
int main() {
    scanf("%d%d%d%d", &h, &w, &a, &b);
    jie[0] = inv[0] = inv[1] = 1;
    for (int i = 1; i < N; i++)
        jie[i] = jie[i - 1] * i % mod;
    for (int i = 2; i < N; i++)
        inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    for (int i = 1; i < N; i++)
        inv[i] = inv[i - 1] * inv[i] % mod;
    ans = (jie[w + h - 2] * inv[w - 1] % mod) * inv[h - 1] % mod;
    for (int i = w - b; i < w; i++) {
        ans = (ans -
            ((((jie[a + i - 1] * inv[a - 1] % mod) * inv[i] % mod) *
            jie[w + h - a - i - 2] % mod) *
            inv[h - a - 1] % mod) * inv[w - i - 1] % mod) % mod;
    }
    if (ans < 0)
        ans += mod;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <assert.h>

const double pi = atan(1.) * 4;

struct Point;
using Vector = Point;
using Polygon = std::vector<Point>;

struct Point {
    int x,y,id;

    Point() {}

    Point(int _x,int _y, int id = -1) : x(_x),y(_y),id(id) {}

    Point operator + (const Point &rhs) const {
        return Point(x + rhs.x,y + rhs.y);
    }

    Point operator - (const Point &rhs) const {
        return Point(x - rhs.x,y - rhs.y);
    }

    bool operator == (const Point &rhs) const {
        return x == rhs.x && y == rhs.y;
    }

    bool operator < (const Point &rhs) const {
        if (x != rhs.x) return x < rhs.x;
        return y < rhs.y;
    }
};

using LL = long long;

LL det(const Point &a,const Point &b) {
    return a.x * 1LL * b.y - a.y * 1LL * b.x;
}

LL det(const Point &a, const Point &b, const Point &c) {
    return det(b - a, c - a);
}

LL dot(const Point &a,const Point &b) {
    return a.x * 1LL * b.x + a.y * 1LL * b.y;
}

const int kN = 100 + 5;
int n;
Point pts[kN];
double result[kN];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%d%d", &pts[i].x, &pts[i].y);
        pts[i].id = i;
    }
    std::sort(pts, pts + n);
    for (int i = 0; i + 1 < n; ++ i)
        assert(pts[i].x != pts[i + 1].x || pts[i].y != pts[i + 1].y);
    std::vector<Point> stack;
    for (int i = 0; i < n; ++ i) {
        while (stack.size() > 1 && det(stack[stack.size() - 2], stack.back(), pts[i]) >= 0) stack.pop_back();
        stack.push_back(pts[i]);
    }
    int m = stack.size();
    for (int i = n - 2; i >= 0; -- i) {
        while (stack.size() > m && stack.size() > 1 && det(stack[stack.size() - 2], stack.back(), pts[i]) >= 0) stack.pop_back();
        stack.push_back(pts[i]);
    }
    stack.pop_back();

    if (stack.size() == 2) {
        result[stack.back().id] = .5;
        result[stack[0].id] = .5;
    }
    else {
        for (int i = 0; i < stack.size(); ++ i) {
            const Point &cur = stack[i];
            Point left = stack[(i + stack.size() - 1) % stack.size()] - cur;
            Point right = cur - stack[(i + 1) % stack.size()];
            result[cur.id] = .5 * acos(1. * dot(left, right) / sqrt(dot(left, left)) / sqrt(dot(right, right))) / pi;
            // result[cur.id] = (pi - acos(1. * dot(left, right) / sqrt(dot(left, left)) / sqrt(dot(right, right)))) / (2 * pi);
        }
    }
    for (int i = 0; i < n; ++ i)
        printf("%.10f\n", result[i]);
}


Measured memory_bytes: 256
from itertools import permutations, combinations,combinations_with_replacement,product

N = int(input())
p = tuple([int(i) for i in input().split()])
q = tuple([int(i) for i in input().split()])

perm = list(permutations([int(i) for i in range(1, N+1)]))

print(abs(perm.index(p) - perm.index(q)))

Measured memory_bytes: 8052
n,t = map(int,input().split())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort()
dp = [[0 for i in range(t+1)]for j in range(n+1)]
for i in range(n):
    ti,vi = ab[i]
    for j in range(t+1):
        if j + ti <= t:
            dp[i+1][j+ti] = max(dp[i+1][j+ti],dp[i][j]+vi)
        dp[i+1][j] = max(dp[i][j],dp[i+1][j])
ma = 0
for i in range(n):
    ma = max(ma,dp[i][t-1]+ab[i][1])
print(ma)

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

class Program
{
    private static readonly Scanner sc = new Scanner();
    static void Main(string[] args)
    {
        int h = sc.Int;
        int w = sc.Int;

        Console.WriteLine(new string('#', w+2));

        for (int i = 0; i < h; i++)
        {
            Console.Write('#');
            Console.Write(sc.Str);
            Console.WriteLine('#');
        }

        Console.WriteLine(new string('#', w+2));
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Line { get { return Console.ReadLine(); } }

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Line.Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public string[] StrArr { get { return Line.Split(' '); } }
    public int Int { get { return int.Parse(Str); } }
    public int[] IntArr { get { return Line.Split(' ').Select(int.Parse).ToArray(); } }
    public long Long { get { return long.Parse(Str); } }
    public long[] LongArr { get { return Line.Split(' ').Select(long.Parse).ToArray(); } }
    public double Double { get { return double.Parse(Str); } }
    public double[] DoubleArr { get { return Line.Split(' ').Select(double.Parse).ToArray(); } }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    int N;
    cin >> N;
    int a[N];
    rep(i,N){
        cin >> a[i];
    }
    int ans=0;

    rep(i,N){
        while(a[i]%2 == 0){
            a[i]/=2;
            ans++;
        }
    }
    cout << ans << endl;
    


}


Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        a: i32,
        b: i32,
    }
    println!("{}", a * b);
}


Measured memory_bytes: 2128
w,a,b=gets.split.map(&:to_i)

ans = 0

if a + w < b
  ans = b - (a + w)
elsif b + w < a
  ans = a - (b + w)
elsif (a + w < b) && (a + w < b + w)
  ans = [b-(a+w), (b+w)-(a+w)].min
elsif (b + w < a) && (b + w < a + w)
  ans = [a-(b+w), (a+w)-(b+w)].min
end

puts ans

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

typedef long long ll;

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

    if (M < 2*N)
        cout << M/2 << endl;
    else {
        ll ans = N;
        M -= 2*N;
        ans += M/4;
        cout << ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define PI 3.14159265359
using namespace std;
int main() {
    int R;
    cin >> R;
    double L;
    L = 2.0 * PI * R;
    cout << fixed << setprecision(15) << L << std::endl;
    return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, ans = 0;
    cin >> n;
    map<ll, ll> m;

    rep(i, n) {
        ll a; cin >> a;
        if(m.count(a)) m[a]++;
        else m[a] = 1;
        ans += a;
    }
    ll q; cin >> q;
    rep(i, q) {
        ll b, c; cin >> b >> c;
        // 変える
        if(m.count(b)) {
            // ある
            if(m[b] > 0) {
                ll num = m[b]; // 個数
                ans = ans - (b*m[b]) + (c*m[b]);
                if(m.count(c)) {
                    m[c] += num;    
                }
                else {
                    m[c] = num;
                }
                m[b] = 0; 
            }
        }
        cout << ans << endl;
    }

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

all = n - 1
for i in range(n):
  all *= i + 1

loc = []
for i in range(n):
  loc.append(list(map(int, input().split())))
tot = 0
for i in range(n):
  for j in range(i + 1, n):
    tot += ((loc[i][0] - loc[j][0]) ** 2 + (loc[i][1] - loc[j][1]) ** 2) ** 0.5
tot *= all // (n * (n - 1) // 2)

print(tot / all * (n - 1))

Measured memory_bytes: 3064
#include <stdio.h>

int n,A[20];

int solve(int i,int m)
{
  int a;
  if( m==0 )
    return 1;
  else if( i>=n )
    return 0;
  else{
    a = solve(i+1,m) || solve(i+1,m-A[i]);
    return a;
  }			  
}

int main()
{
  int q,m,i,answer;

  scanf("%d",&n);
  for( i=0 ; i<n ; i++ ){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for( i=0 ; i<q ; i++ ){
    scanf("%d",&m);
    answer = solve(0,m);
    if( answer == 1 ) printf("yes\n");
    else printf("no\n");
  }

  return 0;			 
  
}



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

int main() {
  int n, m, k; cin >> n >> m;
  int backet[m] = {0};
  for(int i = 0; i < n; i++) {
    cin >> k;
    int a[k];
    for(int j = 0; j < k; j++) {
      cin >> a[j];
      backet[a[j] - 1]++;
    }
  }
  int counter = 0;
  for(int i = 0; i < m; i++) {
    if(backet[i] == n) counter++;
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	N := readString()

	b := []byte(N)
	x, y := 0, 0

	t := int(b[len(b)-1] - '0')
	x, y = x+t, y+(10-t)

	for i := len(b) - 2; i >= 0; i-- {
		t := int(b[i] - '0')
		x, y = min(x+t, y+(t+1)), min(x+(10-t), y+(10-(t+1)))
	}
	fmt.Println(min(x, y+1))
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}


Measured memory_bytes: 4872
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
int n, k, q, a[maxn], ans = 2e9;
int b[maxn], bcnt, c[maxn], ccnt;

void calc() {
	sort(b + 1, b + bcnt + 1);
	for (int i = 1; i <= bcnt - k + 1; ++i) c[++ccnt] = b[i];
}

void solve(int v) {
	bcnt = ccnt = 0;
	for (int i = 1; i <= n; ++i)
		if (a[i] >= v) b[++bcnt] = a[i];
		else if (bcnt) {
			calc(); bcnt = 0;
		}
	if (bcnt) calc();
	sort(c + 1, c + ccnt + 1);
	if (q <= ccnt) ans = min(ans, c[q] - v);
}

int main() {
	scanf("%d%d%d", &n, &k, &q);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++i)
		solve(a[i]);
	printf("%d", ans);
}


Measured memory_bytes: 384
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

ddict = {}
for di in d:
    if di in ddict:
        ddict[di] += 1
    else:
        ddict[di] = 1

tdict = {}
for ti in t:
    if ti in tdict:
        tdict[ti] += 1
    else:
        tdict[ti] = 1

ans = True
for key, value in tdict.items():
    if key in ddict:
        if value > ddict[key]:
            ans = False
            break
    else:
        ans = False
        break

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

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

#define check cnt=0;for(j=0;j<6;j++)if(d1[j]==d2[j])cnt++;
#define r tmp=d2[1];d2[1]=d2[3];d2[3]=d2[4];d2[4]=d2[2];d2[2]=tmp;
#define y tmp=d2[0];d2[0]=d2[3];d2[3]=d2[5];d2[5]=d2[2];d2[2]=tmp;

int main(){
 int d1[6],d2[6],tmp,cnt,j,a=1;

 for(int i=0;i<6;i++){
  cin >> d1[i] ;
 }
 for(int i=0;i<6;i++){
  cin >> d2[i] ;
 }

 check
   if(cnt==6)a=0;

 while(a){
 for(int i=0;i<5;i++){
  for(int k=0;k<4;k++){
 check
   if(cnt==6)break;
   r
  }
 check
   if(cnt==6)break;
  tmp=d2[0];
  d2[0]=d2[1];
  d2[1]=d2[5];
  d2[5]=d2[4];
  d2[4]=tmp;
 }
 
 check
   if(cnt==6)break;
   y

  for(int k=0;k<4;k++){
 check
   if(cnt==6)break;
   r
  }
 
 check
   if(cnt==6)break;
  y
  y

  for(int k=0;k<4;k++){
 check
   if(cnt==6)break;
   r
  }
 check
   if(cnt==6)break;
   a=0;
 }


 if(cnt==6)cout << "Yes" << endl ;
 else cout << "No" << endl ;

 return 0;
}

Measured memory_bytes: 3084
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  const int N = 2e5 + 42;
  vector<int> f(N);
  for (int i = 1; i < N; ++i) {
    int c = __builtin_popcount(i);
    f[i] = 1 + f[i % c];
  }
  int n; cin >> n;
  string s; cin >> s;
  int c = (int) count(ALL(s), '1');
  vector<int> ans(n);
  if (c < n) {
    int md = c + 1;
    int x = 0;
    for (char ch : s) {
      x *= 2;
      x += ch == '1';
      x %= md;
    }
    vector<int> p2(n);
    p2[0] = 1;
    for (int i = 1; i < n; ++i) {
      p2[i] = p2[i - 1] * 2 % md;
    }
    for (int i = 0; i < n; ++i) {
      if (s[i] == '0') {
        int v = (x + p2[n - i - 1]) % md;
        ans[i] = f[v] + 1;
      }
    }
  }
  if (c > 1) {
    int md = c - 1;
    int x = 0;
    for (char ch : s) {
      x *= 2;
      x += ch == '1';
      x %= md;
    }
    vector<int> p2(n);
    p2[0] = 1;
    for (int i = 1; i < n; ++i) {
      p2[i] = p2[i - 1] * 2 % md;
    }
    for (int i = 0; i < n; ++i) {
      if (s[i] == '1') {
        int v = (md + x - p2[n - i - 1]) % md;
        ans[i] = f[v] + 1;
      }
    }
  }
  for (int x : ans) {
    cout << x << '\n';
  }
}


Measured memory_bytes: 5972
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int mini=10,A[5],ans;

int main(){
    rep(i,5){
        cin>>A[i];
        if(A[i]%10!=0){
            mini=min(mini,A[i]%10);
            A[i]=(A[i]/10)*10+10;
        }
        ans+=A[i];
    }
    out(ans+mini-10);
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin>>a>>b>>c;
	if(a>b) swap(a, b);
	if(b>c) swap(b, c);
	if(a>b) swap(a, b);
	cout<<a<<' '<<b<<' '<<c<<'\n';
	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include<unordered_map>
#define ll long long
using namespace std;
#define sd(n) scanf("%d",&n)
#define clr(a) memset(a,0,sizeof(a))
int h[15];
int main(){
	int a;int t=3;
	while(t--){
cin>>a;
h[a]++;}
	if(h[5]==2&&h[7]==1){
		cout<<"YES";
	}
	else cout<<"NO";
}

Measured memory_bytes: 256
// finish date: 2018/07/20
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

vi fact;

//足し算
int add(int a, int b) {
    return (int) (((ll) a + b + bigmod) % bigmod);
}

//引き算
int sub(int a, int b) {
    return (int) (((ll) a - b + bigmod) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}


//割り算  -  逆元(求めたい数とbigmodを渡す)
int divide(int a, int p = bigmod, int b = -1) {
    if (b < 0) b = p - 2;  //int gyakugen(int a, int p, int b = p - 2とできなかったため。)
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        int d = divide(a, p, b / 2);
        return mul(d, d);
    } else {
        return mul(a, divide(a, p, b - 1));
    }
}

int frac(int a, int b) {
    return mul(a, divide(b));
}

int nCk_gyakugen(int n, int k, int p = bigmod) {
    if (k == 0) return 1;
    if (n == 0) 0;
    if (n < k) return 0;
    int denominator = fact[n];
    int molecule1 = fact[k];
    int molecule2 = fact[n - k];
    return mul(denominator, mul(divide(molecule1), divide(molecule2)));
}

int main() {
    int N;
    cin >> N;
//    if(N == 2){
//        cout<<1<<endl;
//    }
    fact = vi(N);
    fact[0] = 1;
    FOR(i, 1, N) fact[i] = mul(fact[i - 1], i);
    vi A(N + 1, 0);
    int ans = 0;
    FOR(k, 1, N) {
        if (k - 1 < N - 1 - k) continue;
        A[k] = mul(nCk_gyakugen(k - 1, N - 1 - k), mul(fact[k], fact[N - 1 - k]));
        ans = add(ans, mul(sub(A[k], A[k- 1]), k));
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 8064
#include <stdio.h>

int count(int n);

int main()
{
	int n;
	while (scanf("%d", &n) != -1) {
		int cnt;
		cnt = count(n);
		printf("%d\n", cnt);
	}
	return 0;
};

int count(int n)
{
	int a, b, c, d;
	int cnt;
	cnt = 0;
	for (a = 0; a < 10; a++) {
		for (b = 0; b < 10; b++) {
			for (c = 0; c < 10; c++) {
				for (d = 0; d < 10; d++) {
					if (a+b+c+d == n) {
						cnt++;
					}
				}
			}
		}
	}
	return cnt;
}

Measured memory_bytes: 596
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int n, q;
		while (true) {
			n = sc.nextInt(); q = sc.nextInt();
			if (n == 0 && q == 0) break;
			String[] era = new String[n];
			int[] erabase = new int[n];
			int[] westy = new int[n];
			for (int i = 0; i < n; i++) {
				era[i] = sc.next();
				erabase[i] = sc.nextInt();
				westy[i] = sc.nextInt();
			}
			I:for (int i = 0; i < q; i++) {
				int query = sc.nextInt();
				for (int j = 0; j < n; j++) {
					if (westy[j]-erabase[j] < query && query <= westy[j]) {
						out.printf("%s %d\n", era[j], query-westy[j]+erabase[j]);
						continue I;
					}
				}
				out.println("Unknown");
			}
			
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

int main() {
    string s; cin >> s;
    int n = s.size();
    if (s.size() < 3) {
        cout << 0 << endl;
        return 0;
    }
    ll num_contiguous_a = 0;
    ll num_op = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'A') {
            num_contiguous_a++;
        } else if (s[i] == 'B'){
            if (i + 1 < n && s[i+1] == 'C') {
                num_op += num_contiguous_a;
                ++i;
            } else {
                num_contiguous_a = 0;
            }
        } else {
            num_contiguous_a = 0;
        }
    }
    cout << num_op << endl;
    return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int div(int x){
int ans=0;
for (int i=1;i<=x;++i) if (x%i==0) ++ans;
return ans;
}

int main(){
int ans=0,n=read(),i;
for (i=1;i<=n;++i) if (i&1&&div(i)==8) ++ans;
write(ans);
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = [inpl() for i in range(n)]
a.sort()
print(sum(a[-1]))

Measured memory_bytes: 57052
#include<bits/stdc++.h>
using namespace std;
int n,m;const int N = 2010;
typedef pair<int,int> pii;
int par[N][N],id[N][N];
int ans;
vector<int> vec[N];
inline void dfs(int x,int pre,int rt){
	// cout << x << " " << rt << " " << pre << endl;
	par[rt][x] = pre;
	for(size_t i=0;i<vec[x].size();i++){
		int v=vec[x][i];
		// cout << x << " " << i << "to" << v << endl;
		if(v!=pre)dfs(v,x,rt);
	}
}

inline void adde(int a,int b){
	// cout << a << " " << b << endl;
	if(id[a][b]==b&&id[b][a]==a)return ;
	if(id[a][b]!=-1) adde(id[a][b],b);
	else if(id[b][a]!=-1) adde(id[b][a],a);
	else {
		// cout << a << " " << b << endl;
		id[a][b] = b;
		id[b][a] = a;
		vector<pii> nxt;
		queue<int> q;
		q.push(b);
		while(q.size()){
			int u=q.front();q.pop();
			// cout << u << "A" << endl;
			for(size_t i=0;i<vec[u].size();i++){
				int v=vec[u][i];
				if(v!=par[a][u]){
					if(id[a][v]!=-1)nxt.push_back(pii(v,b));
					else{
						id[a][v] = b;
						q.push(v);
					}
				}
			}
		}
		q.push(a);
		while(q.size()){
			int u=q.front();q.pop();
			// cout << u << "B" << endl;
			for(size_t i=0;i<vec[u].size();i++){
				int v=vec[u][i];
				if(v!=par[b][u]){
					if(id[b][v]!=-1)nxt.push_back(pii(v,a));
					else{
						id[b][v] = a;
						q.push(v);
					}
				}
			}
		}
		for(size_t i=0;i<nxt.size();i++)adde(nxt[i].first, nxt[i].second);
	}
}
inline void dfs2(int x,int pre,int b){
	if(id[b][x] == x){
		ans++;
		b=x;
	}
	for(size_t i=0;i<vec[x].size();i++){
		int v=vec[x][i];
		if(v!=pre)dfs2(v,x,b);
	}
}

int main()
{
	cin >> n >> m;
	for(int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	memset(id,-1,sizeof(id));
	// cout << "read" << endl;
	for(int i=1;i<=n;i++)dfs(i,0,i);
	// cout << "?" << endl;
	for(int i=1;i<=m;i++){
		int a,b;scanf("%d%d",&a,&b);
		adde(a,b);
	}
	ans = 0;
	for(int i=1;i<=n;i++){
		for(size_t j=0;j<vec[i].size();j++){
			int v = vec[i][j];
			dfs2(v,i,i);
		}
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 32384
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<limits.h>
using namespace std;
typedef pair<int,int> P;
int n,x,y;
vector<P > tree[100001];
int color[100001],dis[100001];
int ans=INT_MIN;
void dfs(int u,int par,int edge){
    dis[u]=dis[par]+edge;
    if(dis[u]>ans){
        x=u;
        ans=dis[u];
    }
    for(int i=0;i<tree[u].size();++i){
        int v=tree[u][i].first;
        int w=tree[u][i].second;
        if(!color[v]){
            color[v]=1;
            dfs(v,u,w);
        }
    }
}
void solve(){
    dfs(0,0,0);
    color[0]=1;
    fill(color,color+n,0);
    fill(dis,dis+n,0);
    ans=INT_MIN;
    color[x]=1;
    dfs(x,x,0);
    printf("%d\n",ans);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<n;++i){
        int u,v,w;
        scanf("%d %d %d",&u,&v,&w);
        tree[u].push_back(make_pair(v,w));
        tree[v].push_back(make_pair(u,w));
    }
    solve();
    return 0;
}



Measured memory_bytes: 14120
#include<iostream>
using namespace std;
int main(){
	int n=0;
	string s;
	cin>>n;
	cin>>s;
	char stock[100];
	int right=0;
	int left=0;
	int num=0;
	for(int i=0;i<n;i++){
		stock[num]=s[i];
		if(s[i]=='('){
			left++;
		}
		if(s[i]==')'){
			right++;
			if(num>=1){
				if(stock[num]!=stock[num-1]){
					right--;
					left--;
					num-=2;
				}
			}
		}
		num++;
	}
	for(int i=0;i<right;i++){
		cout<<'(';
	}
	cout<<s;
	for(int i=0;i<left;i++){
		cout<<')';
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	
	int x,y,n;
	while(1){
		scanf("%d %d",&x,&y);
		if(x>y){
			n=x;
			x=y;
			y=n;
		}
		if(x==0&&y==0){
			break;
		}
		printf("%d %d\n",x,y);
	}
	
	
	
	return 0;
}



Measured memory_bytes: 2044
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

#define bit(n,m)((n>>m)&1)
ll n;
ll ans;
char s[99];
int main(){
	scanf("%s",s);
	n=strlen(s);
	rep(i,0,1<<(n-1)){
		ll ss=0;
		ll temp=s[0]-48;
		rep(j,0,n-1){
			if(bit(i,j))temp=temp*10+s[j+1]-48;
			else {
				ss+=temp;
				temp=s[j+1]-48;
			}
		}
		ss+=temp;
		ans+=ss;
	}
	
	printf("%lld\n",ans);
	
}

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

using namespace std;

#define ll long long
#define ld long double

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

signed main() {
    string s, t;
    cin >> s >> t;
    vector <vector <ll>> ids(s.size());
    for(int i = 0; i < s.size(); ++i) {
        ids[i].resize('z' - 'a' + 1);
        for(int j = 0; j < ids[i].size(); ++j) {
            ids[i][j] = -1;
        }
    }
    ll n = s.size();
    for(int i = n - 1; i >= 0; --i) {
        if(i != n - 1) {
            ids[i] = ids[i + 1];
        }
        ids[i][s[i] - 'a'] = i;
    }
    ll ans = 0;
    ll now = 0;
    for(int i = 0; i < t.size(); ++i) {
        if(ids[0][t[i] - 'a'] == -1) {
            cout << -1;
            return 0;
        }
        if(ids[now][t[i] - 'a'] == -1) {
            ans += n - now;
            now = 0;
        }
        ans += ids[now][t[i] - 'a'] - now + 1;
        now = (ids[now][t[i] - 'a'] + 1) % n;
    }
    cout << ans;
}


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

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans = a/__gcd(a,b)*b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=input()
n=int(n)
nf= n%10
ns =  (n-nf)%100
nt = n-nf-ns

if nf==1 :
    nf=9
elif nf==9:
    nf=1


if ns==10 :
    ns=90
elif ns==90:
    ns=10


if nt==100:
    nt=900
elif nt==900:
    nt=100
    
n=nf+ns+nt


print(n)

Measured memory_bytes: 3060
s = input()
n = len(s)

ans = None
for i in range(n-1):
	if s[i] == s[i+1]:
		print(i+1,i+2)
		ans = 1
		break
if ans == None:
	for i in range(n-2):
		if s[i] == s[i+2]:
			print(i+1,i+3)
			ans = 1
			break

if ans == None:
	print(-1,-1)

Measured memory_bytes: 39408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class252
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int e = 0;
            int sum = 0;
            int last = 0;
            while (sum < N)
            {
                last++;
                sum += last;
            }
            e = sum - N;
            for(int i = 1; i <= last; i++)
            {
                if (i != e) Console.WriteLine(i);
            }
        }
    }
}


Measured memory_bytes: 13140
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	string ans = "Balanced";
	if(a + b > c + d)ans = "Left";
	else if(a + b < c + d)ans = "Right";
	prints(ans);
	
	Please AC;
}


Measured memory_bytes: 888
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	string s;
	cin >> s;
	if (s.length() % 2 == 0) {
		s.pop_back();
	}
	for (long long i = s.length() - 1; i >= 0; i -= 2) {
		long long ok = 1;
		for (int q = 0; q < i / 2; ++q) {
			if (s[q] != s[q + i / 2]) {
				ok = 0;
				break;
			}
		}
		if (ok == 1) {
			cout << i / 2*2 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;




int main()
{

  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>=22 )cout<<"bust";
  else cout<<"win";

  return 0 ;
}


Measured memory_bytes: 256
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a>b) { return a; }return b; }
int Min(int a, int b) { if (a<b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }




int main() {
	char S[101];
	scanf("%s", &S);

	printf("%c%d%c\n", S[0],strlen(S)-2,S[strlen(S)-1]);




#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> m = new HashMap();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (m.get(s) != null) m.replace(s, m.get(s) + 1);
            else m.put(s, 1);
        }
        int max = 0;
        for (Integer val : m.values()) max = Math.max(max, val);
        ArrayList<String> al = new ArrayList();
        for (Map.Entry<String, Integer> e : m.entrySet()) {
            if (e.getValue() == max) al.add(e.getKey()); 
        }
        Collections.sort(al);
        for (String s : al) System.out.println(s);
    }
}

Measured memory_bytes: 83852
//
//  abc170_b.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;
ll INF = 1000000000000000000;
#define PI 3.14159265

ll limitpow (int x, int n) {
  if (n==0) return 1;
  ll u = limitpow(x, n/2);
  if (u > 1000000000 || u < 0) return -1;
  u = (u*u);
  if (u > 1000000000 || u < 0) return -1;
  if (n%2==1) u = (u*x);
  if (u > 1000000000 || u < 0) return -1;
  return u;
}

int main() {
  int x, y;
  cin >> x >> y;
  // if (y%2==1 || y/2 < x || y/4 > x) {
  //   cout << "No" << endl;
  // }
  // else {
  //   cout << "Yes" << endl;
  // }

  for (int i = 0; i <= x; i++) {
    if ((i*2 + (x-i)*4) == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632