akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

bool ok(int i) {
    string a = to_string(i);
    string b = a;
    reverse(a.begin(), a.end());
    return a == b;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for(int i = A; i <= B; i++) {
        if(ok(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];

  sort(a.begin(), a.end());
  vector<int> b = a;
  for(int i=0; i<n-1; i++){
    a[i] = min(a[i], a[n-1]-a[i]);
  }

  sort(a.begin(), a.end());

  int x = a[n-1];
  int y = a[n-2];
  for(int i=0; i<n; i++){
    if( b[i] == y || x-b[i] == y ){
      y = b[i];
      break;
    }
  }
  cout << x << " " << y << endl;


  return 0;
}






// EOF


Measured memory_bytes: 1024
n,m=gets.split.map &:to_i
a=[nil]*n
b=[]
n.times{|i| a[i]=gets.split.map &:to_i}
m.times{|i| b.push(gets.to_i)}
n.times{|i|
s=0
m.times{|j| s+=a[i][j]*b[j]}
p s
}

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

namespace q2
{
    class Program
    {
        static bool IsKaibun(string s)
        {
            for (var i = 0; i < s.Length / 2; i++)
            {
                if (s[i] != s[s.Length - i - 1])
                    return false;
            }
            return true;
        }
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var ret = IsKaibun(input) &&
                IsKaibun(input.Substring(0, input.Length / 2)) &&
                IsKaibun(input.Substring((input.Length + 3) / 2- 1));
            Console.Write(ret ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <limits>

#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl


using namespace std;

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
    if (vec.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
        os << vec.back() << '}';
    }
    return os;
}

template <class T, size_t S>
ostream& operator<<(ostream& os, array<T, S> const& arr) {
    if (arr.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
        os << arr.back() << '}';
    }
    return os;
}

template<class T, class U>
ostream& operator<<(ostream& os, pair<T, U> const& p) {
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

namespace math {
    int64_t gcd(int64_t u, int64_t v) {
        while (v != 0) {
            int64_t r = u % v;
            u = v;
            v = r;
        }
        return u;
    }
    int64_t lcm(int64_t m, int64_t n)
    {
        if ((0 == m) || (0 == n))
            return 0;

        return ((m / math::gcd(m, n)) * n);
    }
}

int main(void) {
    int a, b, k;
    cin >> a >> b >> k;

    for(int n = min(a, b); n >= 1; n--) {
        if(a % n == 0 && b % n == 0)
            k--;
        if(k == 0){
            cout << n << endl;
            break;
        }
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		int max = 1;
		for (int i = 2; i * i <= x; i++) {
			int num = i;
			while (num <= x) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
 		}
		
		System.out.println(max);
		sc.close();
	}
}




Measured memory_bytes: 27064
while True:
    t,y=map(int,input().split())
    if t==y==0:
        break
    else:
        for i in range(t):
            for j in range(y):
                if (i+j)%2==0:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        print()


Measured memory_bytes: 7004
#include<iostream>

using namespace std;

int main() {

	int N,K;
	char S[10];

	cin >> N >> S >> K;
	
	for (int i = 0; i < N; i++) {
		if (S[i] != S[K-1])
			S[i] = '*';
	}

	//output
	//for (int i = 0; i < N; i++)
	//	cout << S[i];
	cout << S;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  bool bad = false;
  for (int i = 0; i < S.size()-1; i++) {
    if (S.at(i) == S.at(i+1)) bad = true;
  }
  
  if (bad) 
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  string ans;
  if(n==25)ans="Christmas";
  if(n==24)ans="Christmas Eve";
  if(n==23)ans="Christmas Eve Eve";
  if(n==22)ans="Christmas Eve Eve Eve";
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

long long n,m,v,p;

bool solve(vector<pair<long long,int>> a,int idx)
{
    long long now=a[idx].first+m; //height of my index
    long long sum=m*v-m; //how many votes left
    vector<long long> up(n,m); //how much more can you raise it
    up[idx]=0;
    for(int i=0;i<n;i++)
    {
        if(a[i].first<=now)
        {
            long long t=min(min(sum,m),min(now-a[i].first,up[a[i].second]));
            a[i].first+=t;
            sum-=t;
            up[a[i].second]-=t;
        }
        else
        {
            long long t=min(min(sum,m),up[a[i].second]);
            a[i].first+=t;
            sum-=t;
            up[a[i].second]-=t;
        }
    }
    vector<pair<long long,int>> b; //up[i],i
    for(int i=0;i<n;i++)
    {
        if(a[i].first==now&&a[i].second!=idx) b.push_back({up[a[i].second],i});
    }
    sort(b.begin(),b.end(),greater<pair<long long,int>>());
    for(pair<long long,int> c:b)
    {
        long long t=min(min(sum,m),c.first);
        sum-=t;
        a[c.second].first+=t;
        up[a[c.second].second]-=t;
    }
    int cnt=0;
    for(int i=0;i<n;i++) if(a[i].first>now) cnt++;
    return (cnt<p);
}

int main()
{
    cin >> n >> m >> v >> p;
    vector<pair<long long,int>> a(n);
    for(int i=0;i<n;i++) cin >> a[i].first;
    sort(a.begin(),a.end(),greater<pair<long long,int>>());
    for(int i=0;i<n;i++) a[i].second=i;
    int l=-1,r=n;
    while(l<r-1)
    {
        int mid=(l+r)/2;
        if(solve(a,mid)) l=mid;
        else r=mid;
    }
    printf("%d\n",l+1);
    return 0;
}


Measured memory_bytes: 8372
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int a = sc.nextInt();
    int sum = 0;
    while (true) {
      h = h - a;
      sum++;
      if (h <= 0) {
        break;
      }
    }
    System.out.println(sum);
  }
}

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



struct comp{
	bool operator()(const pair<int,int>& a,const pair<int,int>& b){
		return a.second > b.second;
	}
};



int main() {
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0)cout<<1;
	else if(b==0)cout<<2;
	else if(c==0)cout<<3;
	else if(d==0)cout<<4;
	else cout<<5;
	return 0;
}

Measured memory_bytes: 3592
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = "abcdefghij";
    char[] ss;
    ss.length = N;
    void solve(int i, int j) {
        if (i == N) {
            writeln(ss);
            return;
        }

        foreach (k; 0..j+2) {
            ss[i] = as[k];
            solve(i+1, max(j, k));
        }
    }

    solve(0, -1);
}

Measured memory_bytes: 1532
n,m = map(int,input().split())

h = list(map(int,input().split()))

# a = [0] * m
# b = [0] * m

ma = [0]*n


for i in range(m):
    a, b = map(int,input().split())
    a -= 1; b -= 1
    ma[a] = max(ma[a],h[b])
    ma[b] = max(ma[b],h[a])

ans = 0    
for i in range(n):
    if h[i] > ma[i]:
        ans += 1
        

print(ans)

Measured memory_bytes: 84844
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head

int x,s,t,m,n,k,res;
int a[501000] = {};
int b[501000] = {};
int c[501000] = {};
vector<PII> g[500010];
queue<int> que2;
ll dp1[100010]={}, dp2[100010]={};
//string s;
vector<ll> dijkstra(ll n, vector<pair<ll,ll> >* G, ll s) {
    vector<ll> d(n, 1ll<<60); d[s] = 0;
    priority_queue<pair<ll, ll> > que;
    que.push(make_pair(0ll, s));
    while (!que.empty()) {
			auto p = que.top();que.pop();
			ll prov_cost = p.first;
			ll src = p.second;
			if(d[src]<prov_cost) continue;
			rep(i,0,g[src].size()){
				ll dest = g[src][i].first;
				ll weight = g[src][i].second;
				if ((d[dest] > d[src] + weight)){
					d[dest] = d[src] + weight;
					que.push({-d[dest],dest});
				}
			}
		}
    return d;
}

signed main() {
	std::cin >>n>>m>>s>>t;
	s--,t--;
	rep(i,0,m){
		std::cin >> a[i]>>b[i]>>c[i];
		b[i]--,a[i]--;
		g[a[i]].pb(mp(b[i], c[i]));
		g[b[i]].pb(mp(a[i], c[i]));
	}
	vector<ll> d = dijkstra(n, g, s);
	vector<PII> vec;
	rep(i,0, n) vec.pb({d[i], i});
	sort(all(vec));
	dp1[s] = 1;
	rep(i,0,n){
		for(auto e : g[vec[i].second]){
			if(d[vec[i].second] + e.second == d[e.first]) {
        dp1[e.first] += dp1[vec[i].second];
				dp1[e.first] %= mod;
      }
		}
	}
	d = dijkstra(n, g, t);


	vector<ll> d1 = dijkstra(n, g, s);
	dp2[t] = 1;
for(int i=n-1; i>=0; --i) {
	for(PII e: g[vec[i].second]) {
		if(d1[vec[i].second] == d1[e.first] + e.second) {
			dp2[e.first] += dp2[vec[i].second];
			dp2[e.first] %= mod;
		}
	}
}
	res = dp1[t]*dp2[s]%mod;
	rep(i,0,n){
		if( d[i]*2ll == d[s] && d1[i]*2ll == d1[t]){
			res -= ((dp1[i]%mod*dp1[i]%mod)*dp2[i]%mod)*dp2[i]%mod;
			res += mod;
			res %= mod;
		}
	}

	rep(i,0,m){
		if(d1[a[i]]*2ll <d[s] && d[b[i]]*2ll <d[s] && d[b[i]]+c[i] == d[a[i]] && d1[a[i]]+c[i] == d1[b[i]]){
			res -= ((dp1[a[i]]%mod*dp1[a[i]]%mod)*dp2[b[i]]%mod)*dp2[b[i]]%mod;
			res += mod;
			res %= mod;
		}
		else if (d[a[i]]*2ll < d[s] && d1[b[i]]*2ll < d[s] && d[a[i]]+c[i] == d[b[i]] && d1[b[i]]+c[i] == d1[a[i]]){
			res -= ((dp2[a[i]]%mod*dp2[a[i]]%mod)*dp1[b[i]]%mod)*dp1[b[i]]%mod;
			res += mod;
			res %= mod;
		}
	}
	res %= mod;
	std::cout << res << '\n';
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<pll> p(N);
    REP(i, N){
    	cin >> p[i].first >> p[i].second;
    }

    ll M = 10000;
    double kaku = 2*M_PI/M;
    double res = -1;
    REP(i, M){
    	double now = 0.01 + i*kaku;
    	double x = sin(now);
    	double y = cos(now);
    	double x_tmp = 0, y_tmp = 0;
    	//dump(now)
    	//dump(x)
    	//dump(y)
    	REP(j, N){
    		if(p[j].first * x + p[j].second * y >=0 ) x_tmp += p[j].first, y_tmp += p[j].second;
    	}
    	res = max(res, sqrt(x_tmp * x_tmp + y_tmp * y_tmp));
    	//dump(res)
    }
    printf("%.10f\n", res);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
void mozi_sort(char str[], int length) {
	int tmp[10000] = {};
	int memo = 0;
	for (int i = 0; i < length; i++) {
		tmp[(int)str[i]]++;
	}
	for (int i = 0; i < 256; i++) {
		while (tmp[i] > 0) {
			str[memo] = (char)i;
			memo++;
			tmp[i]--;
		}
	}
}
//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}
int main() {
	long long int a, b, c, d, n, m, num[2000][2] = {}, result = 0;
	char str[200005];
	scanf("%s", str);
	printf("%c%d%c", str[0], strlen(str)-2, str[strlen(str)-1]);
			
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define MAX_N 1001
#define rank dfasfds
using namespace std;
int par[MAX_N],rank[MAX_N];

void init(int n){for(int i=0;i<n;i++)par[i]=i,rank[i]=0;}

int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}

void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=y;
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
bool same(int x,int y){return find(x)==find(y);}

struct edge{
  int a,b,c;
  bool operator < (edge t) const{return c<t.c;}
};

int n,m;
edge e[10001];
int solve(){
  init(n+1);
  for(int i=0,cnt=0;i<m;i++){
    if(same(e[i].a,e[i].b)) continue;
    unite(e[i].a,e[i].b);
    if(cnt++==(n-1)/2) return e[i].c;
  }
  return 0;
}

int main(){
  while(1){
  cin>>n>>m;
  if(!n&&!m)return 0;
  for(int i=0;i<m;i++)cin>>e[i].a>>e[i].b>>e[i].c;
  sort(e,e+m);
  cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    string str;
    cin>>str;
    if(str=="0"){
      break;
    }
    int sum=0;
    for(int i=0;i<(int)str.size();i++){
      sum+=str[i]-'0';
    }
    cout<<sum<<endl;
  }
  return 0;
}


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

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


K = int(input())

print(A[K-1])

Measured memory_bytes: 38384
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int a[100];
    int i;
    int min, max;
    for (i = 0; i < n; i++)
        scanf("%d", a + i);
    min = max = a[0];
    for (i = 1; i < n; i++) {
        if (a[i] < min)
            min = a[i];
        if (a[i] > max)
            max = a[i];
    }
    printf("%d\n", max - min);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)


int main(){
	ll H;
	cin>>H;

	ll kougeki_kaisuu = 0;
	ll ni_kaizyou = 1;	
	while(H > 0){
		H = H / 2;
		kougeki_kaisuu += ni_kaizyou;
		ni_kaizyou = ni_kaizyou * 2;
	}

	cout<<kougeki_kaisuu<<endl;
	return 0;
}



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

int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	
	if (0 < c - a - b && 4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

/* Cheating Sheets {{{ 1

{{{ 2 priority_queue
    <T,vector<T>,less<T> or greater<T>>
    int top()
    void push()
    void pop()
    bool empty()
}}} 2



}}} 1 ***/

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)
// }}} 2

// numerous {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// systems }}} 2

// }}} 1


int main() {

    priority_queue<int,vector<int>,greater<int> > P;

    int n,x;
    int a;
    Scd2( n, x);
    Rep( i , n ){
        Scd(a);
        P.push( a );
    }

    int cnt = 0;
    while( !0 ){
        x -= P.top();
        P.pop();
        if( x < 0 ) break;
        if( x > 0 && P.empty() ) break;
        cnt++;
    }

    printf ("%d\n", cnt);

    return 0;
}



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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int64_t N, K, Q;
  cin >> N >> K >> Q;
  vector<int64_t> scores(N + 1, K - Q);
  for (int64_t i = 1; i <= Q; ++i) {
    int64_t A;
    cin >> A;
    ++scores[A];
  }

  for (int64_t i = 1; i <= N; ++i) {
    cout << (scores[i] > 0 ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int n; cin >> n;
    vector<int> a(n + 1, 0);
    vector<int> b(n + 1, 0);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        b[i] += b[i - 1];
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, a[i] - a[0] + b[n] - b[i - 1]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int b1,b2,b3;
	scanf("%d",&b1);
	scanf("%d",&b2);
	scanf("%d",&b3);
	
	if(b1==1 && b2==0 && b3==0) {
		printf("Close\n");
	}
	else if(b1==0 && b2==1 && b3==0) {
		printf("Close\n");
	}
	else if(b1==0 && b2==0 && b3==1) {
		printf("Open\n");
	}
	else if(b1==1 && b2==1 && b3==0) {
		printf("Open\n");
	}
	else if(b1==0 && b2==0 && b3==0) {
		printf("Close\n");
	}
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const int MAX_N = 112345;
int accepted[MAX_N];
int wrong[MAX_N];

int main2() {

  CLR(accepted, 0);
  CLR(wrong, 0);

  int N = nextInt();
  int M = nextInt();

  int ac = 0;
  int wa = 0;
  REP(i, M) {
    int a = nextInt();
    string s; cin >> s;

    if (s == "AC") {
      accepted[a] = true;
    } else {
      if (!accepted[a]) wrong[a]++;
    }
  }

  REP(i, N+1) if (accepted[i]) { ac++; wa += wrong[i]; }

  cout << ac << " " << wa << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
ll i;

int main(){
    ll N,M;
    cin>>N>>M;
    V A(N);
    rep(i,N)cin>>A.at(i);
    ll sum=0;
    rep(i,N)sum+=A.at(i);
    sort(A.begin(),A.end(),greater<ll>());
    if(A.at(M-1)*4*M>=sum)cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}


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


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<int> vec;
    while(n!=0)
    {
        int tn = n%26;
        if (tn == 0)
        {
            tn = 26;
            n -= 26;
        }
        vec.push_back(tn);
        n/=26;
        
        // if (n==0) break;
    }
    reverse(vec.begin(), vec.end());
    rep(i,vec.size())
    {
        int tmpn = vec[i]-1;
        tmpn += 26;
        tmpn %= 26;
        char c = 'a' + tmpn;
        cout << c;
    }
    cout << endl;

    // rep(i,vec.size()) cout << vec[i]-1 << " ";
}


Measured memory_bytes: 3620
#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>

int main()
{
	int N, K;
	std::vector<int> H;
	std::cin >> N >> K;
	for (int i = 0; i < N; ++i)
	{
		int t;
		std::cin >> t;
		H.push_back(t);
	}
	std::sort(H.begin(), H.end(), std::greater<int>());

	long sol = 0;
	for (int i = K; i < N; i++)
	{
		sol += H[i];
	}
	std::cout << sol << std::endl;
}

Measured memory_bytes: 1400
package main

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

func main() {
  var stdin = bufio.NewScanner(os.Stdin)
  stdin.Scan()
  var n, _ = strconv.Atoi(stdin.Text())
  var cubic = n * n * n
  fmt.Println(cubic)
}


Measured memory_bytes: 1080
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, A, B, C, D;

int main()
{
	in >> N >> A >> B >> C >> D;

	rep(m, N)
	{
		if ((N - m - 1)*C - m*D <= abs(A - B) && abs(A - B) <= (N - m - 1)*D - m*C)
		{
			out << "YES" << std::endl;
			return 0;
		}
	}
	out << "NO" << std::endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static StringBuilder sb;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0)break;
			Map<String,String> map=new HashMap<String,String>();
			for(int i=0;i<n;i++){
				map.put(sc.next(),sc.next());
			}
			int m=sc.nextInt();
			sb=new StringBuilder();
			for(int i=0;i<m;i++){
				String s=sc.next();
				if(map.containsKey(s))sb.append(map.get(s));
				else sb.append(s);
			}
			System.out.println(sb.toString());
		}
	}
}

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

int a[100010] = {};

int main(void){
    // Here your code !
    int n,result = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    
    for(int i = 1; i <= n; i++){
        if(i == a[a[i]]){
            result++;
        }
    }
    
    cout << result / 2 << endl;
    
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main () {
    int n, s; cin >> n >> s;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<vector<mint>> dp(n+1, vector<mint> (s+1));
    dp[0][0] = 1;
    rep(i, n) {
        rep(j, s+1) {
            dp[i+1][j] += dp[i][j]*2;
            if (j+a[i] <= s) {
                dp[i+1][j+a[i]] += dp[i][j];
            } 
        }
    }
    cout << dp[n][s] << endl;

    return 0;
}

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



public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		String s = fs.next();
		if(s.equals("AAA") || s.equals("BBB") || s.equals("CCC")) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}

}

class FastScanner {
    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() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; 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 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 int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23124
#include <algorithm>
#include <iostream>
#include <vector>
#include <string> 
#include <set>
typedef long long ll;
using namespace std;

int inf = 1000001;
int mod = 1e9 + 7;
int arr[200007];
int main() {
    int n; cin >> n;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        sum += arr[i];
        sum = sum % mod;
    }
    ll res = 0;
    for (int i = 0; i < n; ++i) {
        sum -= arr[i]; 
        if (sum < 0)sum += mod;
        res += sum * arr[i];
        res = res % mod;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4388
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define MINF -1000000000

typedef pair<int,int> pii;

const int K = 11;
const int M = 2001;

int dp[K][M];

int main(){
	
	int n,m;
	cin>>n>>m;
	
	vector<int> book[K];
	
	rep(i,n){
		int a,b;
		cin>>a>>b;
		book[b].push_back(a);
	}
	
	rep(i,K){
		sort(book[i].begin(), book[i].end());
		reverse(book[i].begin(), book[i].end());
	}
	
	vector<int> sum[K];
	rep(i,K){
		sum[i].push_back(0);
		rep(j,book[i].size()){
			sum[i].push_back( sum[i][j]+book[i][j]+(j*2) );
		}
	}
	
	/*
	rep(i,K){
		rep(j,sum[i].size()){
			printf("%d ",sum[i][j]);
		}puts("");
	}*/
	
	rep(i,K)rep(j,M)dp[i][j]=MINF;
	reps(j,1,M)dp[0][j]=0;
	
	
	for(int i=1; i<K; i++){
		for(int j=1; j<M; j++){
			for(int k=0; k<sum[i].size(); k++){
				if(j-k < 0)break;
				dp[i][j] = max(dp[i][j], dp[i-1][j-k]+sum[i][k]);
			}
		}
	}
	
	/*
	reps(i,1,3+1){
		reps(j,1,4+2){
			if(dp[i][j]==MINF)printf("oo ");
			else printf("%2d ",dp[i][j]);
		}puts("");
	}*/
	
	printf("%d\n",dp[K-1][m+1]);
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
using namespace std;
     
     
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
#define forn(i,a,n) for(int i = a; i < n ; i++)
const int MOD = 1e9+7, N = 1e7 + 10;

int main() {
    int n;
    cin >> n;
    int arr[n];
    int temp = 1;
    int count = 0;
    forn(i,0,n) {
        cin >> arr[i];
        if(arr[i] == temp) {
            temp++;
        }
        else
            count++;
    }
    if(count == n)
        count = -1;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>

using namespace std;

typedef long long ll;

ll n, m, ans;
priority_queue <ll> q;

int main()
{
    cin >> n >> m;
    for (ll i = 1; i <= n; i++)
    {
        int now;
        cin >> now;
        q.push(now);
    }
    for (ll i = 1; i <= m; i++)
    {
        ll x = q.top();
        q.pop();
        x /= 2;
        q.push(x);
    }
    while (!q.empty())
    {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  
  char km[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  char om[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  
  char za=s[k-1];
  
  for(int tt=0;tt<=25;tt++){
    if(za==om[tt]){
      s[k-1]=km[tt];
      break;}
  }
  cout<<s<<endl;
 
}

Measured memory_bytes: 256
x,K,D=map(int,input().split())
X=abs(x)
ans=0
if D<X and K*D > X:
    if (K-X//D)%2==0:
        ans=X%D
    else:
        ans=D-X%D
    
elif D<X and K*D<=X:
    ans=X-D*K
elif D>=X:
    if K%2 ==0:
        ans=X
    else:
        ans=D-X
print(abs(ans))



Measured memory_bytes: 61648
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 5e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n; vector<ll>a(n + 1);
	vector<ll>b(n);
	for (ll i = 1; i <= n; i++) cin >> a[i];
	ll kek = 0;
	for (ll i = 1; i <= n; i++) {
		if (i % 2)kek += a[i];
		else kek -= a[i];
	}
	b[0] = kek / 2;
	for (ll i = 1; i < n; i++) {
		b[i] = a[i] - b[i-1];
	}
	for (ll i = 0; i < n; i++) b[i] *= 2, cout << b[i] << " ";
	return 0;
}
/*

*/

Measured memory_bytes: 2944
n=int(input())
data=[]
for i in range(n):
    data.append(int(input()))
leftmin=data[0]
for j in range(1,n):
    if data[j-1]<leftmin:
        leftmin=data[j-1]
    ansj=data[j]-leftmin
    if j==1:
        ans=ansj
    else:
        if ansj>ans:
            ans=ansj

print(ans)



Measured memory_bytes: 13592
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
const int MOD = 1000000007;

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

	vi p(1000 + 1, 1);
	p[0] = p[1] = 0;
	FOR(i, 2, 100) {
		if (p[i]) {
			for (int j = i*i; j <= 1000; j += i) {
				p[j] = 0;
			}
		}
	}

	vi c(1000 + 1, 0);
	ll ans = 1;
	FOR(i, 2, N) {
		int m = i;
		FOR(j, 2, 1000) {
			if (p[j] == 1) {
				while (m%j == 0) {
					c[j]++;
					m /= j;
				}
			}
		}
	}

	FOR(i, 2, 1000) {
		ans = (ans * (c[i] + 1)) % MOD;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc166/tasks/abc166_e

fun main() {
    abc166e()
}

fun abc166e() {
    val n = readLine()!!.toInt()
    val height = readLine()!!.split(" ").map { it.toLong() }
    var count = 0L
    val plus = mutableMapOf<Long, Long>()
    val minus = mutableMapOf<Long, Long>()
    for ((i, v) in height.withIndex()) {
        val p = i.toLong() + 1L + v
        val m = i.toLong() + 1L - v
        plus[p] = plus.getOrDefault(p, 0L) + 1L
        minus[m] = minus.getOrDefault(m, 0L) + 1L
    }
    for ((key, value) in plus) {
        count += (minus.getOrDefault(key, 0L) * value)
    }
    println(count)
}


Measured memory_bytes: 97060
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int MAX_N=100000;
const int MAX_Q=100000;
int par[MAX_N+1];
bool vis[MAX_N+1];
int N, Q;

int main(){
    while(scanf("%d %d", &N, &Q)&&N>0){
        memset(vis, 0, sizeof(vis));
        vis[1]=1;
        par[1]=1;
        for(int i=2; i<=N; i++) scanf("%d ", &par[i]);
        long long cnt=0;
        for(int i=1; i<=Q; i++){
			char ch; int num;
        	scanf("%c ", &ch); 
			scanf("%d ", &num); 
           if(ch=='M'){
                vis[num]=1;
            }
            else if(ch=='Q'){
                int cur=num;
                while(cur>0){
                    if(vis[cur]){
                        cnt+=cur;
                        break;
                    }
                    else cur=par[cur];
                } 
            }
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 3648
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        for(int i = 0; i < n; i+=2){
            System.out.print(s.charAt(i));
        }
        System.out.println();
    }
}


Measured memory_bytes: 29532
#include <iostream>
#include <cstring>
#include <stack>
#include <vector>

using namespace std;
stack<int>S;
stack< pair<int,int> >S1;
vector<int>V;
int main()
{
    char water[20000];
    int sum=0;
    int count = 0;
    int sum_temp=0;
    int j;
    cin>>water;
    for(int i=0;i<strlen(water);i++)
    {
        if(water[i]=='\\')
            S.push(i);
        else if(water[i]=='/' && !S.empty())
        {
            j=S.top();
            sum+=(i-j);
            sum_temp=i-j;
            S.pop();
            while(!S1.empty() && S1.top().first>j)
            {
                sum_temp+=S1.top().second;
                S1.pop();
            }
            S1.push(make_pair(j,sum_temp));
        }
    }
    cout<<sum<<endl;
    cout<<S1.size();
    int len=S1.size();
    for(int i=0;i<len;i++) {
        V.push_back(S1.top().second);
        S1.pop();
    }
    for(int i=V.size()-1;i>=0;i--)
        cout<<' '<<V[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3252
<?php
$arrA = ['.','#'];
$arrB = ['#','.'];
while(true){
    fscanf(STDIN,"%d %d",$h,$w);
    if( $h===0 and $w===0 ) break;
    for ( $i = 0 ; $i < $h ; $i ++){
        for ( $j = 0 ; $j < $w ; $j++ ){
            if( $i%2 === 0){
                echo $arrB[$j%2];
            }else{
                echo $arrA[$j%2];
            }
        }
        echo PHP_EOL;
    }
    echo PHP_EOL;
}

Measured memory_bytes: 15244
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define fi first
#define se second
const int LEN = 2e5+5;
typedef long long ll;
int n, dp[LEN];
int main() {

   // freopen ("myfile.txt","r",stdin);
   // freopen ("myfile.txt","w",stdout);

   // ios_base::sync_with_stdio(0); cin.tie(NULL);
   scanf("%d",&n);
   int ar[LEN];
   for(int i =0;i<n;i++) {
   		scanf("%d",&ar[i]);
   }

   dp[0] = 0;
   dp[1] = abs(ar[1]-ar[0]);
   for(int i =2;i<n;i++) {
   		dp[i] = min(abs(ar[i]-ar[i-2])+dp[i-2],abs(ar[i]-ar[i-1])+dp[i-1]);
   }
   cout<<dp[n-1]<<endl;
}   

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
constexpr long long int MOD = 1000000007;
int main() {
	int n, k; std::cin >> n >> k;
	std::vector<int> numbers(n); for (auto& a : numbers) std::cin >> a;
	std::sort(numbers.begin(), numbers.end());
	std::vector<long long int> factorial(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1);
	for (auto i = 2; i <= n; ++i) {
		factorial[i] = i * factorial[i - 1] % MOD;
		inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
		inv_fact[i] = inv[i] * inv_fact[i - 1] % MOD;
	}
	long long int result = 0;
	int length = 1;
	for (auto i = 0; i < numbers.size(); ++i) {
		if (i == numbers.size() - 1 || numbers[i] != numbers[i + 1]) {
			const auto prev = (i + 1) - length;
			const auto next = n - i - 1;
			if (prev + length >= k) {
				const auto all = factorial[prev + length] * inv_fact[k] % MOD * inv_fact[prev + length - k] % MOD;
				const auto not_p = (prev >= k) ? (factorial[prev] * inv_fact[prev - k] % MOD * inv_fact[k] % MOD) : 0LL;
				result += (all - not_p) % MOD * numbers[i] % MOD;
				result %= MOD;
			}
			if (next + length >= k) {
				const auto all = factorial[next + length] * inv_fact[k] % MOD * inv_fact[next + length - k] % MOD;
				const auto not_p = (next >= k) ? (factorial[next] * inv_fact[next - k] % MOD * inv_fact[k] % MOD) : 0LL;
				result -= (all - not_p) % MOD * numbers[i] % MOD;
				result %= MOD;
			}
			length = 1;
		}
		else ++length;
	}
	std::cout << (result % MOD + MOD) % MOD << std::endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    vector<int> ans(n+1);
    int m = 0;
    for(int i = n; i > 0; i--){
        int tmp = 0;
        for(int j = i; j  <= n; j += i){
            tmp += ans[j];
        }
        if(tmp%2 != a[i]){
            ans[i] ++;
        }
    }
    for(int i = 1; i <= n; i++){
        if(ans[i] != 0){
            m++;
        }
    }
    cout << m << endl;
    for(int i = 1; i <= n; i++){
        if(ans[i] != 0){
            cout << i << " ";
        }
        
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2432
#include<stdio.h>

int main(void)
{
        int v1 = 0,v2 = 0;
        int i = 0, j = 0;
        int line[10]={0,0,0,0,0,0,0,0,0,0};
        int sum = 0;
        double x = 0, y = 0;
        int ans=0;

        while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"
                , &line[0], &line[1], &line[2], &line[3], &line[4],
                  &line[5], &line[6], &line[7], &line[8], &line[9], &v1, &v2) != EOF)
        {

                for(i = 0;i < 10; i++)
                {
                        sum += line[i];
                }
                y = (double)sum / ((double)v2 / (double)v1 + 1);
                x = (double)v2 / (double)v1 * y;
/*
                printf("y=%f\n",y);
                printf("x=%f\n",x);
*/
                sum = 0;
                for(i = 0; i < 10; i++)
                {
                        sum = sum +  line[i];
                        if(sum >= y)
                        {
                                printf("%d\n",i+1);
                                break;
                        }
                }
                sum = 0;
                x = 0;
                y = 0;
        }
        return 0;
}

Measured memory_bytes: 596
import java.util.*;

class Main{
    Main(){
        Scanner SC = new Scanner(System.in);

        long N = Long.parseLong(SC.next());
        long A = Long.parseLong(SC.next());
        long B = Long.parseLong(SC.next());

        long R = N / (A+B) * A;
        if( N%(A+B) > A){
            R += A;
        } else {
            R += N % (A+B);
        }

        System.out.println(R);
    }

    public static void main(String[] args){
        Main main = new Main();
    }
}


Measured memory_bytes: 23124
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    string revs;
    cin >> revs;
    int n = revs.size();
    string s = revs;
    reverse(revs.begin(), revs.end());

    if (revs == s){
        int i = 0;
        int j = (n-1)/2-1;
        for(int a = i; a < j; a++){
            if (s[a] != s[j-a]) {cout<< "No";rn 0;}
        }
        i = (n+3)/2-1;
        j = (n-1);
        for(int a = i; a < j; a++){
            if (s[a] != s[j-a]) {cout<< "No";rn 0;}
        }
        cout << "Yes";
        rn 0;
    }
    cout << "No";
    rn 0;
    
    
}


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

int main(){
  int n;
  for (int i = 1; 1; i++ ){
    cin >> n;
    if ( n == 0 ) break;
    cout << "Case" << " "  << i;
    cout << ":" << " " << n << endl;
  }

  return 0;
}

Measured memory_bytes: 2996