akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, K; cin >> N >> K;
    ll mxa = -1, mna = LINF; vl A(N);
    REP(i, N){
        cin >> A[i];
        mxa = max(mxa, A[i]);
        mna = min(mna, A[i]);
    }
    if(mxa < K){
        cout << "IMPOSSIBLE" << endl; return 0;
    }
    
    ll g = A[0];
    REP(i, N) g = gcd(g, A[i]);
    REP(i, N){
        if(abs(K-A[i])%g == 0){
            cout << "POSSIBLE" << endl; return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

using namespace std;

const int MAX = 5 * 100001;

int ans = 0;
vector<int> cnt(MAX);
vector<int> a(MAX);
void remove(int idx){
	 --cnt[a[idx]];
	 if(cnt[a[idx]]==0) --ans;		
}
void add(int idx){
	++cnt[a[idx]];
	if(cnt[a[idx]]==1) ++ans;
}
int get_answer(){
	return ans;
}

int block_size = 600;

struct Query {
    int l, r, idx;
    Query(int l, int r, int idx){
    	this->l = l;
    	this->r = r;
    	this->idx = idx;
    	
	}
	bool operator<(Query other) const
    {
        return make_pair(l , r) <
               make_pair(other.l , other.r);
    }
 
};

bool cmp(const Query& p, const Query& q) {
    if (p.l / block_size != q.l / block_size)
        return p < q;
    return (p.l / block_size & 1) ? (p.r < q.r) : (p.r > q.r);
}

vector<int> mo_s_algorithm(vector<Query> queries) {
    vector<int> answers(queries.size());
    sort(queries.begin(), queries.end(),cmp);

    // TODO: initialize data structure

    int cur_l = 0;
    int cur_r = -1;
    // invariant: data structure will always reflect the range [cur_l, cur_r]
    for (Query q : queries) {
    //	cout << q.l << "  --  " << q.r << "\n"; 
        while (cur_l > q.l) {
            cur_l--;
            add(cur_l);
        }
        while (cur_r < q.r) {
            cur_r++;
            add(cur_r);
        }
        while (cur_l < q.l) {
            remove(cur_l);
            cur_l++;
        }
        while (cur_r > q.r) {
            remove(cur_r);
            cur_r--;
        }
        answers[q.idx] = get_answer();
    }
    return answers;
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	int n,  q;
	cin >> n >> q;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	vector<Query> qu;
	for(int i = 0; i < q; i++){
		int l,r;
		cin >> l >> r;
		--l,--r;
		Query tmp(l,r,i);
	//	cout << tmp.l << " " << tmp.r << "\n";
		qu.push_back(tmp);
	}
	vector<int> ans = mo_s_algorithm(qu);
	for(int i = 0; i < q; i++){
		cout << ans[i] << " \n";
	}
	return 0;
}


Measured memory_bytes: 20780
using System;
using System.Linq;

namespace ABC86
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Solve1();
        }
    }

    public class Solver
    {

        public void Solve1()
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(ab[0] * ab[1] % 2 == 0 ? "Even" : "Odd");

        }

    }
}


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

#define MAX 101

int arr[MAX];

int main() {

    int N;
    int sum, prevsum;
    while (std::cin >> N) {
        for (int i = 0; i < N; i++) std::cin >> arr[i];
        std::sort(arr, arr+N);
        sum = prevsum = 0;

        for (int i = 0; i < N; i++) {
            sum += arr[i] + prevsum;
            prevsum += arr[i];

        }

        std::cout << sum << std::endl;
    }

    return  0;


}



Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
using namespace std;
int dp[102][1 << 16], x[102][16];
int N, M, S, E, L;
int main() {
	while (true) {
		for (int i = 0; i < 102; i++) {
			for (int j = 0; j < (1 << 16); j++) {
				dp[i][j] = 0; x[i][j % 16] = 0;
			}
		}
		cin >> N; if (N == 0)break;
		for (int i = 0; i < N; i++) {
			cin >> M >> L; int V = 0;
			for (int j = 0; j < M; j++) {
				cin >> S >> E; S -= 6; E -= 6;
				for (int k = S; k < E; k++) {
					x[i][k] = 1; V += (1 << k);
				}
			}
			for (int j = 0; j < (1 << 16); j++)dp[i + 1][j] = dp[i][j];
			for (int j = 0; j < (1 << 16); j++) {
				int bit[16], T; for (int k = 0; k < 16; k++)bit[k] = (j / (1 << k)) % 2;
				int OK = 0; for (int k = 15; k >= 0; k--) { if (x[i][k] == 1 && bit[k] == 1) { j += (1 << k) - 1; goto E; } }
				T = j | V;
				dp[i + 1][T] = max(dp[i + 1][T], dp[i][j] + L);
			E:;
			}
		}
		int maxn = 0;
		for (int i = 0; i < (1 << 16); i++)maxn = max(maxn, dp[N][i]);
		cout << maxn << endl;
	}
	return 0;
}

Measured memory_bytes: 27276
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#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 <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(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 EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);


struct node{
	vs f;
	pii pos;
	string hash;
	node(vs f,pii pos):f(f),pos(pos){
	hash=to_s();}
	string to_s() const{
		if(hash!=""){
			return hash;
		}
		int n=f.size();
		string ret; 
		REP(i,n){
			REP(j,n){
				ret+=pos.first==i&&pos.second==j?'@':f[i][j];
			}
		}
		return ret;
	}
	bool operator<(const node &other)const{
		return hash<other.hash;
	}
};
int dy[]={-1,-1,-1,0,1,1,1,0};
int dx[]={-1,0,1,1,1,0,-1,-1};

vs change(vs &f,int y,int x){
	int n=f.size();
	vs nf(f);
	REP(i,n){
		REP(j,n){
			if(y==i&&x==j)continue;
			int cnt=0;
			REP(d,8){
				int yy=i+dy[d];
				int xx=j+dx[d];
				if(yy>=0&&xx>=0&&yy<n&&xx<n){
					cnt+=f[yy][xx]=='#'||(y==yy&&x==xx);
				}
			}
			switch(f[i][j]){
			case '.':
				nf[i][j]=cnt==3?'#':'.';
				break;
			case '#':
				nf[i][j]=(cnt==2||cnt==3?'#':'.');
				break;
			default:
				assert(0);
			}
		}
	}
	return nf;
}

bool done(vs &f){
	int n=f.size();
	REP(i,n){
		REP(j,n){
			if(f[i][j]=='#'){
				return false;
			}
		}
	}
	return true;
}

int main(){
	int N;
	while(cin>>N,N){
		vs f(N);
		pii p;
		REP(i,N){
			cin>>f[i];
			REP(j,N){
				if(f[i][j]=='@'){
					p=make_pair(i,j);
					f[i][j]='.';
				}
			}
		}
		queue<node> q;
		map<node,int> cost;
		q.push(node(f,p));
		cost[node(f,p)]=0;
		int ans=-1;
		while(q.size()){
			node n=q.front();q.pop();
			if(done(n.f)){
				ans=cost[n];
				break;
			}
			REP(d,8){
				int y=n.pos.first+dy[d];
				int x=n.pos.second+dx[d];
				if(y>=0&&x>=0&&y<N&&x<N){
					if(n.f[y][x]=='.'){
						vs nf=change(n.f,y,x);
						node nnode(nf,make_pair(y,x));
						if(!EXIST(cost,nnode)){
							cost[nnode]=cost[n]+1;
							q.push(nnode);
						}
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

int N;
string s;

int main() {
    cin>>N>>s;
    int cnt=0;
    for (int i=0; i<s.size()-2; i++) {
        if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[4];
int n,i;
string s;

int main()
{
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        if(s.at(0)=='A')
            a[0]++;
        if(s.at(0)=='W')
            a[1]++;
        if(s.at(0)=='T')
            a[2]++;
        if(s.at(0)=='R')
            a[3]++;
    }
    cout<<"AC x "<<a[0]<<"\nWA x "<<a[1]<<"\nTLE x "<<a[2]<<"\nRE x "<<a[3];
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 5;

int n, q;
vector<vector<int> > tree;
vector<int> cmd, ans;

void dfs(int v, int p) {
  if (p != -1) {
    ans[v] += ans[p];
  }
  ans[v] += cmd[v];
  for (int i = 0; i < tree[v].size(); i++) {
    if (tree[v][i] != p) {
      dfs(tree[v][i], v);
    }
  }
}

int main()
{
  cin >> n >> q;
  tree.resize(n);
  cmd.resize(n, 0);
  ans.resize(n, 0);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  for (int i = 0; i < q; i++) {
    int p, x;
    cin >> p >> x;
    p--;
    cmd[p] += x;
  }
  dfs(0, -1);

  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

map<string, string> mp, mpg, mpa;


/*--------------------template--------------------*/

int main() {

    cin >> n >> m;
    cout << (double)2 * m - n << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int w,h,x,y,r;
scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
if(x+r<=w && x-r>=0 && y-r>=0 && y+r<=h){
printf("Yes\n");
}
else{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 1820
N,M=map(int,input().split())

parent = [i for i in range(N+1)]
distance = [0 for i in range(N+1)]
depth = [1 for i in range(N+1)]

def root(x):
    if x == parent[x]:
        return x
    else:
        return root(parent[x])

def to_root(x):
    if x == parent[x]:
        return 0
    else:
        return distance[x] + to_root(parent[x])

for _ in range(M):
    L, R, D = map(int, input().split())
    # print("distance", D, to_root(L), to_root(R))
    # print("root    ", root(L), root(R))
    # print(_, L, R, D)
    if root(L) == root(R):
        l = to_root(L)
        r = to_root(R)
        # print("distance", D, l, r)
        # print("root    ", root(L), root(R))
        if D != r-l:
            # print(parent)
            # print(distance)
            print("No")
            exit()
    else:
        rootL = root(L)
        rootR = root(R)
        if depth[rootL] < depth[rootR]:
            L,R = R,L
            D = -D
        rootL = root(L)
        rootR = root(R)
        parent[rootR] = rootL
        distance[rootR] = -to_root(R)+to_root(L)+D
        depth[rootL] = max(rootL, depth[rootR]+1)
print("Yes")


Measured memory_bytes: 10272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  long long s =0;
  for(int i=0;i<n.size();i++){
    long long  a = n[i] - '0';
    s += a;
  }
  if(s%9 ==0)
  cout << "Yes" <<endl;
  else cout << "No" << endl;
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

const long long mod = 1000000007;

// auto mod int
struct mint {
    ll x; // typedef long long ll;
    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, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    ll cnt1 = 0, cnt2 = 0;
    rep(i, n) {
        rep(j, n) {
            if (a[j] > a[i]) {
                ++cnt1;
                if (j < i) ++cnt2;
            }
        }
    }
    mint ans = mint(cnt1) * k * (k-1) / 2 + cnt2 * k;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstring>

using namespace std;

#define MAX 35

int H,W,N;
char field[MAX][MAX];
bool flg;

bool inField(int y,int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

void del(){
  bool rem[MAX][MAX];
  memset(rem,false,sizeof(rem));
  for(int y = 0 ; y < H ; y++){
    for(int x = 0 ; x < W ; x++){
      if(field[y][x] == '.') continue;
      int n = 0, nx = x, ny = y; 
      char ch = field[y][x];
      while(true){
        if(!inField(ny,nx)) break;
        if(field[ny][nx] != ch) break;
        n++; nx++;
      }
      if(n >= N){
        for(int j = 0 ; j < n ; j++){
          rem[y][nx-j-1] = true;
        }
      }
      nx = x, ny = y, n = 0;
      while(true){
        if(!inField(ny,nx)) break;
        if(field[ny][nx] != ch) break;
        n++; ny++;
      }
      if(n >= N){
        for(int j = 0 ; j < n ; j++){
          rem[ny-j-1][x] = true;
        }
      }
    }
  }
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      if(rem[i][j]){
        flg = true;
        field[i][j] = '.';
      }
    }
  }
}

void fall(){
  char t[MAX][MAX];
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      t[i][j] = '.';
    }
  }
  
  for(int j = 0 ; j < W ; j++){
    int idx = H-1;
    for(int i = H-1 ; i >= 0 ; i--){
      if(field[i][j] == '.') continue;
      t[idx--][j] = field[i][j];
    }
  }

  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      field[i][j] = t[i][j];
    }
  }
}

bool check(){
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      if(field[i][j] != '.') return false;
    }
  }
  return true;
}

bool solve(){
  if(check()) return true;
  flg = false; del(); 
  if(flg){
    fall(); 
    if(solve()) return true;
  }
  return false;
}

int main(){
  cin >> H >> W >> N;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> field[i][j];
    }
  }
  char tmp[MAX][MAX];
  bool ok = false;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W-1 ; j++){
      if(field[i][j] == field[i][j+1]) continue;
      for(int k = 0 ; k < H ; k++){
        for(int l = 0 ; l < W ; l++){
          tmp[k][l] = field[k][l];
        }
      }
      swap(field[i][j],field[i][j+1]);
      if(field[i][j] == '.' || field[i][j+1] == '.'){
        fall();
      }
      if(solve()){
        ok = true;
        goto end;
      }
      for(int k = 0 ; k < H ; k++){
        for(int l = 0 ; l < W ; l++){
          field[k][l] = tmp[k][l];
        }
      }
    }
  }
 end:;
  cout << (ok ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 1164
import itertools
N = int(input())
N_List =list(map(int,input().split()))
cnt = 0
for pairs in itertools.permutations(N_List, 3):
    if len(set(pairs)) == 3:
        if list(pairs) == sorted(list(pairs)):
            a = list(pairs)
            if a[0] + a[1] > a[2]:
                cnt += 1
print(cnt)

Measured memory_bytes: 9180
#include<iostream>
using namespace std;
int main(){
  int a,b;
  
  while(cin>>a>>b){
    a+=b;
    b=1;
    for(int i=1;i<=7;i++){
      b*=10;
      if(a<b){
	cout<<i<<endl;
	break;
      }
    }
  }
  return 0;
}

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

using namespace std;

int ans;

string str,tmp;
deque<char> deq;

int main(){
	ios::sync_with_stdio(false);
	cin>>str;
	for(int i=0;i<str.length();++i){
		if(str[i]!='x') tmp+=str[i];
	}
	for(int i=0,j=tmp.length()-1;i<=j;++i,--j){
		if(tmp[i]!=tmp[j]){
			puts("-1");
			return 0;
		}
	}
	for(int i=0;i<str.length();++i)
		deq.push_back(str[i]);
	while(deq.size()){
		while(deq.front()!='x' && deq.back()=='x')
			++ans,deq.pop_back();
		while(deq.back()!='x' && deq.front()=='x')
			++ans,deq.pop_front();
		deq.pop_front();
		if(deq.size()) deq.pop_back();
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
int main()
{
    long long n, x, y, inf = 1000000000, cost = inf;
    scanf("%lld %lld %lld", &n, &x, &y);
    vector<vector<vector<long long>>> dp(n + 1, vector<vector<long long>>(401, vector<long long>(401, inf)));
    dp[0][0][0] = 0;
    for (long long i = 1, a, b, c; i <= n; i++)
    {
        scanf("%lld %lld %lld", &a, &b, &c);
        dp[i][0][0] = 0;
        for (long long j = 0; j <= 400; j++)
        {
            for (long long k = 0; k <= 400; k++)
            {
                dp[i][j][k] = dp[i - 1][j][k];
                if (j >= a && k >= b)
                {
                    dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - a][k - b] + c);
                }
            }
        }
    }
    for (long long j = 1; j <= 400; j++)
    {
        for (long long k = 1; k <= 400; k++)
        {
            if (j * y == x * k)
            {
                cost = min(cost, dp[n][j][k]);
            }
        }
    }
    printf("%lld\n", cost >= inf ? -1 : cost);
}


Measured memory_bytes: 53504
#include <stdio.h>
int main(void){
  int i,j,data[10],tmp;
  for(i=0;i<10;i++){
    scanf("%d",&data[i]);
  }
  for(i=0;i<10;i++){
    for(j=9;j>i;j--){
      if(data[j]>data[j-1]){
	tmp=data[j];
	data[j]=data[j-1];
	data[j-1]=tmp;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",data[i]);
  }
  return(0);
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

const ll MOD = 1000000007LL;

ll dp[101010];
ll flg[101010];
ll N, M;

int main(){

    dp[0] = 1;
    cin >> N >> M;
    for(ll i = 0; i < M; i++){
        ll a;
        cin >> a;
        flg[a] = 1;
    }
    for(ll i = 0; i <= N; i++){
        if(flg[i + 1] == 0)dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
        if(flg[i + 2] == 0)dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
    }
    cout << dp[N] << endl;

    return 0;
}

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

map<int, int> prime_factor(int N){
  map<int, int> ret;

  for(int i = 2; i*i <= N; i++){
    while( N % i == 0){
      ret[i]++;
      N = N / i;
    }
  }
  if(N!=1){
    ret[N] = 1;
  }
  return ret;
}

map<int, int> map_merge(map<int,int>m1, map<int, int>m2){
  for(auto p : m1){
    if(m2.count(p.first) == 0){
      m2[p.first] = p.second;
    } else {
      m2[p.first] += p.second;
    }
  }
  return m2;
}


int main(){

  long long N; 
  cin >> N;
  // N = 1000;

  map<int, int> pf;
  for(int i = 2; i <= N; i++){
    pf = map_merge(pf, prime_factor(i));
  }

  long long ans = 1;
  long long mod = 1000000000 + 7;
  for(auto p : pf){
    cerr << p.first << " " << p.second << endl;
    ans = ans * (long long)(p.second + 1);
    ans = ans % mod;
  }

  cout << ans << endl;

}

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

typedef long long ll;



int main(void){

    string s;
    cin >> s;

    for (int i = 0; i<s.size()-8; i++){
        cout << s[i];
    }

   
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = []
xy = [[] for i in range(N)]
for i in range(N):
    A.append(I())
    for j in range(A[i]):
        x,y = LI()
        xy[i].append([x-1,y])

# 人は0-index
# 各人が正直者か不親切な人かで全探索、1…正直者、0…不親切な人

ans = 0
for i in range(2**N):
    B = [[] for _ in range(N)]
    a = 0  # 正直者の人数
    for j in range(N):
        if (i>>j) & 1:  # jが正直者
            B[j].append(1)
            a += 1
            for k in range(A[j]):
                B[xy[j][k][0]].append(xy[j][k][1])
        else:  # jが不親切な人
            B[j].append(0)
    if sum(len(set(B[j])) for j in range(N)) != N:  # この場合矛盾
        continue
    else:
        ans = max(ans,a)

print(ans)

Measured memory_bytes: 75396
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N;
    cin>>N;
    vector<int>W(N);
    int A=0;
    for(int i=0;i<N;i++){
        cin>>W[i];
        A+=W[i];
    }
    int B=A;
    int C=0;
    for(int i=0;i<N;i++){
        C+=W[i];
        B=min(B,abs(C-(A-C)));
    }

    cout<<B<<endl;

}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line = br.readLine();

        while(!(line.equals("0 0"))){
            String[] input = line.split(" ");
            int h = Integer.valueOf(input[0]);
            int w = Integer.valueOf(input[1]);
            StringBuilder sb = new StringBuilder();

            for(int i = 0; i < h; i++){
                boolean which = i%2 == 0;
                for(int j = 0; j < w; j++){
                    if(which) sb.append("#");
                    else sb.append(".");
                    which = !which;
                }
                sb.append("\n");
            }

            System.out.println(sb);

            line = br.readLine();
        }

    }
}



Measured memory_bytes: 25772
n = input()
list = input().split(" ")
list = [int(a) for a in list]
even = [a for a in list if a % 2==0]
ans = []
for a in even:
    if a % 3 == 0 or a % 5 == 0:
        ans.append(True)
if len(even) ==len(ans):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
def f(n, m, d):
    if d == 0:
        return (m-1)/n
   
    numerator = m-1
    denom = n*n

    numerator *= (2*(n-d))
   
    return numerator / denom
   
n, m, d = [int(i) for i in input().split()]
print(f(n, m, d))

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

class DICE{
    public:
        int a;
        int b;
        int c;
        int d;
        int e;
        int f;
    DICE(int _a,int _b,int _c,int _d,int _e,int _f){
        a = _a;
        b = _b;
        c = _c;
        d = _d;
        e = _e;
        f = _f;
    }
    DICE S(){
        return DICE(e,a,c,d,f,b);
    }
    DICE N(){
        return DICE(b,f,c,d,a,e);
    }
    DICE E(){
        return DICE(d,b,a,f,e,c);
    }
    DICE W(){
        return DICE(c,b,f,a,e,d);
    }
    void Print(){
        cout << a << endl;
    }
};

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    DICE Dice(a,b,c,d,e,f);
    string S;
    cin >> S;
    for(int i = 0;S[i] != '\0';i++){
        if(S[i] == 'S'){
            Dice = Dice.S();
        }else if(S[i] == 'W'){
            Dice = Dice.W();
        }else if(S[i] == 'E'){
            Dice = Dice.E();
        }else{
            Dice = Dice.N();
        }
    }
    Dice.Print();
}


Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int T = scan.nextInt();
		int t = 0;
		int count = 0;
		for (int i = 0; i < N; i++) {
			int before = t;
			t = scan.nextInt();
			if (t == 0 || t - before > T) {
				count += T;
			} else {
				count += t - before;
			}
		}
		System.out.println(count);
	}
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	long long money = 1000, stocks = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		money += stocks * a[i];
		stocks = 0;
		if (a[i] < a[i + 1]) {
			stocks = money/a[i];
			money -= stocks * a[i];
		}
	}
	money += stocks * a[n - 1];
	cout << money;
}


Measured memory_bytes: 3572
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 1e9 + 7;
ll bp(ll x, ll a) {
	ll r = 1;
	while(a) {
		if(a&1) r = (r*x)%mod;
		a>>=1;
		x  = (x*x)%mod;
	}
	return r;
}
const int maxn = 1e6 + 55;
ll fact[maxn], inv[maxn];
void setup() {
	fact[0] = 1;
	for(int i = 1; i < maxn; i++) fact[i] = (fact[i-1]*i)%mod;
	for(int i = 0; i < maxn; i++) inv[i] = bp(fact[i], mod-2);
}
ll nck(ll n, ll k) {
	if(k>n) return 0;
	ll r = (fact[n]*inv[k])%mod;
	return (r*inv[n-k])%mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	setup();
	ll x, y, ans = 0;
	cin >> x >> y;
	if((x+y)%3) return cout << 0, 0;
	ll t = (x+y)/3, d = abs(x-y);
	ans = nck(t,d + (t-d)/2);
	cout << ans;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C,D;
  str N,N2;
  vector<int>K(3);
  cin>>K[0]>>K[1]>>K[2];
  sort(all(K));
  if(K[0]==K[1])cout<<K[2]<<endl;
  else cout<<K[0]<<endl;
}


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

int main(){
  string s, t;

  cin >> s;
  cin >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if (s < t) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
using namespace std;

int n, m;
int d[200005];
int t[200005];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &d[i]);
	}
	d[n] = 1500000000;
	scanf("%d", &m);
	for(int i = 0; i < m; i++){
		scanf("%d", &t[i]);
	}
	sort(d, d+n);
	sort(t, t+m);
	/*for(int i = 0; i <= n; i++){
		printf("%d ", d[i]);
	}
	printf("\n");*/
	int i, j = 0;
	int vis = t[0];
	while(1){
		//printf("vis = %d\n", vis);
		int cntd = 0, cntt = 0;
		while(d[i] <= vis){
			if(d[i] == vis){
				i++;
				cntd++;
			}else{
				i++;
			}
		}
		while(t[j] == vis){
			j++;
			cntt++;
			if(j == m){
				break;
			}
		}
		if(cntd < cntt){
			printf("NO\n");
			return 0;
		}
		vis = t[j];
		if(j == m){
			printf("YES\n");
			return 0;
		}
	}
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint;
        var A = cin.scanint;
        var B = cin.scanint;
        for (int i = 1; i < N; i++)
        {
            A[i] += A[i - 1];
            B[i] += B[i - 1];
        }
        int max = 0;
        for (int i = 0; i < N; i++)
        {
            if (i > 0) max = Math.Max(max, A[i] + B[N - 1] - B[i - 1]);
            else max = A[i] + B[N - 1];              
        }
        WriteLine(max);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11092
N=int(input())
H=list(map(int,input().split()))

cnt=0
l=[]

if N==1:
	cnt=0
	l.append(cnt)
else:
	for i in reversed(range(1,N)):
		if H[i]<=H[i-1]:
			cnt+=1
			if i==1:
				l.append(cnt)
		else:
			l.append(cnt)
			cnt=0

print(max(l))

Measured memory_bytes: 14252
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main(void){
    double a,b,C,S,L,h;
    cin>>a>>b>>C;
    C*=(3.14159265/180);
    S=(1/2.0)*a*b*sin(C);
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(C));
    h=b*sin(C);
    printf("%.5f\n",S);
    printf("%.5f\n",L);
    printf("%.5f\n",h);
    return 0;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int head[200001],num_edge,n,l,p,fa[200001];
struct Edge
{
	int next,to;
}edge[200001];
int v[200001],ans[200001];
void add(int from,int to)
{
	edge[++num_edge].next=head[from];
	edge[num_edge].to=to;
	head[from]=num_edge;
}
int find(int x)
{
    if(fa[x]==x) return x;
    else return fa[x]=find(fa[x]);
}
void get_together(int a,int b)
{
    fa[find(a)]=find(b);
}
void dfs1(int x,int tag,map<int,int>&num)
{
	if(v[x]==tag) return ;
	v[x]=tag;
	num[find(x)]++;
	for(int i=head[x];i;i=edge[i].next)
	  dfs1(edge[i].to,tag,num);
}
void dfs2(int x,int tag,map<int,int>&num)
{
	if(v[x]==tag) return ;
	v[x]=tag;
	ans[x]+=num[find(x)];
	for(int i=head[x];i;i=edge[i].next)
	  dfs2(edge[i].to,tag,num);
}
int main(){
	cin>>n>>p>>l;
	for(int i=1;i<=n;i++)
	  fa[i]=i;
	for(int i=1;i<=p;i++)
	{
		int a,b;
		cin>>a>>b;
		get_together(a,b);
	}
	for(int i=1;i<=l;i++)
	{
		int a,b;
		cin>>a>>b;
		add(a,b);
		add(b,a);
	}
	for(int i=1;i<=n;i++)
	  if(!v[i])
	  {
	  	map<int,int> num;
	  	dfs1(i,i,num);
	  	dfs2(i,-i,num);
	  }
	for(int i=1;i<=n;i++)
	  cout<<ans[i]<<' ';
}

Measured memory_bytes: 7680
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vvvd vector<vector<vector<double>>>


//#define int long long

using namespace std;

signed compare_ll(const void *a, const void *b)
{
	ll *A = (ll *)a;
	ll *B = (ll *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}

int init(vector<int>& map, int n){
	int i;

	for(i=0;i<=n;i++){
		map[i]=0;
	}
	return 0;
}

int search(int n,int a,int count,vector<vector<int>>& graph, vector<int>& vec, vector<int>& map){
	int i;
	queue<pair<int,int>> que;
	pair<int,int> ptemp;

	que.emplace(a,0);
	
	while(que.size()!=0){
		ptemp=que.front();
		if(map[ptemp.first]==0){
			a=ptemp.first;
			count=ptemp.second;
			map[a]=1;
			vec[count]++;
			for(i=0;i<graph[a].size();i++){
				que.emplace(graph[a][i],count+1);
			}
		}
		que.pop();
	}

	return 0;
}

signed main(void)
{
	//変数の宣言
	int n,m;
	int h,w;
	int x,y;
	static int p[100010];
	vector<vector<int>> graph;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	vector<int> vec;
	vector<int> vtemp;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	
	//データの読み込み


	scanf("%d %d %d",&n,&x,&y);
//	scanf_s("%d %d %d",&n,&x,&y);


//	scanf("%s",&s);
//	scanf_s("%s",&s,20);


/*	//scanf("%c",&dummy);
	scanf_s("%c",&dummy);
	for(i=0;i<n;i++){
//		scanf("%c",&s[i]);
		scanf_s("%c",&s[i]);
	}*/


/*	for(i=0;i<a;i++){
//		scanf("%lld",&p[i]);
		scanf_s("%lld",&p[i]);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	for(i=0;i<=n;i++){
		graph.push_back(vtemp);
	}
	for(i=1;i<=n;i++){
		if(i!=1){
			graph[i].push_back(i-1);
		}
		if(i!=n){
			graph[i].push_back(i+1);
		}
	}
	graph[x].push_back(y);
	graph[y].push_back(x);

	for(i=0;i<=n;i++){
		vec.push_back(0);
	}

	vector<int> map(n+1,0);

	for(i=1;i<=n;i++){
		init(map,n);
		search(n,i,0,graph,vec,map);
	}

	for(i=1;i<n;i++){
		printf("%d\n",vec[i]/2);
	}


//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	//printf("%d",(d[i-1][j-1]+1)/2);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 384
#! python3
# selectSort.py - 選択ソートを行う 配列の端から、残りのすべての数の一番小さい数と交換していく

N = int(input())
l = input().split(' ')
A = [int(i) for i in l]
# print(A)

def selectSort(A, N):
    counter = 0
    for i in range(N-1):
        minij = i
        for j in range(i + 1, N):
            if A[minij] > A[j]:
                minij = j

        if A[i] > A[minij]:
            v = A[i]
            A[i] = A[minij]
            A[minij] = v
            counter += 1

    map_list = map(str, A)
    a = ' '.join(map_list)
    print(a)
    print(counter)

selectSort(A, N)


Measured memory_bytes: 5604
def main():
    N = int(input())
    A = list(map(int,input().split()))
    for i in range(N):
        A[i] -= i+1
    
    def f(b):
        res = 0
        for a in A:
            res += abs(a-b)
        return res
    
    INF = 10**9+10
    l = -INF
    r = +INF

    while l < r-2:
        m1 = (r-l)*2//3+l
        m2 = (r-l)//3+l
        tmp1 = f(m1)
        tmp2 = f(m2)

        if tmp2 < tmp1:
            r = m1
        else:
            l = m2
    print(f((l+r)//2))

main()

Measured memory_bytes: 104244
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K; cin >> N >> K;
    vector<ll> p(N);
    rep(i,N) cin >> p[i];

    vector<ll> A(N+1);
    rep(i,N) A[i+1] = A[i] + p[i];
    ll ans = 0;
    rep(i,N-K+1) {
        chmax(ans,A[i+K]-A[i]);
    }

    cout << fixed << setprecision(10) << double(ans+K)/2.0 << endl;
}

Measured memory_bytes: 3456
import java.io.*;
import java.util.*;
	
	class Main {
		static BufferedReader br = new BufferedReader(new InputStreamReader(
				System.in));
		static StringBuilder out= new StringBuilder();
	
		public static void main(String[] args) throws IOException {
			int N = Integer.parseInt(br.readLine());
			String A1[] = br.readLine().split(" ");
			String A2[] = Arrays.copyOf(A1, N);
			bubblesort(A1, N);
			selectsort(A2, N);
			isstable(A1, A2);
		      out.append(A1[0]);
		        for(int i=1; i<A1.length; i++) out.append(' ').append(A1[i]);
		        out.append('\n');
		        out.append("Stable\n");
		        out.append(A2[0]);
		        for(int i=1; i<A2.length; i++) out.append(' ').append(A2[i]);
		        out.append('\n');
		        out.append(isstable(A1, A2)?"Stable\n":"Not stable\n");
		        System.out.print(out);
	
		}
	
		public static void bubblesort(String[] A, int N) {
			for (int i = 0; i < N-1; i++) {
				for (int j = N - 1; j > i; j--) {
					if (A[j].charAt(1) < A[j - 1].charAt(1)) {
						String tmp = A[j];
						A[j] = A[j - 1];
						A[j - 1] = tmp;
					}
				}
			}
		}
	
		public static void selectsort(String[] A, int N) {
			for (int i = 0; i < N; i++) {
				int min = i;
				for (int j = i+1; j < N; j++) {
					if (A[j].charAt(1) < A[min].charAt(1)) {
						min = j;
					}
				}
				if (i != min) {
					String t = A[i];
					A[i] = A[min];
					A[min] = t;
				}
			}
		}
	
		public static boolean isstable(String[] A1, String[] A2) {
			for (int i = 0; i < A1.length; i++) {
				if (A1[i].charAt(0) != A2[i].charAt(0)) {
					return false;
				}
			}
			return true;
		}
	}

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

bool p[260000];

void erato(){
	fill(p, p+260000, true);
	p[0] = p[1] = false;

	for(int i=0; i < 260000; i++){
		if(!p[i]) continue;

		for(int j=i+i; j < 260000; j+=i){
			p[j] = false;
		}
	}
}

int main(){
	erato();
	int n;

	while(cin >> n, n){
		int ans = 0;
		for(int i =n+1; i <= 2 * n; i++){
			if(p[i]) ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    int cnt=0;
    repi(i,1,n+1){
        int a=log10(i)+1;
        if(a%2==1) cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 3944
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int K,T;
	cin>>K>>T;
	int a[100];
	int mx=0;
	rep(i,T){
		cin>>a[i];
		mx=max(mx,a[i]);
	}
	int ans=max(0,2*mx-K-1);
	cout<<ans<<endl;
}

Measured memory_bytes: 384
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005
ll mod=1e9+7;
int main()
{
    fastread;
    ll n,k;
    cin>>n>>k;
    vec arr(n+1);
    for(ll i=1;i<=n;i++)
    	cin>>arr[i];
    ll dp[n+1][maxi];
    dp[0][0]=1;
    for(ll i=1;i<maxi;i++)
    	dp[0][i]=1;
    for(ll i=1;i<=n;i++)
    {
    	for(ll j=0;j<maxi;j++)
    	{
    		ll ind=max(j-arr[i],0LL);
    		ll temp=dp[i-1][j];
    		if(ind!=0)
    			temp=(temp-dp[i-1][ind-1]+mod)%mod;
    		dp[i][j]=temp;
    	}
    	for(ll j=1;j<maxi;j++)
    		dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
    }
    if(k==0)
    	cout<<dp[n][k]<<endl;
    else
    	cout<<(dp[n][k]-dp[n][k-1]+mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 79232
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, K;
int main(){
    int i, j;
    scanf("%d%d%d",&n,&m,&K);
    for(i=0;i<=n;i++){
        for(j=0;j<=m;j++){
            if(i*m+j*n-i*j*2==K){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}

Measured memory_bytes: 128
g_0 = [["#"]*100 for _ in range(50)]
g_1 = [["."]*100 for _ in range(50)]

a,b = map(int, input().split())
print("100 100")
for i in range(a-1):
    g_0[2*(i//49) + 1][2*(i%49) +1] = "."

for i in range(b-1):
    g_1[2*(i//49) + 1][2*(i%49) +1] = "#"

for i in range(50):
    print("".join(g_0[i]))
for i in range(50):
    print("".join(g_1[i]))





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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = (int)2e5 + 50;

#define lson(x) 2*x+1
#define rson(x) 2*x+2

struct node {
    int sum, pref;

    void add(int val) {
        sum += val;
        pref = max(sum, 0);
    }
};

node merge(node L, node R) {
    return {L.sum + R.sum, max(L.sum + R.pref, L.pref)};
}

struct Tree {
    node dat[4 * N];
    void init(int x, int l, int r) {
        if(l == r) {dat[x] = {-1, 0}; return ;}
        int mid = (l + r) / 2;
        init(lson(x), l, mid);
        init(rson(x), mid + 1, r);
        dat[x] = merge(dat[lson(x)], dat[rson(x)]);
    }

    void update(int pos, int x, int l, int r, int val) {
        if(l == r) {dat[x].add(val); return ;}
        int mid = (l + r) / 2;
        if(pos <= mid) update(pos, lson(x), l, mid, val);
        else update(pos, rson(x), mid + 1, r, val);
        dat[x] = merge(dat[lson(x)], dat[rson(x)]);
    }

    node query(int a, int b, int x, int l, int r) {
        if(r < a || b < l) return {0, 0};
        int mid = (l + r) / 2;
        if(a <= l && r <= b) return dat[x];
        else return merge(query(a, b, lson(x), l, mid),
                query(a, b, rson(x), mid + 1, r));
    }
} tree;

int n, m;
vector<int> add[N];

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

    cin >> n >> m;
    int mx = max(0, n - m);
    tree.init(0, 0, m - 1);
    for(int i = 0; i < n; i++) {
        int l, r; cin >> l >> r; l--, r--;
        add[r].push_back(l);
    }
    int cur_r = 0;
    int non = 0;
    for(int r = m; r >= 0; r--) {
        for(auto l : add[r]) {
            if(l >= 0) tree.update(l, 0, 0, m - 1, 1);
            else non++;
        }
        mx = max(mx, tree.dat[0].pref + non - (m - r));
    }
    cout << mx << '\n';
}


Measured memory_bytes: 14080
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  ll H,W,N;
  cin >> H >> W >> N;
  vector<P> p;
  for(int i=0; i<N; i++){
    int a,b;
    cin >> a >> b;
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        int na = a-j;
        int nb = b-k;
        if(na<=0 || nb<=0 || H<na+2 || W<nb+2) continue;
        p.emplace_back(na,nb);
      }
    }
  }
  sort(p.begin(),p.end());
  vector<ll> sum(10,0);
  for(int i=0; i<p.size(); i++){
    int cnt=1;
    while(i+1<p.size() && p[i].first == p[i+1].first && p[i].second == p[i+1].second){
      cnt++;
      i++;
    }
    sum[cnt]++;
  }
  ll s=0;
  for(int i=1; i<=9; i++){
    s += sum[i];
  }
  sum[0] = (H-2)*(W-2) - s;
  for(int i=0; i<10; i++){
    cout << sum[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 10220
package main

import "fmt"

func main() {
	var n int
	var x float64
	var u string

	fmt.Scan(&n)

	var sum float64
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		fmt.Scan(&u)

		if u == "JPY" {
			sum += x
		} else {
			sum += x * 380000
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512