akhauriyash/Code-Regression huggingface dataset:
from functools import reduce


def li():
    return list(map(int, input().split()))


def mi():
    return map(int, input().split())


def ii():
    return int(input())


N = ii()
v = li()

v.sort()


res = reduce(lambda v1, v2: (v1 + v2) / 2, v)

print(res)


Measured memory_bytes: 3572
H,W,M=map(int,input().split())
h_lis=[0]*H
w_lis=[0]*W
hw_set=set()

for _ in range(M):
    h,w=map(int,input().split())
    h_lis[h-1]+=1
    w_lis[w-1]+=1
    hw_set.add((h-1,w-1))
    
h_max=max(h_lis)
w_max=max(w_lis)

h_maxlis=[i for i, x in enumerate(h_lis) if x==h_max]
w_maxlis=[i for i, x in enumerate(w_lis) if x==w_max]
import sys

for hi in h_maxlis:
    for wi in w_maxlis:
        if (hi,wi) not in hw_set:
            print(h_max+w_max)
            sys.exit()
else:
    print(h_max+w_max-1)

Measured memory_bytes: 166836
// JAI SHREE RAM
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll s,w;
	cin>>s>>w;
	if(w>=s)
		cout<<"unsafe";
	else
		cout<<"safe";


}

Measured memory_bytes: 3636
#include <iostream>
#include <stack>
#include <cstring>
#include <algorithm>
#include <vector> 
#include <map>
#include <string>
using namespace std;
int a[21];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((a[i - 1] < a[i] && a[i] < a[i + 1]) || (a[i-1]> a[i] && a[i] > a[i+1])) {
			ans++;
		}
	}
	cout << ans << '\n';






}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <sstream>
using namespace std;
int n, m;
string p[100000];
int a[100000];
queue<int> q;
int c, s, t;
int u;
int main()
{
	cin >> n >> m;
	c=n;
	u=0;
	for(int i=0; i<n; i++)
	{
		cin >> p[i] >> a[i];
		q.push(i);
		q.push(a[i]);
	}
	while(c>0)
	{
		s=q.front();
		q.pop();
		t=q.front();
		q.pop();
		if(t>m)
		{
			t-=m;
			q.push(s);
			q.push(t);
			u+=m;
		}
		else
		{
			u+=t;
			cout << p[s] << " " << u << endl;
			c-=1;
		}
	}
	return 0;
}

Measured memory_bytes: 4968
n = int(input())
nn = pow(2, n)

for i in range(nn):
    if i == 0:
        print("0:")
    else:
        bin_str = "0" + str(n) + "b"
        bin_i = format(i, bin_str)
        ilist = list(bin_i)
        tmplist = []
        for j, bini in enumerate(ilist):
            if bini == '1':
                tmplist.append(n - j - 1)
        tmplist.sort()
        tmp_str = ' '.join(str(tmp) for tmp in tmplist)
        print(str(i) + ": " + tmp_str)



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

int main(void){
  int i, sum = 0;
  std::string s;
  cin >> s;

  for(i = 0; s[i] != '\0'; i ++){
    if(s[i] == '+') sum ++;
    if(s[i] == '-') sum --;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


//sからtへの最大流 O(E flow)を横着してO(VV flow)
#define VMAX 210
int vcnt;
int foodoflag[VMAX];
int resflow[VMAX][VMAX];

int foododfs(int s,int t){
	if(s==t)return 1;
	foodoflag[s]=1;
	rep(i,0,vcnt)if(!foodoflag[i]&&resflow[s][i]>0){
		if(foododfs(i,t)){
			resflow[s][i]--;
			resflow[i][s]++;
			return 1;
		}
	}
	return 0;
}
int foodo(int s,int t){
	int ans=0;
	while(foododfs(s,t)){
		ans++;
		rep(i,0,vcnt)foodoflag[i]=0;
	}
	return ans;
}
#undef VMAX

char s[110][110];
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	rep(i,0,h)scanf(" %s",s[i]);
	//縦は1～h、横はh+1～h+w
	rep(i,0,h)rep(j,0,w){
		if(s[i][j]=='o'){
			resflow[i+1][h+j+1]=1;
			resflow[h+j+1][i+1]=1;
		}else if(s[i][j]=='S'){
			resflow[0][i+1]=1000;
			resflow[0][h+j+1]=1000;
		}else if(s[i][j]=='T'){
			resflow[i+1][h+w+1]=1000;
			resflow[h+j+1][h+w+1]=1000;
		}
	}
	vcnt=h+w+2;
	int ans=foodo(0,h+w+1);
	printf("%d",ans>=1000?-1:ans);
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int ok[3];
int main(){
    //~ freopen("file.in", "r", stdin);
	ok[0]=ok[1]=ok[2]=1;
	string s;
	cin>>s;
	for(int i=0;i<3;i++)
		if(s[i]!=s[0])
			ok[0]=0;
	for(int i=0;i<4;i++)
		if(s[i]!=s[0])
			ok[2]=0;		
	for(int i=1;i<4;i++)
		if(s[i]!=s[3])
			ok[1]=0;
	if(ok[0]|ok[1]|ok[2])
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
ll N;
vector<vector<int>> uvw;
vector<vector<pair<int, int>>> graph;
vector<int> black;

void solve(int i) {
  for(auto x : graph[i]) {
    // cout << x.first << endl;
    if(black[x.first] == -1) {
      if(x.second % 2 == 0) {
        black[x.first] = black[i];
      } else {
        if(black[i] == 1) {
          black[x.first] = 0;
        } else {
          black[x.first] = 1;
        }
      }
      // cout << x.first << ' ' << black[x.first] << endl;
      solve(x.first);
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  uvw.assign(N, vector<int>(3));
  graph.assign(N, vector<pair<int, int>>());
  black.assign(N, -1);
  for(int i = 0; i < N - 1; i++) {
    for(int j = 0; j < 3; j++) {
      cin >> uvw[i][j];
    }
  }
  for(int i = 0; i < N - 1; i++) {
    graph[uvw[i][0] - 1].push_back(make_pair(uvw[i][1] - 1, uvw[i][2]));
    graph[uvw[i][1] - 1].push_back(make_pair(uvw[i][0] - 1, uvw[i][2]));
  }
  black[0] = 0;
  solve(0);
  for(int i = 0; i < N; i++) {
    cout << black[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 12544
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 30){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}



void solve(){
  ll N;
  cin >> N;
  vector<ll> P(N);
  rep(i, N) cin >> P[i];
  ll m = INFL;
  ll ans = 0;
  rep(i, N){
    if(m > P[i]) ans++;
    m = min(m, P[i]);
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int i,j;
 int k;
long int sum =9;
long int lunlun[12][10];

void find(void){
    for(j=1;j<10;j++){
      lunlun[1][j]=lunlun[1][j-1]+lunlun[2][j-1];
      for(i=2;i<11;i++){
	long int tasu = lunlun[i-1][j-1]+lunlun[i][j-1]+lunlun[i+1][j-1];
	//printf("%ld\n",tasu);
	lunlun[i][j]=tasu;
	if(sum+tasu >= k){
	  //printf("%d %d\n",i,j);
	  return;}
	sum+=tasu;}}
}

int main(){
 
  scanf("%d",&k);

  if(k<=9){
    printf("%d\n",k);
    return 0;}
  for(int i=1;i<11;i++){
    lunlun[i][0]=1;}
  for(int j=0;j<10;j++){
    lunlun[0][j]=0;
    lunlun[11][j]=0;}

  find();

    long int ans = i-1;
    while(j>0){
      j--;
      ans*=10;
      if(sum+lunlun[i-1][j]>=k){
	ans+=i-2;
	i--;
	continue;}
      sum+=lunlun[i-1][j];
      if(sum+lunlun[i][j]>=k){
	ans+=i-1;
	continue;}
      sum+=lunlun[i][j];
      ans+=i;
      i++;}
 

    printf("%ld\n",ans);

  return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	c := make([][]int, 10)
	for i := range c {
		c[i] = make([]int, 10)
	}
	for i := 1; i <= N; i++ {
		val := i
		last := val % 10
		for val/10 != 0 {
			val /= 10
		}
		first := val
		c[first][last]++
	}
	count := 0
	for i := 0; i <= 9; i++ {
		for j := 0; j <= 9; j++ {
			count += c[i][j] * c[j][i]
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1776
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int n;
int p[200];
int invp[200];
void ope(int k) {
	Rep(i, k, n) {
		swap(p[i], p[i - k]);
	}
	rep(i, n)invp[p[i]] = i;
}
vector<int> ans;
void oper(int k) {
	ans.push_back(k); ope(k);
}
void solve() {
	cin >> n;
	rep(i, n)cin >> p[i]; rep(i, n)invp[p[i]] = i;
	rep(i,49900) {
		if (p[0]>0&&p[0] < p[n - 1])oper(n - 1);
		oper(1);
	}
	while (p[0] != 0)oper(1);
	cout << ans.size() << endl;
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}
	/*rep(i, n) {
		if (i > 0)cout << " ";
		cout << p[i];
	}
	cout << endl;*/
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  int input;
  int min = 1e9;
  int ans = 0;

  REP(i, n) {
    cin >> input;
    if (input < min) {
      min = input;
      ans++;
    }
  }

  cout << ans << endl;

}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
    if(a>b){
        a = b; return true;
    }
    else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
    if(a<b){
        a = b; return true;
    }
    else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
    cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    int n; cin >> n;
    vpl v(n);
    rep(i,n) cin >> v[i].first >> v[i].second;
    sort(all(v));
    cout << v.back().first + v.back().second << endl;
}

Measured memory_bytes: 4848
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<cassert>

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

	int n;
	int i;

	std::cin >> n >> i;

	std::cout << n - i + 1 << '\n';

	return 0;
}

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

const ll MOD = 1e9 + 7;

ll dp[100010][4];
int main() {
  string S;
  cin >> S;
  int N = S.size();
  dp[0][0] = 1;
  for (int i = 0; i < N; ++i) {
    bool f = S[i] == '?';
    if (S[i] == 'A' || f) {
      for (int j = 0; j < 4; ++j) (dp[i + 1][j] += dp[i][j]) %= MOD;
      (dp[i + 1][1] += dp[i][0]) %= MOD;
    }
    if (S[i] == 'B' || f) {
      for (int j = 0; j < 4; ++j) (dp[i + 1][j] += dp[i][j]) %= MOD;
      (dp[i + 1][2] += dp[i][1]) %= MOD;
    }
    if (S[i] == 'C' || f) {
      for (int j = 0; j < 4; ++j) (dp[i + 1][j] += dp[i][j]) %= MOD;
      (dp[i + 1][3] += dp[i][2]) %= MOD;
    }
  }
  cout << dp[N][3] << endl;
  return 0;
}


Measured memory_bytes: 6856
sa = input()
sb = input()
sc = input()
turn = "a"
while True:
    if turn == "a":
        if len(sa)==0:
            print("A")
            exit(0)
        turn = sa[0]
        sa = sa[1:]
    elif turn == "b":
        if len(sb)==0:
            print("B")
            exit(0)
        turn = sb[0]
        sb = sb[1:]
    else:
        if len(sc)==0:
            print("C")
            exit(0)
        turn = sc[0]
        sc = sc[1:]


Measured memory_bytes: 3064
n,m=map(int, input().split())
s=[list(map(int, input().split())) for i in range(m)]
x=max(a for a,b in s)
dp=[0]*(n+x)
for i in range(0,n+x):
  if i>0:
    dp[i]=min(dp[i-a]+b for a,b in s)
print(min(dp[n:]))

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

vector<int> g[200005];
vector<int> ans(200005);

void dfs(int a, int p = -1) {
	for (auto& c : g[a]) {
		if (c == p) continue;
		ans[c] += ans[a];
		dfs(c, a);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, q;
	cin >> n >> q;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	rep(i, q) {
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	dfs(0);
	rep(i, n) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 23552
#include<bits/stdc++.h>
struct px{int a;int b;}x[2000000];
bool cmp(px x,px y){return x.b<y.b;}
using namespace std;
int main()
{
	int n,sum=1,mi;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>x[i].a>>x[i].b;
		x[i].a-=x[i].b;
		x[i].b+=x[i].b+x[i].a;
	}
	sort(x+1,x+n+1,cmp);
	mi=x[1].b;
	int j=1;
	while(j<=n)
	{
	    j++;
	    if(x[j].a>=mi){sum++;mi=x[j].b;}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	while(1){
		s = s.substr(0, s.size() - 2);
		string fr = s.substr(0, s.size()/2), bk = s.substr(s.size()/2);
		if(fr == bk){
			cout << s.size() << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}

fn main() {

    let a: u8 = read();
    let b: u8 = read();

    let mut result: bool = false;
    for c in 1..3 {

        let x = (a * b * c) % 2;
        if x != 0 {
            result = true;
        }
    }

    if result {

        println!("Yes");
    } else {

        println!("No");
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int p[maxn],vis[maxn],col[maxn],mark[maxn],dep[maxn],rt[maxn],deg[maxn];
int len[maxn],dis[maxn];
int cnt[maxn],f[maxn];
std::vector<int>a;
int n,tot;
int main()
{
	// freopen("agc008E.in","r",stdin);
	// freopen("agc008E.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++)
		p[i]=read();
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			int now=i;
			while(!vis[now]){
				a.push_back(now); vis[now]=1;
				now=p[now];
			}
			if(col[now]){
				int sz=a.size();
				for(int j=sz-1;j>=0;j--)
					col[a[j]]=col[now],rt[a[j]]=rt[now],dep[a[j]]=dep[now]+(sz-j);
			}
			else{
				int sz=a.size(),flag=0;
				++tot;
				for(int j=sz-1;j>=0;j--){
					col[a[j]]=tot;
					if(!flag)mark[a[j]]=1,rt[a[j]]=a[j],dep[a[j]]=0;
					else rt[a[j]]=now,dep[a[j]]=dep[a[j+1]]+1;
					flag|=(a[j]==now);
				}
			}
			a.clear();
		}
	// puts("QAQ");
	for(int i=1;i<=n;i++)
		if(!mark[i])++deg[p[i]];
	for(int i=1;i<=n;i++)
		if(deg[i]>=2){
			puts("0"); return 0;
		}
	for(int i=1;i<=n;i++)
		len[rt[i]]=std::max(len[rt[i]],dep[i]);
	memset(vis,0,sizeof(vis));
	ll ans=1;
	for(int i=1;i<=n;i++)
		if(mark[i]&&!vis[i]){
			// writeln(i);
			a.push_back(i); vis[i]=1;
			int now=p[i];
			while(now!=i){
				// printf("%d %d\n",i,now);
				a.push_back(now); vis[now]=1;
				now=p[now];
			}
			int flag=0,sz=a.size();
			for(int j=0;j<sz;j++)
				if(len[a[j]]){
					flag=1; break;
				}
			if(flag){
				int last=-1,first=-1;
				for(int j=0;j<sz;j++)
					if(len[a[j]]){
						if(~first)dis[a[j]]=j-last;
						else first=j;
						last=j;
					}
				dis[a[first]]=first+sz-last;
				for(int j=0;j<sz;j++)
					if(len[a[j]]){
						if(len[a[j]]<dis[a[j]])ans=ans*2%mod;
						else if(len[a[j]]>dis[a[j]]){
							puts("0"); return 0;
						}
					}
			}
			else ++cnt[sz];
			a.clear();
		}
	// puts("TAT");
	// writeln(ans);
	for(int i=1;i<=n;i++){
		int w=((i&1)&&(i>1))?2:1;
		f[0]=1; f[1]=w;
		for(int j=2;j<=cnt[i];j++)
			f[j]=(f[j-1]*w+(ll)(j-1)*f[j-2]%mod*i)%mod;
		ans=ans*f[cnt[i]]%mod;
		// printf("%d ***\n",i);
		// for(int j=0;j<=cnt[i];j++)
		// 	writesp(f[j]);
		// putchar('\n');
	}
	writeln(ans);
	// for(int i=1;i<=n;i++)
	// 	printf("%d : %d %d %d %d || %d %d\n",i,col[i],mark[i],dep[i],rt[i],len[i],dis[i]);
	// for(int i=1;i<=n;i++)
	// 	writesp(cnt[i]);
	// putchar('\n');
	return 0;
}

Measured memory_bytes: 7164
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

tmp = make_divisors(N)
if len(tmp) % 2 == 0:
    print(tmp[-1] + tmp[-2] - 2)
else:
    print(tmp[-1]*2 - 2)


Measured memory_bytes: 3280
function Main(input) {
	const lines = input.split("\n");
	const line1 = lines[0].split(" ");
  const answer = line1[0].split('').reduce((acc, s) =>  {
    return acc + (s === '1' ? 1 : 0);
  }, 0)
	console.log('%s',answer)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30468
"use strict";
function main(input) {
  const s = input[0];
  const n = s.length;

  let judge = false;
  if(s === s.split("").reverse().join("")){
    let a = s.substr( 0, (n-1)/2);
    //console.log(a)
    if(a === a.split("").reverse().join("")){
      let b = s.substr( (n+3)/2 -1, n-1);
      //console.log(b)
      if(b === b.split("").reverse().join("")){
        judge = true;
      }
    }
  }

  console.log(judge?"Yes":"No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 21956
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
s.sort()
t.sort()
ans = 0
count = 1
count2 = 0
for i in range(len(s)):
    if i != len(s)-1:
        if s[i] == s[i+1]:
            count+=1
            continue
    for j in range(len(t)):
        if s[i] > t[j]:
            continue
        elif s[i] < t[j]:
            break
        else:
            count2+=1
    ans = max(count-count2,ans)
    count2 = 0
    count = 1
print(ans)

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int sum = 0;
  vector<int> ss(n);
  for (int i = 0; i < n; i++) {
    int s;
    cin >> s;
    sum += s;
    ss[i] = s;
  }
  sort(ss.begin(), ss.end());

  if (sum % 10 != 0) {
    cout << sum << endl;
    return 0;
  }

  for (int i = 0; i < n; i++) {
    if ((sum - ss[i]) % 10 != 0) {
      cout << sum - ss[i] << endl;
      return 0;
    }
  }

  cout << 0 << endl;

  return 0;
}

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

main(){
  int i,j,cjoi=0,cioi=0;
  char w[10001];

  while(scanf("%s",w)!=EOF){
   cjoi=0,cioi=0;
    for(i=0;i<strlen(w)-2;i++){
      if(w[i]=='J'&&w[i+1]=='O'&&w[i+2]=='I')cjoi++;
      if(w[i]=='I'&&w[i+1]=='O'&&w[i+2]=='I')cioi++;
    }
    printf("%d\n%d\n",cjoi,cioi);
  }
}

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

int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  
  sort(a.begin(), a.end() );
  reverse(a.begin(), a.end() );
  
  long long count=0;
  for(long long i=1;i<n;i++){
    count += a[i/2];
    
  }
  
  
  
  cout << count << endl;
  
  return 0;
}


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

#define N 50

int match(const char *s1, const char *s2, int len) {
    int i;
    for (i = 0; i < len; i++) {
        if (s1[i] != '?' && s2[i] != '?' && s1[i] != s2[i]) {
            return 0;
        }
    }
    return 1;
}

int main(void) {
    int i;
    int match_index;
    int s_len;
    char s[N + 1];
    int t_len;
    char t[N + 1];

    scanf("%s", s);
    s_len = strlen(s);

    scanf("%s", t);
    t_len = strlen(t);

    match_index = -1;
    for (i = s_len - t_len; i >= 0; i--) {
        if (match(s + i, t, t_len)) {
            match_index = i;
            break;
        }
    }

    if (match_index == -1) {
        printf("UNRESTORABLE\n");
    } else {
        for (i = 0; i < t_len; i++) {
            s[match_index + i] = t[i];
        }
        for (i = 0; i < s_len; i++) {
            s[i] = s[i] == '?' ? 'a' : s[i];
        }
        printf("%s\n", s);
    }

    return 0;
}


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

#define _u(i,a,b) for(int i=a;i<=b;++i)
#define _d(i,a,b) for(int i=a;i>=b;--i)
#define endl "\n"
#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
#define FIO() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FI(task) freopen(task".inp","r",stdin)
#define FO(task) freopen(task".out","w",stdout)

using namespace std;

const int N = 1e5+7;
const int M = 1e9+7;

ll f[N][2];
vector<int>edge[N];
int n;

void dfs(int u, int p){
    f[u][0] = f[u][1] = 1;
    for(int v:edge[u]){
        if(v==p) continue;
        dfs(v, u);
        f[u][0] = (f[u][0] * ((f[v][1] + f[v][0]) % M)) % M;
        f[u][1] = (f[u][1] * f[v][0]) % M;
    }
}

#define task "test"

int main(){
    FIO();
    //FI(task);
    ///FO(task);

    cin >> n;
    _u(i,2,n){
        int u, v;
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(1,1);
    cout << (f[1][0] + f[1][1]) % M;
    return 0;
}


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


int main(void) {
  ll n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (n <= 2 && m <= 2) {
    cout << 0 << endl;
    return 0;
  }

  if (n == 1 || m == 1) {
    if (n > m) swap(n, m);
    cout << m - 2 << endl;
    return 0;
  }

  cout << (n - 2) * (m - 2) << endl;
  
  return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi colors(9, 0);
    rep(i, n) {
        int color = a[i] / 400;
        colors[min(color, 8)]++;
    }
    int mn = 0;
    int mx = 0;
    rep(i, 8) {
        if (colors[i]) {
            mn++; mx++;
        } 
    }
    chmax(mn, 1);
    mx += colors[8];
    cout << mn << " " << mx << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

static bool sieve[1000010];
static int primecount[1000010];

int main() {
	fill(sieve, sieve+1000010, true);
	sieve[0]=sieve[1]=false;
	primecount[0]=primecount[1]=0;
	int partial_count = 0;
	for(int i = 2; i < 1000010; i++) {
		primecount[i] = partial_count;
		if(!sieve[i])continue;
		primecount[i] = ++partial_count;
		if(i<10000)
			for(int j = i*i; j < 1000010; j+=i) {
				sieve[j]=false;
			}
	}
	while(true) {
		int n; if(scanf("%d", &n)<1)break;
		printf("%d\n", primecount[n]);
	}
	return 0;
}

Measured memory_bytes: 0
// 答えを見た
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORED(i, s, n) for (int i = (s); i >= (int)(n); i--)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define debugs(s) cerr << s << "\n"
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

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

#define fst first
#define snd second
#define pb push_back
#define mk(x,y) make_pair((x),(y))

// http://ehafib.hatenablog.com/entry/2015/12/23/164137
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qpm(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){
    if (a == 0 || b == 0) {
        return max(a, b);
    }
    return b?gcd(b,a%b):a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define sz(v) int(v.size())

// x1, x2ライブラリとの被りを避ける
#define x1 x192837465
#define x2 x123456789
#define y1 y192837465
#define y2 y123456789

// typo
#define itn int
#define reutrn return
#define reutnr return
#define srting string

#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;

int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}


const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    make(int, N);

    vector<int> As(N+2);
    REP(i, N) {
        make(int, A);

        As.at(i+1) = A;
    }

    int ans = 0;

    vector<int> Ls(N+2);
    vector<int> Rs(N+2);
    Ls.at(0) = 0;
    FORE(i, 1, N) {
        Ls.at(i) = gcd(Ls.at(i-1), As.at(i));
    }

    Rs.at(N) = 0;
    FORED(i, N, 1) {
        Rs.at(i) = gcd(As.at(i), Rs.at(i+1));
    }

    // 1個隠して、最大公約数取って、一番大きいものが勝ち
    FORE(i, 1, N) {
        ans = max(ans, gcd(Ls.at(i-1), Rs.at(i+1)));
    }

    cout << ans << endl;
}


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

int main(){
    int n, x;
    cin >> n >> x;

    vector<int> m(n);
    int sum = 0;
    for(int i=0; i<n; i++){
        cin >> m[i];
        sum += m[i];
    }
    sort(m.begin(),m.end());
    cout << n + (x - sum) / m[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b,c,x,y,abm,xymi,xyma,sum;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(x < y) {
		xymi =x;
		xyma =y;
		abm =b;
	}
	else {
		xymi = y;
		xyma = x;
		abm =a;
	}
 	sum = 2*c*xymi+abm*(xyma-xymi);
 	if(sum > a*x+b*y) sum= a*x+b*y ;
 	if(sum > 2*c*xyma) sum = 2*c*xyma;
 	printf("%d\n",sum );
}

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

typedef long long ll;
typedef pair<ll, int> P;
const int N = (int)2e5 + 50;

int n, k;
ll num[N];
P p[N];
int bit[N];

void add(int x, int val) {
    for(int i = x; i < n; i |= i + 1) bit[i] += val;
}

ll get(int x) {
    ll res = 0;
    for(int i = x; i >= 0; i = (i & (i + 1)) - 1)  res += bit[i];
    return res;
}


int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> num[i], num[i] -= k;
    for(int i = 1; i <= n; i++) num[i] += num[i-1];
    n++;
    for(int i = 0; i < n; i++) {
        p[i].first = num[i];
        p[i].second = i;
    }
    sort(p, p + n);
    ll res = 0;
    int r = 0;
    for(int i = 0; i < n; i = r) {
        while(r < n && p[i].first == p[r].first) {
            res += get(p[r].second);
            r++;
        }
        res += 1LL * (r - i) * (r - i - 1) / 2;
        for(int j = i; j < r; j++) add(p[j].second, 1);
    }
    cout << res << endl;


}

Measured memory_bytes: 5760
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    IN(n, m);
    cout << (n == m ? "Yes" : "No") << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r; cin >> r;
  if(r < 1200) cout << "ABC" << endk;
  else if(r < 2800) cout << "ARC" << endk;
  else cout << "AGC" << endk;
  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		
		
		while(scan.hasNext())
		{
			int n,k;
			n=scan.nextInt();
			k=scan.nextInt();
			String s,s1 ;
			s=scan.next();
			char arr[]=s.toCharArray();
			char c=Character.toLowerCase(arr[k-1]);
			arr[k-1]=c;
			System.out.println(arr);
			
			
			
		}
	}

}


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

int judge(char a){
    if(a=='A'){return 1;}
    if(a=='C'){return 1;}
    if(a=='T'){return 1;}
    if(a=='G'){return 1;}
    return 0;
}

int main(){
    string s;
    int cou=0,sum=0;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(judge(s.at(i))){
            cou++;
        }else{
            sum=max(sum,cou);
            cou=0;
        }
    }
    sum=max(sum,cou);
    cout << sum << endl;
}

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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const ll INF = (ll) 1e16 + 7;

int main(int argc, char *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll a, b, n;
	cin >> a >> b >> n;

	ll l = 0, r = n;
	ll ans = LONG_MIN;
	while (l <= r) {
		ll mid = (l + r) / 2;
		ll x = (a * mid) / b - a * (mid / b);
		if (x >= ans) {
			ans = x;
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define int long long
#define re(i,n) for(i=0;i<n;i++)
#define bre(i,n) for(i=n;i>0;i--)
#define rep(i,l,r) for(i=l;i<r;i++)
#define brep(i,l,r) for(i=r;i>l;i--)
const int inf=1145141919810893;
const int mod=998244353;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
template<int H,int W>int wa(int x1,int y1,int x2,int y2,int(&p)[H][W]){
	return p[y2][x2]-p[y2][x1]-p[y1][x2]+p[y1][x1];
}
struct Unif{
	vector<int> e;
	vector<int> rank;
	Unif(int n):e(n,-1),rank(n,1){}
	void uni(int a,int b){
		if(e[a]!=-1)
			uni(e[a],b);
		else if(e[b]!=-1)
			uni(a,e[b]);
		else{
			if(a==b)
				return;
			int ra=rank[a],rb=rank[b];
			if(ra>=rb){
				e[b]=a;
				if(ra==rb)
					rank[a]++;
			}
			else
				e[a]=b;
		}
	}
	bool find(int a,int b){
		if(e[a]!=-1)
			return find(e[a],b);
		else if(e[b]!=-1)
			return find(a,e[b]);
		else
			return a==b;
	}
	int num(int a){
		if(e[a]!=-1)
			return num(e[a]);
		else
			return a;
	}
};
int A,B,C,D,N,M,K,S,T,H,W,Q;
signed main(){
	int i,j,k;
	cin>>Q;
	re(i,Q){
		cin>>A>>B;
		if(A==B){
			cout<<A+B-2<<endl;
			continue;
		}
		double r=sqrt(static_cast<double>(A)*static_cast<double>(B));
		int x=floor(r),y=ceil(r);
		if(x==y&&x*y>=A*B)
			x--;
		else if(x*y>=A*B)
			y--;
		cout<<x+y-2<<endl;
	}
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
 */

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

signed main() {
  int n, m;
  cin >> n >> m;

  int ac = 0, wa = 0;
  vector<bool> aced(n);
  vi wac(n);

  rep(i, 0, m){
    int p;
    string s;
    cin >> p >> s;
    p--;

    if(s == "AC"){
      if(!aced[p]){
        aced[p] = true;
        ac++;
        wa += wac[p];
      }
    }else{
      if(!aced[p]){
        wac[p]++;
      }
    }
  }

  cout << ac << " " << wa << endl;

  return 0;
}



Measured memory_bytes: 1024
r = 0
while r == 0:
        n = map(int,raw_input().split())
        if n[0] == n[1] == 0:
                break
        elif n[0] < n[1]:
                print n[0] ,
                print n[1] 
        else:
                print n[1] ,
                print n[0]

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n, m, k;
  cin >> n >> m >> k;

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

  vector<ll> b(m);
  for (ll i = 0; i < m; ++i) {
    cin >> b[i];
  }

  vector<ll> suma(n+1);
  for (ll i = 1; i <= n; ++i) {
    suma[i] = suma[i-1] + a[i-1];
  }

  vector<ll> sumb(m+1);
  for (ll i = 1; i <= m; ++i) {
    sumb[i] = sumb[i-1] + b[i-1];
  }

  ll ans = 0;
  for (ll i = 0; i <= n; ++i) {
    ll x = k;
    if (suma[i] <= x) {
      ans = max(ans, i);
      x -= suma[i];
    }

    ll lb = 0;
    ll ub = m;
    while (ub-lb > 1) {
      ll mid = (lb+ub) / 2;
      if (x < sumb[mid]) {
        ub = mid;
      } else {
        lb = mid;
      }
    }
    if (suma[i]+sumb[lb] <= k) {
      ans = max(ans, i+lb);
    }
    if (suma[i]+sumb[ub] <= k) {
      ans = max(ans, i+ub);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9584
#pragma GCC optimize ("Ofast")

#include <cstdio>
#include <cstring>

const int MAX_N = 3e3 + 5;
const int MOD = 998244353;
const int INV = 499122177;

int n, s, a[MAX_N], t[MAX_N], f[MAX_N][MAX_N], g[MAX_N][MAX_N], ans;

void add(int *a, int *b)
{
	for (int i = 0; i < MAX_N; ++i)
		(a[i] += b[i]) %= MOD;
}

int main()
{
	scanf("%d%d", &n, &s);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		memcpy(f[i], f[i - 1], MAX_N * sizeof(int));
		memset(t, 0x00, a[i] * sizeof(int));
		memcpy(t + a[i], f[i], (MAX_N - a[i]) * sizeof(int));
		(t[a[i]] *= i) %= MOD;
		add(f[i], t);
		//printf("f[%d] = %d\n", i, f[i][s]);
		(ans += f[i][s]) %= MOD;
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main() {

	int n, S[10000] = { 0 }, q, T[500] = { 0 };
	int cnt = 0;

	cin >> n;

	for (int i = 0;i < n;i++) {
		cin >> S[i];
	}

	cin >> q;

	for (int i = 0;i < q;i++) {
		cin >> T[i];
	}

	for (int i = 0;i < q;i++) {
		for (int j = 0;j < n;j++) {
			if (S[j] == T[i]) {
				cnt++;
				break;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int N,i,temp,ans=0;
	vector<int> p;
	cin>>N;
	for(i=0;i<N;i++){
		cin>>temp;
		p.push_back(temp);
	}
	for(i=1;i<N-1;i++){
		if((p.at(i-1)<p.at(i))&&(p.at(i)<p.at(i+1))){
			ans++;
		}else if((p.at(i-1)>p.at(i))&&(p.at(i)>p.at(i+1))){
			ans++;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1<<30
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;

int main() {
    ll N, K;
    cin >> N >> K;
    ll x[51], y[51], xi, xj, yi, yj, i;
    vector<ll> xary, yary;
    ll num;
    for(i=0; i<N; i++) {
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }
    sort(xary.begin(), xary.end());
    sort(yary.begin(), yary.end());
    
    ll ans=-1;
    for(xi=0; xi<N; xi++) {
        for(xj=0; xj<N; xj++) {
            for(yi=0; yi<N; yi++) {
                for(yj=0; yj<N; yj++) {
                    num=0;
                    ll lx=x[xi], rx=x[xj];
                    ll by=y[yi], uy=y[yj];
                    for(i=0; i<N; i++) {
                        if(lx<=x[i] && x[i]<=rx && by<=y[i] && y[i]<=uy)
                            num++;
                    }
                    if(num>=K) {
                        if(ans<0) ans=(rx-lx)*(uy-by);
                        else ans=min(ans, (rx-lx)*(uy-by));
                        
                        
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
sum_a = sum(a_list)
num_a = [0]*(10**5)
for i in a_list:
    num_a[i-1] += 1
    
q = int(input())
for _ in range(q):
    b, c = list(map(int, input().split()))
    sum_a = sum_a + c * num_a[b-1] - b *num_a[b-1]
    num_a[c-1] += num_a[b-1]
    num_a[b-1] = 0
    print(sum_a)

Measured memory_bytes: 20972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b;
    cin>>a>>b;
    ll x=b-a+1;
    ll y=b+a-1;
    for(ll i=x;i<=y;i++)
        cout<<i<<" ";
    return 0;
}


Measured memory_bytes: 256