akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int N;
    cin >> N;

    vector<string> strs;
    inputVector(strs, N);

    unordered_set<string> st;
    rep(i, N) {
        if (st.count(strs[i])
            || i > 0 && strs[i - 1].back() != strs[i][0]) {
            cout << "No" << endl;
            return 0;
        }
        st.insert(strs[i]);
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
string s,t;
int ans=10000000;
int minn(string s1,string s2)
{
	int cnt=0;
	rep(i,s1.size()) if(s1[i]!=s2[i]) cnt++;
	return cnt;
}
int main()
{
	cin>>s>>t;
	rep(i,s.size()-t.size()+1) ans=min(ans,minn(t,s.substr(i,s.size())));
	re(ans)
	return 0;}

Measured memory_bytes: 3624
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
#define int long long
typedef long long ll;
#define MAXN 800006
int n , m , res = 0;
int A[MAXN] , S[MAXN];
signed main() {
    cin >> n;
    for( int i = 1 ; i <= n ; ++ i ) scanf("%lld",&A[i]) , S[A[i]] += 1;
    for( int i = 1 ; i <= 3000 ; ++ i ) S[i] += S[i - 1];
    sort( A + 1 , A + 1 + n );
    for( int i = 1 ; i <= n ; ++ i )
        for( int j = i + 1 ; j <= n ; ++ j )
            res += S[A[i] + A[j] - 1] - S[ A[j] - A[i] ] - ( A[i] > A[j] - A[i] ) - ( A[j] > A[j] - A[i] );
    cout << res / 3 << endl;
}

Measured memory_bytes: 2304
def f(a, b)
  result = 0
  until a == b
    result += 1 unless a % 2 == 0
    result += 1 unless b % 2 == 0
    a = (a + 1) / 2
    b = b / 2 
  end
  result
end
 
n = gets.to_i
n.times do
  s, d = gets.split.map!(&:to_i)
  puts f(s, d)
end

Measured memory_bytes: 8512
# -*- coding: utf-8 -*-

N, K = map(int,input().split())

A = []
table = []

for i in range(N):
    #二つの整数を読み取って、配列としてたす
    a,b = map(int,input().split())
    table.append([a,b])

table.sort(key=lambda x:x[0])
t = 0

for i in range(N):
    t += table[i][1]
    if t >= K:
        print (table[i][0])
        break


Measured memory_bytes: 21248
use proconio::input;
use proconio::marker::{Chars, Usize1};

fn main() {
    input! {
        _: usize,
        a: Usize1,
        b: Usize1,
        c: Usize1,
        d: Usize1,
        s: Chars,
    };
    if c < d {
        let mut is_ok = true;
        for i in a + 1..=c {
            if s[i - 1] == '#' && s[i] == '#' {
                is_ok = false;
                break;
            }
        }
        for i in b + 1..=d {
            if s[i - 1] == '#' && s[i] == '#' {
                is_ok = false;
                break;
            }
        }
        println!("{}", if is_ok { "Yes" } else { "No" });
    } else {
        let mut is_ok = true;
        for i in a + 1..=c {
            if s[i - 1] == '#' && s[i] == '#' {
                is_ok = false;
                break;
            }
        }
        let mut is_ng = true;
        for i in b + 1..=d + 1 {
            if s[i - 2] == '.' && s[i - 1] == '.' && s[i] == '.' {
                is_ng = false;
                break;
            }
        }
        println!("{}", if is_ok && !is_ng { "Yes" } else { "No" });
    }
}


Measured memory_bytes: 3028
#include <stdio.h>
#include <stdbool.h>

bool judgeRectTriangle(int , int , int);

int main(void)
{
    int edge1, edge2, edge3;

    scanf("%d", &edge1);//問題文読み間違えたので最初のデータを捨てます。

    while (scanf("%d%d%d", &edge1, &edge2, &edge3) != EOF) {
        if (judgeRectTriangle(edge1, edge2, edge3) ){
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    
    return 0;
}

bool judgeRectTriangle(int x, int y, int z)
{
    if (x * x + y * y == z * z || y * y + z * z == x * x || z * z + x * x == y * y) {
        return true;
    } else {
        return false;
    }
}

Measured memory_bytes: 1008
#include <stdio.h>

int main()
{
	int n;

	while (1) {
		int x = 0, emp[4000] = {};

		scanf("%d", &n);
		if(n == 0) break;

		for (int i = 0; i < n; i++) {
			int e, p, q;
			scanf("%d %d %d", &e, &p, &q);

			emp[e] += p*q;

			if(emp[e] >= 1000000) {printf("%d\n", e); x = 1;}
		}

		if (x != 1) printf("NA\n");
	}

	return 0;
}

Measured memory_bytes: 2620
#include <bits/stdc++.h>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

int m;
ll n, s, a[10010];

int main(){

	cin >> n >> m;
	for(int i = 1; i <= m; i++)
		cin >> a[i], s += a[i];
	if(s > n) puts("-1");
	else cout << n - s << "\n"; 

	return 0;
}


Measured memory_bytes: 3696
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			int[] x = new int[N+1];

			for (int i = 1; i <= N; i++) {
				x[i] = dpCore(i, x);
			}
			System.out.println(x[N]);
		};
	}

	static int dpCore(int target, int[] cache) {
		List<Integer> candidates = new ArrayList<>();
		for (int i = 1; i <= target; i*=9) {
			candidates.add(cache[target-i]+1);
		}
		for (int i = 1; i <= target; i*=6) {
			candidates.add(cache[target-i]+1);
		}
		return candidates.stream().mapToInt(i -> i).min().orElse(999999);
	}
}


Measured memory_bytes: 46444
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

X = list(itertools.permutations(P))
X.sort()
for i,x in enumerate(X):
	if x == P:
		a = i
	if x == Q:
		b = i

print(abs(a-b))

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N*N*N);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        vec.at(i+j+k)=i+j+k;
      }
    }
  }
  cout << vec.size() << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#define INF 0x3f3f3f3f
#define ONF 0xc0c0c0c0
using namespace std;
typedef long long ll;
int par[10000005], num[10000005];
void init(int n)
{
    for (int i = 1; i <= n; i++) {
        par[i] = i;
        num[i] = 1; //这里是求最大集合的个数，如果求最后集合中权值最大为多少就让num数组初始化为最开始各个元素的权值。
    }
}
int get_par(int x)
{
    return par[x] == x ? x : par[x] = get_par(par[x]);
}
void doit(int x, int y)
{
    int dx = get_par(x);
    int dy = get_par(y);
    if (dx != dy) {
        par[dx] = dy;
        num[dy] = num[dx] + num[dy];
    }
}
int main()
{
    int n, x, y, m;
    cin >> n >> m;
    init(n);
    for (int i = 1; i <= m; i++) {
        scanf("%d %d", &x, &y);
        doit(x, y);
    }
    int Max = 0;
    for (int i = 1; i <= n; i++)
        Max = max(Max, num[i]);
    cout << Max << endl;
}


Measured memory_bytes: 5228
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//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/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n,d;
  cin>>n>>d;
  d*=d;
  ll ans=0;
  rep(i,n){
    ll x,y;
    cin>>x>>y;
    if(x*x+y*y<=d) ans++;
  }
  out(ans);
}

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


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

void test_case(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	int prefR[n], prefW[n];
	if(s[0]=='R') prefR[0] = 1;
	else prefR[0] = 0;
	for(int i=1;i<n;i++) prefR[i] = prefR[i-1]+((s[i]=='R') ? 1 : 0);

	if(s[0]=='W') prefW[0]=1;
	else prefW[0] = 0;
	for(int i=1;i<n;i++) prefW[i] = prefW[i-1]+((s[i]=='W') ? 1 : 0);

	int ans=n;
	// red starts from index i
	for(int i=1;i<n;i++){
		int temp = max(prefW[i-1], prefR[n-1] - prefR[i-1]);

		ans = min(ans, temp);
	}

	ans = min(ans, prefR[n-1]);
	ans = min(ans, prefW[n-1]);
	cout << ans << endl;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int t=1;
	// cin >> t;

	while(t--) test_case();
	
	return 0;
}



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

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(),b=s.nextInt(),c=s.nextInt();
        if(a>c) System.out.println("NO");
        else if(a==c||a+b>=c) System.out.println("YES");
        else System.out.println("NO");
    }


}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25168
#include <stdio.h>

int main(){
	int i,j,k;

	while(scanf("%d %d",&i,&j) != EOF){
		k = i + j;
		int l = 0;
		while(k > 0){
			k = k/10;
			l = l + 1;
		}
		printf("%d\n",l);
	}
	return 0;
}

Measured memory_bytes: 600
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
int x,y,z;
int main(){
    read(x),read(y),read(z);
    printf("%d\n",(x-z)/(y+z));
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val (n, a, b) = readLine()!!.split(" ").map(String::toLong)
    val result = if (a % 2 == 1L && b % 2 == 1L || a % 2 == 0L && b % 2 == 0L) {
        Math.abs(a - b) / 2
    } else {
        val big = if (a > b) a else b
        val small = if (a < b) a else b
        if (small - 1 + big - 1 < n - small + n - big) {
            val dis = small - 1
            Math.abs((small - dis - (big - dis - 1)) / 2) + (dis + 1)
        } else {
            val dis = n - big
            Math.abs(((small + dis + 1) - (b + dis)) / 2) + (dis + 1)
        }
    }
    println(result)
}




Measured memory_bytes: 37932
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

const ll mod = 1000003;

inline ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

inline ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

inline ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

ll F[mod];
ll IF[mod];

void init() {
	F[0] = 1;
	for(int i=1; i<mod; i++) F[i] = mul(F[i-1], i);
	IF[mod-1] = power(F[mod-1], mod-2);
	for(int i=mod-2; i>=0; i--) IF[i] = mul(IF[i+1], i+1);
}

ll get(ll x, ll n) {
	return mul(F[x+n-1], IF[x-1]);
}

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

	init();
	int tc;
	cin >> tc;
	while(tc--) {
		ll x, d, n;
		cin >> x >> d >> n;
		if(d == 0) cout << power(x, n) << endl;
		else {
			x = mul(x, power(d, mod-2));
			if(x == 0) {
				cout << 0 << endl;
				continue;
			}
			if(mod <= x + n - 1) {
				cout << 0 << endl;
				continue;
			}
			ll res = get(x, n);
			cout << mul(res, power(d, n)) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

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

    li n, m;
    cin >> n >> m;

    vector<vector<li>> g(n);
    vector<li> indeg(n);

    for (int i = 0; i < m; ++i) {
        li fr, to;
        cin >> fr >> to;
        fr--; to--;
        g[fr].push_back(to);
        indeg[to]++;
    }

    queue<li> q;
    for (int i = 0; i < n; ++i) {
        q.push(i);
    }

    vector<bool> vis(n);
    vector<li> dp(n);
    while (not q.empty()) {
        li pos = q.front();
        q.pop();

        if (vis[pos] || indeg[pos] > 0) {
            continue;
        }

        vis[pos] = true;

        for (const auto &next : g[pos]) {
            q.push(next);
            dp[next] = max(dp[next], dp[pos] + 1);
            indeg[next]--;
        }
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	map<string, vector<int> > m;
	string str;
	int n;
	while(cin >> str >> n){
		m[str].push_back(n);
	}
	map<string, vector<int> >::iterator it;
	for(it = m.begin();it != m.end();it++){
		cout << it -> first << endl;
		sort(it -> second.begin(), it -> second.end());
		int i;
		for(i = 0;i < it -> second.size()-1;i++)
			cout << it -> second[i] << " ";
		cout << it -> second[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3040
import bisect
n = int(input())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))

al.sort()
bl.sort()
cl.sort()

ans = 0
for b in bl:
    a_num = bisect.bisect_left(al,b)
    c_num = n - bisect.bisect_right(cl,b)
    ans += a_num*c_num

print(ans)

Measured memory_bytes: 105292
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c; scanf("%d%d%d", &a, &b, &c);
  int penk[101] = {0};
  penk[a]=1;
  penk[b]=1;
  penk[c]=1;
  int res = 0;
  for (int i = 1; i < 101; i++) res += penk[i];
  printf("%d\n",res);
}

Measured memory_bytes: 256
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
	int h, w;
	cin >> h >> w;
	vector<string> M(h + 2, string(w + 2, '#'));
	int wnum = 0;
	for (int i = 1; i <= h; i++) {
		string tmp;
		cin >> tmp;
		for (int j = 1; j <= w; j++) {
			M[i][j] = tmp[j-1];
			if (tmp[j - 1] == '.') wnum++;
		}
	}

	const vector<int> mx{ 1,-1,0,0 }, my{ 0,0,1,-1 };
	vector<vector<bool>> seen(h + 2, vector<bool>(w + 2, false));
	vector<vector<int>> distance(h + 2, vector<int>(w + 2, 0));
	queue<pair<int, int>> que;
	que.push({ 1,1 });
	seen[1][1] = true;
	distance[1][1] = 1;
	while (!que.empty()) {
		int x = que.front().first, y = que.front().second;
		que.pop();

		for (int i = 0; i < 4; i++) {
			int x2 = x + mx[i], y2 = y + my[i];
			if (M[y2][x2] == '.' && !seen[y2][x2]) {
				que.push({ x2, y2 });
				seen[y2][x2] = true;
				distance[y2][x2] = distance[y][x] + 1;
			}
		}
	}

	if (seen[h][w]) {
		cout << wnum - distance[h][w] << endl;
	}
	else {
		cout << "-1\n";
	}

	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include <time.h> 
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 200010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
ll dp[1 << 22];
int mat[23][23];
int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n;
  sd(n);
  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < n; j++)
      sd(mat[i][j]);
  }
  dp[0] = 1;
  for(int mask = 1; mask < (1 << n) ; mask++)
  {
      for(int j = 0; j < n; j++)
      {
         int ones = __builtin_popcount(mask);
         if(mask & (1 << j)) // can turn off
         {
            int cur = mask ^ (1 << j);
            if(mat[ones - 1][j])
              dp[mask] = (dp[mask] + dp[cur] ) % MOD;
         }
      }
  }
  printf("%lld\n", dp[(1 << n) - 1]);
  return 0;
} 

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

int main() {
  int n;
  cin >> n;
  int x=0;
  for(int i=0;i<n;i++){
    int l,r;
    cin >> l >> r;
    x+=r-l+1;
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c,k;
signed main()
{
	cin>>a>>b>>c>>k;
	if(k%2==0){
		cout<<a-b<<endl;
	}else{
		cout<<b-a<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int x;
  cin >> x;
  
  if (x == 4 || x == 6 || x == 9 || x == 10 || x == 14 || x == 21
      || x == 22 || x == 25 || x == 26) {
    cout << "2" << endl;
  }
  
  else if (x == 28 || x == 30) {
    cout << "4" << endl;
  }
  
  else if (x == 8 || x == 12 || x == 18 || x == 20 || x == 27) {
    cout << "5" << endl;
  }
  else if (x == 16) {
    cout << "14" << endl;
  }
  
  else if (x == 24) {
    cout << "15" << endl;
  }
  
  else if (x == 32) {
    cout << "51" << endl;
  }
  
  else {
    cout << "1" << endl;
  }
}

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

int main() {
	int N;
  	cin >> N;
  	vector<double> x(N);
  	vector<string> u(N);
  
  	for(int i = 0; i < N; i++) {
    	cin >> x.at(i) >> u.at(i);
    }
  
  	double ans = 0;
  
  	for(int i = 0; i < N; i++) {
    	if(u.at(i) == "BTC") {
          ans += x.at(i) * 380000;
        }else {
          ans += x.at(i);
        }
    }
  
  	cout << ans << endl;
  
  	
}

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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;

    int count = 0;
    for (int i = 0; i < n - 2; i++) {
        if(s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C') {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
//  Created by liszt on 2019/08/01.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int a,b,c;
    cin>>a >>b >>c;
    if(a!=b&&b!=c&&c!=a){
        cout<<3<<endl;
    }else if((a==b&&b!=c)||(a==c&&b!=c)||(c==b&&a!=c)){
        cout<<2<<endl;
    }else{
        cout<<1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=3005;
const double pi=acos(-1.0);
int n,L;
int t[N];
double tx=0,ty=0;
int main(){
	n=read(),L=read();
	For(i,1,n)
		t[i]=read();
	For(i,1,n)
		For(j,i+1,n){
			int a=j-i-1,b=n-a-2;
			b-=a;
			int p=t[i]+t[j];
			tx+=cos(pi*p/L)*b;
			ty+=sin(pi*p/L)*b;
		}
	LL s=(LL)n*(n-1)*(n-2)/6;
	tx/=s,ty/=s;
	printf("%.10lf %.10lf\n",tx,ty);
	return 0;
}

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

int n,k;

long long mul(long long a){return a*a*a;}

int main(){
	scanf("%d%d",&n,&k);
	if (k&1) printf("%lld\n",mul(n/k));
	else printf("%lld\n",mul(n/k)+mul((n+k/2)/k));
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

//ostream& operator << (ostream &a, const vector<int> &b) {
//    for (auto k : b) cout << k << " ";
//    return a;
//}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")s
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i =0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 && a[i] % 5) {
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
}
/*
*/


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

char s[201010];
int main() {
	scanf("%s", s);

	int n = strlen(s);

	int left = 0;
	while (s[left] != 'A') left++;
	int right = n - 1;
	while (s[right] != 'Z') right--;

	int ans = right - left + 1;
	printf("%d\n", ans);
}

Measured memory_bytes: 384
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"3 3
dxx
axx
cxx"# => r#"axxcxxdxx"#,

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize, _l: usize,
        mut s: [String; n],
    }

    s.sort();
    s.join("").to_string()
}

Measured memory_bytes: 4352
from collections import defaultdict
S = input()
alphabet = list("abcdefghijklmnopqrstuvwxyz")
d = defaultdict(int)

for s in S:
     d[s] += 1
for s in alphabet:
     if d[s] == 0:
          ans = s
          break
else:
     ans = "None"
print(ans)


Measured memory_bytes: 39280
// inputに入力データ全体が入る
function Main(input) {
  var [N, K] = input[0].split(" ").map(v=>v-0);
  var ans = BigInt(0);
  for(var i=K;i<=N+1;i++){
    var min = i*(i-1)/2;
    var max = i*((N-i+1)+N)/2;
    ans += BigInt(max-min+1);
  }
  console.log((ans%BigInt(Math.pow(10,9)+7)).toString());
}



Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));

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

using namespace std;

bool sumS(string t)
{
  for(int i = 1; i < t.length(); ++i)
  {
  	if(t[i] != t[i-1] || t[i] == 0)
  		return false;
  }
  
  return true;
}

int main()
{
  int n;
  cin >> n;
  
  string s = to_string(n);
  
  while(!sumS(s))
  	s = to_string(++n);
  	
  cout << n << endl;
}

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

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

bool solve() {
    int h, w;
    std::cin >> h >> w;
    if (h == 0) return false;

    auto dp = vec(h, vec(w, 0));
    int q;
    std::cin >> q;
    while (q--) {
        int x, y;
        std::cin >> x >> y;
        dp[--x][--y] = -1;
    }

    for (int x = 0; x < h; ++x) {
        for (int y = 0; y < w; ++y) {
            if (x == 0 && y == 0) {
                dp[x][y] = 1;
            } else if (dp[x][y] == -1) {
                dp[x][y] = 0;
            } else {
                if (x > 0) dp[x][y] += dp[x - 1][y];
                if (y > 0) dp[x][y] += dp[x][y - 1];
            }
        }
    }

    std::cout << dp[h - 1][w - 1] << "\n";
    return true;
}

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

    while (solve()) {}

    return 0;
}



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

short nail[5001][5001];

int main()
{
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int a, b, x;
    cin >> a >> b >> x;
    --a, --b; ++x;
    nail[a][b] = max< short >(nail[a][b], x);
  }
  int ret = nail[0][0] > 0;
  for(int i = 1; i < N; i++) {
    for(int j = 0; j <= i; j++) {
      nail[i][j] = max< short >(nail[i][j], max(nail[i - 1][max(0, j - 1)], nail[i - 1][j]) - 1);
      ret += nail[i][j] > 0;
    }
  }
  cout << ret << endl;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

struct UnionFind {
  vector<int> data;

  UnionFind(int sz) { data.assign(sz, -1); }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return (false);
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if (data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) { return (-data[find(k)]); }
};

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  vector<ll> f(n, 0);
  REP(i, m) {
    ll a, b;
    cin >> a >> b;
    --a, --b;
    uf.unite(a, b);
    ++f[a], ++f[b];
  }
  vector<vector<ll>> bl(n);
  REP(i, k) {
    ll c, d;
    cin >> c >> d;
    --c, --d;
    bl[c].push_back(d);
    bl[d].push_back(c);
  }

  REP(i, n) {
    ll ans = uf.size(i) - 1 - f[i];
    for (auto x : bl[i]) {
      if (uf.find(x) == uf.find(i)) --ans;
    }
    cout << ans << " ";
  }
  return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    ll dp[100] = {2,1};
    for(int i = 2;i <= 86;i++)dp[i] = dp[i-1] + dp[i-2];
    cout << dp[N] << endl;
}

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

int prime[MAX]={0};
void is_prime(){
    prime[0] = prime[1] = 1;
    
    for(int i = 2 ; i*i < MAX ; i++)
        if(!prime[i])
            for(int j = i*2 ; j < MAX ; j += i)
                prime[j] = 1;
}

int main(){
    int n;
    
    is_prime();
    
    while(cin >> n,n){
        int a,b;
        
        for(int i = 0 ; i <= n ; i++){
            if(i >= 2 && !prime[i] && !prime[i-2]){
                a = i-2;
                b = i;
            }
        }
        
        cout << a << ' ' << b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 300005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,ar[N]; vector<ll> vc[N];
void dfs(ll i,ll p){
	for(auto it:vc[i]){
		if(it==p) continue;
		ar[it]+=ar[i];
		dfs(it,i);
	}
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,q;
	cin>>n>>q;
	for(i=1;i<n;i++){
		cin>>k>>l;
		vc[k].ps(l);
		vc[l].ps(k);
	}

	while(q--){
		cin>>k>>l;
		ar[k]+=l;
	}
	dfs(1,1);
	for(i=1;i<=n;i++){
		cout<<ar[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll h, n, a, b;
  a = 0;
  in2(h, n);
  rep(i, n){
    in(b);
    a += b;
  }
  if(a >= h)
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n;
string s;
cin >> n >> s;
ll ans = 0;
for (ll i = 0; i < n; i++) {
    map<char, bool> a;
    map<char, bool> b;
    ll tmp = 0;
    for (ll j = 0; j < i; j++) {
        a[s[j]] = true;
    }
    for (ll j = i; j < n;j++){
        b[s[j]] = true;
    }
    for (ll i = 0; i < 26;i++){
        char t = 'a' + i;
        if (a[t] && b[t]) tmp++;
    }
    chmax(ans, tmp);
}
cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;
const ll INF = 1ll << 56;
const ll MOD = 1e9 + 7;

pair<vector<ll>, vector<ll>> calc(const vector<vector<pair<int, ll>>> &G, int S) {
  vector<ll> dist(G.size(), INF);
  priority_queue<pair<ll, int>> q;
  q.emplace(0, S);
  dist[S] = 0;
  while (!q.empty()) {
    auto p = q.top(); q.pop();
    int v = p.second;
    for (auto e: G[v]) {
      int u = e.first;
      ll c = e.second;
      if (dist[v] + c < dist[u]) {
        dist[u] = dist[v] + c;
        q.emplace(-dist[u], u);
      }
    }
  }
  vector<bool> used(G.size(), false);
  vector<ll> dp(G.size(), 0);
  q.emplace(0, S);
  used[S] = true;
  dp[S] = 1;
  while (!q.empty()) {
    auto p = q.top(); q.pop();
    int v = p.second;
    for (auto e: G[v]) {
      int u = e.first;
      ll c = e.second;
      if (dist[v] + c == dist[u]) {
        dp[u] += dp[v];
        dp[u] %= MOD;
        if (!used[u]) {
          used[u] = true;
          q.emplace(-dist[u], u);
        }
      }
    }
  }
  return make_pair(dist, dp);
}

int main() {
  int N, M;
  cin >> N >> M;
  int S, T;
  cin >> S >> T;
  --S;
  --T;
  vector<vector<pair<int, ll>>> G(N);
  for (int i = 0; i < M; i++) {
    int U, V;
    ll D;
    cin >> U >> V >> D;
    --U;
    --V;
    G[U].emplace_back(V, D);
    G[V].emplace_back(U, D);
  }
  auto ps = calc(G, S);
  auto pt = calc(G, T);
  vector<ll> distS = ps.first, dpS = ps.second;
  vector<ll> distT = pt.first, dpT = pt.second;
  ll res = dpS[T] * dpT[S] % MOD;
  ll dame = 0;
  for (int v = 0; v < N; v++) {
    for (auto e: G[v]) {
      int u = e.first;
      ll c = e.second;
      if (distS[v] + c + distT[u] == distS[T] &&
          distT[u] + c + distS[v] == distT[S]) {
        if (distS[v] + c > distT[u] && distT[u] + c > distS[v]) {
          ll tmp = dpS[v] * dpT[u] % MOD;
          dame = (dame + tmp * tmp % MOD) % MOD;
        }
      }
    }
  }
  for (int v = 0; v < N; v++) {
    if (distS[v] + distT[v] == distT[S] && distS[v] == distT[v]) {
      ll tmp = dpS[v] * dpT[v] % MOD;
      dame = (dame + tmp * tmp % MOD) % MOD;
    }
  }
  res = (res - dame + MOD) % MOD;
  cout << res << endl;
  return 0;
}


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

string s;

int main() {
    getline(cin,s);
    int x = s.length();
    char t[x];
    for (int i=0; i<x; i++) {
        t[i] = s[i];
        if ((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z')) t[i] = (t[i] ^ 32);
        cout << t[i];
    }
    cout << endl;
}


Measured memory_bytes: 3160
n, k, q = gets.chomp.split().map(&:to_i)

ar = Array.new(n, 0)

q.times do |i|
  a = gets.chomp.to_i
  ar[a-1]+=1
end

ar.each do |e|
  if k - (q-e) > 0
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 3196
let getTop n = if n = 100 then 101 else n
let getZero d = 
	let rec zero d s = 
    	if d = 0 then s else zero (d - 1) s ^ "00"
	in zero d ""
let calc d n = string_of_int (getTop n) ^ getZero d
let main = print_string (Scanf.scanf "%d %d" calc)

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  string S;cin>>S;
  string ans = "";
  REP(i,0,S.size())ans+='x';
  print(ans)
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,Edges[100100];
vector < pair < int,int > > v[100100];


void DFS(int x, int p)
{

    set < int > st;
    for(auto j : v[x])
    {
        if(Edges[j.second])  st.insert(Edges[j.second]);
    }

    int cnt = 1;

    for(auto j : v[x])
    {
        if(!Edges[j.second])
        {
            while(st.find(cnt) != st.end())  cnt++;
            Edges[j.second] = cnt;
            st.insert(cnt);
        }
    }

    for(auto j : v[x])
    {
        if(j.first != p)  DFS(j.first, x);
    }
}

int main()
{
    cin >> n;
    for(int i = 0; i<n - 1; i++)
    {
        int x,y;
        cin >> x >> y;
        v[x].push_back({y, i});
        v[y].push_back({x, i});
    }
    DFS(1, -1);
    int Res = 0;
    for(int i = 0; i<n - 1; i++)  Res = max(Res , Edges[i]);
    cout << Res << '\n';
    for(int i = 0; i<n - 1; i++)  cout << Edges[i] << '\n';
    return 0;
}


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

const int Maxn = 10005;
const int Inf = 1000000000;

int h, n;
int A[Maxn], B[Maxn];
int dp[Maxn];

int main()
{
    scanf("%d %d", &h, &n);
    for (int i = 0; i < n; i++)
        scanf("%d %d", &A[i], &B[i]);
    fill(dp, dp + Maxn, Inf);
    dp[h] = 0;
    for (int i = h; i > 0; i--) if (dp[i] < Inf)
        for (int j = 0; j < n; j++) {
            int ni = max(0, i - A[j]);
            dp[ni] = min(dp[ni], dp[i] + B[j]);
        }
    cout << dp[0] << endl;
    return 0;
}


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

int main() {
  vector<int> cntlist(3);
  for (int i = 0; i < 3; i++) {
    cin >> cntlist[i];
  }
  int k;
  cin >> k;

  vector<vector<ll> > vlist(3);
  for (int i = 0; i < 3; i++) {
    vlist[i].resize(cntlist[i]);
    for (int j = 0; j < cntlist[i]; j++) {
      cin >> vlist[i][j];
    }
    sort(vlist[i].begin(), vlist[i].end(), greater<ll>());
  }

  priority_queue<pair<ll, vector<int> > > pq;
  ll v = vlist[0][0] + vlist[1][0] + vlist[2][0];
  vector<int> vec(3, 0);
  pq.push(make_pair(v, vec));

  set<pair<ll, vector<int> > > ss;
  ss.insert(make_pair(v, vec));

  while(k--) {
    if (!pq.empty()) {
      pair<ll, vector<int> > p = pq.top(); pq.pop();
      cout << p.first << endl;
      for (int i = 0; i < 3; i++) {
        if (p.second[i] + 1 < cntlist[i]) {
          ll v = p.first - vlist[i][p.second[i]] + vlist[i][p.second[i] + 1];
          vector<int> vec = p.second;
          vec[i]++;
          pair<ll, vector<int> > np = make_pair(v, vec);
          if (ss.count(np) == 0) {
            pq.push(np);
            ss.insert(np);
          }
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1408
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")

N,A,B=map(int, input().split())
H=[int(input()) for i in range(N)]
p(N,A,B,H)

import math
C=A-B
TMax=math.ceil(max(H)/B)
TMin=1
p(A,B,C,TMax,TMin)

def canWipe(t):
  x=0
  for h in H:
    x+=max(0,math.ceil((h-B*t)/C))
    if x>t: break
  return (t>=x)

t=TMax
ans=t
while TMax!=TMin:
  t=(TMax+TMin)//2
  if canWipe(t):
    ans=t
    TMax=t
  else:
    TMin=t+1
print(ans)


Measured memory_bytes: 10504
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int ans = 0, i = 0;
	char s[4];
	scanf("%s", s);
	for (i = 0; i < 3; i++) {
		if (s[i] == '1') {
			ans++;
		}
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
package main

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

func main() {
	nextInt()
	S := nextBytes()

	x := 0
	m := 0

	for i := 0; i < len(S); i++ {
		if S[i] == 'I' {
			x++
		} else {
			x--
		}

		m = max(m, x)
	}

	fmt.Println(m)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 1808
#include <cstdio>

using namespace std;

char S[65536];

int main() {
    int N;
    fgets(S, sizeof(S), stdin);
    sscanf(S, "%d", &N);
    fgets(S, sizeof(S), stdin);
    int count = 0;
    int ret = 0;
    for(int n=0; n<N; ++n) {
        char c = S[n];
        if(c=='(') {
            ++count;
        }
        else {
            if(count==0) {
                ++ret;
            }
            else {
                --count;
            }
        }
    }
    for(int i=0; i<ret; ++i) {
        printf("(");
    }
    for(int n=0; n<N; ++n) {
        printf("%c", S[n]);
    }
    for(int i=0; i<count; ++i) {
        printf(")");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<vector>
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
typedef long long ll;
using namespace std;
char c[100001];
int main()
{	scanf("%s",c+1);
	int n=strlen(c+1),l=1,r=n,ans=0;
	while(l<r)
	{	if(c[l]==c[r]) l++,r--;
		else if(c[l]=='x') ans++,l++;
		else if(c[r]=='x') ans++,r--;
		else{cout<<-1<<endl;return 0;}
	}
	cout<<ans<<endl;
 	return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    cin >> n;
    int64_t h,a,d,s;
    vector<int64_t> hs,as,ds,ss;
    vector<pair<int64_t,int64_t>> ps;
    vector<int> idx;
    cin >> h >> a >> d >> s;
    rep(i,0,n){
        int64_t h_,a_,d_,s_;
        cin >> h_ >> a_ >> d_ >> s_;
        if(a-d_<=0){
            if(a_-d>0){
                cout << -1 << endl;
                return;
            }
            continue;
        }
        idx.push_back(idx.size());
        ps.push_back(make_pair(max(a_-d,int64_t(0)),(h_+a-d_-1)/(a-d_)-(s_<s?1:0)));
        hs.push_back(h_);
        as.push_back(a_);
        ds.push_back(d_);
        ss.push_back(s_);
    }
    sort(idx.begin(),idx.end(),[&](int i,int j){
        if(a-ds[i]<=0) return true;
        if(a-ds[j]<=0) return false;
        return ps[j].first*((hs[i]+a-ds[i]-1)/(a-ds[i]))>
               ps[i].first*((hs[j]+a-ds[j]-1)/(a-ds[j]));
    });
    int64_t ans=0,sum=0;
    for(int i:idx){
        ans+=ps[i].first*ps[i].second+sum*((hs[i]+a-ds[i]-1)/(a-ds[i]));
        sum+=ps[i].first;
        if(ans>=h){
            cout << -1 << endl;
            return;
        }
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 5820