akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//DEBUG
#define DEBUG false
#define debugf if (DEBUG) printf
//MATH
#define MAXN 200309
#define MAXM 900009
#define ALFA 256
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define EPS 1e−9
#define PI 3.141592653589793238462643383279502884
//LOOP
#define FOR(x,n) 	for(int x =0; (x)<int(n); (x)++)
#define FOR1(x,n) for(int x=1; (x)<=int(n); (x)++)
#define REP(x,n) 	for(int x=int (n)−1; (x) >=0; (x)−−)
#define REP1(x,n) for(int x=(n ); (x) >0; (x)−−)
//DATA STRUCTERES
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mp make_pair
#define sz(x)	int(x.size())
#define all(x) x.begin(), x.end()
#define mset(x, y) memset(&x ,(y), sizeof(x))
//INPUT AND OUTPUT
#define in(x) scanf("%d", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define out(x) printf("%d\n", x)
#define out2(x, y) printf("%d %d\n", x, y)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
typedef vector<int> vi;
typedef pair<int , int> ii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin >> s >>t;
	int n = sz(s);
	int ans = 0;
	for(int i = 0; i<n; i++){
		if(s[i] != t[i])
			ans++;
		}
	cout << ans <<endl;
	
	}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
int main()
{
   int a,b;
   cin>>a>>b;
   if(a%3==0||b%3==0||(a+b)%3==0)
      cout<<"Possible";
   else
      cout<<"Impossible";
    cout<<nl;
    return 0;
}


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

int main(){
    vector<vector<char>> c(3,vector<char>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c.at(i).at(j);
        }
    }
    cout << c.at(0).at(0) << c.at(1).at(1) << c.at(2).at(2) << endl;
    
}

Measured memory_bytes: 256
def koch_curve(z1, z2)
  [(z1*2+z2)/3.0,
   (Math.sqrt(3)/6.0)*(z1-z2)*1i + (z1+z2)/2.0,
   (z1+z2*2)/3.0]
end

def solve(z1, z2, n)
  if n == 0
    puts "#{z1.imag} #{z1.real}"
    return
  end
  new_z1, new_z2, new_z3 = koch_curve(z1, z2)
  solve(z1, new_z1, n-1)
  solve(new_z1, new_z2, n-1)
  solve(new_z2, new_z3, n-1)
  solve(new_z3, z2, n-1)
end

z1 = Complex(0, 0)
z2 = Complex(0, 100)
solve(z1, z2, gets.to_i)
puts "#{z2.imag} #{z2.real}"



Measured memory_bytes: 8956
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ1043
{
    class Program
    {
        private static void Main()
        {
            foreach (var sortedTeams in from teams in ReadInputs()
                                        select
                                            from team in teams
                                            orderby team.Id ascending
                                            orderby team.Penalty ascending
                                            orderby team.Correct descending
                                            select team)
            {
                var picked = new List<Team>();
                foreach (var team in sortedTeams)
                {
                    var sameAffiliation = picked.Count(t => t.Affiliation == team.Affiliation);

                    if (picked.Count < 10)
                    {
                        if (sameAffiliation < 3)
                        {
                            picked.Add(team);
                        }
                    }
                    else if (picked.Count < 20)
                    {
                        if (sameAffiliation < 2)
                        {
                            picked.Add(team);
                        }
                    }
                    else if (picked.Count < 26)
                    {
                        if (sameAffiliation == 0)
                        {
                            picked.Add(team);
                        }
                    }
                }

                foreach (var team in picked)
                {
                    Console.WriteLine(team.Id);
                }
            }
        }

        public static IEnumerable<Team[]> ReadInputs()
        {
            while (true)
            {
                var count = int.Parse(Console.ReadLine() ?? "");
                if (count == 0) yield break;

                var teams = new Team[count];

                for (var i = 0; i < count; i++)
                {
                    var values = (Console.ReadLine() ?? "").Split(' ').Select(int.Parse).ToArray();
                    teams[i] = new Team(values[0], values[1], values[2], values[3]);
                }

                yield return teams;
            }
        }
    }

    public class Team
    {
        public int Id { get; private set; }
        public int Affiliation { get; private set; }
        public int Correct { get; private set; }
        public int Penalty { get; private set; }

        public Team(int id, int affiliation, int correct, int penalty)
        {
            Id = id;
            Affiliation = affiliation;
            Correct = correct;
            Penalty = penalty;
        }
    }
}

Measured memory_bytes: 6660
l=input()
mod=10**9+7

# dp[digit][smaller]
# dp[i][j]
dp = [[0 for _ in range(2)] for _ in range(len(l)+1)]
dp[0][0]=1 # smaller:1==False
for i in range(len(l)):
    dp[i+1][1] += (3*dp[i][1])
    if l[i] == "1":
        dp[i+1][1] += dp[i][0]
        dp[i+1][0] += (2*dp[i][0])
    else:
        dp[i+1][0] += dp[i][0]
    dp[i+1][0] %= mod
    dp[i+1][1] %= mod

ans = dp[-1][0] + dp[-1][1]
print(ans % mod)

Measured memory_bytes: 54108
from fractions import gcd

Q = int(input())
qs = []
for _ in range(Q):
	qs.append(list(map(int, input().split())))

for q in qs:
	a, b, c, d = q[0], q[1], q[2], q[3]
	if a < b or b > d:
		print("No")
	elif b <= c:
		print("Yes")
	elif d % b == 0:
		if a % b > c:
			print("No")
		else:
			print("Yes")
	else:
		a = a % b
		d = d % b
		d = gcd(b, d)
		if a > c:
			print("No")
		elif (a + ((c - a) // d) * d + d) % b <= c:
			print("Yes")
		else:
			print("No")

Measured memory_bytes: 5972
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 100005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define VI vector<int>
#define db double
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
const double EPS = 1e-8;
int sgn(double x){return (x > EPS) - (x < -EPS);}
int hd[N], EN;
struct node{
    int u, v, w, nx;
}E[400100 * 2];
void add_edge(int u, int v, int w){
    E[EN].w = w; E[EN].v = v; E[EN].nx = hd[u]; hd[u] = EN++;
}
int n, m, u, v, w, in[N], f[N];
bool go(){
    queue<int> q;
    FF(i, 1, n) if(in[i] == 0) q.push(i);
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int k = hd[u], v; v = E[k].v, ~k; k = E[k].nx){
            if(f[v] != 0){
                if(f[v] != f[u] + E[k].w) return 0;
            }
            f[v] = f[u] + E[k].w;
            --in[v];
            if(in[v] == 0) q.push(v);
        }
    }
    FF(i, 1, n) if(in[v]) return 0;
    return 1;
}
int main(){
   // IN;
    SCC(n, m);
    EN = 0;
    memset(hd, -1, sizeof hd);
    FF(i, 1, m){
        SCCC(u, v, w);
        ++in[v];
        add_edge(u, v, w);
    }
    puts(go() ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 4864
//https://vjudge.net/contest/365276#problem/A
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 100005;
int a[N], b[N], a1, b1, m;

int main(){
    io;
    //freopen("input.txt", "r", stdin);
    cin >> a1 >> b1 >> m;
    int minA = inf, minB = inf;
    rep(i, 1, a1){
        cin >> a[i];
        minA = min(minA, a[i]);
    }
    rep(i, 1, b1){
        cin >> b[i];
        minB = min(minB, b[i]);
    }
    int minMoney = minA + minB;
    rep(i, 1, m){
        int x, y, c; cin >> x >> y >> c;
        minMoney = min(minMoney, a[x] + b[y] - c);
    }
    cout << minMoney;
    return 0;
}


Measured memory_bytes: 1152
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
vector<string> ans;
ll n;
void dfs(int d, set<int> used, string s){
    if(d == n){
        ans.push_back(s);
        return;
    }
    for(char i = 'a'; i <= 'a' + min(d, (int)used.size()); i++){
        set<int> nused = used;
        
        nused.insert(i);
        
        dfs(d + 1, nused, s + i);
    }
}
int main(void){

    cin >> n;

    string s = "a";
    set<int> used;
    used.insert('a');
    dfs(1, used, s);
    

    sort(all(ans));
    rep(i, ans.size()){
        cout << ans[i] << endl;
    }
} 

Measured memory_bytes: 7796
N = int(input())
ABC = (list(map(int, input().split())) for _ in range(N))

DP = [[0, 0, 0] for _ in range(N)]

for i, abc in enumerate(ABC):
  if i == 0:
    for j in range(3):
      DP[i][j] = abc[j]
  else:
    for j in range(3):
      DP[i][j] = max(DP[i-1][k] + abc[j] for k in range(3) if j != k)

print(max(DP[N-1]))

Measured memory_bytes: 22772
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let a = v[0];
    let b = v[1];
    let c = v[2];

    if b - a == c - b {
        println!("YES");
    } else {
        println!("NO");
    }
}



Measured memory_bytes: 4352
N = int(input())
A = input().split()
A = [int(int(A[int(i)])==int(i)+1) for i in range(N)]
ans=0
for i in range(N-1):
  if A[i] and A[i+1]:
    A[i]=A[i+1]=0
    ans+=1
print(ans+sum(A))

Measured memory_bytes: 10680
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("\\s");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(a<=b&&b<=c){
System.out.println(a+" "+b+" "+c);
}
else if (a<=c&&c<=b){
System.out.println(a+" "+c+" "+b);
}
else if(b<=a&&a<=c){
System.out.println(b+" "+a+" "+c);
}
else if(b<=c&&c<=a){
System.out.println(b+" "+c+" "+a);
}
else if(c<=a&&a<=b){
System.out.println(c+" "+a+" "+b);
}
else if(c<=b&&b<=a){
System.out.println(c+" "+b+" "+a);
}

    }
}


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


int abs(int num);

int main(){
    int N, L;
    cin >> N >> L;

    int taste_sum = 0;
vector<int> apple(N);
    int min_abs = 10000;

    // 食べるリンゴを選ぶ
    for(int i = 1; i <= N; i++){
        int taste = abs(L + i - 1);
        if(taste < min_abs) min_abs = taste;
    }

    // N-1このリンゴの「味」の総和を求める
    for(int i = 1; i <= N; i++){
        if(abs(L + i - 1) == min_abs) continue;
        taste_sum += L + i - 1;
    }

    cout << taste_sum << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#define MAXN 305
#define INF 2000000000
using namespace std;
char star[MAXN][MAXN];
int dp[MAXN][MAXN], x[MAXN], y[MAXN];
int add[MAXN][MAXN];
int n, m, ans;
int dfs(int a, int b)
{
    if(a < 0 || b < 0) return 0;
    if(dp[a][b] != -1) return dp[a][b];
    return dp[a][b] = add[a][b] + min(dfs(a - 1, b), dfs(a, b - 1));
}
int work(int a, int b)
{
    for(int i = 0; i < n; i++) x[i] = star[i][a] - 'a';
    for(int i = 0; i < n; i++) y[i] = star[i][b] - 'a';
    memset(dp, -1, sizeof(dp));
    memset(add, 0, sizeof(add));
    for(int i = 0; i < n; i++)
    {
        int res = 0;
        for(int j = n - 1, k = n - 1 - i; j >= 0 && k >= 0; j--, k--)
        {
            if(x[j] == y[k]) res++;
        }
        for(int j = n - 1, k = n - 1 - i; j >= 0 && k >= 0; j--, k--)
        {
            add[j][k] = res;
            if(x[j] == y[k]) res--;
        }
    }
    for(int i = 0; i < n; i++)
    {
        int res = 0;
        for(int j = n - 1 - i, k = n - 1; j >= 0 && k >= 0; j--, k--)
        {
            if(x[j] == y[k]) res++;
        }
        for(int j = n - 1 - i, k = n - 1; j >= 0 && k >= 0; j--, k--)
        {
            add[j][k] = res;
            if(x[j] == y[k]) res--;
        }
    }
    return dfs(n - 1, n - 1);
}
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++) scanf("%s", star[i]);
    ans = 0;
    for(int i = 1; i < m; i++) ans += work(i - 1, i);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1152
/// referenced: https://beta.atcoder.jp/contests/abc066/submissions/2252964
#include <bits/stdc++.h>
using namespace std;

constexpr int64_t MOD = 1000000007;

int64_t Power(int64_t base, int64_t exp) {
  int64_t x = 1;
  while (exp) {
    if (exp % 2) {
      x = x * base % MOD;
    }
    base = base * base % MOD;
    exp /= 2;
  }
  return x;
}

int64_t Inv(int64_t x) {
  return Power(x, MOD - 2);
}

int64_t Factorial[100002],InvFact[100002];

int64_t C(int64_t n,int64_t r){
  return Factorial[n]*InvFact[r]%MOD*InvFact[n-r]%MOD;
}

int main(){
  int64_t n,a;
  bool c[100002];
  cin >> n;
  for(int64_t i=1;i<=n;i++) c[i]=false;
  int64_t p[100002];
  int64_t x,y;

  for(int64_t i=0;i<=n;i++){
    cin >> a;
    if(c[a]){
      x=p[a];
      y=i;
    }
    c[a]=true;
    p[a]=i;
  }


  Factorial[0]=1;
  for(int64_t i=1;i<=n+1;i++) Factorial[i]=i*Factorial[i-1]%MOD;
  for(int64_t i=0;i<=n+1;i++) InvFact[i]=Inv(Factorial[i]);

  for(int64_t i=1;i<=n+1;i++){
    int64_t ans;
    ans=C(n+1,i);
    if(i-1<=n-(y-x)) ans+=MOD-C(n-(y-x),i-1);
    cout << (ans%MOD) << endl;
  }

  return 0;
}


Measured memory_bytes: 3584
n = int(input())
a = list(map(int, input().split()))
if n == 0 and a[0] != 1:
    print(-1)
    exit(0)
b = [0] * (n + 2)
for i in range(n, 0, -1):
    b[i - 1] = b[i] + a[i]
t = 1 - a[0]
ans = 1
for i in range(n):
    m = min(t * 2, b[i])
    if m < a[i + 1]:
        print(-1)
        exit(0)
    ans += m
    t = m - a[i + 1]
print(ans)


Measured memory_bytes: 20008
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class UnionFind {
    int n;
    vector<int> par, rank;

public:
    UnionFind(int N) : n(N), par(N, -1), rank(N) {}
    int root(int i) {
        if (par[i] < 0) return i;
        return par[i] = root(par[i]);
    }
    bool same(int i, int j) { return root(i) == root(j); }
    void unite(int i, int j) {
        i = root(i);
        j = root(j);
        if (i == j) return;
        if (rank[i] <= rank[j]) {
            par[i] = j;
            if (rank[i] == rank[j]) { rank[j]++; }
        } else {
            par[j] = i;
        }
    }
};

class Main {
    ll N, M;
    vector<ll> A, B;

    void input() {
        cin >> N >> M;
        A.resize(M);
        B.resize(M);
        REP(i, M) { cin >> A[i] >> B[i]; }
    }
    void output() {
        UnionFind ufd(N);
        REP(i, M) { ufd.unite(A[i], B[i]); }
        vector<int> cnt(N);
        REP(i, N) { cnt[ufd.root(i)]++; }
        cout << *max_element(cnt.begin(), cnt.end()) << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 8748
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> cnt(M);
    rep(i, N) {
        int K;
        cin >> K;
        rep(j, K) {
            int A;
            cin >> A;
            A--;
            cnt[A]++;
        }
    }

    int ans = 0;
    rep(i, M) {
        if(cnt[i] == N) {
            ans++;
        }
    } 

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 2147483646;
const double pi = 3.141592653589793;

bool compare(string u, string v) {
  if(u.size() > v.size()) {
    int diff = u.size() - v.size();

    for(int i = 0 ; i < diff; i++) {
      v += 'a';
    } 
  }
  else if(u.size() < v.size()) {
    int diff = v.size() - u.size();

    for(int i = 0 ; i < diff; i++) {
      u += 'a';
    } 
  }
  return u < v;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  int K;
  cin >> K;
  set<string>st;

  for(int i = 0 ; i < s.size() ; i++) {
    string tmp;
    for(int j = i ; j < s.size() ; j++) {
      tmp += s[j];
      if(tmp.size() > K) break;
      st.insert(tmp);
    }
  }

  vector<string> arr;

  for(auto x : st) {
    arr.pb(x);
  } 

  sort(arr.begin(), arr.end(), compare);
  cout << arr[K - 1] << endl;
} 


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

int main() {
	string a, b;
	getline(cin, a);
	getline(cin, b);
	int len_a = (int)a.length(), len_b = (int)b.length();
	if(len_a < len_b)
		cout << "LESS";
	else if(len_a > len_b)
		cout << "GREATER";
	else {
		bool flag = true;
		for(int i = 0; i < len_a; ++i) {
			if(a[i] != b[i]) {
				if(a[i] > b[i]) {
					cout << "GREATER";
					flag = false;
					break;
				}
				else {
					cout << "LESS";
					flag = false;
					break;
				}
			}
		}
		if(flag) {
			cout << "EQUAL";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int ans[n]={},b[m];
	for(int i=0;i<m;i++){
		cin>>b[i];
		b[i]--;
	}
	for(int i=0;i<m;i++){
		int k;
		for(int j=0;j<n;j++){
			cin>>k;
			k--;
			if(k==b[i]){
				ans[j]++;
				//cout<<j<<" "<<ans[j]<<endl;
			}else{
				ans[b[i]]++;
			}
			//cout<<j<<" "<<ans[j]<<endl;
			//cout<<b[i]<<" "<<ans[b[i]]<<endl;
		}
	}
	for(int j=0;j<n;j++){
		cout<<ans[j]<<endl;
	}
}


Measured memory_bytes: 3108
import fractions

def calc_factors(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n /= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n /= f
        else:
            f += 2   
    if n != 1: 
        a.append(n)
    return a

A, B = map(int, input().split())
g = fractions.gcd(A,B)
if g == 1:
    print(1)
else:
    print(len(set(calc_factors(g)))+1)

Measured memory_bytes: 5472
M = int(input())
ans = 0

c1 = []
for _ in range(M):
    d, c = map(int, input().split())
    v1 = ((d*c)//9)-((d*c)%9==0 and d*c>0)
    v2 = c-1
    ans += v1+v2
    c1.append(d*c-9*v1)

ans += M-1
s = sum(c1)
ans += (s//9)-(s%9==0 and s>0)
print(ans)


Measured memory_bytes: 10020
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

ll MOD = 1000000007;
ll lcm(ll a, ll b) { return (a / __gcd(a, b) * b); }

int main() {
  //
  int n;
  cin >> n;
  ll ans = 0;
  ll maxt = 0, maxa = 0;
  rep(i, n) {
    ll t, a;
    cin >> t >> a;
    if (ans == 0) {
      ans = t + a;
      maxt = t;
      maxa = a;
    } else {
      ll d = max(maxt / t + (maxt % t != 0), maxa / a + (maxa % a != 0));
      ans = (t + a) * d;
      maxt = t * d;
      maxa = a * d;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n), f(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> f[i];
	sort(a.begin(), a.end());
	sort(f.rbegin(), f.rend());
	ll l = -1, r = 1e12;
	while (r - l > 1) {
		ll c = (l + r) / 2;
		bool ok = [&] {
			ll s = 0;
			rep(i, n) {
				s += max(0LL, a[i] - c / f[i]);
			}
			return s <= k;
		}();
		if (ok) r = c;
		else l = c;
	}
	printf("%lld\n", r);
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 180 * (n - 2);

        // 出力
        System.out.println(result);
    }
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

int main() {
  ll N;cin>>N;
  map<int,int> mp;
  REP(i,N) {
    int a;cin>>a;
    mp[a]++;
  }
  int ans = 0;
  for (auto m:mp) {
    if (m.second%2==1) ans++;
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // input
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    // output
    vector<ll> B = A;
    sort(B.rbegin(), B.rend());
    ll m = B[0], s = B[1];
    rep(i, N)
    {
        if (A[i] == m) {
            cout << s << endl;
        } else {
            cout << m << endl;
        }
    }
    return 0;
}

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

#define online_judge			freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio					ios::sync_with_stdio(false);cin.tie(0);
#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define vpll                    vector<pll>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(ll i=0; i<n;++i)
#define fr1(i, n)               for(ll i=1; i<=n; ++i)
#define rfr(i, n)                for(ll i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh                        while
#define mp                        make_pair
#define le                        length()


ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

ll lcm(ll a,ll b) 
{ return (a*b)/__gcd(a,b); }

ll power(ll x,ll y,ll p) 
{ ll res=1; x=x%p;
    while(y>0) 
    { if (y&1) res=(res*x)%p; 
      y=y>>1; x=(x*x)%p; } 
    return res; } 
    
bool inside(ll x,ll y,ll n,ll m)
{
    return(x>=0&&x<n&&y>=0&&y<=m);
}   

void solve()
{    
	ll n;
	cin>>n;
	ll p=8;
	ll s=400,e=599;
	wh(1)
	{
		if(n>=s&&n<=e)
		{
			cout<<p<<endl;
			return;
		}
		p--;
		s+=200;
		e+=200;
	}
	
}
	

int main()
{
    fastio
//	int t;
//  	cin>>t;
//	fr1(i,t)
    {
//    	cout<<"Case "<<i<<":"<<endl;
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

i64 N;
int main(){
  cin >> N;
  i64 ans = 1e9;

  for(int i = 1;i < N;i++){
    i64 a = i;
    i64 b = N - i;
    i64 sum = 0;
    while(!(a == 0 && b == 0)){
      sum += (a % 10) + (b % 10);
      a /= 10;
      b /= 10;
    }
    ans = min(sum,ans);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int a,b,c,i;
	scanf("%d%d%d",&a,&b,&c);
	for(i=b;i<=c;i++)
	if(i%a==0) break;
	if(i>c) printf("NG");
	else printf("OK");
}

Measured memory_bytes: 3228
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, M;
	cin >> N;
	M = 1LL << (long long)(log2(N));
	if (N == M) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if (N % 2 == 1) {
		for (int i = 2; i <= N; i += 2) {
			cout << i << " " << i + 1 << endl;
			cout << i + 1 << " " << 1 << endl;
			cout << 1 << " " << i + N << endl;
			cout << i + N << " " << i + 1 + N << endl;
		}
		cout << 1 + N << " " << 2 << endl;
	}
	else {
		cout << N << " " << M + 1 << endl;
		cout << M << " " << M + 1 << endl;
		cout << M + 1 << " " << 1 << endl;
		cout << 1 << " " << M + N << endl;
		cout << N - M + N << " " << N + N << endl;
		cout << N + N << " " << M + 1 + N << endl;
		cout << M + 1 + N << " " << 1 + N << endl;
		for (int i = 2; i <= N - 2; i += 2) {
			if (i == M) continue;
			cout << i << " " << i + 1 << endl;
			cout << i + 1 << " " << 1 << endl;
			cout << 1 << " " << i + N << endl;
			cout << i + N << " " << i + 1 + N << endl;
		}
	}
}

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

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    double bit = 0.0;
    int yen = 0;
    while (n-- > 0) {
      String x = sc.next();
      String u = sc.next();
      if (u.equals("JPY")) yen += Integer.parseInt(x);
      else bit += Double.parseDouble(x);
    }
    System.out.println((double) yen + 380000.0 * bit);
  }
}

Measured memory_bytes: 22740
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=3010;
int n;
LL a[maxn];

int main()
{
    while (scanf("%d",&n)!=EOF)
    {
        LL ans=0;
        for (int i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
            a[i]--;
            ans+=a[i];
        }

        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cstdlib>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 100001
#define PLUS 0
#define MINUS 1

using namespace std;

ll N, T, A;

ll get(ll x)
{
	return T * 1000 - x * 6;
}

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	cin >> N >> T >> A;
	ll ret = 1;
	ll diff = LLONG_MAX;
	for (ll i = 1; i <= N; i++)
	{
		ll h; cin >> h;
		if (abs(1000 * A - get(h)) < diff)
		{
			ret = i;
			diff = abs(1000 * A - get(h));
		}

	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  while(1){
    int a[11][11]={0};
    int tate[11]={0};
    int n,b,c,d,e;
    scanf("%d",&n);
    if(n==0)break;
    for(b=0;b<n;b++){
      for(c=0;c<n;c++){
	scanf("%d",&a[b][c]);
	a[b][n]=a[b][n]+a[b][c];
	tate[c]=tate[c]+a[b][c];
	tate[n]=tate[n]+a[b][c];
      }
    }
    for(b=0;b<n;b++){
      for(c=0;c<n+1;c++){
	if(c==n){
	  printf("%5d\n",a[b][c]);
	}
	else{
	  printf("%5d",a[b][c]);
	}
      }
    }
    for(b=0;b<n+1;b++){
      if(b==n){
	printf("%5d\n",tate[b]);
      }
      else{
	printf("%5d",tate[b]);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 612
def enq(a,x)
  b = a[i=-1]
  until b.frozen?
    return a << x  if x >= (a=b)[-1]
    return a.unshift x  if x <= a[0]
    b = a[i = a.bsearch_index{|y| x < (y.frozen? ? y: y[0])}-1]
  end  if b && b=a
  return a.insert i+1, x  unless a[i+9]
  i>0 ? a[i]=[b,x] : enq(a[i+=1].to_a,x)  rescue a[i]=[x,a[i]]
end
def deq(a) r=a.shift; a.unshift *a.shift if !a[0].frozen?; r end
def poq(a) r=a.pop; a.push *a.pop if !a[-1].frozen?; r end
N,M,*A = $<.read.split.map{|x| -x.to_i}
A.sort!
(-M).times { break if A[0]==0; enq A, -(-(deq A)/2)}
p A.flatten.inject(0,:-)

Measured memory_bytes: 14296
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N = 1e5 + 10;  
ll Lft[3*N], Rit[3*N];
int num[3*N];
int main()  
{  
  //  freopen("in.txt", "r", stdin);
   	int n;
   	while (~scanf("%d", &n))
   	{
   		for (int i = 1; i <= 3*n; i++)
   			scanf("%d", num + i);
   		priority_queue<int, vector<int>, greater<int> >qmin; 
   		priority_queue<int> qmax;
   		ll sum = 0;
   		// qmin.push(num[0]);

   		for (int i = 1; i <= n; i++)
   		{
   			sum += num[i];
   			qmin.push(num[i]);
   		}
   		int m = n<<1;
   		Lft[n] = sum;
   		for (int i = n + 1; i <= m; i++)
   		{
   			if (qmin.top() < num[i])
   			{
   				sum += num[i];
   				sum -= qmin.top();
   				qmin.pop();
   				qmin.push(num[i]);
   			}
   			Lft[i] = sum;
   		}

   		sum = 0;
   		for (int i = 3*n; i >= m + 1; i--)
   		{
   			sum += num[i];
   			qmax.push(num[i]);
   		}
   		Rit[m+1] = sum;
   		for (int i = m; i >= n + 1; i--)
   		{
   			if (num[i] < qmax.top())
   			{
   				sum += num[i];
   				sum -= qmax.top();
   				qmax.pop();
   				qmax.push(num[i]);
   			}	
   			Rit[i] = sum;
   		}
   		ll ans = Lft[n] - Rit[n + 1];
   		for (int i = n; i <= m; i++)
   		{

   			ans = max(Lft[i] - Rit[i+1], ans);
   		}
   		printf("%lld\n", ans);
   	}

   return 0;  
}  

Measured memory_bytes: 5240
import sys
import itertools

N, A = map(int, sys.stdin.readline().split())
x = map(lambda x: int(x) - A, sys.stdin.readline().split())
maxX = max(x) + A
dp = [[0 for _a in xrange(N * maxX * 2 + 1)] for _b in xrange(N + 1)]

for j in xrange(N + 1):
    for k in xrange(N * maxX * 2 + 1):
        if j == 0 and k == N * maxX:
            dp[j][k] = 1
        elif j >= 1 and (k - x[j - 1] < 0 or k - x[j - 1] >= 2 * N * maxX):
            dp[j][k] = dp[j - 1][k]
        elif j >= 1 and 0 <= k - x[j - 1] <= 2 * N * maxX:
            dp[j][k] = dp[j - 1][k] + dp[j - 1][k - x[j - 1]]
        else:
            dp[j][k] = 0

print dp[N][N * maxX] - 1


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

int main() {
    int N, C;

    cin >> N;

    C = N % 10;

    if (C == 2 || C == 4 || C == 5 || C == 7 || C == 9) {
        cout << "hon" << endl;
    } else if (C == 3) {
        cout << "bon" << endl;
    } else {
        cout << "pon" << endl;
    }

    return 0;
}


Measured memory_bytes: 3600
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int A=Integer.parseInt(sc.next());
int B=Integer.parseInt(sc.next());
int C=Integer.parseInt(sc.next());
int K=Integer.parseInt(sc.next());
int temp1,temp2,temp3;
int ans=0;
temp1=A;
temp2=B;
temp3=C;
for(int i=0;i<K;i++){
if((temp1*2+temp2+temp3>=temp1+temp2*2+temp3)&&(temp1*2+temp2+temp3>=temp1+temp2+temp3*2)){
temp1*=2;
}else if((temp1+temp2*2+temp3>=temp1*2+temp2+temp3)&&(temp1+temp2*2+temp3>=temp1+temp2+temp3*2)){
temp2*=2;
}else if((temp1+temp2+temp3*2>=temp1*2+temp2+temp3)&&(temp1+temp2+temp3*2>=temp1+temp2*2+temp3)){
temp3*=2;
}
}
ans=temp1+temp2+temp3;
System.out.println(ans);
}
}

Measured memory_bytes: 20948
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    items = list(map(lambda x: int(x), inputs))
    items.sort()
    price = items.pop() // 2
    for i in items:
        price += i
    return price


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    char c; cin>>c;
    if(c>='a' && c<='z'){
        cout << "a\n";
    }else{
        cout << "A\n";
    }
}

Measured memory_bytes: 3624
#!/usr/bin/env python
import bisect
from collections import defaultdict
import math

def main():
    N, K = map(int, input().split())

    prob = 0
    for n in range(N):
        n += 1
        if n >= K:
            p = 1.0
        else:
            min_val = math.ceil(math.log2(K / n))
            p = 0.5 ** min_val
        prob += p

    print(prob / N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;

public class Main {
	static int[][] field;
	static String[] wall;
	static int[] dx = {1, 0, -1, 0};
	static int[] dy = {0, 1, 0, -1};
	static int w, h;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			w = sc.nextInt();
			h = sc.nextInt();
			if (w == 0) {
				break;
			}
			field = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					field[i][j] = 0;
				}
			}
			field[0][0] = 1;
			
			wall = new String[2*h-1];
			sc.nextLine();
			for (int i = 0; i < 2 * h - 1; i++) {
				wall[i] = sc.nextLine();
			}
			//debug();
			solve();
		}
	}
	
	public static void debug() {
		for (int i = 0; i < wall.length; i++) {
			System.out.println(wall[i]);
		}
	}
	
	public static void solve() {
		Queue<Field> que = new LinkedList<Field>();
		que.offer(new Field(0, 0));
		while (que.peek() != null) {
			Field tmp = que.poll();
			if (tmp.x == w - 1 && tmp.y == h - 1) {
				//break;
			}
			for (int i = 0; i < 4; i++) {
				int nx = tmp.x + dx[i];
				int ny = tmp.y + dy[i];
				//System.out.println(tmp.x + " " + tmp.y + " " + nx + " " + ny + ": ");
				if (0 <= nx && nx < w && 0 <= ny && ny < h && !isWall(tmp.x, tmp.y, nx, ny) && field[ny][nx] == 0) {
					que.offer(new Field(nx, ny));
					field[ny][nx] = field[tmp.y][tmp.x] + 1;
				}
			}
		}
		System.out.println(field[h-1][w-1]);
	}
	
	// 隣接する2マスに壁があればtrue，そうでなければfalseを返すメソッド
	public static boolean isWall(int x1, int y1, int x2, int y2) {
		if (y1 == y2) {
			// 横2マスの場合
			//System.out.println("'" + wall[2*y1].charAt(x1 + x2) + "'");
			if (wall[2*y1].charAt(x1 + x2) == '1') {
				return true;
			} else {
				return false;
			}
		} else {
			// 縦2マスの場合
			//System.out.println("'" + wall[y1+y2].charAt(2 * x1) + "'");
			if (wall[y1+y2].charAt(2 * x1) == '1') {
				return true;
			} else {
				return false;
			}
		}
	}
}

class Field {
	int x;
	int y;
	Field(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 40344
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int alpha[26];

int main(){
	string s;
	cin >> s;
	rep(i,s.length()){
		alpha[s[i]-'a']++;
	}

	rep(i,26){
		if(alpha[i]%2==1){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3588
n = int(input())
h = list(map(int,input().split()))
cnt = 0
ans = 0
for i in reversed(range(1,len(h))):
  if h[i-1] >= h[i] :
    cnt +=1
  else:
    ans = max(ans,cnt)
    cnt = 0
  if i == 1 :
    ans = max(ans,cnt)
  
print(ans)

Measured memory_bytes: 14252
N, K, Q = map(int, input().split(' '))
A = [0] * N
for i in range(Q):
  k = int(input())
  A[k - 1] += 1
for i in range(N):
  if K - (Q - A[i]) > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 50904
def haiku(sentence_length_list):

    length_five_cnt=0
    length_seven_cnt=0
    for s in sentence_length_list:
        if s=='5':
            length_five_cnt=length_five_cnt+1
        if s=='7':
            length_seven_cnt=length_seven_cnt+1

    if length_five_cnt==2 and length_seven_cnt==1:
        return 'YES'
    else:
        return 'NO'

if __name__=='__main__':
    length_list = input().split()
    print(haiku(length_list))

Measured memory_bytes: 2940
import math


a, b, x = map(int, input().split())
#めっちゃ傾かせる
if (a*a*b) / 2 > x:
    ok = math.degrees(math.atan(b/a))
    ng = 90.0
    cnt = 0
    while True:
        cnt += 1
        mid = (ok + ng) / 2
        if (b / math.tan(math.radians(mid)))*a*b / 2 > x:
            ok = mid
        else:
            ng = mid
        if cnt >= 10000:
            break
    print(ok)
#そんなに傾かせない
else:
    ok = math.degrees(math.atan(b/a))
    ng = 0
    cnt = 0
    while True:
        cnt += 1
        mid = (ok + ng) / 2
        if a*a*b - a*a*a*math.tan(math.radians(mid)) / 2 < x:
            ok = mid
        else:
            ng = mid
        if cnt >= 10000:
            break
    print(ok)

Measured memory_bytes: 39664
program time_limit_exceeded
  implicit none
  integer :: n, l, c, t, i, a = 1001
  read(*,*) n, l
  do i = 1, n
    read(*,*) c, t
    if (t <= l) a = min(a,c)
  end do
  if (a == 1001) then
    write(*,'(a)') "TLE"
  else
    write(*,'(i0)') a
  end if
end program time_limit_exceeded

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

using namespace std;

long long solve(long long x, long long y) {
  long long res = 1e18;
  for (long long i = 1; i < x; ++i) {
    long long a = (x-i)*y;
    long long b = i*(y/2);
    long long c = i*(y-y/2);
    long long mx = max(a, max(b, c));
    long long mn = min(a, min(b, c));
    if (mx - mn < res) res = mx-mn;
  }
  return res;
}

long long solve2(long long x, long long y) {
  long long a = (x/3)*y;
  long long b = x*y - 2*a;
  return abs(a-b);
}

long long solve3(long long x, long long y) {
  long long a = ((x+2)/3)*y;
  long long b = x*y - 2*a;
  return abs(a-b);
}

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

  long long h, w;
  cin >> h >> w;

  long long a = min(solve(h, w), solve(w, h)); 
  long long b = min(solve2(h, w), solve2(w, h)); 
  long long c = min(solve3(h, w), solve3(w, h)); 

  cout << min(min(a, b),c) << endl;

  return 0;
}



Measured memory_bytes: 256