akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _Ty> static _Ty tp_abs(const _Ty& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _Ty> static _Ty tp_min(_Ty a, _Ty b) {
	return a < b ? a : b;
}
template <class _Ty> static _Ty tp_max(_Ty a, _Ty b) {
	return a > b ? a : b;
}
template<class T> static void getint(T& a) {
	const char* fmt = " %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class T> static void getint(T& a, T& b) {
	const char* fmt = " %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class T> static void getint(T& a, T& b, T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static const int EduDp_INF = 1100000000;
static const int MOD_NUM = 1000000007;
static void E_task();

#if 1
int main()
{
	E_task();
	fflush(stdout);
	return 0;
}
#endif

static void E_task()
{
	LLONG N, W;
	getint<LLONG>(N, W);

	std::vector<int> vn(N + 1, 0);
	std::vector<LLONG> wn(N + 1, 0);

	int vsum = 0;
	for (int i = 1; i <= N; i++) {
		int w, v; getint(w, v);
		wn[i] = w;
		vn[i] = v;
		vsum += v;
	}

	std::vector<std::vector<LLONG>> dp(N + 1);
	for (int i = 0; i <= N; i++) {
		dp[i].resize(vsum + 1, EduDp_INF * 2LL);
	}

	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int v = 0; v <= vsum; v++) {
			if (v >= vn[i]) {
				dp[i][v] = tp_min<LLONG>(dp[i - 1][v - vn[i]] + wn[i], dp[i][v]);
			}
			dp[i][v] = tp_min<LLONG>(dp[i][v], dp[i - 1][v]);
		}
	}

	int ans = 0;
	for (int v = 1; v <= vsum; v++) {
		if (dp[N][v] <= W) {
			ans = v;
		}
	}

	printf("%d\n", ans);
}


Measured memory_bytes: 79488
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()

cnt = Counter(S)
low = min(cnt["0"],cnt["1"])
ans = low*2

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

using namespace std;

#define rep(i, n) for(int64 i = 0; i < (int64)(n); i++)

using int64 = long long;
const int64 INF = 1LL << 60;

int main()
{
  string s, t;
  cin >> s >> t;
  sort(begin(s), end(s));
  sort(begin(t), end(t));
  reverse(begin(t), end(t));
  if(s < t) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }
 
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int ton(string s){
  return atoi(s.c_str());
}
string tos(int N){
  stringstream ss;
  ss<<N;
  string s = ss.str();
  while(s.size() < 4) s = "0" + s;
  return s;
}
int solve(string s){
  if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) return -1;
  int ans = 0;
  while(true){
    if(s == "6174") break;
    sort(s.begin(), s.end());
    int S = ton(s);
    reverse(s.begin(), s.end());
    int L = ton(s);
    int N = L - S;
    s = tos(N);
    ans += 1;
  }
  return ans;
}
 
int main(){
  string s;
  while( cin>>s && s != "0000"){
    int ans = solve(s);
    if(ans == -1) cout<<"NA"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3132
n = int(input())
w = [input() for _ in range(n)]

s = set()
l = []

for c in w:
    s.add(c)
    l.append([c[0], c[len(c) - 1]])

if len(s) != len(w):
    print("No")
    exit()

for i in range(len(l)):
    if i == len(l) - 1:
        break
    
    if l[i][1] != l[i + 1][0]:
        print("No")
        exit()

print("Yes")

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
   
    int a,b;
    cin>>a>>b;
    cout << max(0,a-b-b) << endl;
}

Measured memory_bytes: 256
A, B, C, D, E, F = list(map(int, input().split()))
consentration_max = 0
suger_water_max = 0
suger_max = 0
for A_cnt in range(0, 31):
    for B_cnt in range(0, 31):
        water = A_cnt * 100 * A + B_cnt * 100 * B
        if water > F or water <= 0:
            continue
        max_solt = int(E*water/100)
        for C_cnt in range(0, int(max_solt/C)+1):
            for D_cnt in range(0, max(int((max_solt - C_cnt*C)/D) + 1, 1)):
                suger = C_cnt * C + D_cnt * D
                consentration = suger/(water+suger)
                if consentration_max <= consentration and (water+suger) <= F:
                    consentration_max = consentration
                    suger_water_max = water+suger
                    suger_max = suger
print("{} {}".format(suger_water_max, suger_max))


Measured memory_bytes: 3064
// Copyright 2017 wu_qing
#include <cstdio>
#include <algorithm>
const int N = 200;
int n, s[N], sum, f = -1;
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", s + i);
    std::sort(s, s + n);
    for (int i = 0; i < n; i++) {
        sum += s[i];
        if (s[i] % 10 != 0 && f == -1)
            f = s[i];
    }
    if (sum % 10 == 0) {
        if (f == -1)
            sum = 0;
        else
            sum -= f;
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static boolean[] array;
	public static int count = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		array = new boolean[str.length()];
		for (int i = 0; i < array.length; i++) {
			if (str.charAt(i) == '1') {
				array[i] = true;
			}
		}
		boolean p = array[0];
		exec(0);
		System.out.println(count);
	}
	
	public static boolean exec(int index) {
		if (index >= array.length - 1) {
			return false;
		} else {
			if (array[index] == array[index + 1]) {
				array[index + 1] = !array[index + 1];
				count++;
			}
			return exec(index + 1);
		}
	}
}


Measured memory_bytes: 34700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  string s;
  cin >> s;
  ull len = s.size();
  bool can = true;
  rep(i,len){
    if(s[i] != s[len-i-1]){
      can = false;
    }
  }
  rep(i,(len-1)/2){
    if(s[i] != s[(len-1)/2-i-1]){
      can = false;
    }
  }
  rep(i,(len-1)/2){
    if(s[i+ (len+1)/2] != s[len-1-i]){
      can = false;
    }
  }
  if(can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100000
using namespace std;

vector< int > graph[MAX_N];

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

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

  for(int i = 0; i < m; i++){
    graph[a[i]].push_back(b[i]);
    graph[b[i]].push_back(a[i]);
  }

  deque< int > path;
  path.push_back(a[0]); path.push_back(b[0]);
  set< int > vertices;
  vertices.insert(a[0]); vertices.insert(b[0]);
  while(true){
    bool all = true;
    for(int v: graph[path[0]]){
      if(vertices.find(v) == vertices.end()){
        all = false;
        path.push_front(v); vertices.insert(v);
        break;
      }
    }
    if(all) break;
  }
  while(true){
    bool all = true;
    for(int v: graph[path[path.size() - 1]]){
      if(vertices.find(v) == vertices.end()){
        all = false;
        path.push_back(v); vertices.insert(v);
        break;
      }
    }
    if(all) break;
  }

  string buf;
  buf += to_string(path.size()) + "\n";
  for(int v: path){
    buf += to_string(v + 1) + " ";
  }

  cout << buf << endl;

  return 0;
}


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

#define ll long long

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define alll(it,A) for(it=A.begin();it!=A.end();it++)

#define err1(a) cout<<a<<endl
#define err2(a,b) cout<<a<<" "<<b<<endl
#define err3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>

const ll N=100005;
const ll M = 1000000007;

ll A[N][3],dp[N][3];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    rep(i,0,n) rep(j,0,3)	cin>>A[i][j];
    rep(i,0,3)	dp[0][i]=A[0][i];
    rep(i,1,n){
    	rep(j,0,3){
    		rep(k,0,3){
    			if(j==k)	continue;
    			dp[i][j]=max(dp[i][j],dp[i-1][k]+A[i][j]);
    		}
    	}
    }
    ll ans=0;
    rep(i,0,3)	ans=max(ans,dp[n-1][i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4992
/* 
 * Author: aps
 * Time: 2019-07-13 22:43:34
**/
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll inf = 1e18;
const ll mod = 1e9+7;
 
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int n,k; cin >> n >> k;

    int maxi = ((n-1)*(n-2))/2;
    if(k > maxi) {
        cout << -1 << endl;
    } else {
        vector<pii> ans;
        for(int i=1;i<=n-1;i++) {
            ans.pb({i,n});
        }

        int del = maxi - k;
        for(int i=1;i<=n-1;i++){
            for(int j=i+1;j<=n-1;j++){
                if(del == 0){
                    cout << (int)ans.size() << endl;
                    for(pii p: ans){
                        cout << p.fi << " " << p.se << endl;
                    }
                    return 0;
                } else {
                    ans.pb({i,j});
                    --del;
                }
            }
        }

        cout << (int)ans.size() << endl;
        for(pii p: ans) cout << p.fi << " " << p.se << endl;
    }

    return 0;
}


Measured memory_bytes: 384
import sys
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
for z in range(101):
  if X<z<=Y and all(x[i]<z for i in range(n)) and all(y[j]>=z for j in range(m)):
    print('No War')
    sys.exit()
for z in range(1,101):
  if X<z*(-1)<=Y and all(x[i]<z*(-1) for i in range(n)) and all(y[j]>=z*(-1) for j in range(m)):
    print('No War')
    sys.exit()
print('War')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

int main(){
  long long N;
  bool flag = 0;
  cin >> N;
  deque<int> v;
  while(N){
    if(N%2){
      v.push_back(1);
      N -= 1;
    }
    else{
      v.push_back(0);
    }
    N /= -2;
  }
  while(v.size()){
    if(v.back())flag = 1;
    if(flag)cout << v.back();
    v.pop_back();
  }
  if(!flag)cout << 0;
  cout << endl;
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
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 (b<a) { a=b; return 1; } return 0; }

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;

    ll ans = 0;
    repf(i,1,n+1){
        if(i%3==0 || i%5==0){

        }else{
            ans+=i;
        }
    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3680
N,X,Y = map(int,input().split())

g = [[] for _ in range(N+1)]
for i in range(1,N):
    g[i].append(i+1)
    g[i+1].append(i)
g[X].append(Y)
g[Y].append(X)

from collections import deque
def bfs(u):
    queue = deque([u])
    d = [None]*(N+1)
    d[u]=0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i]=d[v]+1
                queue.append(i)
    return d

ans = [0]*(N-1)
for i in range(1,N+1):
    d = bfs(i)
    for j in range(1,N+1):
        if d[j]>0:
            ans[d[j]-1] += 1
for a in ans:
    print(a//2)

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

int main(){
	int n,m;

	while(std::cin >> n >> m){
		
		if(n == 0 && m == 0) return 0;

		std::vector<int> a(n);

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

		std::sort(a.begin(), a.end(), std::greater<int>());//降順

		int cost = 0;

		for(int i = 0; i < n; ++i){
			if((i+1) % m != 0) cost += a[i];//mの倍数番目に高い野菜を無料にする
		}

		std::cout << cost << std::endl;
	}
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define MAXN 100010

int n, m, q;
int color[MAXN], vq[MAXN], d[MAXN], c[MAXN], maxp[MAXN];
vector<int> adj[MAXN];

void fill(int query){
	int s = vq[query], p = d[query], cs = c[query];
	queue<ii> Q;
	if(p<=maxp[s] || p<0){
	//if(p<0){
		return ;
	}
	Q.push(ii(s, p));
	maxp[s] = max(maxp[s], p);
	while(!Q.empty()){
		ii pf = Q.front(); Q.pop();
		int u = pf.first, pu = pf.second;
		if(color[u]==0){
			color[u] = cs;
		}
		int tam = adj[u].size();
		for(int i=0; i<tam; i++){
			int v = adj[u][i], pv = pu-1;
			if(pv>maxp[v] && pv>=0){
			//if(pv>=0){				
				Q.push(ii(v, pv));
				maxp[v] = max(maxp[v], pv);
			}
		}
	}
}

int main(){
	while(scanf("%d %d", &n, &m)!=EOF){
		int u, v;
		for(int i=0; i<n; i++){
			adj[i].clear();
		}
		for(int i=0; i<m; i++){
			scanf("%d %d", &u, &v);
			u--; v--;	
			adj[u].push_back(v);
			adj[v].push_back(u);	
		}
		scanf("%d", &q);
		for(int i=0; i<q; i++){
			scanf("%d %d %d", &vq[i], &d[i], &c[i]);
			vq[i]--;
		}
		memset(color, 0, sizeof(color));
		memset(maxp, -1, sizeof(maxp));
		for(int i=q-1; i>=0; i--){
		//for(int i=0; i<q; i++){
			fill(i);
		}
		for(int i=0; i<n; i++){
			printf("%d\n", color[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 8912
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+n)

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

	if (a <= x && x <= a + b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repp(i, l, r) for (ll i = (l); i < (r); i++)
#include <stdio.h>
#include <math.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    double x[10], y[10], sum = 0;
    rep(i, n)
    {
        scanf(" %lf %lf", &x[i], &y[i]);
    }
    rep(i, n)
    {
        repp(j, i, n)
        {
            sum += 2 * sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }
    sum /= n;
    printf("%f", sum);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int w,n,i,temp;
        int[] num;
        String line;

        w=scan.nextInt();
        n=scan.nextInt();
        num = new int[w];
        for(i=0;i<w;i++){
            num[i]=i+1;
        }

        for(i=0;i<n;i++){
            line=scan.next();
            String[] ab = line.split(",");
            int a = Integer.parseInt(ab[0]);
            int b = Integer.parseInt(ab[1]);

            temp=num[a-1];
            num[a-1]=num[b-1];
            num[b-1]=temp;
        }

        for(i=0;i<w;i++){
            System.out.println(num[i]);
        }

    }
}


Measured memory_bytes: 25804
package main

import (
	"fmt"
	"regexp"
)

func main() {
	var a string
	fmt.Scan(&a)
	lower := regexp.MustCompile("[a-z]")
	pos := lower.FindIndex([]byte(a))
	if len(pos) > 0 {
		fmt.Println("a")
	} else {
		fmt.Println("A")
	}
}


Measured memory_bytes: 2000
import sys
# import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

tower = [[[0] * 10 for i in range(3)] for j in range(4)]

N, M = map(int, readline().split())
A = [[int(i) for i in readline().split()] for _ in range(N)]
B = [int(readline()) for _ in range(M)]
li = [0] * N
for n,i in enumerate(A):
    for num, j in enumerate(B):
        li[n] += i[num] * j

print(*li, sep='\n')



Measured memory_bytes: 5936
/*c++11*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <deque>

using namespace std;

int main(int args, char *argc[]){
  char a,b,c;
  char t;
  int joi=0;
  int ioi=0;
  deque<char> que;

  while(scanf("%c",&a)!=EOF){
    scanf("%c%c",&b,&c);
    que.clear();
    joi=0;
    ioi=0;
    if(a=='J' && b=='O' && c=='I')
      joi++;
    else if(a=='I' && b=='O' && c=='I')
      ioi++;

    que.push_back(a); 
    que.push_back(b); 
    que.push_back(c); 

    while(scanf("%c",&t)!=EOF){
      if(t=='\n')
        break;
      que.pop_front();
      que.push_back(t);

      if(que[0]=='J' && que[1]=='O' && que[2]=='I')
        joi++;
      else if(que[0]=='I' && que[1]=='O' && que[2]=='I')
        ioi++;
    }
    printf("%d\n%d\n",joi,ioi);
  }
  return 0;
}


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

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  double n,k;
  cin>> n >> k;
  double pro;
  for(int i=1; i<=n; i++){
    double count=1.0/n;
    double sum=i;
    while(k > sum){
      sum *=2;
      count*=0.5;
    }
    pro += count;
  }
  std::cout<<std::fixed<<std::setprecision(10)<<pro<<endl;
}

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

int main(void){
  int n,i=0,a[32]={};
  scanf("%d",&n);
  if(n==0){
    printf("0\n");
    return 0;
  }
  while(n!=0){
    a[i] =abs(n%2);
    if(n<0 && a[i]==1) n-=1;
    n/=-2;
    i++;
  }
  while(i--) printf("%d",a[i]);
  printf("\n");
  return 0;
}

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

int n, a[100100];
ll s[100100], f[100100], sf[100100], g[100100], facn = 1, ans;

inline ll qpow(ll a,int x) {
	ll r = 1;
	for (;x;x>>=1) {
		if (x & 1) r = r * a % P;
		a = a * a % P;
	} return r;
}
inline ll inv(int x) {return qpow(x,P-2);}

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",a+i);
		s[i] = (s[i-1] + a[i]) % P;
		facn = facn * i % P;
	}
	for (int i=1;i<=n-2;i++) sf[i] = (sf[i-1] + (f[i] = facn * 2 * inv(i+1) % P * inv(i+2) % P)) % P;
	for (int i=1;i<=n-1;i++) g[i] = facn * inv(i+1) % P;
	
	for (int r=2;r<n;r++) ans = (ans + s[r] * sf[r-1]) % P;
	for (int l=2;l<n;l++) ans = (P + ans - s[l-1] * sf[n-l] % P) % P;
	
	for (int r=1;r<n;r++) ans = (ans + s[r] * g[r]) % P;
	for (int l=2;l<=n;l++) ans = (ans + (P + s[n] - s[l-1]) * g[n-l+1]) % P;
	ans = (ans + s[n] * facn) % P;
	
//	for (int l=1;l<=n;l++) for (int r=l;r<=n;r++) {
//		if (l == 1 && r == n) ans = (ans + (s[r] - s[l-1]) * facn) % P;
//		else if (l == 1 || r == n) ans = (ans + (s[r] - s[l-1]) * g[r-l+1]) % P;
//		else ;//ans = (ans + (s[r] - s[l-1]) * f[r-l+1]) % P;
//	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
	int h, w;
	string temp;
	vector<string> s;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> temp;
		s.push_back(temp);
	}
	for (int i = 0; i < h; i++)cout << s[i] << endl << s[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ll long long
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll n;
		cin>>n;
		cout<<fixed<<setprecision(10);
		vector<double> A(n);
		forn(i,n)cin>>A[i];
		vector<double> dp(n+1,0);
		dp[0]=1;
		forn(i,n)
		{
			for(ll j=i+1;j>=0;j--)
			{
				dp[j]=(j==0?0:dp[j-1]*(A[i]))+dp[j]*(1-A[i]);

			}
		}
		long double ans=0;
		forn(i,n+1)
		{
			ll tails=n-i;
			ll heads=i;
			if(heads>tails)
			{
				ans+=dp[i];
			}
		}
		cout<<ans<<endl;
		
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 3824
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main() {
    int H, W;
    cin >> H >> W;
    int alph[26];
    fill(alph, alph + 26, 0);
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            alph[s[j] - 97]++;
        }
    }
    int four = 0;
    int two = 0;
    int one = 0;
    for (int i = 0; i < 26; i++) {
        int num = alph[i];
        int a = alph[i] / 4;
        four += a;
        num -= a * 4;
        if (num >= 2) {
            two++;
            num -= 2;
        }
        if (num >= 1) {
            one++;
        }
    }
    int tar4, tar2;
    if (H % 2 == 0 && W % 2 == 0) {
        tar4 = H * W / 4;
        tar2 = 0;
    } else if (H % 2 == 1 && W % 2 == 1) {
        tar4 = (H / 2) * (W / 2);
        tar2 = (H / 2) + (W / 2);
    } else if (H % 2 == 1 && W % 2 == 0) {
        tar4 = (H / 2) * (W / 2);
        tar2 = W / 2;
    } else {
        tar4 = (H / 2) * (W / 2);
        tar2 = H / 2;
    }
    bool ok = true;
    if (tar4 > four) {
        ok = false;
    } else {
        int rem = (four - tar4) * 2 + two;
        if (rem != tar2) {
            ok = false;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 250

int main(){
  int n,i,x[N];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&x[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,x[i]);
    if(i/2>=1){
      printf("parent key = %d, ",x[i/2]);
    }
    if(i*2<=n){
      printf("left key = %d, ",x[i*2]);
    }
    if(i*2+1<=n){
      printf("right key = %d, ",x[i*2+1]);
    }
    printf("\n");
  }
    return 0;
}



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

struct UF{
    int n;
    vector<int> p, club;
    
    UF(int siz){
        n = siz;
        p.resize(n);
        club.resize(n, -1);
        for(int i = 0; i < n; i++)  p[i] = i;
    }

    int getparent(int x){
        if(p[x] != x){
            p[x] = getparent(p[x]);
        }
        return p[x];
    }

    bool same(int x, int y){
        return getparent(x)==getparent(y);
    }

    bool unite(int x, int y){
        x = getparent(x), y = getparent(y);
        if(club[x] == -1){
            p[x] = y;
            return true;
        }else if(club[y] == -1){
            p[y] = x;
            return true;
        }else if(club[x] == club[y]){
            return true;
        }
        return false;
    }

    bool assign(int x, int val){
        x = getparent(x);
        if(club[x] == -1 || club[x] == val){
            club[x] = val;
            return true;
        }
        return false;
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    UF uf(n);
    int a, b, c;
    for(int i = 1; i <= k; i++){
        cin >> a >> b >> c;
        b--, c--;
        bool act = true;
        if(a == 1){
            act = uf.unite(b, c);
        }else{
            act = uf.assign(b, c);
        }
        if(!act){
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3640
x1,y1,x2,y2=(map(int,input().split()))

x=x2-x1
y=y2-y1

ans=[]
ans="U"*y+"R"*x+"D"*y+"L"*x
ans+="L"+"U"*(y+1)+"R"*(x+1)+"D"*1+"R"*1+"D"*(y+1)+"L"*(x+1)+"U"*1
print(ans)

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

int main() {
  int a, b, x, y;
  string s;
  cin >> a >> b >> s;

  if (count(s.begin(), s.end(), '-')!=1) {
    cout << "No" << endl;
    return 0;
  } else {
    for (int i=0; i<s.size(); i++) {
      if (s[i]=='-') x=i;
    }
    y=s.size()-x-1;
  }

  cout << (a==x && b==y ? "Yes": "No") << endl;
}

Measured memory_bytes: 384
(let* ((str (reverse (read-line))))
  (defun f (str-f)
    (if (not (string= str-f ""))
        (cond ((and (<= 6 (length str-f)) (string= (subseq str-f 0 6) "resare")) (f (subseq str-f 6)))
            ((and (<= 5 (length str-f)) (string= (subseq str-f 0 5) "esare")) (f (subseq str-f 5)))
            ((and (<= 7 (length str-f)) (string= (subseq str-f 0 7) "remaerd")) (f (subseq str-f 7)))
            ((and (<= 5 (length str-f)) (string= (subseq str-f 0 5) "maerd")) (f (subseq str-f 5)))
            (t nil))
        t))
  (if (f str) (princ "YES") (princ "NO")))

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n,m;
  cin>>n>>m;

  int64_t a = 1900*m;
  int64_t b = 100*(n-m);
  int64_t c = 1LL<<m;
  cout<< (a+b)*c <<endl;

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Problem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long H = in.nextLong();
            HashMap<Long, Long> memo = new HashMap<>();
            long res = countAttacks(H, 0, memo);
            out.println(res);
        }

        public long countAttacks(long H, long res, HashMap<Long, Long> memo) {
            if(H == 1)
                return res + 1;

            if(memo.containsKey(H))
                return memo.get(H);

            long res1 = countAttacks(H/2, res, memo);
            memo.put(H/2, res1);
            long res2 = countAttacks(H/2, res, memo);
            return res1 + res2 + 1;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a;
    string b;
    cin >> a >> b;
    int c = b[0] - '0';
    for (int i = 1; i < b.size(); i++) {
        if (b[i] == '.') continue;  
        c *= 10;
        c += b[i] - '0';
    }
    long long ans = (a * c) / 100;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3648
line = input().rstrip().split(" ")
a=int(line[0])    #高木の体力
b=int(line[1])    #高木の攻撃
c=int(line[2])    #青木の体力
d=int(line[3])    #青木の攻撃

i=0
while i>=0:
    if i%2==0:#偶数
        c=c-b
    
    elif i%2==1:
        a=a-d
    
    i=i+1
    
    if c<=0:
        i=0-1
    elif a<=0:
        i=0-1
    
    
if a<c:
    print("No")
else :
    print("Yes")

Measured memory_bytes: 9204
def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs


MOD = 10**9 + 7
f, inv = prepare(10**5+100, MOD)

n, k = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse=True)

p = 0
m = 0
for i in range(n):
    if n - i >= k:
        cn = n - i - 1
        ck = k - 1
        if cn >= ck:
            combi = f[cn] * inv[ck] % MOD * inv[cn - ck] % MOD
            if a[i] >= 0:        
                p += (a[i] * combi) % MOD
            else:
                p += (a[i] * combi) % -MOD
            if p >= 0:
                p %= MOD
            else:
                p %= -MOD
    if i >= k - 1:
        cn = i
        ck = k - 1
        if cn >= ck:
            combi = f[cn] * inv[ck] % MOD * inv[cn - ck] % MOD
            if a[i] >= 0:        
                m += (a[i] * combi) % MOD
            else:
                m += (a[i] * combi) % -MOD
            if m >= 0:
                m %= MOD
            else:
                m %= -MOD
        
print((p - m)%MOD)

Measured memory_bytes: 27976
#include <bits/stdc++.h>
using namespace std;
int main() {
  int R;
  cin >> R;
  if(R < 1200) {
    cout << "ABC" << endl;
  }else if(R < 2800) {
    cout << "ARC" << endl;
  }else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int x,y,z;
  vector<int> fn(N,0);
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      for(int k=0;k<100;k++){
        x = i + 1;
        y = j + 1;
        z = k + 1;
        int n=(x+y+z)*(x+y+z) - x*y - y*z - z*x;
        if(n<=N){
          fn.at(n-1)++;
        }
      }
    }
  }
  for(int i=0;i<N;i++) cout << fn.at(i) << endl;
  return 0;
}

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

int main(){

        int x,y;
        int W,H;
        int r;

        cin >> W >> H >> x >> y >> r;

        if(r<=x && x<=W-r && r<=y && y<=H-r){
        cout << "Yes" <<endl;
        return 0;
        }

        cout << "No" <<endl;

        return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
int n,s,e,m,l,dp[102][1<<16];
main(){
  while(cin>>n,n){
    memset(dp,0,sizeof(dp));
    r(i,n){
      cin>>m>>l;
      int range=0;
      r(j,m){
        cin>>s>>e;
        s-=6;
        e-=6;
        for(int k=s;k<e;k++)range|=(1<<k);
      }
      r(j,1<<16){
        if(j&range)continue;
        else dp[i+1][range|j]=max(dp[i+1][range|j],dp[i][j]+l);
      }
      r(j,1<<16)dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
    }
    int ans=0;
    r(i,1<<16)ans=max(ans,dp[n][i]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 55304
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = LI()
cnt = 0
s = set()
for i in L:
    if i >= 3200:
        cnt += 1
    else:
        s.add(i // 400)


print(max(1, len(s)), len(s) + cnt)

Measured memory_bytes: 39664
/**
*    author:  yuya1234
*    created: 09.07.2020 15:45:27
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  string s;
  cin>>s;

  string ans="";
  REP(i,SZ(s))
  {
    if(s[i]=='B' && SZ(ans)>0)ans.erase(SZ(ans)-1);
    else if(s[i]=='0' || s[i]=='1')ans+=s[i];
  }

  cout<<ans<<endl;

  return 0;
}

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

 
int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a % b);
}
 
int main() {
 
  int x, y;
  cin >> x >> y;
  int g = gcd(x, y);
  cout << g + 1 + ((x / g - 1) + (y / g - 1)) * g << endl;  

}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,t1,i,j,l1,r1,l2,r2,a[2010][2010],b[2010][2010],c[2010][2010],ans;
char s[2010][2010];
int main(){
	scanf("%d%d%d",&n,&m,&t1);
	for(i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		for(j=1;j<=m;j++){
		  if(s[i][j]=='1')a[i][j]=1;
		  if(j>1&&s[i][j]=='1'&&s[i][j-1]=='1')b[i][j]=1;
		  if(i>1&&s[i][j]=='1'&&s[i-1][j]=='1')c[i][j]=1;
	  }
	}
	for(i=1;i<=n;i++)
	 for(j=1;j<=m;j++){
	  a[i][j]=a[i][j]+a[i-1][j]+a[i][j-1]-a[i-1][j-1],
	  b[i][j]=b[i][j]+b[i-1][j]+b[i][j-1]-b[i-1][j-1],
	  c[i][j]=c[i][j]+c[i-1][j]+c[i][j-1]-c[i-1][j-1];
	  //printf("%d %d %d %d %d\n",i,j,a[i][j],b[i][j],c[i][j]);
}
	while(t1--){
		scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
		ans=a[l2][r2]-a[l1-1][r2]-a[l2][r1-1]+a[l1-1][r1-1];
		//printf("%d\n",ans);
		ans-=b[l2][r2]-b[l2][r1]-b[l1-1][r2]+b[l1-1][r1];
		//printf("%d\n",ans);
		ans-=c[l2][r2]-c[l2][r1-1]-c[l1][r2]+c[l1][r1-1];
		printf("%d\n",ans);
	}
}
/*
想了半年还是不会做>_< 

显然每个小矩形的蓝色路径也不会成环，
那么按照树的定义，
算到区域内相邻蓝色的数目，即边数，用蓝色格子总数减去它就是森林数了
*/

Measured memory_bytes: 52992
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int N[]={0,1,5,4},E[]={0,3,5,2},S[]={0,4,5,1},W[]={0,2,5,3},R[]={3,1,2,4};
class Dice{
public:
	int num[6];
	void turn(char key){
		for(int i=0;i<3;++i){
			if(key=='W'){
				swap(num[W[i]],num[W[i+1]]);
			}else if(key=='N'){
				swap(num[N[i]],num[N[i+1]]);
			}else if(key == 'E'){
				swap(num[E[i]],num[E[i+1]]);
			}else if(key=='S'){
				swap(num[S[i]],num[S[i+1]]);
			}else{
				swap(num[R[i]],num[R[i+1]]);
			}
		}
	}
};
bool operator==(Dice&a,Dice&b){
	for(int i=0;i<6;++i){
		if(a.num[i]!=b.num[i]){
			return false;
		}
	}
	return true;
}
bool check2(Dice A,Dice B){
	for(int i=0;i<4;++i){
		if(A==B)return true;
		A.turn('R');
	}
	return false;
}
bool check1(Dice &A,Dice &B){
	bool flag = false;
	string str = "NNNNENNNN";
	for(int i=0;i<str.size();++i){
		flag |= check2(A,B);
		A.turn(str[i]);	
	}
	return flag;
}

int main(){
	int num;
	cin>>num;
	vector<Dice> line(num);
	for(int i=0;i<num;++i){
		for(int j=0;j<6;++j){
			cin>>line[i].num[j];
		}
	}
	bool flag = true;
	for(int i=0;i<num;++i){
		for(int j=i+1;j<num;++j){
			if(check1(line[i],line[j])){
				flag = false;
				break;
			}
		}
	}
	cout<<(flag ? "Yes":"No")<<endl;		
	return 0;
}



Measured memory_bytes: 3232
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
q = 1000000007

if N == 1:
    if M == 0:
        print(1)
    elif M == 1:
        print(0)
else:
    cost = [0 for _ in range(N + 1)]
    cost[0] = 1

    cnt = 0
    A.append([0])
    for i in range(1, N + 1):
        if i == A[cnt]:
            cnt += 1
            continue
        else:
            cost[i] = cost[i - 1] + cost[i - 2]

    print(cost[-1] % q)


Measured memory_bytes: 469684
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> tot(N + 1, 0);
    for(int i = 1;i <= N;i++) {
        tot[i + 1] = tot[i];
        if(S[i - 1] == 'A' && S[i] == 'C') {
            tot[i + 1]++;
        }
    }
    while(Q--) {
        int l, r;
        cin >> l >> r;
        l--;
        cout << tot[r] - tot[l] -  int(l > 0 && S[l - 1] == 'A' && S[l] == 'C') << endl;
    }
    return 0;
}

Measured memory_bytes: 1488
N, Y = [int(nyc) for nyc in input().split()]

#10000円札の枚数がn枚（n=0～N）であるとして5000円札と1000円札の鶴亀算をする
for n in range(N+1):
  nm_10000_bill = n
  amount_10000 = 10000 * nm_10000_bill
  nm_5000_1000_bill = N - nm_10000_bill
  amount_5000_1000 = Y - amount_10000
  mx_amount_5000 = 5000 * nm_5000_1000_bill
  d = mx_amount_5000 - amount_5000_1000
  nm_1000_bill = d // 4000
  nm_5000_bill = nm_5000_1000_bill - nm_1000_bill
  if nm_1000_bill >= 0 and nm_5000_bill >= 0:
    if 10000 * nm_10000_bill + 5000 * nm_5000_bill + 1000 * nm_1000_bill == Y:
      print(str(nm_10000_bill) + " " + str(nm_5000_bill) + " " + str(nm_1000_bill))
      break
else:
  print("-1 -1 -1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
const int INF = 1001001001;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

bool isPrime(int x){
    if(x==1)return 0;
    if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i++)if(x%i==0)return 0;
    return 1;
}
int a[12][12];
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int>c(n);
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int ans=INF;
    for(int bit; bit<(1<<n); bit++){
        vector<int>d(m);
        int cost = 0;
        rep(i,n){
            if(bit>>i&1){
                cost += c[i];
                rep(j,m)d[j]+=a[i][j];
            }
        }
        bool ok = true;
        rep(j,m)if(d[j]<x)ok=false;
        if(ok)ans = min(ans,cost);
    }
    if(ans==INF)cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int cnt=0;
  for(int i=a;i<=b;i++){
    int temp=i;
    vector<int>vec;
    while(temp){
      vec.push_back(temp%10);
      temp/=10;
    }
    if(vec[0]==vec[4]&&vec[1]==vec[3])cnt++;
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 256