akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Map<String, Integer> map = new HashMap<>();
        int max = 0;
        for(int i = 0; i < N; i++) {
            String key = scanner.next();
            if(map.containsKey(key)) {
                map.put(key, map.get(key) + 1);
                max = Math.max(max, map.get(key));
            }else{
                map.put(key, 1);
                max = Math.max(max, 1);
            }
        }

        List<String> listOfCountryNames = new ArrayList<>();
        for (String key : map.keySet()) {
            if(map.get(key) == max) {
                listOfCountryNames.add(key);
            }
        }

        java.util.Collections.sort(listOfCountryNames);

        for (String name : listOfCountryNames) {
            System.out.println(name);
        }

    }
}


Measured memory_bytes: 82340
#include <bits/stdc++.h>
using namespace std;
int main () {
    int ans = INT_MAX;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        int k = 0;
        while (a % 2 == 0) {
            a /= 2;
            k++;
        }
        ans = min(ans, k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = gets.to_i
Fs = N.times.inject([]){|ary, i| ary << gets.split.map(&:to_i)}
Ps = readlines.map{|l| l.split.map(&:to_i)}

require 'matrix'
f = Matrix[*Fs]
j = Matrix[*(1 ... 2**10).map{|i| ("%010b" % i).split(//).map(&:to_i)}.transpose]
puts (f * j).transpose.to_a.map{|a| (0 ... N).inject(0){|s, i| s + Ps[i][a[i]]}}.max

Measured memory_bytes: 4476
use proconio::*;

#[fastout]
fn main() {
    input! {
        n: usize,
    };
    let mut ans = [0; 10001];

    for x in 1..=100 {
        for y in x..=100 {
            for z in y..=100 {
                let t = x * x + y * y + z * z + x * y + y * z + x * z;
                if t <= n {
                    ans[t] += if x == y && y == z {
                        1
                    } else if x == y || y == z || x == z {
                        3
                    } else {
                        6
                    };
                }
            }
        }
    }

    for a in &ans[1..=n] {
        println!("{}", a);
    }
}


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

#define MAXN (100010)

char str[MAXN];

int main(){
	scanf("%s", str);
	int n = strlen(str);
	int cnt = 0, ans = 0;
	for(int i = 0; i < n; ++ i){
		if(cnt){
			cnt --;
			ans += str[i] == 'g';
		}
		else{
			cnt ++;
			ans -= str[i] == 'p';
		}
	}
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	long long A=n%(a+b),B=n/(a+b);
	if(A==0)
	{
		cout<<B*a;
	
	}
	else if(A>=a)
	{
		cout<<B*a+a;
	
	}
	else if (A<a)
	{
		cout<<B*a+A;
		return 0;
	}
 } 

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

int main(){
  const int N= 3;
  vector<string> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }
  
  bool is_satisfied= true;
  for(int i=1; i<N; i++){
    if(data.at(i-1).back()!=data.at(i).at(0)){
      is_satisfied= false;
      break;
    }
  }

  string ans= (is_satisfied) ? "YES"
                             : "NO";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    if(N%2 == 0){
        if(N/2 >= K) cout << "YES" << endl;
        else cout << "NO" << endl;
    }else{
        if((N+1)/2 >= K) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> 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(int i=0;i<x;i++)
#define repn(i,x) for(int 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())
int n,q;
vector<int>edge[100005];
int a[100005];
int lb[100005],ub[100005],cnt[100005],num[100005],u[100005],v[100005];
int up[100005][20],dep[100005];
void dfs(int v,int u){
	up[v][0] = u;
	if(u == -1) dep[v] = 0; else dep[v] = dep[u]+1;
	rep(i,edge[v].size()) if(edge[v][i]!=u) dfs(edge[v][i],v);
}
int lca(int a,int b){
	if(dep[a] > dep[b]) swap(a,b);
	for(int i=19;i>=0;i--) if(dep[b]-dep[a] >= (1<<i)) b = up[b][i];
	if(a == b) return a;
	for(int i=19;i>=0;i--) if(up[b][i] != up[a][i]) { a = up[a][i]; b = up[b][i]; }
	return up[a][0];
}
vector<P>query[100005];
vector<int>qquery[100005];
struct s{
	int v[(1<<17)];
	int f(int x){ return x&-x;}
	void init(){ memset(v,0,sizeof(v)); }
	void update(int a,int x){
	    a++;
	    for(;a<(1<<17);a+=f(a)) v[a] += x;
	}
	int query(int a){
	    a++; int ret = 0;
	    for(;a>0;a-=f(a)) ret+=v[a];
	    return ret;
	}
}kaede;
vector<int>za;
void dfs2(int v,int u){
	kaede.update(a[v],1);
	rep(i,query[v].size()){
		int id = query[v][i].fi;
		int coef = query[v][i].sc;
		if(ub[id]-lb[id] <= 1) continue;
		int mid = (lb[id]+ub[id])/2;
		int f = POSU(za,mid); f--;
		cnt[id] += coef * kaede.query(f);
	}
	rep(i,qquery[v].size()){
	    int id = qquery[v][i];
	    if(ub[id]-lb[id] <= 1) continue;
	    int mid = (lb[id]+ub[id])/2;
	    cnt[id] += (za[a[v]] <= mid);
	}
	rep(i,edge[v].size()) if(edge[v][i]!=u) dfs2(edge[v][i],v);
	kaede.update(a[v],-1);
}
int main(){
	scanf("%d%d",&n,&q);
	repn(i,n) {scanf("%d",&a[i]);za.pb(a[i]);}
	SORT(za); ERASE(za);
	repn(i,n) a[i] = POSL(za,a[i]);
	for(int i=1;i<n;i++){
		int a,b; scanf("%d%d",&a,&b);
		edge[a].pb(b);
		edge[b].pb(a);
	}
	rep(i,q){
		scanf("%d%d%d",&u[i],&v[i],&num[i]);
		lb[i] = 0,ub[i] = INF+2;
	}
	dfs(1,-1);
	rep(j,19) repn(i,n) if(up[i][j]==-1) up[i][j+1] = -1; else up[i][j+1] = up[up[i][j]][j];

	rep(i,q){
		int x = lca(u[i],v[i]);
		query[u[i]].pb(mp(i,1));
		query[v[i]].pb(mp(i,1));
		query[x].pb(mp(i,-2));
		qquery[x].pb(i);
	}
	while(1){
		bool upd = 0;
		rep(i,q){
			cnt[i] = 0;
			if(ub[i]-lb[i] > 1) upd = 1;
		}
		if(!upd) break;
		kaede.init();
		dfs2(1,-1);
		rep(i,q){
			if(ub[i]-lb[i] <= 1) continue;
			if(cnt[i] >= num[i]) ub[i] = (lb[i]+ub[i])/2;
			else lb[i] = (lb[i]+ub[i])/2;
		}
	}
	rep(i,q) printf("%d\n",ub[i]);
}


Measured memory_bytes: 37732
s=input()
k=int(input())
ans=0
if len(set(list(s)))==1:
  ans=(k*len(s))//2
  print(ans)
  exit()
x=0
y=0
t=s*2
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    x+=1
    s=s[:i+1]+'0'+s[i+2:]
for i in range(len(t)-1):
  if t[i]==t[i+1]:
    y+=1
    t=t[:i+1]+'0'+t[i+2:]   
ans=x+(k-1)*(y-x)
print(ans)

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

int main()
{
  while (true)
  {
    string class_name;
    int am_num, pm_num;
    cin >> class_name >> am_num >> pm_num;
    if ( cin.eof() ) break;
    cout << class_name << ' '<< am_num+pm_num  << ' ' << 200*am_num + 300*pm_num << endl;
  }
}

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

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

    string s,t;
    int a,b;
    string u;

    cin >> s >> t >> a >> b >> u;

    if(u == s) cout << a - 1 << " " << b << endl;
    else if(u == t) cout << a << " " << b - 1 << endl;
}



Measured memory_bytes: 256
s = gets.chomp.reverse
l = s.length
t = %w(eraser dreamer dream erase).map(&:reverse)
u = ""
now = ""
l.times do |i|
  now += s[i]
  t.each do |tt|
    if now == tt
      u += tt
      now = ""
    end
  end
end
puts u == s ? "YES" : "NO"


Measured memory_bytes: 72720
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();

		Set<Long> set = new HashSet<>();
		List<Long> list = divList(n);
		for (long k : list) {
			if (k == 1) {
				continue;
			}
			long x = n;
			while (true) {
				if (x % k == 0) {
					x /= k;
				} else {
					break;
				}
			}
			x--;
			if (x % k == 0) {
				set.add(k);
			}
		}
		list = divList(n - 1);
		set.addAll(list);
		System.out.println(set.size() - 1);
	}

	static List<Long> divList(long n) {
		List<Long> list = new ArrayList<>();
		long end = (long) Math.sqrt(n);
		for (int i = 1; i <= end; i++) {
			if (n % i == 0) {
				list.add((long) i);
			}
		}
		int i = end * end == n ? list.size() - 2 : list.size() - 1;
		for ( ; i >= 0; i--) {
			list.add(n / list.get(i));
		}
		return list;
	}
}


Measured memory_bytes: 24020
program range_set
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: n, a, b, i, j
  integer(8) :: x = 1, f(0:5000, 2) = 0, g(0:5000, 2) = 0
  read(*,*) n, a, b
  if (a > b) then
    i = a
    a = b
    b = i
  end if
  g(1, 2) = 1
  do i = 2, b - 1
    g(i, 2) = mod(g(i - 1, 1) + g(i - 1, 2), modu)
    do j = a, i - 1
      g(i, 1) = g(i, 1) + g(i - j, 2)
    end do
    g(i, 1) = mod(g(i, 1), modu)
  end do
  f(0, :) = 1
  do i = 1, n
    x = mod(x * 2, modu)
    do j = 1, min(a - 1, i)
      f(i, 1) = f(i, 1) + f(i - j, 2)
    end do
    f(i, 1) = mod(f(i, 1), modu)
    do j = 1, min(b - 1, i)
      if (i == n) f(i, 1) = mod(f(i, 1) + f(i - j, 1) * g(j, 1), modu)
      f(i, 2) = f(i, 2) + merge(g(j, 1) + g(j, 2), mod(f(i - j, 1) * g(j, 2), modu), j == i)
    end do
    f(i, 2) = mod(f(i, 2), modu)
  end do
  write(*,'(i0)') modulo(x - f(n, 1) - f(n, 2), modu)
end program range_set

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

int main()
{
    int n, a[200], b[200], result = 0;
    scanf("%d", &n);
    a[0] = 10000000;
    for (int i = 0; i < n - 1; i++)
    {
        scanf("%d", &b[i]);
        a[i + 1] = b[i];
        a[i] = min(a[i], b[i]);
        result += a[i];
    }
    a[n - 1] = b[n - 2];
    result += a[n - 1];
    printf("%d\n", result);
}


Measured memory_bytes: 256
s = input()
l = len(s)

def f(s):
    if s == s[::-1]:
        return True
    return False


txt = 'No'
n1 = (l - 1) // 2
n2 = (l + 3) // 2


if f(s) and f(s[:n1]) and f(s[n2 - 1:]):
    txt = 'Yes'

print(txt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    int N=s.size();

    REP(S,1<<(N-1)){
        int sum=s[0]-'0';
        string ans; ans+=s[0];
        REP(i,N-1){
            if(S>>i&1){
                sum+=s[i+1]-'0';
                ans+='+'; ans+=s[i+1];
            }
            else{
                sum-=s[i+1]-'0';
                ans+='-'; ans+=s[i+1];
            }
        }
        if(sum==7){
            ans+="=7";
            cout<<ans<<endl;
            return 0;
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  if(n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  vector<char> s(n);
  rep(i, n) cin >> s.at(i);
  rep(i, n / 2) {
    if (s.at(i) != s.at(i + n / 2)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

vector<vector<int> > edges;
bitset<100> used;

int solve(int pos)
{
    used[pos] = true;

    int ret = 1;
    for(unsigned i=0; i<edges[pos].size(); ++i){
        int next = edges[pos][i];
        if(!used[next])
            ret = max(ret, 1 + solve(next));
    }

    used[pos] = false;
    return ret;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        edges.assign(100, vector<int>(0));
        for(int i=0; i<n; ++i){
            int a, b;
            cin >> a >> b;
            edges[a-1].push_back(b-1);
            edges[b-1].push_back(a-1);
        }

        int ret = 0;
        for(int i=0; i<100; ++i)
            ret = max(ret, solve(i));
        cout << ret << endl;
    }
}

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

using namespace std;

#define INF 1001000100010001000
#define INFd 1010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define double long double
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define vd vector<double>
#define vvd vector<vd>

 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign


void mmprint(int a)
{
    string st;
    if (!a) cout << 0 << " ";
    else {
        while (a) {
            st.pb((a&1)+'0');
            a >>= 1;
        }
        reverse(all(st));
        cout << st << " ";
    }
}
 
signed main()
{
    double len;
    char t;
    while (scanf("%Lf", &len) != EOF) {
        vi cake;
        while (scanf("%c", &t), t != '\n') {
            Int(tmp);
            cake.pb(tmp);
        }
        if (!cake.size()) {
            cout << "OK" << endl;
            continue;
        }
        vvd dp(1 << cake.size(), vd(cake.size(), INFd));
        dp[0][0] = 0.0;
 
        
        rep(i, cake.size()) {
            int tmp = 1 << i;
            dp[tmp][i] = cake[i];
        }
        
        rep(i, 1 << cake.size()) {
           // mmprint(i);
            rep(j, cake.size()) {
                if (i & (1 << j)) {
                    //cout << "sento:" << j << " ";
                    rep(k, cake.size()) {
                        if (!(i & (1 << k))) {
                            //cout << "tsuika" << k << " ";
                            //cout << "tsuikasaki" << (i|(1 << k)) << " ";
                            dp[i|(1 << k)][k] = min(dp[i|(1 << k)][k],
                                    dp[i][j] + 
        sqrt( (double)((cake[j]+cake[k])*(cake[j]+cake[k])-
                (cake[k]-cake[j])*(cake[k]-cake[j])) ));
                        }
                    }
                }
            }
            //cout << endl;
        }
        rep(i, 1 << cake.size()) {
            //mmprint(i);
            rep(j, cake.size()) {
                //cout << dp[i][j] << " ";
            }
            //cout << endl;
        }
        bool ans = false;
        rep(i, cake.size()) {
            if (len >= dp[(1 << cake.size())-1][i] + (double)cake[i]) {
                ans = true;
                break;
            }
        }
        cout << ( (ans) ? "OK" : "NA" ) << endl;
    }



    return 0;
}

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

public class Main {
    Scanner sc;
    Main() {
        sc = new Scanner(System.in);
    }
    public static void main(String[] args) {
        new Main().run();
    }
    void debug(Object ... o) {
        System.out.println(Arrays.deepToString(o));
    }
    int a, b;
    boolean init() {
        a = sc.nextInt();
        b = sc.nextInt();
        if (a == 0 && b == 0) return false;
        return true;
    }
    ArrayList<Integer> factor(int n) {
        ArrayList<Integer> ret = new ArrayList<Integer>();
        for (int i = 2; i <= n; i++) {
            if (n % i == 0) {
                ret.add(i);
                while (n % i == 0) {
                    n /= i;
                }
            }
        }
        return ret;
    }
    int key(int n) {
        ArrayList<Integer> factors = factor(n);
        int sum = 0;
        for (int f : factors) {
            sum += f;
        }
        int biggest = factors.get(factors.size() - 1);
        sum -= biggest;
        return biggest - sum;
    }
    void run() {
        while (init()) {
            System.out.println(key(a) > key(b) ? "a" : "b");
        }
    }
}

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,i;cin>>n>>i;
  cout<<n-i+1<<endl;
}


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

vector<int>E[100];
bool used[200];
int match[200];

bool dfs(int u) {
	used[u] = true;
	for (int v : E[u]) {
		int w = match[v];
		if (w == -1 || (!used[w] && dfs(w))) {
			match[u] = v; match[v] = u;
			return true;
		}
	}
	return false;
}
int x[100], y[100], z[100], a[100], b[100];
double d[100][100];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n)scanf("%d%d%d", &x[i], &y[i], &z[i]);
		rep(i, m)scanf("%d%d", &a[i], &b[i]);
		rep(i, n)rep(j, m)d[i][j] = hypot(x[i] - a[j], y[i] - b[j]) / z[i];
		double l = 0, r = 15000;
		rep(i, 50) {
			double t = (l + r) / 2;
			rep(j, n) {
				E[j].clear();
				rep(k, m) {
					if (d[j][k] <= t)E[j].push_back(n + k);
				}
			}
			int cnt = 0;
			memset(match, -1, sizeof(match));
			rep(j, n) {
				if (match[j] == -1) {
					memset(used, 0, sizeof(used));
					cnt += dfs(j);
				}
			}
			if (cnt == m)r = t;
			else l = t;
		}
		printf("%.14lf\n", l);
	}
}

Measured memory_bytes: 3384
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <stack>
#include <cctype>
#include <map>
using namespace std;
bool PathernMatch(char *sWildcard, char *sString)
{
	char *s = NULL;
	char *p = NULL;
	bool bStarChar = false;
	bool bBreak = false;
	do{
		bBreak = false;
		for (s = sString, p = sWildcard; *s; ++s, ++p){
			switch (*p){
			case '?':
				break;
			case '*':
				bStarChar = true;
				sString = s;
				sWildcard = p;
				if (!*++sWildcard)
					return true;
				bBreak = true;
				break;
			default:
				if (*s != *p){
					if (!bStarChar)
						return false;
					sString++;
					bBreak = true;
				}
				break;
			}
			if (bBreak)
				break;
		}
		if (bBreak == false){
			if (*p == '*')
				++p;
			return (!*p);
		}
	} while (true);
}
bool IsMatch(string sString1, string sString2, bool lpUseWildcard = false){
	if (!lpUseWildcard)
		return sString1 == sString2;
	else{
		return PathernMatch(const_cast<char*>(sString1.c_str()), const_cast<char*>(sString2.c_str()));
	}
}
int main(){
	ios::sync_with_stdio(false);
	string sTest;
	string sMatch("*C*F*");
	getline(cin, sTest);
	if (IsMatch(sMatch, sTest, true))
		cout << "Yes\n";
	else
		cout << "No\n";
endapp:
	//system("pause > nul");
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

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

int main(){
    int a, b; cin>>a>>b;
    a--, b--;
    char g[100][100];
    for(int i=0; i<100; i++){
        for(int j=0; j<100; j++){
            g[i][j]=(i<50?'#':'.');
        }
    }

    for(int i=0; i<45; i++){
        if(i%2==1 || a==0) continue;
        for(int j=0; j<100; j++){
            if(i%4==0 && j%2==0){
                g[i][j]='.';
                a--;
            }
            else if(i%4==2 && j%2==1){
                g[i][j]='.';
                a--;
            }

            if(a==0) goto END1;
        }
    }
    END1:;

    for(int i=99; i>=55; i--){
        if(i%2==0 || b==0) continue;
        for(int j=0; j<100; j++){
            if(i%4==3 && j%2==0){
                g[i][j]='#';
                b--;
            }
            else if(i%4==1 && j%2==1){
                g[i][j]='#';
                b--;
            }

            if(b==0) goto END2;
        }
    }
    END2:;

    cout << 100 << " " << 100 << endl;
    for(int i=0; i<100; i++){
        for(int j=0; j<100; j++){
            cout << g[i][j];
        }
        cout << endl;
    }
}

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

int N;
vector<pair<int, int>> R;

int main(){
    cin >> N;
    R.resize(N);
    vector<int> x;
    for(int i=0; i<N; i++){
        int X, L;  cin >> X >> L;
        R[i].first = X - L;
        R[i].second = X + L;
    }
    sort(R.begin(), R.end(),[](const pair<int,int> &a, const pair<int,int> &b){
        return a.second < b.second;
    });

    int ans = 0;
    int right = -1e9 - 50;
    for(int i=0; i<N; i++){
        if(right <= R[i].first){
            ans++;
            right = R[i].second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>

int main() {
  std::string S[3];
  std::cin >> S[0] >> S[1] >> S[2];

  for (int i = 0; i < 3; ++i)
    std::reverse(S[i].begin(), S[i].end());

  char t = 'a';
  while (true) {
    if (S[t-'a'].empty())
      return !printf("%c\n", t-'a'+'A');

    char u = S[t-'a'].back();
    S[t-'a'].pop_back();
    t = u;
  }
  return 1;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var pn = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
            var max = 0.0;

            var cumSum = pn.CumulativeSum();

            for (var i = 0; i <= nk[0] - nk[1]; i++)
            {
                var sum = cumSum.ElementAt(i + nk[1]) - cumSum.ElementAt(i);
                if (max < sum) max = sum;
            }
            Console.WriteLine((max + nk[1]) / 2.0);
        }
    }

    public static class LinqExtensions
    {
        public static IEnumerable<double> CumulativeSum(this IEnumerable<double> items)
        {
            if (items.Count() < 1) throw new ArgumentException();
            var list = new List<double>() { 0 };
            for (var i = 0; i < items.Count(); i++)
            {
                list.Add(items.ElementAt(i) + list[i]);
            }
            return list.AsEnumerable();
        }
    }
}


Measured memory_bytes: 34268
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
ll a,b,k;
  cin>>a>>b>>k;
  if(b-a+1 <=k){
    for(ll i=0;i<b-a+1;i++){
      if(i!=b-a)
    cout<<a+i<<endl;
      else
        cout<<a+i;
    }
  }
  else{
  for(ll i=0;i<k;i++){
  cout << a+i<<endl;
  }
    
    ll t=b-k+1;
  if(a+k-1 >= b-k+1){
  t=a+k;
  }
    for(ll i=t;i<=b;i++){
      if(i!=b)
  cout << i<<endl;
      else
        cout<<i;
  }
  }
return 0;

}

Measured memory_bytes: 256
import sys,collections
n = int(sys.stdin.readline())
#A = list(map(int,sys.stdin.readline().split()))
A = list(map(int,sys.stdin.readline().split()))
def CountingSort(A,B,k):
  #print(A)
  C = [0]*(k)
  for j in range(n):
    C[A[j]] += 1
    #print(C)
  for i in range(1,k):
    C[i] = C[i]+C[i-1]
  #print(C)
  for j in range(n)[::-1]:
    B[C[A[j]]-1] = A[j]
    C[A[j]] -= 1
    #print(B,C)
    #print(B)
B = [0]*n
CountingSort(A,B,10000)
print(" ".join(map(str,B)))


Measured memory_bytes: 245128
N,A,B,*v = `dd`.split.map(&:to_i)
v.sort!.reverse!
V = v[0...A].inject(:+).to_f/A
p V
R = v[0...A].count{ |a| a != v[A-1] }
XA = A-R; XB = V == v[A-1] ? B-R : XA
M = v.count(v[A-1])
p (XA..XB).map{ |k| (1..M).inject(:*)/(1..[M-k,1].max).inject(:*)/(1..k).inject(:*) }.inject(:+)


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <functional>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n,k; cin >>n >>k;
	vector<int> x(n);
	cinf(n,x);
	sort(x.begin(),x.end());
	ll ans=1000000000;
	for(int i=0;i<n-k+1;i++){
		ll sum=x[i+k-1]-x[i]+abs(x[i]);
		ll sum1=x[i+k-1]-x[i]+abs(x[i+k-1]);
		ans=min({ans,sum,sum1});
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

vector<int> z(100050);
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x;
	cin >> n >> x;
	stack<int> z;
	int a;
	rep(i,n){
		cin >> a;
		z.emplace(abs(max(a,x) - min(a,x)));
	}
	while(z.size() != 1){
		int c = z.top();
		z.pop();
		int d = z.top();
		z.pop();
		z.emplace(gcd(c,d));
	}
	cout << z.top() << '\n';
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef int ll;

const ll INF = 1 << 28;

int main(void) {
  string S, T;
  cin >> S >> T;
  ll N = S.length(), M = T.length();

  vector<ll> nextS0(N + 1), nextS1(N + 1);
  ll lastS0 = N, lastS1 = N;
  nextS0[N] = nextS1[N] = N;
  for (ll i = N - 1; i >= 0; i--) {
    nextS0[i] = lastS0;
    nextS1[i] = lastS1;
    if (S[i] == '0') lastS0 = i;
    if (S[i] == '1') lastS1 = i;
  }

  vector<ll> nextT0(M + 1), nextT1(M + 1);
  ll lastT0 = M, lastT1 = M;
  nextT0[M] = nextT1[M] = M;
  for (ll i = M - 1; i >= 0; i--) {
    nextT0[i] = lastT0;
    nextT1[i] = lastT1;
    if (T[i] == '0') lastT0 = i;
    if (T[i] == '1') lastT1 = i;
  }

  vector<vector<ll>> dp(N + 1, vector<ll>(M + 1, INF));
  dp[lastS0][lastT0] = 1;
  dp[lastS1][lastT1] = 1;
  REP(i, 0, N + 1) REP(j, 0, M + 1) {
    dp[nextS0[i]][nextT0[j]] = min(dp[nextS0[i]][nextT0[j]], dp[i][j] + 1);
    dp[nextS1[i]][nextT1[j]] = min(dp[nextS1[i]][nextT1[j]], dp[i][j] + 1);
  }

  vector<vector<bool>> ok(N + 1, vector<bool>(M + 1));
  ok[N][M] = true;
  for (ll i = N; i >= 0; i--) for (ll j = M; j >= 0; j--) {
    if (ok[nextS0[i]][nextT0[j]] && dp[i][j] + 1 == dp[nextS0[i]][nextT0[j]]) ok[i][j] = true;
    if (ok[nextS1[i]][nextT1[j]] && dp[i][j] + 1 == dp[nextS1[i]][nextT1[j]]) ok[i][j] = true;
  }

  string ans = "";
  ll i, j;
  if (ok[lastS0][lastT0]) {
    i = lastS0;
    j = lastT0;
    ans += '0';
  } else if (ok[lastS1][lastT1]) {
    i = lastS1;
    j = lastT1;
    ans += '1';
  }
  while (i != N || j != M) {
    if (ok[nextS0[i]][nextT0[j]] && dp[i][j] + 1 == dp[nextS0[i]][nextT0[j]]) {
      i = nextS0[i];
      j = nextT0[j];
      ans += '0';
    } else if (ok[nextS1[i]][nextT1[j]] && dp[i][j] + 1 == dp[nextS1[i]][nextT1[j]]) {
      i = nextS1[i];
      j = nextT1[j];
      ans += '1';
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 67720
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
int main()
{
    string s;
    int sum=0;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='p'){
                sum--;
            }
        }else{
            if(s[i]=='g'){
                sum++;
             //   cout<<"足す"<<endl;
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 512
from itertools import groupby

s1=input()
k=int(input())

s2=[[h, len(list(g))] for h, g in groupby(s1)]

c=0
if len(s2)!=1:
    for i in range(len(s2)):
        if i!=0 and i!=len(s2)-1:
            c+=(s2[i][1]//2)*k

    if s2[0][0]==s2[-1][0]:
        c+=((s2[0][1]+s2[-1][1])//2)*(k-1)
        c+=(s2[0][1]//2+s2[-1][1]//2)
    else:
        c+=(s2[0][1]//2+s2[-1][1]//2)*k
else:
    c+=(s2[0][1]*k)//2

print(c)


Measured memory_bytes: 3064
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
	fast;

	ll n;
	cin>>n;
	ll k=n/500;
	n-=500*k;
	ll p=n/5;
	cout<<1000*k+5*p;
}
//Goodbye...

Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 
#define MAXM 
#define mod
#define inf (1<<30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(register int i = x; i <= y; ++i)
#define repd(i, x, y) for(register int i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".my", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}

int main() {
	int n;
	read(n);
	cout << (n-2) * 180 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    ll ai,ao,at,aj,al,as,az;
    cin>>ai>>ao>>at>>aj>>al>>as>>az;
    
    ll ans1 = ai+aj+al-ai%2-aj%2-al%2;

    ll three = 0;
    ll ans2 = 0;
    if(ai>0&&aj>0&&al>0){
        three = 3;
        ai--;
        aj--;
        al--;
        ans2 = three + ai+aj+al-ai%2-aj%2-al%2; 
    }

    // cout<<ans1+ao<<ans2+ao<<endl;

    cout<< max(ans1,ans2) +ao <<endl;
}

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

const ll MOD = 1e9+7;
ll k;
vector<vector<int>> graph(100001);

template<class T>
T pow(long long a, long long b, T mod){
    if(b == 0) return 1;
    if(b % 2 == 0){
        T d = pow(a,b/2,mod);
        return (d*d)%mod;
    }else return a%mod*pow(a,b-1,mod)%mod;
}

// (k-2)Pn
ll perm_table[100001];
ll perm(ll n){
    if(perm_table[n] != 0) return perm_table[n];
    ll ret = 1LL;
    for(ll i = k-2; i >= (k-n-1); --i) ret = ret*i%MOD;
    return perm_table[n] = ret;
}

vector<bool> visited(100001, false);
ll dfs(int now){
    if(now != 0 && graph[now].size() == 1) return 1LL;
    visited[now] = true;
    ll ret = 1LL;
    if(now == 0) for(ll i = k; i >= k-graph[now].size(); --i) ret = ret*i%MOD;
    else ret *= perm(graph[now].size()-1);
    
    rep(i,graph[now].size()){
        int next = graph[now][i];
        if(visited[next]) continue;
        ret = ret*dfs(next)%MOD;
    }
    return ret;
}

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

    int n; cin >> n >> k;
    int a, b;
    rep(i,n-1){
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    if(n == 1 && k == 1){
        cout << 1 << endl;
        return 0;
    }else if(k == 1){
        cout << 0 << endl;
        return 0;
    }

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

Measured memory_bytes: 9216
let memoize n f =
  let dp = Hashtbl.create n in
  let rec get x =
    try Hashtbl.find dp x with
    | Not_found ->
        let result = f get x in
        Hashtbl.add dp x result;
        result in
  get

let () = Scanf.scanf "%d\n" @@ fun n ->
  let hs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun h -> h in
  let cost = memoize n @@ fun cost -> function
    | 0 -> 0
    | 1 -> abs (hs.(0) - hs.(1))
    | i -> min (abs (hs.(i) - hs.(i - 1)) + cost (i - 1)) (abs (hs.(i) - hs.(i - 2)) + cost (i - 2)) in
  Printf.printf "%d\n" @@ cost (n - 1)



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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N, K, Q;
int val[MAXN];
bool y[MAXN];
int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> K >> Q;
    for(int i=1; i<=Q; i++)
    {
        int x;
        cin >> x;
        x--;
        val[x]++;
    }

    //int ans = 0;
    for(int i=0; i<N; i++)
    {
        bool b = true;
        int a = K - (Q - val[i]);
        //scout << val[i] << " " << a << "\n";
        if(a<=0)
        {
            b = false;
        }

        b ? cout << "Yes\n" : cout << "No\n";
    }

    //cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int a=0,b=0, c=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=b&&b<=c)
	{
		printf("%d %d %d\n",a,b,c );
	}
	else if(a<=c&&c<=b)
	{
		printf("%d %d %d\n",a,c,b );
	}
	else if(b<=c&&c<=a)
	{
		printf("%d %d %d\n",b,c,a );
	}
	else if(b<=a&&a<=c)
	{
		printf("%d %d %d\n",b,a,c );
	}
	else if(c<=b&&b<=a)
	{
		printf("%d %d %d\n",c,b,a );
	}
	else 
	{
		printf("%d %d %d\n", c,a,b);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(6);
  vector<int> cnt(4,0);
  for(int i=0;i<6;i++){
    cin>>a[i];
    cnt[a[i]-1]++;
  }
  sort(cnt.begin(),cnt.end());
  bool flg=true;
  for(int i=0;i<4;i++){
    //printf("%d\n",cnt[i]);
    if(i<2&&cnt[i]!=1){
      flg=false;
    }
    else if(i>=2&&cnt[i]!=2){
      flg=false;
    }
  }
  cout<<(flg?"YES":"NO")<<endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long int a,b,n,i,flag=0;
   cin>>n>>a>>b;
  for(i=a;i<=b;i++)
  {
  	if(i%n==0)
  	{
  		flag=1;
  		break;
	  }
  }
  if(flag==1)
  {
  	cout<<"OK"<<endl;
  }
  else{
  	cout<<"NG"<<endl;
  }
    return 0;

}

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

const long double rate = 380000;

void solve(long long N, std::vector<long double> x, std::vector<std::string> u){
    long double ans = 0.0;
    for(long long i = 0; i < N; ++i){
        if(u[i] == "JPY") ans = ans + x[i];
        else ans = ans + rate * x[i];
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long double> x(N);
    std::vector<std::string> u(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%Lf",&x[i]);
        std::cin >> u[i];
    }
    solve(N, std::move(x), std::move(u));
    return 0;
}

Measured memory_bytes: 256
#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)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int x;
  cin >> x;
  for(int i = x; i < 1000; i++){
    if(i%10 == i/10%10 && i/10%10 == i/100%10){
      cout << i << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 256
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>

using namespace std;


int main(int argc, const char * argv[]) {
    
    int k;
    cin >> k;
    vector<long long> a;
    
    for(int i=1; i<=9; i++) a.push_back(i);
    
    while(1)
    {
        if(k <= a.size())
        {
            cout << a[k-1] << endl;
            return 0;
        }
        
        k -= a.size();
        vector<long long> old;
        swap(old, a);
        
        for(long long x : old)
        {
            for(int i=-1; i<=1; i++)
            {
                int d = x % 10 + i;
                
                if(d < 0 || d > 9) continue;
                
                long long nx = x * 10 + d;
                a.push_back(nx);
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 1712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(ReadLine());
            string o = "";
            switch (x)
            {
                case 7:
                case 5:
                case 3:
                    o = "YES";
                    break;
                default:
                    o = "NO";
                    break;
            }

            WriteLine(o);
        }
    }
}


Measured memory_bytes: 11092
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n;
  cin>>n;
  cout<<n/2*(n-n/2)<<endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    ll k, x;
    cin>>k>>x;
    if(500*k < x){
        print("No");
    }
    else print("Yes");
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
   
}


Measured memory_bytes: 256
from bisect import bisect_left as bl
from bisect import bisect_right as br
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
c.sort()
ans = 0
for i in range(n): ans += bl(a,b[i])*(n-br(c,b[i]))
print(ans)

Measured memory_bytes: 23360
use std::io::stdin;

fn main(){
    let (n, k) = getpair();
    let xs = getvec();
    let mut ys: Vec<usize> = Vec::new();
    for i in xs.iter() {
        if *i < k {
            ys.push(*i);
        }
    }
    ys.sort();
    println!("{}", if ys.len()==0 {0} else {solve(&ys, k, 0, ys.len())});
}

fn solve(xs: &Vec<usize>, k: usize, a: usize, b: usize) -> usize{
    if a==0 && b==1 { if need(xs, 0, k) {0} else {1}}
    else if a+1==b { b }
    else if need(xs, (a+b)/2, k) { solve(xs, k, a, (a+b)/2) }
    else { solve(xs, k, (a+b)/2, b) }
}

fn need(xs: &Vec<usize>, i: usize, k: usize) -> bool {
    let mut dp = vec![false; k*2];
    dp[0] = true;
    for j in 0..xs.len(){
        if i!=j{
            for h in (0..k).rev(){
                if dp[h as usize] {
                    dp[(h+xs[j])]=true;
                }
            }
        }
    }
    dp[k-xs[i]..k].iter().fold(false, |acc, &x|{acc || x})
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec() -> Vec<usize>{
    let line = getline();
    line.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn getpair() -> (usize, usize){
    let nm = getvec();
    (nm[0], nm[1])
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = (ull)1e9 + 7;


struct warshall_floyd {
	static void solve(vector<vector<ll>>& d) {
		int n = d.size();
		rep(k, n) {
			rep(i, n) {
				rep(j, n) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}
};
int main(void)
{
	ll h, w;
	cin >> h >> w;
	vector<string> grid(h);
	rep(i, h) {
		cin >> grid[i];
	}
	const ll INF = 1e15;
	vector<vector<ll>> g(h*w, vector<ll>(h*w,INF));
	rep(i, h) {
		rep(j, w) {
			int id = i * w + j;
			g[id][id] = 0;
			if (i != 0) {
				int d = (i - 1) * w + j;
				if (grid[i][j] == '.' && grid[i - 1][j] == '.') {
					g[id][d] = 1;
					g[d][id] = 1;
				}
			}
			if (i != h - 1) {
				int d = (i + 1) * w + j;
				if (grid[i][j] == '.' && grid[i + 1][j] == '.') {
					g[id][d] = 1;
					g[d][id] = 1;
				}
			}
			if (j != 0) {
				int d = i * w + j-1;
				if (grid[i][j] == '.' && grid[i][j-1] == '.') {
					g[id][d] = 1;
					g[d][id] = 1;
				}
			}
			if (j != w - 1) {
				int d = i * w + j + 1;
				if (grid[i][j] == '.' && grid[i][j + 1] == '.') {
					g[id][d] = 1;
					g[d][id] = 1;
				}
			}
		}
	}
	warshall_floyd::solve(g);
	ll dist = 0;
	rep(i, h) {
		rep(j, w) {
			rep(i2, h) {
				rep(j2, w) {
					int id = i * w + j;
					int id2 = i2 * w + j2;
					if (g[id][id2] != INF) {
						dist = max(dist, g[id][id2]);
					}
				}
			}
		}
	}
	cout << dist << endl;

	return 0;
}


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

void solve(int N, string c) {
    int i = 0, j = N - 1;
    int ans = 0;
    // WR をなくす
    // →左から W を探して、右から R を探して、入れ替える
    while (1) {
        while (i < N - 1 && c[i] == 'R') {
            i++;
        }
        if (i == N - 1) {
            break;
        }
        while (j > 0 && c[j] == 'W') {
            j--;
        }
        if (j == 0) {
            break;
        }
        if (i < j) {
            ans++;
            i++;
            j--;
        } else {
            break;
        }
    }
    cout << ans << endl;
}


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format
    int N;
    cin >> N;
    string c;
    cin >> c;
    solve(N, c);
    return 0;
}


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

#define ll long long
#define ld long double
#define oo 2e18

using namespace std;

const int N = 1e5 + 5;
int n, a, b, c;
vector<char> v;
map<char, int> p;
string s[N];
bool vis[N][2];

bool rec(int indx, bool pre) {
    if (indx == n) {
        if (p['A'] >= 0 && p['B'] >= 0 && p['C'] >= 0) {
            cout << "Yes\n";
            for (auto i : v) {
                cout << i << "\n";
            }
            exit(0);
        }
        return 0;
    }
    bool &re = vis[indx][pre];
    if (re) {
        return 0;
    }
    re = 1;
    if (p[s[indx][0]] > 0) {
        p[s[indx][0]]--;
        p[s[indx][1]]++;
        v.push_back(s[indx][1]);
        rec(indx + 1, 0);
        v.pop_back();
        p[s[indx][0]]++;
        p[s[indx][1]]--;
    }
    if (p[s[indx][1]] > 0) {
        p[s[indx][0]]++;
        p[s[indx][1]]--;
        v.push_back(s[indx][0]);
        rec(indx + 1, 1);
        v.pop_back();
        p[s[indx][0]]--;
        p[s[indx][1]]++;
    }
    return 0;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> a >> b >> c;
    p['A'] = a;
    p['B'] = b;
    p['C'] = c;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    rec(0, 0);
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 14968
#include<stdio.h>
#include<math.h>
int main(){
	int a,b;
	while(scanf("%d",&a),a){
		scanf("%d",&b);double val=0;int num=0;
		for(int i=0;i<a;i++){
			int c,d,e;
			scanf("%d%d%d",&c,&e,&d);
			if(d==1){
				double p=1.0+(double)e/100*b;
				if(p>val){val=p;num=c;}
			}
			if(d==2){
				double p=pow(1.0+(double)e/100,(double)b);
				if(p>val){val=p;num=c;}
			}
		}printf("%d\n",num);
	}
}


Measured memory_bytes: 2892