akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using 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 (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 2010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll n;
point g[100010];
bool cmp_y(point a,point b){
    return a.second < b.second;
}
double closest_pair(point *a,ll n){
    if (n <= 1) return INF;
    ll m = n/2;
    double x = a[m].first;
    double d = min(closest_pair(a,m),closest_pair(a+m,n-m));
    inplace_merge(a,a+m,a+n,cmp_y);
    vector<point> b;
    rep(i,n){
        if (fabs(a[i].first-x) >= d) continue;
        rep(j,b.size()){
            double dx = a[i].first-b[b.size()-j-1].first;
            double dy = a[i].second-b[b.size()-j-1].second;
            if (dy >= d) break;
            chmin(d,sqrt(dx*dx+dy*dy));
        }
        b.push_back(a[i]);
    }
    return d;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double x,y;
    cin >> n;
    rep(i,n){
        cin >> x >> y;
        g[i] = point(x,y);
    }
    sort(g,g+n);
    printf("%.10f\n",closest_pair(g,n));
}



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

using namespace std;
using ll = long long;

int
main(void){

  ll n, m, d;
  cin >> n >> m >> d;
  double val = 0.0;
  if(d == 0) val = (m-1)/(double)n;
  else val = (m-1) * 2 * (n-d) / (double)(n*n) ;

  printf("%.10f\n", val);
  
  return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) {
      cout << 0 << endl;
    }
    else if (a*c > b) {
      cout << b/a << endl;
    }
    else {
      cout << c << endl;
    }
}

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

using namespace std;
typedef long long ll;

int main(){
    ll N,M, ans=0;
    cin >> N >> M;
    priority_queue<int> lis;
    for (int i = 0; i < N ; ++i){
      	ll A;
        cin >> A;
        lis.push(A);
    }
    while(M){
        ll max = lis.top();
        lis.pop();
        lis.push(max/2);
      --M;
    }
    while (!lis.empty()){
        ans += lis.top();
        lis.pop();
    }
    cout << ans;
  return 0;
 }







Measured memory_bytes: 892
H,W = map(int,input().split())
A = [[-1 for _ in range(W+2)]]
for _ in range(H):
    a = list(map(int,input().split()))
    a.insert(0,-1)
    a.append(-1)
    A.append(a)
for i in range(1,H+1):
    for j in range(1,W+1):
        A[i][j] = A[i][j]%2
row = 1
col = 1
cnt = 0
Op = []
while row<=H and col<=W:
    if row%2==1:
        if col<W and A[row][col]==0:
            col += 1
        elif col<W and A[row][col]==1:
            Op.append([row,col,row,col+1])
            cnt += 1
            A[row][col] = 0
            A[row][col+1] = (A[row][col+1]+1)%2
            col += 1
        elif col==W and A[row][col]==0:
            row += 1
        elif col==W and A[row][col]==1:
            if row<H:
                Op.append([row,col,row+1,col])
                cnt += 1
                A[row][col]=0
                A[row+1][col]=(A[row+1][col]+1)%2
            row += 1
    else:
        if col>1 and A[row][col]==0:
            col -= 1
        elif col>1 and A[row][col]==1:
            Op.append([row,col,row,col-1])
            cnt += 1
            A[row][col]=0
            A[row][col-1]=(A[row][col-1]+1)%2
            col -= 1
        elif col==1 and A[row][col]==0:
            row += 1
        elif col==1 and A[row][col]==1:
            if row<H:
                Op.append([row,col,row+1,col])
                cnt += 1
                A[row][col]=0
                A[row+1][col]=(A[row+1][col]+1)%2
            row += 1
print(cnt)
for i in range(cnt):
    print(*Op[i])

Measured memory_bytes: 72924
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int MaxN = 1e5 + 5;
int siz[MaxN];
LL pre[MaxN];
bool vis[MaxN];
int n;
int cnt;
int main(){
	while(~scanf("%d", &n)){
		for(int i = 1; i <= n; i++){
			scanf("%d", &siz[i]);
		}
		sort(siz + 1, siz + 1 + n);
		for(int i = 1; i <= n; i++)
			pre[i] = pre[i - 1] + siz[i];
		cnt = n;
		int temp = 0;
		for(int i = 1; i < n; i++){
			LL sum = pre[i];
			if(sum * 2 < siz[i + 1]){cnt =cnt - (temp + 1); temp = 0;}
			else temp++;
		}
		printf("%d\n", cnt);
		memset(pre, 0, sizeof(pre));
	}
	return 0;
}


Measured memory_bytes: 1280
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;



int main(){
	int N;
	string lst="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	while(cin>>N){
		if(N==0)break;
		vector<int>ky(N);
		REP(i,N)cin>>ky[i];
		string str,res="";
		cin>>str;
		REP(i,SZ(str)){
			res+=lst[(52+lst.find(str[i])-ky[i%N])%52];
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))
//単純に考えて並べ方は最大でも10*9*8通り(十分)
//存在するか否かで検索をかけるのにいくつ掛かるか？が問題→多分余裕

ll s[10];
set<int> nums;

ll keta(ll a){
    ll b=a;
    ll ans=10;
    while(b/10!=0){
        b/=10;
        ans*=10;
    }
    return ans;
}

ll getsearch(ll n,ll k,ll used,ll value){
    ll ans=0;
    if(k==0){
        if(nums.find(value)==nums.end()){
            nums.insert(value);
        dbg cout <<"kouho:"<<value<<endl;
            return 1;
        }else{
            return 0;
        }
    }
    for(ll i=0; i < n; i++){
        if((used & (1<<i))==0){
            used+=(1<<i);
            ans+=getsearch(n,k-1,used,value*keta(s[i])+s[i]);
            used-=(1<<i);
        }
    }    
    return ans;
}

int main(){
    ll ans;

    while(true){
        ll n,k;
        nums.clear();
        cin >>n>>k;
        if(n==0&&k==0)break;
        for(int i=0;i<n;i++){
            cin >>s[i];
        }
        cout <<getsearch(n,k,0,0)<<endl;

    }

    return 0;

}


Measured memory_bytes: 3204
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include<queue>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef long long ll;
typedef long long LL;
typedef vector<long long > VLL;
typedef vector<long long > vll;
typedef pair<long long , long long> pll;
typedef pair<long long , long long> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define VECMAX(x) *max_element(ALL(x))
#define VECMIN(x) *min_element(ALL(x))
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MULTIPLE(i,n,k) for(int i = (k) ; i<(n) ; i+=k+1)//倍数ループ
//constant
//------------------------------------------



int main(){
    LL n ;

    cin >> n;
    ll ans;
    ll m=10000000000000;
    for(ll i = 1 ; i*i<= n ; i++){
        if(n%(i)==0){
            if(m>i+n/i)
           m=i+n/(i);
        }
    }
    
  
    cout << m-2<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;

// ========================================================================

//ライブラリ(*'▽')

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計を出す
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します



// ========================================================================


vl e(250000);
vl f(250000, 100000000000);

int main() {
	ll n; cin >> n;
	string a; cin >> a;
	ll cnt = 0;
	ll cnt2 = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == 'R') cnt++;
	}
	for (int i = 0; i < cnt; i++) {
		if (a[i] == 'R') cnt2++;
	}
	cout << cnt - cnt2 << endl;

	return 0;
}

Measured memory_bytes: 7632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <math.h>
using namespace std;

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

    if ((n * 100) % 108 == 0) {
        int ans = n / 1.08;
        int ans2 = ans * 1.08;
        if (n == ans2) cout << ans << endl;
        else cout << ":(" << endl;
    }
    else {
        int ans = n / 1.08 + 1;
        int ans2 = ans * 1.08;
        if (n == ans2) cout << ans << endl;
        else cout << ":(" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
inline int getint(){
    char c=getchar();int x=0;bool p=0;
    while((c>'9'||c<'0')&&c!='-')c=getchar();
    if(c=='-')p=1,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    if(p)x=-x;return x;
}
int main(){
	int k=getint(),a=getint(),b=getint();ll x=1;
	if(a+2>=b){x+=k;cout<<x<<endl;return 0;}
	int t=min(a-1,k); 
	x+=t;k-=t;
	if(!k){cout<<x<<endl;return 0;}
	x=x+1ll*(k/2)*(b-a);
	if(k&1)++x;
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;
map<int, int> mp;

int main() {
  cin >> N;
  rep(i, 0, N) {
    int a;
    cin >> a;
    ++mp[a];
  }

  int ans = 0;
  repe(i, -1, 100001) {
    int cnt = 0;
    cnt += mp[i - 1];
    cnt += mp[i];
    cnt += mp[i + 1];
    chmax(ans, cnt);
  }

  cout << ans;
}


Measured memory_bytes: 8228
#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>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
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++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

ll n,a,b;

void solve(){
    cin >> n >> a >> b;
    if (a>b or (n==1 & a!=b)) {
        cout << 0 << endl;
        return;
    }
    cout << (b-a)*(n-2)+1 << endl;
}

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

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int n = in.nextInt();
		int[] r = new int[n];
		for (int i = 0; i < n; i++) {
			r[i] = in.nextInt();
		}
		int[] max = new int[n];
		max[n-1] = r[n-1];
		for (int i = n - 2; i > 0; i--) {
			max[i] = Math.max(max[i+1], r[i]);
		}
		int[] min = new int[n];
		min[0] = r[0];
		for (int i = 1; i < n; i++) {
			min[i] = Math.min(min[i-1], r[i]);
		}
		int ret = 0x80000000;
		for (int i = 1; i < n; i++) {
			ret = Math.max(ret, max[i] - min[i-1]);
		}
		out.println(ret);
	}
}

Measured memory_bytes: 97272
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    string ss;
    cin>>ss;
    int cnt=0;
    for(int i=0;i<ss.size();i++){
        if(ss[i]=='A')if(ss[i+1]=='B'&&ss[i+2]=='C')cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int N,a;
cin>>N;
int count = 100000;


for(int i=0;i<N;i++){
 int s =0;
 cin>>a;
 if(a%2==1){
	 count = 0;
	 break;
 }
else{
 while(a%2==0){
	 a /=2;
	 s++;
 } 

}
count = min(s,count);
}



cout<< count <<endl;
 
}


Measured memory_bytes: 256
def main():
    length = int(input())
    lucky_num = input()
    answer = 0
    for i in range(1000):
        target = str(i).zfill(3)
        index = [-1, -1, -1]
        index[0] = lucky_num.find(target[0])
        if index[0] >= 0:
            index[1] = lucky_num.find(target[1], index[0] + 1)
            if index[1] > index[0]:
                index[2] = lucky_num.find(target[2], index[1] + 1)
                if index[2] > index[1]:
                    answer += 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int h1,h2,k1,k2,a,b,c,d,H,K;
    cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
    
    H = h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d;
    K = k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d;
    
    if(H > K){
        cout << "hiroshi";
    }
    else if(H < K){
        cout << "kenjiro";
    }
    else{
        cout << "even";
    }
    cout << endl;
}


Measured memory_bytes: 3104
def main():
    x = int(input())
    kyu = {
        1: 1800,
        2: 1600,
        3: 1400,
        4: 1200,
        5: 1000,
        6:  800,
        7:  600,
        8:  400,
    }
    for k, v in kyu.items():
        if x>=v:
            print(k)
            return

main()

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int ans ;
    ans = max(a + b, max(a - b, a * b));
    cout << ans << endl;
}

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


int main(void){
	
	char s[4];
	
	int sum = 700;
	
	do{
	
	scanf("%s",s);	
	
	}while(strlen(s) != 3);
	
	for(int i = 0;i < 3;i++){
		
		if(s[i] == 'o')
			sum += 100;
			
	}
	
	printf("%d",sum);
	
	return 0;
	
}
	
	
	

Measured memory_bytes: 128
<?php

while (true) {
    fscanf(STDIN, '%d', $n);
    if (feof(STDIN)) {
        break;
    }
    $d = 1;
    for ($i = 1; $i <= $n; $i++) {
        $d += $i;
    }
    echo $d . PHP_EOL;
}

Measured memory_bytes: 6576
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
struct edge{int to;ll cap;int rev;};
vector<edge> G[100010];
int lev[100010];
int itr[100010];
struct Dinic{
    void add_edge(int from,int to,ll cap){
        G[from].push_back((edge){to,cap,(int)G[to].size()});
        G[to].push_back((edge){from,0LL,(int)G[from].size()-1});
    }

    void bfs(int s){
        memset(lev,-1,sizeof(lev));
        queue<int> q;
        lev[s]=0;
        q.push(s);
        while(!q.empty()){
            int v=q.front();q.pop();
            for(int i=0;i<G[v].size();i++){
                edge &e=G[v][i];
                if(e.cap>0&&lev[e.to]<0){
                    lev[e.to]=lev[v]+1;
                    q.push(e.to);
                }
            }
        }
    }

    ll dfs(int v,int t,ll f){
        if(v==t)return f;
        for(int &i=itr[v];i<G[v].size();i++){
            edge &e=G[v][i];
            if(e.cap>0&&lev[v]<lev[e.to]){
                ll d=dfs(e.to,t,min(f,e.cap));
                if(d>0){
                    e.cap-=d;
                    G[e.to][e.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }
    
    ll max_flow(int s,int t){
        ll flow=0;
        for(;;){
            bfs(s);
            if(lev[t]<0)return flow;
            memset(itr,0,sizeof(itr));
            ll f;
            while((f=dfs(s,t,LINF))>0){
                flow+=f;
            }
        }
    }
};
int main(){
    int v,e;cin>>v>>e;
    Dinic d;
    for(int i=0;i<e;i++){
        int a,b,c;cin>>a>>b>>c;
        d.add_edge(a,b,c);
    }
    cout<<d.max_flow(0,v-1)<<endl;
    return 0;
}



Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 200000000
#define N 51



int32_t main()
{
    IOS;

    int n;
    cin >> n;
    cout << n * n * n;
    
    
}   
 
 


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

int N, ans;

void Zalgo(string S) {
    int i = 1, j = 0, len = S.size();
    vector<int> A(len);
    while (i < len) {
        while (i + j < len && S[j] == S[i+j]) j++;
        A[i] = j;
        if (j == 0) {
            i++;
            continue;
        }
        int k = 1;
        while (i + k < len && k + A[k] < j) A[i+k] = A[k], k++;
        i += k;
        j -= k;
    }

    rep(i, len) ans = max(ans, min(i, A[i]));
}

int main() {
    string S;
    cin >> N >> S;
    rep(i, N) Zalgo(S.substr(i));
    cout << ans << endl;
}

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

int main(){
 int N;
  cin>>N;
 vector<int> vec(N);
  for (int i =0;i<N;i++){
    cin >> vec.at(i);
  }
string ans = "APPROVED";
  for (int i= 0;i<N;i++){
    if(vec.at(i)%2==0 && vec.at(i)%3==0){
      continue;
    }
    else if (vec.at(i)%2==0 && vec.at(i)%5==0){
      continue;
    }
    else if (vec.at(i)%2==0) {
      ans = "DENIED";
      break;
     }
  }
  cout << ans;
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ans = new Restaurant[N];

            for (int i = 0; i < N; i++)
            {
                var input = Console.ReadLine().Split().ToArray();
                ans[i] = new Restaurant { Index = i + 1, S = input[0], P = int.Parse(input[1]) };
            }

            foreach (var a in ans.OrderBy(t => t.S).ThenByDescending(t => t.P))
            {
                Console.WriteLine(a.Index);
            }
        }

        class Restaurant
        {
            public int Index { get; set; }
            public string S { get; set; }
            public int P { get; set; }
        }
    }
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  vector<int> count(5, 0);
  int a;
  REP(i, 6) {
    cin >> a;
    ++count.at(a);
  }

  if (count.at(1) <= 2 && count.at(2) <= 2 && count.at(3) <= 2 &&
      count.at(4) <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: Grid Coloring
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 100;
const int MAX_W = 100;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int cs[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  int h, w, n;
  scanf("%d%d%d", &h, &w, &n);

  int x = 0, y = 0, dx = 1;
  for (int i = 1; i <= n; i++) {
    int ai;
    scanf("%d", &ai);

    for (int j = 0; j < ai; j++) {
      cs[y][x] = i;
      x += dx;
      if (x >= w) y++, x = w - 1, dx = -1;
      else if (x < 0) y++, x = 0, dx = 1;
    }
  }

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if (x) putchar(' ');
      printf("%d", cs[y][x]);
    }
    putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long inputHorizontal = scanner.nextLong();
        long inputVertical = scanner.nextLong();
        if (inputHorizontal != 1 && inputVertical != 1) {
            long kakezan = inputHorizontal * inputVertical;
            long answer = kakezan / 2;
            if (kakezan % 2 != 0) {
                answer += 1;
            }
            System.out.println(answer);
        } else {
            System.out.println(1);
        }
    }
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
    public static void main(String[] args) {
    	
    	try{
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");

				int a = Integer.parseInt(st.nextToken());
				String op = st.nextToken();
				int b = Integer.parseInt(st.nextToken());

				if(op.equals("?"))	break;

				if(0 <= a && a<=20000 && 0 <= b && b<=20000){

					if( op.equals("+") ){
						System.out.printf("%d\n",a+b);

					}else if( op.equals("-") ){
						System.out.printf("%d\n",a-b);

					}else if( op.equals("*") ){
						System.out.printf("%d\n",a*b);

					}else if( op.equals("/") ){
						System.out.printf("%d\n",a/b);

					}
				}
			}
    	} catch(IOException e) {
    		System.err.println(e);
		}
    }
}

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

int f[200010][4],n;
char s[200010];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline bool check(int l1,int r1,int l2,int r2)
{
	if (r1-l1!=r2-l2) return false;
	for (int i=l1;i<=r1;i++) if (s[i]!=s[i-l1+l2]) return false;
	return true;
}

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++) for (int j=1;j<=3;j++) f[i][j]=-1;
	for (int i=1;i<=n;i++)
	{
		if (i<=3) f[i][i]=1;
		for (int j=1;j<=3&&j<i;j++) for (int k=1;k<=3&&k<=i-j;k++)
		{
			if (!check(i-j-k+1,i-j,i-j+1,i)) f[i][j]=max(f[i][j],f[i-j][k]+1);
		}
	}
	int ans=0;
	for (int i=1;i<=3;i++) ans=max(ans,f[n][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3584
package main

import (
	"fmt"
	"math"
	"sort"
)

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

	h := make([]int, N)
	for i := range h {
		fmt.Scan(&h[i])
	}
	sort.Ints(h)

	ans := math.MaxInt64
	for i := 0; i+K-1 < N; i++ {
		cnt := h[i+K-1] - h[i]
		ans = min(ans, cnt)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 5504
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	int t = -1;
	int f = vec.size();
	while (f - t > 1) {
		int m = (t + f) / 2;
		if (vec[m] < xx) {
			t = m;
		}
		else {
			f = m;
		}
	}
	return f;
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) { for (TT t : vec) cin >> t; }


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx == 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n,a,t=0,c=0,ans=INF;
	cin >> n;
	vector<int>vec(n+1);
	rep(i, n) {
		cin >> a;
		t += a;
		vec[i + 1] = t;
	}
	for(int i=1; i<n; i++) {
		ans = min(ans,abs((vec.back() - vec[i]) - vec[i]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    rep(i,n)cin >> a[i] >> b[i] >> c[i];

    int dp[n][3];
    rep(i,n){
        if(i == 0){
            dp[i][0] = a[i];
            dp[i][1] = b[i];
            dp[i][2] = c[i];
        }else{
            dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
            dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b[i];
            dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
        }
    }

    int ans = max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int main(){
	int a, b, c, s;
	while(cin >> a >> b){
		c = 1;
		s = a + b;
		while(s = s / 10, s){
			c++;
		}
		cout << c << "\n";
	}
	return 0;
}

Measured memory_bytes: 1156
program test
	implicit none
    integer::a,b,c,x,i,j,k,ans
    read*,a,b,c,x
    ans=0
    do i=0,a
    	do j=0,b
        	do k=0,c
            	if(i*500+j*100+k*50==x)then
                	ans=ans+1
                end if
             end do
         end do
    end do
    print*,ans
end program test

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
A = read_int()
B = read_int()

# i番目の勇者までで、残したモンスターが最も少なくなる倒し方
def solve():
    init_A = sum(A)
    # A,破壊的
    for i in range(N):
        b_residual = max(B[i] - A[i], 0)
        if b_residual == 0:
            A[i] -= B[i]
            continue
        A[i] = 0
        A[i + 1] = max(A[i + 1] - b_residual, 0)
    return init_A - sum(A)

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 20020
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = sum(b)

for i in range(n-1):
    if a[i]+1 == a[i+1]:
        sum += c[a[i]-1]

print(sum)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>

int main(){
	int data[31];
	data[1]=1,data[2]=2,data[3]=4;
	for(int i=4;i<31;i++)data[i]=data[i-1]+data[i-2]+data[i-3];
	int n;
	while(std::cin>>n,n){
		std::cout<<std::ceil(data[n]/10.0/365.0)<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  a += b;
  if(a >= 10){
    cout << "error\n";
    return 0;
  }
  cout << a << "\n";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, M;
  
  cin >> N;
  vector<string> plus(N);
  for(int i = 0; i < N; i++){
    cin >> plus.at(i);
  }
  
  cin >> M;
  vector<string> minus(M);
  for(int i = 0; i < M; i++){
    cin >> minus.at(i);
  }
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    int count = 1;
    
  //  cout << i << ':' << count << endl; // test message1
    
    if(N != 1 && i != N - 1){
      for(int j = i + 1; j < N; j++){
        if(plus.at(i) == plus.at(j)){
          
  //        cout << "made it!" << endl; // test message2.5
          
          count++;
        }
      }
    }
    
  //  cout << i << ':' << count << endl; // test message2
    
    for(int j = 0; j < M; j++){
      if(plus.at(i) == minus.at(j)){
        count--;
      } 
    }
    
  //  cout << i << ':' << count << endl; // test message3
    
    if(count >= ans){
      ans = count;
    }
  }
  
  cout << ans << endl;
  
    
}

Measured memory_bytes: 256
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))

X = list(accumulate(A))

# A[:m]をできるだけ均等に、A[:l + 1], A[l + 1:]に分けるようなlを探す
l = 0
L = [-1] * N
for m in range(2, N - 1):
    target = X[m - 1] / 2
    while (l + 1 <= m) and abs(target - X[l]) >= abs(target - X[l + 1]):
        l += 1
    L[m] = l

# A[m:]をできるだけ均等に、A[:r + 1], A[r + 1:]に分けるようなrを探す
r = N - 1
r_sum = 0
R = [-1] * N
for m in reversed(range(2, N - 1)):
    target = (X[-1] - X[m - 1]) / 2
    while (r - 1 >= m) and abs((target - r_sum)) >= abs((target - (r_sum + A[r]))):
        r_sum += A[r]
        r -= 1
    R[m] = r

ans = float('inf')
for m in range(2, N - 1):
    li, ri = L[m], R[m]
    B, C, D, E = X[li], X[m - 1] - X[li], X[ri] - X[m - 1], X[-1] - X[ri]
    ans = min(ans, max(B, C, D, E) - min(B, C, D, E))

print(ans)


Measured memory_bytes: 27252
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int k = s.length();
        int c = Character.getNumericValue(s.charAt(0));
        for (int i = 1; i < k; i++) {
            if (s.charAt(i) != '9') {
                System.out.println(c + 9 * (k - 1) - 1);
                return;
            }
        }
        System.out.println(c + 9 * (k - 1));
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long
typedef pair<int, int> P;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int d[60][60];
int sx, sy, gx, gy;
int H, W;
string S[60];

int bfs() {
	queue<P> que;
	que.push({ sx,sy });
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			d[i][j] = mod;
		}
	}
	d[sy][sx] = 1;
	while (que.size()) {
		P p = que.front();
		que.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if (nx >= 0 && nx < W && ny >= 0 && ny < H && d[ny][nx] == mod && S[ny][nx] != '#') {
				que.push({ nx,ny });
				d[ny][nx] = d[p.second][p.first] + 1;
			}
		}
	}
	return d[gy][gx];
}

int main()
{
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '.') {
				ans++;
			}
		}
	}
	sx = 0; sy = 0, gx = W - 1, gy = H - 1;
	if (bfs() == mod) {
		cout << -1 << endl;
	}
	else {
		cout << ans - bfs() << endl;
	}
}


Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #a,b,c=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    for i in range(n):
        x,y=map(int, readline().rstrip().split())
        if i==0:
            a,b=x,y
            continue
        start=max(a//x,b//y)
        zz=start-1
        for z in range(start,start+1000):
            if x*z>=a and y*z>=b:
                zz=z
                break
        a,b=x*z,y*z
    print(a+b)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 5628
// ABC077
// A - Rotation
#include<bits/stdc++.h>

using namespace std;

int main(){
    string c1,c2;
    cin >> c1 >> c2;
    if(c1[0]==c2[2] && c1[1]==c2[1] && c1[2]==c2[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
//O7Oo7oO7O

#include <bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

using ll = long long int;

int main()
{
	IOS
	
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
    	if(i%5 && i%3)
    		sum+=i;
    }
    cout<<sum<<"\n";

    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
bool pd[1<<10];
string s;
ll ans;

void calc(int mask) {
    ll x = 0;
    rep(i, 0, s.size()) {
        x = (x*10) + (s[i]-'0');
        if(mask & (1<<i)) ans += x, x = 0;
    }
    ans += x;
}

int main(int argc, char ** argv) {
    cin >> s;
    int sz = s.size()-1;
    rep(i, 0, (1<<sz)) calc(i);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3620
def cinr(i):
    tmp = (i.split(" "))
    W = int(tmp[0])
    H = int(tmp[1])
    x = int(tmp[2])
    y = int(tmp[3])
    r = int(tmp[4])

    if x >= 0 + r and x <= W - r and y >= 0 + r and y <= H  - r:
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == "__main__":
    ret = cinr(input())


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using P =pair<int,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};



bool dfs(vector<vector<P>> &data, vector<long long> &d, queue<int> &temp, vector<bool> &used)
{
    while(!temp.empty())
    {
        int i= temp.front();
        temp.pop();
        used[i] = true;
        for(int j=0;j<data[i].size();j++)
        {
            if(d[data[i][j].first] == LONG_LONG_MAX)
            {
                d[data[i][j].first] = d[i] + data[i][j].second;
                temp.push(data[i][j].first);
                
            }
            else if(d[data[i][j].first] != d[i] + data[i][j].second)
            {
                return false;
                break;
            }
        }
    }
    return true;
}


int main()
{
    int N,M;
    cin >>N >> M;
    
    vector<vector<P>> data(N);
    for(int i=0;i<M;i++)
    {
        int a,b,c;
        cin >> a >> b >> c;
        
        data[a-1].push_back(make_pair(b-1,c));
        data[b-1].push_back(make_pair(a-1,-c));
    }
    
    vector<bool> used(N,false);
    
    
    bool ok = true;
    
    for(int i=0;i<N;i++)
    {
        if(!ok) break;
        if(!used[i] && data[i].size() != 0)
        {
            vector<long long> d(N,LONG_LONG_MAX);
            queue<int> temp;
            temp.push(i);
            d[i] = 0;
            if(!dfs(data,d,temp,used))
            {
                ok = false;
            }
        }
    }
    
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
     
}








Measured memory_bytes: 9728
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d\n",&a,&b);
    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else if(a==b){
        printf("a == b\n");
    }
    
    return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
using namespace std;

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

	if (accumulate(l.begin(), l.end(), 0) - *(l.end()-1) > *(l.end()-1)) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
l=[]
for i in range(h):
    l.append(list(input()))
wl=[]
for i in range(h):
    wf=0
    for j in range(w):
        if l[i][j]=='.':
            wf+=1
    if wf<w:
        wl.append(i)
    
hl=[]
for i in range(w):
    hf=0
    for j in range(h):
        if l[j][i]=='.':
            hf+=1
    if hf<h:
        hl.append(i)
for i in wl:
    for j in hl:
        print(l[i][j],end='')
    print()


Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <climits>
#include <queue>

using namespace std;

#define int long long int

// int MOD = 1e9 + 7;
int dp[101];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	for(int i = 0; i<101; i++){
		dp[i] = -1;
	}
	for(int i = 1; i<10; i++){
		for(int j = 1; j<10; j++){
			dp[i*j] = 1;
		}
	}
	int N; cin>>N;
	if(dp[N] == 1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val nums = StdIn.readLine().split(" ").map(_.toInt)
  val (a, b, c) = (nums.head, nums(1), nums(2))
  val result = a + b >= c match {
    case true => "Yes"
    case _ => "No"
  }
  println(result)
}

Measured memory_bytes: 25540
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    List<String> list = new ArrayList<>();
    
    for(int i=0; i<s.length(); i++){
      if(list.size()==0&&s.charAt(i) =='B'){
        continue;
      }
      
      if(s.charAt(i)=='0'){
        list.add("0");
      }
      if(s.charAt(i)=='1'){
        list.add("1");
      }
      if(s.charAt(i)=='B'){
        list.remove(list.size()-1);
      }
    }
    for(int i=0; i<list.size(); i++){
      System.out.print(list.get(i));
    }
  }
}
    

Measured memory_bytes: 35544
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int a,b;
	scan(a>>b);
	if(a>b) swap(a,b);
	rep(i,b) printf("%d",a);
	kaigyo;
	return 0;
}


Measured memory_bytes: 256
#025B
n=int(input())
#A>0 B>0

for i in range(1,n):
	A=i
	B=n-i
	#print(i)
	count_a=0
	count_b=0
	while(A!=0):
		count_a+=A%10
		A=int(A/10)

	while(B!=0):
		count_b+=B%10
		B=int(B/10)
	count=count_a+count_b
	if(i==1):
		ans=count

	if(ans>count):
		ans=count
print(ans)





Measured memory_bytes: 3060