akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = items[0];
            var M = items[1];
            var A = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var total = A.Sum();
            var ableCount = A.Count(elem => elem * 4 * M >= total);
            var answer = M <= ableCount ? "Yes" : "No";

            Console.WriteLine(answer);
        }
    }
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	LL p[100010], q[100010], r[100010];
	rep(i,A) cin >> p[i];
	rep(i,B) cin >> q[i];
	rep(i,C) cin >> r[i];
	vector<LL> ap;
	sort(p,p+A,greater<LL>());
	sort(q,q+B,greater<LL>());
	sort(r,r+C,greater<LL>());
	rep(i,X) ap.emplace_back(p[i]);
	rep(i,Y) ap.emplace_back(q[i]);
	sort(ap.begin(),ap.end());
	LL ans=0;
	if(X+Y<C){
		rep(i,X+Y){
			if(ap[i]<r[i]) ans+=r[i];
			else ans+=ap[i];
		}
		cout << ans << endl;
		return 0;
	}
	rep(i,C){
		if(ap[i]<r[i]) ans+=r[i];
		else ans+=ap[i];
	}
	for(int i=C; i<X+Y; i++) ans+=ap[i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    vector<int>A(N) ;
    vector<int>B(N) ;
    vector<int>C(N) ;
    int S=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
        S+=B[i];
        //cout<<S<<endl;
    }
    for(int i=0;i<N;i++){
        cin>>C[i];
    }
    for(int i=0;i<N;i++){
        if(A[i]+1==A[i+1]){
            S+=C[A[i]-1];
        }
    }
    cout<<S<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    map<string,int>m;
    string s;
    rep(i,0,n){
        cin>>s;
        m[s]++;
    }
    cout<<m.size()<<endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int>p(n);
	for (int i = 0; i < n; i++)cin >> p.at(i);
	ll ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if (p.at(i - 1) <= p.at(i) && p.at(i) <= p.at(i + 1))ans++;
		else if (p.at(i + 1) <= p.at(i) && p.at(i) <= p.at(i - 1))ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

int main () {
    double x1,x2,x3,x4,y1,y2,y3,y4;
    
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x3,&y3,&x2,&y2,&x4,&y4)!=EOF){
        double tc=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3);
        double td=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4);
        
        double ta=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1);
        double tb=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2);
        
        if(tc*td<0&&ta*tb<0){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 1224
N, M, X, Y = map(int, input().split(' '))
max_x = max(map(int, input().split(' ')))
min_y = min(map(int, input().split(' ')))

if max_x < min_y:
    cand = [max_x+i+1 for i in range(min_y - max_x)]
    is_war = True
    for i in cand:
        if X < i <= Y:
            print('No War')
            is_war = False
            break
    if is_war:
        print('War')
else:
    print('War')

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

int main(){
    int A, B, C ,X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    int y1, y2, y3;
    y1 = A*X + B*Y;
    y2 = (X>Y ? 2*Y*C+(X-Y)*A : 2*X*C+(Y-X)*B);
    y3 = (X>Y ? 2*X*C : 2*Y*C);
    
    int min = y1;
    if(min>y2)  min = y2;
    if(min>y3)  min = y3;
    
    cout << min << endl;
    
    
    
    return 0;

}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int N, M;
    int P[100010], Y[100010];
    pair<int,int> city[100010];
    int c[100010];
    int y[100010];

    cin >> N >> M;
    for(int i = 0;i<M;i++){
        cin >> P[i] >> Y[i];
        city[i] = make_pair(Y[i],i);
    }
    sort(city,city+M);
    for(int i = 0;i < M;i++){
        c[P[city[i].second]]++;
        y[city[i].second] = c[P[city[i].second]];
    }
    for(int i = 0;i < M;i++){
        cout << setfill('0') << right << setw(6) << P[i] << setfill('0') << right << setw(6) << y[i] << endl;;
    }
}

Measured memory_bytes: 6144
import re


def main():
    s = input().replace('BC', 'X')
    S = re.split('[BC]', s)
    answer = 0

    for i in S:
        tmp = 0
        for j in i:
            if j == 'A':
                tmp += 1
            else:
                answer += tmp

    print(answer)


if __name__ == '__main__':
    main()

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

using namespace std;

int n,dp1[100010],dp2[100010],dp3[100010];

void read()
{
    cin >> n;
}

void solve()
{
    for (int i = 1;i <= n;i++){
        int a,b,c;
        cin >> a >> b >> c;
        dp1[i] = max(dp2[i-1] , dp3[i-1]) + a;
        dp2[i] = max(dp1[i-1] , dp3[i-1]) + b;
        dp3[i] = max(dp1[i-1] , dp2[i-1]) + c;
    }
    cout << max(max(dp1[n],dp2[n]),dp3[n]);
}

main()
{
    read();
    solve();
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s; cin >> s;
    int k; cin >> k;
    set<string> table;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 1; j <= 5; j++) {
            table.insert(s.substr(i,j));
        }
    }
    auto it = table.begin();
    for (int i = 1; i < k; i++) {
        it++;
    }
    cout << *it << endl;


    return 0;
}

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

typedef long long ll;

ll a[3];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if ((a[0] & 1) & (a[1] & 1) & (a[2] & 1))
        cout << a[0] * a[1];
    else
 		cout << 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
const int mo = 1e9 + 7;
using namespace std;
typedef long long ll;
ll fpm(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1) res = res * a % mo;
		a = a * a % mo;
		b >>= 1; 
	}
	return res;
}
const int MAXN = 2e3 + 10;
const int MAXV = 4e6 + 10;
ll fac[MAXV], facinv[MAXV];
int n, k;
inline void pre()
{
	fac[0] = 1;
	for (register int i = 1; i <= n * k; ++i) fac[i] = 1ll * i * fac[i - 1] % mo;
	facinv[n * k] = fpm(fac[n * k], mo - 2);
	for (register int i = n * k; i > 0; --i) facinv[i - 1] = 1ll * facinv[i] * i % mo;
	 
}
template <class T> 
inline ll binom(T a, T b)
{
	if (a - b < 0) return 0;
	if (b < 0) return 0;
	return fac[a] * facinv[b] % mo * facinv[a - b] % mo;
}
ll f[MAXN][MAXN];
int main(int argc, char **argv)
{
	cin >> n >> k;
	if (k == 1) return puts("1"), 0; 
	pre();
	f[0][0] = 1;
	for (register int i = 1; i <= n; ++i)
	{
		for (register int j = 0; j <= i; ++j)
		{
			f[i][j] = f[i - 1][j];
			if (!j) continue;
			f[i][j] = (f[i][j] + f[i][j - 1] * (n - j + 1) % mo * binom(n - i + (n - j + 1) * (k - 1) - 1, k - 2) % mo) % mo; 
		}
	}
	cout << f[n][n] << endl;
	return 0;
}

Measured memory_bytes: 92800
object Main{
  def main(args: Array[String]){
    val sc = new java.util.Scanner(System.in)
    val a, b = sc.nextInt
    
    val isEven = (x: Int, y: Int) => x * y % 2 == 0

    if(isEven(a, b)){
      println("Even")
    }else{
      println("Odd")
    }
  }
}

Measured memory_bytes: 25540
N=int(input())
A=[]
for i in range(0,N):
    A.append(int(input()))
a=max(A)
b=A.count(a)
if b>1:
    for i in range(0,N):
        print(a)
else:
    for i in range(0,N):
        if A[i]!=a:
            print(a)
        else:
            A[i]=0
            print(max(A))

Measured memory_bytes: 12532
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int x;
  cin >> x;
  
  for(int i=x;i<=100003;i++){
    bool sosu = true;
    for(int j=2;j<=sqrt(i);j++) {
      if(i%j==0) sosu = false;
    }
    if(sosu) {
      cout << i << endl;
      return 0;
    }
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
#define reprange(i, a) for(int i : vector<int>a)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
const ll inf=1LL << 60;
const ll mod=1e9+7;

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int ans=min(b, d)-max(a, c);
  cout << (ans>0 ? ans : 0) << endl;

  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>
#include <stdlib.h>

#define PI 3.1415926
void swap(int* x, int* y) {
	int a = *x;
	int b = *y;
	*x = b;
	*y = a;
}
int factorial(int n);
int sum(int n, int*);
int ave(int n, int*);
int min(int n, int*), min(int n, int m);
int max(int n, int*), max(int n, int m);

int main() {
	int N, A, B, C, D[200];
	scanf("%d", &N);
	scanf("%d %d", &A, &B);
	scanf("%d", &C);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &D[i]);
	}
	int Ds[200];
	
	for (int i = 1; i <= pow(N,2); i++) {
		for (int j = 1; j <= N - 1; j++) {
			if (D[j] < D[j + 1]) {
				swap(&D[j], &D[j + 1]);
			}
		}
	}
	
	for (int i = 1; i <= N; i++) {
		//printf("%d\n", D[i]);
	}
	int s = 0;
	D[0] = 0;
	int n;
	for (int i = 1; i <= N; i++) {
		if ((C + s)*(A + i*B) >= (C + s + D[i])*(A + (i - 1)*B)) {
			n = i - 1;
			break;
		}
		s += D[i];
	}
	printf("%d\n", (C + s) / (A + n*B));
	return 0;
}

int factorial(int n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else {
		return 1;
	}
}
int sum(int n, int *all) {
	int total = 0;
	for (int i = 0; i < n; ++i) {
		total += all[i];
	}
	return total;
}
int ave(int n, int *all) {
	int total = 0;
	for (int i = 0; i<n; ++i) {
		total += all[i];
	}
	return total / n;
}
int min(int n, int *all) {

	int min = all[0];
	for (int i = 1; i < n; ++i) {
		if (all[0] > all[i]) {
			min = all[i];
		}
	}
	return min;
}
int max(int n, int *all) {
	int max = all[0];
	for (int i = 1; i<n; ++i) {
		if (all[0]<all[i]) {
			max = all[i];
		}
	}
	return max;
}
int max(int n, int m) {
	if (n >= m) {
		return n;
	}
	else {
		return m;
	}
}
int min(int n, int m) {
	if (n >= m) {
		return m;
	}
	else {
		return n;
	}
}

Measured memory_bytes: 2676
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

class unionfind {
	vector<int> par;
	vector<int> sz;
public:
	unionfind(int n) {
		par = vector<int>(n);
		for (int i = 0; i < n; i++) par[i] = i;
		sz = vector<int>(n, 1);
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	int si(int x) { return sz[find(x)]; }
	bool same(int x, int y) { return find(x) == find(y); }
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (sz[x] < sz[y]) {
			par[x] = y;
			sz[y] += sz[x];
		}
		else {
			par[y] = x;
			sz[x] += sz[y];
		}
	}
};

typedef pair<P, ll> PP;

bool comp(PP a, PP b) {
	return a.first.second < b.first.second;
}

struct edge {
	ll u, v, cost;
	bool operator <(const edge &other) {
		return cost < other.cost;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	
	int n;
	cin >> n;
	vector<PP> p(n);
	rep(i, n) {
		cin >> p[i].first.first >> p[i].first.second;
		p[i].second = i;
	}
	vector<edge> graph;
	sort(all(p));
	rep(i, n - 1) graph.pb({ p[i].second,p[i + 1].second,p[i + 1].first.first - p[i].first.first });
	sort(all(p), comp);
	rep(i, n - 1) graph.pb({ p[i].second,p[i + 1].second,p[i + 1].first.second - p[i].first.second });
	sort(all(graph));
	unionfind uni(n);
	ll ans = 0;
	for (edge e : graph) {
		if (!uni.same(e.u, e.v)) {
			uni.unite(e.u, e.v);
			ans += e.cost;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 10864
package main

import "fmt"

func main() {
	mod := 1000000007
	f := make([]int, 2010101)
	rf := make([]int, 2010101)
	f[0] = 1
	for i := 1; i < 2010101; i++ {
		f[i] = (f[i-1] * i) % mod
	}
	for i := 0; i < 2010101; i++ {
		rf[i] = inv(f[i], mod)
	}

	var X, Y int
	fmt.Scan(&X, &Y)
	for a := 0; a < X+1; a++ {
		b := Y - 2*a
		if a+2*b == X {
			fmt.Println(C(a+b, a, mod, f, rf))
			return
		}
	}
	fmt.Println(0)
}
func inv(x, mod int) int {
	res := 1
	k := mod - 2
	y := x
	for k > 0 {
		if (k & 1) == 1 {
			res = (res * y) % mod
		}
		y = (y * y) % mod
		//k /= 2
		k = k >> uint(1)
	}
	return res
}
func C(n, k, mod int, f, rf []int) int {
	a := f[n]
	b := rf[n-k]
	c := rf[k]

	bc := (b * c) % mod

	return (a * bc) % mod
}


Measured memory_bytes: 32896
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s,t;
    cin >> s >> t;
    int answer=10000;
    
    REP(i,s.length()-t.length()+1){
        int count=0;
        REP(j,t.length()){
            if(s[i+j]!=t[j])count++;
        }
        answer = min(answer,count);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s,char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

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

std::string revString(std::string s) {
	string ret;
	auto it = s.rend();
	while (it != s.rbegin()) {
		ret.push_back(*it);
		++it;
	}
	return ret;
}

signed main() {
	makei(n);
	makev(v, n);
	reverse(all(v));
	say(v);
}


Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Contest
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var a = new int[26];
            for (int i = 0; i < 4; i++)
            {
                a[S[i] - 'A']++;
            }

            Console.WriteLine(a.Count(i => i == 2) == 2 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
    int d[5], k = 0, i = 0;
    for(i = 0; i < 5; i++){
        cin >> d[i];
    }
    int min = 200;
    int num = 0;
    int newNum[5];
    int flag = 0;
    for(k = 0; k < 5; k++){
        num = d[k]%10;
        if(num == 0){
            newNum[k] = d[k];
        }
        else{
            newNum[k] = (d[k]-num)+10;
        }
        if(min > num && num != 0){
            flag = k;
            min = num;
        }
    }
    int sum = 0;
    for(i = 0; i < 5; i++){
        if(i == flag){
            sum += d[i];
        }
        else{
            sum += newNum[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

a, b = map(int, input().split())

if a == b:
    print(str(a) * a)
elif a > b:
    print(str(b) * a)
else:
    print(str(a) * b)


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

int ary[128];
int kat[7][3]={{1,8,9},{8,16,24},{1,2,3},{7,8,15},{1,9,10},{8,9,17},{1,7,8}};
int main(){
	while(true){
		char ch;
		for(int i=0;i<64;i++){
			cin>>ch;
			ary[i]=ch-'0';
		}
		if(cin.eof()) break;
		int res=-1;
		for(int i=0;i<64;i++){
			if(ary[i]){
				for(int j=0;j<7;j++){
					bool fla=true;
					for(int k=0;k<3;k++){
						if(!ary[i+kat[j][k]]) fla=false;
					}
					if(fla){
						res=j;
						goto aaa;
					}
				}
			}
		}
aaa:
		cout<<(char)('A'+res)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3092
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
nl = lambda: list(map(int, stdin.readline().split()))

n, m = na()
ans = 10 ** 9 + 7
sc = [na() for _ in range(m)]
for i in range(10 ** n):
    st = str(i)
    if len(st) != n:
        continue
    ok = True
    for s, c in sc:
        if int(st[s-1]) != c:
            ok = False
    if ok:
        print(st)
        exit(0)
print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include<cstdio>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a;
  cin >> a;
  if (a < 10) cout << a; 
  if (a >= 10 && a < 100 ) cout << 9;
  if (a >= 100 && a < 1000 ) {
    int res = 9 + (a-99);
    cout << res;
  }
  if (a >= 1000 && a < 10000 ) cout << 909;
  if (a >= 10000 && a < 100000 ) {
    int res = 9 + 900 + (a-9999);
    cout << res;
  }
  if (a == 100000) cout << 90909;
  
  return 0;
}


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

int N;

bool can_make_stairs(vector<int> &H) {
    int MAX = 0;
    for (int i = 0; i < N; i++) {
        if (H[i] < MAX - 1) {
            return false;
        }
        if (H[i] > MAX) {
            MAX = H[i];
        }
    }

    return true;
}

int main() {
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &H[i]);
    }

    cout << (can_make_stairs(H) ? "Yes" : "No") << endl;
  
  	return 0;
}

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

struct t {
  string s;
  int p;
  int i;
};

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

  vector<t> v;
  rep(i, N) {
    string s;
    int p;
    cin >> s >> p;
    v.emplace_back(t{s, p, i + 1});
  }

  sort(v.begin(), v.end(),
       [](auto x, auto y) { return x.s != y.s ? x.s < y.s : x.p > y.p; });

  rep(i, N) {
    cout << v[i].i << endl;
  }
}

Measured memory_bytes: 256
def f(Y):
  if len(Y)==1:
    print(Y[0])
    exit()
  x=Y[0]
  del Y[0]
  if x=="a":
    Z=A
  elif x=="b":
    Z=B
  else:
    Z=C
  return f(Z)


A=list(input())+["A"]
B=list(input())+["B"]
C=list(input())+["C"]
f(A)

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

main() {
  int n;
  double avg = 0.0;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    avg = (avg*(i-1) + a)/i;
  }
  cout << (int)avg << endl;
}

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

/*
struct Edge
{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

vector<vector<ll>> d(310, vector<ll>(310, INF));
vector<vector<bool>> not_need(310, vector<bool>(310, false));

void warshallFloyd(int n)
{
    for (int i = 0; i < n; i++)
        d[i][i] = 0;

    for (int k = 0; k < n; k++) // 経由する頂点
    {
        for (int i = 0; i < n; i++) // 始点
        {
            for (int j = 0; j < n; j++) // 終点
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]); // 距離
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N));
    vector<vector<bool>> isNeed(N, vector<bool>(N, true));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> A[i][j];
            d[i][j] = A[i][j];
        }
    }

    for (int k = 0; k < N; k++)
    {
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                if (A[i][k] + A[k][j] < A[i][j])
                {
                    cout << -1 << endl;
                    return 0;
                }
                else if (A[i][k] + A[k][j] == A[i][j] && i != k && k != j)
                    isNeed[i][j] = false;
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i; j < N; j++)
        {
            if (isNeed[i][j])
                ans += A[i][j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4676
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "Sunny")
      cout << "Cloudy" << endl;
  if (s == "Cloudy")
      cout << "Rainy"  << endl;
  if (s == "Rainy")
      cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int m;
   cin>>m;
  int n=sqrt(m);
 map<int,int>mp;
   for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
        for(int k=1;k<=n;k++)
        {
            int p=(i*i)+(j*j)+(k*k)+(i*j)+(k*j)+(i*k);
          //  cout<<p<<endl;
            mp[p]++;
            //cout<<mp[p]<<endl;
        }
    }
   }
   for(int i=1;i<=m;i++)
   {
       cout<<mp[i]<<endl;
   }

}



Measured memory_bytes: 5352
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
int dp[3001][3001];
int findLCS(int i, int j, string s,string t){
    if(i == -1 || j == -1) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    if(s[i] == t[j]) return dp[i][j] = 1+findLCS(i-1,j-1,s,t);
    return dp[i][j] = max(findLCS(i,j-1,s,t), findLCS(i-1,j,s,t));
}
int main() {
    string s,t;
    cin >> s;
    cin >> t;
    int n = s.size(), m = t.size();
   // memset(dp, -1 ,sizeof(dp[0][0])*3001*3001);
    //findLCS(s.size()-1,t.size()-1,s,t);
    for(int i=0;i<n+1;i++) dp[i][0] = 0;
    for(int j=0;j<m+1;j++) dp[0][j] = 0;
    
    
    for(int i=1;i<n+1;i++){
        for(int j=1;j<m+1;j++){
            if(s[i-1] == t[j-1]) 
                dp[i][j] = 1 + dp[i-1][j-1];
            else 
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    
   
    string ans= "";
    int i = n, j = m;
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            ans.push_back(s[i-1]);
            i--; j--;
        }
       
        else{
           
            if(dp[i][j-1] > dp[i-1][j]) j--;
            else i--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
	return 0;
}


Measured memory_bytes: 38792
n,d = map(int,input().split())
dots = []
ans = 0
for _ in range(n):
  t = list(map(int,input().split()))
  if len(dots)!=0:
    for l in dots:
      a = [(y-z)**2 for y,z in zip(t,l)]
      if ((sum(a))**.5).is_integer():
        ans += 1
  dots.append(t)
print(ans) 

Measured memory_bytes: 9348
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    for(int i=0;i<n;i++){
    	cout << "x";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
I=lambda:list(map(int,input().split()))
n,m=I()
e=eval('(I()[0],I()),'*m)
dp=[9e9]*2**n
dp[0]=0
for i in range(2**n):
    if dp[i]==9e9:continue
    for a,c in e:
        b=i
        for j in c:b|=2**(n-j)
        dp[b]=min(dp[b],dp[i]+a)
print(-(dp[-1]==9e9)or dp[-1])

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

using ull = unsigned long long;
using ll = long long;

template<class T>           //自定义读入函数
inline void read(T &a) {
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    a = x * flag;
}

template <class T>        //自定义写入函数
inline void write(T x) {
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }   //自定义比较函数
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }   //自定义比较函数

#define For(i, a, b) for (int i = (a); i <= (b); ++i)   //从小到大重复
#define Rep(i, a, b) for (int i = (a); i >= (b); --i)   //从大到小重复
#define For_edge(x) for (int i = head[x]; i; i = net[i])
#define mem0(a) memset(a, 0, sizeof a)                  //内存复制


//判断是否是质数
bool is_prime(ll n)
{
	int sqrtN = (int)sqrt((double)n);
	if(n == 1)
		return false;
	if(n == 2)
		return true;
	for(int i = 2; i <= sqrtN; ++i)
		if(n % i == 0)
			return false;
	return true;
}

unordered_map<ll, int> m;   //存储所有的质因数

void find_all_prime_factor(ll n)
{
	if(n == 1)
		return;
	if(n == 2)
	{
		++m[n];
		return;
	}
	if(is_prime(n))
	{
		++m[n];
		return;
	}
	int i;
	for(i = 2; i <= n; ++i)
		if(is_prime(i) && n % i == 0)
		{
			++m[i];
			break;
		}

	find_all_prime_factor(n / i);
}

int main()
{
	ll N;
	scanf("%lld", &N);
	int times = 0;
	find_all_prime_factor(N);
	if(m.empty())
		cout << 0 << endl;
	else
	{
		for(auto iter = m.begin(); iter != m.end(); ++iter)
		{
			for(int i = 1; i <= iter->second; ++i)
			{
				++times;
				iter->second = iter->second - i;
			}
		}
		cout << times << endl;
	}

	return 0;
}



Measured memory_bytes: 3752
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
#define ld long double
const ll mod=998244353;

void solve(){
    int n,y;
    cin>>n>>y;
    if((y&1)||y>4*n||y<2*n)
    cout<<"No";
    else
    cout<<"Yes";


}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    solve();

}


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

namespace A___Not
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var result = 0;
            if (n == 0)
            {
                result = 1;
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27456
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
	int a[100005], n,maxx,b[100005];
	while (cin >> n)
	{
		memset(a, 0, sizeof(a));
		maxx = 1;
		cin >> b[0];
		a[b[0]]++;
		for (int i = 1; i < n; i++)
		{
			cin >> b[i];
			a[b[i]]++;
		}
		if (n > 2) {
			for (int i = 0; i <= n - 2; i++)
			{
				if (a[i] + a[i + 1] + a[i + 2] > maxx)
					maxx = a[i] + a[i + 1] + a[i + 2];
			}
		}
		else if (n == 2)
			if (b[0] + 1 == b[1] || b[0] - 1 == b[1] || b[0] == b[1])
				maxx = 2;
		cout << maxx << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int a=scan.nextInt();
    int b=scan.nextInt();
    if(a*500>=b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,k;
  cin >> n >> k;

  int tmp = n/k, ans = tmp*tmp*tmp;

  int cnt = 0;
  FOR(i,1,n+1){
    if((i%k)*2 == k) cnt++;
  }

  ans += cnt*cnt*cnt;

  cout << ans << endl;

  return 0;
}

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

#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>
#define rep(x, l, r) for (x = l; x < r; x++)

const ll mod=1000000007;


void solve()
{
	ll i, j, k, l, m, n, x, y, u, v, r, p,a,b,d;
    cin>>n;
    cout<<n+n*n+n*n*n;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
//    cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main()
{
   int t , d , x ,x1=0;
   cin>>t>>d>>x;
   for(int i=0 ; i<10 ; i++){
    x1 = (t*x)-d;
    cout<<x1<<endl;
    x=x1;



   }
    return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

struct UnionFind{
	vector<int> data;
	UnionFind(int n):data(n,-1){}
	int Find(int x){
		return data[x]<0?x:data[x]=Find(data[x]);
	}
	bool Unite(int a,int b){
		int ra=Find(a),rb=Find(b);
		if(ra==rb) return false;
		if(-data[ra]<-data[rb]) swap(ra,rb);
		data[ra]+=data[rb],data[rb]=ra;
		return true;
	}
};

int main()
{
	for(int n,m;cin>>n>>m;){
		vector<int> x(n),y(n);
		for(int i=0;i<n;i++)
			cin>>x[i]>>y[i];
		vector<int> s(m),d(m);
		vector<double> w(m);
		for(int i=0;i<m;i++){
			cin>>s[i]>>d[i]; s[i]--,d[i]--;
			w[i]=hypot(x[d[i]]-x[s[i]],y[d[i]]-y[s[i]]);
		}
		
		{
			vector<pair<double,pair<int,int>>> p(m);
			for(int i=0;i<m;i++) p[i]=make_pair(w[i],make_pair(s[i],d[i]));
			sort(begin(p),end(p));
			for(int i=0;i<m;i++){
				w[m-1-i]=p[i].first;
				s[m-1-i]=p[i].second.first;
				d[m-1-i]=p[i].second.second;
			}
		}
		
		UnionFind uf(n);
		double res=0;
		for(int i=0;i<m;i++)
			if(!uf.Unite(s[i],d[i]))
				res+=w[i];
		printf("%f\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000000
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vs vector<string>
#define psi pair<string,ll>
#define pii pair<ll,ll>
#define vsi vector<psi>
#define vii vector<pii>
#define mp make_pair
#define pb push_back
#define rep(n) for(long i=0;i<n;i++)
#define repr(n) for(long i=(n-1);i>=0;i--)
#define fori(i,a,b) for(auto i=a;i<=b;i++)
#define ford(i,b,a) for(auto i=b;i>=a;i--)
#define mset(a,i) memset(a,i,sizeof(a))
#define minv(a) min_element(a.begin(),a.end())
#define maxv(a) max_element(a.begin(),a.end())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define sotit(a) sort(a.begin(),a.end());
#define sot(a) sort(a,a+n);
#define ff first
#define maxheap(v) priority_queue<v>
#define minheap(v) priority_queue<v, vector<v>, greater<v>>
#define ss second
#define endl "\n"
#define NL cout<<endl;
#define printmat(a,m,n) for(int i=0;i<m;i++){       \
							for(int j=0;j<n;j++){   \
								cout<<a[i][j]<<" "; \
							}                       \
							cout<<endl;             \
						}
#define dbgn(x) cout<<" $ "<<x<<" $ "<<endl;
#define dbg(x) cout<<" $ "<<x<<" $ ";
#define all(v) v.begin(),v.end()
#define len(s) (ll)(s.size())
#define show(a,n) for(int i=0;i<n;i++){ cout<<a[i]<<" "; } NL
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);cin.tie(NULL);
 
// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val

int main() {
	fast_io()
 

	ll t;
	//cin>>t;
	t=1;
	while(t--){
		ll n;
		cin>>n;
		ll h[n][3],dp[n][3];
		rep(n){
			cin>>h[i][0]>>h[i][1]>>h[i][2];
		}
		mset(dp,0);
		dp[0][0]=h[0][0];
		dp[0][1]=h[0][1];
		dp[0][2]=h[0][2];
		fori(i,1,n-1){
			dp[i][0] = h[i][0] + max(dp[i-1][1],dp[i-1][2]);
			dp[i][1] = h[i][1] + max(dp[i-1][0],dp[i-1][2]);
			dp[i][2] = h[i][2] + max(dp[i-1][1],dp[i-1][0]);
		}
		cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	}
	return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int a, b;
    std::cin >> a >> b;

    if (a + b == 15) {
        std::cout << "+" << std::endl;
    } else if (a * b == 15) {
        std::cout << "*" << std::endl;
    } else {
        std::cout << "x" << std::endl;
    }
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Vector;

class Scanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int q = sc.nextInt();
		Vector<Integer> vec = new Vector<Integer>();
	    for (int i = 0; i < q; ++i)
	    {
	    	int query = sc.nextInt();
	    	switch (query) {
	    	case 0:
	    		pushBack(sc, vec);
	    		break;
	    	case 1:
	    		randomAccess(sc, vec);
	    		break;
	    	case 2:
	    		popBack(vec);
	    		break;
	    	}
	    }
	}

	static void pushBack(Scanner sc, Vector<Integer> vec)
	{
		int v = sc.nextInt();
		vec.add(v);
	}

	static void randomAccess(Scanner sc, Vector<Integer> vec)
	{
		int p = sc.nextInt();
		System.out.println(vec.elementAt(p));
	}

	static void popBack(Vector<Integer> vec)
	{
		vec.remove(vec.size()-1);
	}

}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 200001


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

    int n;
    cin >> n;
    ll v;
    vector <ll> vec;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> v;
        vec.pb(v);
    }
    sort(all(vec));
    vector <ll> nvec;
    nvec.resize(n - (n & 1));
    int l = n / 2 - 1 , r = n / 2;
    for (int i = 0; i < n / 2; i++) {
        if (i % 2 == 0) {
            nvec[l--] = vec[n - 1 - i];
            nvec[r++] = vec[i];
        }
        else {
            nvec[l--] = vec[i];
            nvec[r++] = vec[n - 1 - i];
        }
    }
    if ((n & 1)) {
        n--;
        ans += max(abs(nvec[0] - vec[n / 2]) , abs(nvec[n - 1] - vec[n / 2]));
    }
    for (int i = 1; i < n; i++) {
        ans += abs(nvec[i] - nvec[i - 1]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1908
#include <iostream>
using namespace std;
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  bool can = false;
  for(int i = 1; i <= B; ++i){
    if((i*A)%B == C){
      can = true;
      break;
    }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

using namespace std;

int main(){
    string a;
    string temp1;
    string temp2;
    int len_a;
    int c,x;
    int i;
    
    for (;;){
        cin >> a;
        if ( a== "-") break;
        len_a = a.length();
        cin >> c;
        for ( i = 0 ; i < c ; i++){
            cin >> x;
            temp1 = a.substr(0,x);
            temp2 = a.substr(x,len_a-x);
            a = temp2 + temp1;
            //cout << a << endl;
        }
        cout << a << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3136
#include<iostream>
using namespace std;
void dfs(int,int);
int a[50][50]={};

int main(){
  while(1){
    int count=0,w,h;
    cin>>w>>h;
    if(w+h==0)break;
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	cin>>a[i][j];

    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(a[i][j]==1){
	  dfs(j,i);
	  count++;
	}
    cout<<count<<endl;  
  }
  return 0;
}

  void dfs(int x,int y){
    a[y][x]=0;
    int nx,ny;
    int dx[8]={1,1,1,0,-1,-1,-1,0};
    int dy[8]={1,0,-1,-1,-1,0,1,1};
    for(int k=0;k<8;k++){
	nx=x+dx[k];
	ny=y+dy[k];

	if(nx>=0&&nx<50&&ny>=0&&ny<50&&a[ny][nx]==1)
	  dfs(nx,ny);
    }
  }

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

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

  int p;
  vector<int> ans(n, 0);

  rep(i, q) {
    cin >> p;
    ans[p-1]++;
  }

  rep(i, n) {
    int point = k - q + ans[i];
    if (point > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
#include <iostream>
#include <cassert>
#include <queue>
#include <unordered_map>
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define rep(i,a,b) for(int i = a;i < b; ++i)
using namespace std;

int add(int a, int b) {
    int MOD = 1e9 + 7;
    a += b;
    if (a < 0) a += MOD;
    return a % MOD;
}
int main() {

    int N, M;
    cin >> N >> M;
    vector<int> S(N);
    vector<int> T(M);
    for (int i = 0; i < N; ++i) {
        cin >> S[i];
    }
    for (int i = 0; i < M; ++i) {
        cin >> T[i];
    }
    // f[i][j]:不承诺结尾, 不包括空集
    vector<vector<int>> f(N+1, vector<int>(M+1));
    // dp[i][j]：以S[i-1], T[j-1]为结尾的集合
    vector<vector<int>> dp(N+1, vector<int>(M+1));
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= M; ++j) {
            if (S[i-1] != T[j-1]) dp[i][j] = 0;
            else dp[i][j] = add(f[i-1][j-1], 1);

            f[i][j] = add(f[i][j], f[i][j-1]);
            f[i][j] = add(f[i][j], f[i-1][j]);
            f[i][j] = add(f[i][j], -f[i-1][j-1]);
            f[i][j] = add(f[i][j], dp[i][j]);
        }
    }
    cout << f[N][M] + 1;

    return 0;
}

Measured memory_bytes: 31744
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
    int H, W;
    cin >> H >> W;
    char A[H][W];

    int cnt = 0;

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        cin >> A[i][j];
        if(A[i][j]=='#') cnt++;
      }
    }

    if(cnt == H+W-1){
      cout << "Possible" <<endl;
    }else{
      cout << "Impossible" <<endl;
    }

  	return 0;
}


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

int main()
{
	string S;
	cin >> S;
	vector<int> v = { 0,0,0 };
	for (int i = 0; i < S.size(); i++)
	{
		v[S[i] - 'a']++;
	}
	if (v[0]==1 && v[1] == 1 && v[2] == 1)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256