akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>

using namespace std;

int mem[200][200];
bool p[200][200];
int a[200];

int rec(int f,int l){
  if(l-f==1)return 0;
  if(p[l][f]++)return mem[l][f];
  mem[l][f]=0;
  for(int m=f+1;m<l;m++){
    mem[l][f]=max(mem[l][f],rec(f,m)+rec(m,l)+abs(a[f]-a[m]));
  }
  return mem[l][f];
}

int main(){
  int T;
  cin>>T;
  while(T--){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>a[i];
      a[i+n]=a[i];
    }
    int ans=0;
    fill(p[0],p[200],0);
    for(int i=0;i<n;i++){
      ans=max(ans,rec(i,i+n));
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1360
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const ll mod = 1e9 + 7;



int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string s; cin >> s;
    int sum = 0;
    trav(i, s)
    {
        sum += (i - '0');
    }
    if (sum % 9 == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}





Measured memory_bytes: 3380
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(void) {
  int i;
  char S[101];
  scanf("%s", S);
  for (i = 0; S[i] != '\0'; i++) {
    if (i % 2 == 0) {
      if (S[i] == 'L') {
        break;
      }
    }
    else {
      if (S[i] == 'R') {
        break;
      }
    }
  }
  if (S[i] == '\0') {
    printf("Yes");
  }
  else {
    printf("No");
  }
  return 0;
}

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

#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

template <typename T1, typename T2>
inline bool umin(T1& x, const T2& y){return x>y ? x=y,true : false;}

template <typename T1, typename T2>
inline bool umax(T1& x, const T2& y){return x<y ? x=y,true : false;}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int N    = (int)1e6+7;
const int mod  = (int)1e9+7;
const int INF  = (int)1e9+17;
const ll LLINF = (ll)1e18+17;


int n, m;


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    #define FILENAME "boot"
//    freopen(FILENAME".in", "r", stdin);
//    freopen(FILENAME".out", "w", stdout);
#endif

    ll x, y;
    cin >> x >> y;
    if (x % y == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << x << endl;

#ifdef TIME
    cerr << "\nRunning time = " << 1. * clock() / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static long X, Y;
    static void input()
    {
        cin = new Scanner();
        X = cin.nextLong();
        Y = cin.nextLong();
    }
    static void solve()
    {
        input();
        int ans = 0;
        while(Y >= X)
        {
            X <<= 1;
            ans++;
        }
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <unordered_set>



using namespace std; 
#define ll long long

int main(){
  ll n;
  cin >> n;
  
  for(ll i = 0; i < n; i++){
    string s;
    cin >> s;
    ll m = s.length();
    unordered_set<string> us;
    us.insert(s);
    for(ll t = 0; t < m; t++){
      string s1 = s.substr(0,t);
      string s2 = s.substr(t);
      string s1r = s1;
      string s2r = s2;
      //      cout << s1 << ' ' << s2 << ' ' << s1r << ' ' << s2r << endl;
	 
      reverse(s1.begin(),s1.end());
      reverse(s2.begin(),s2.end());
      us.insert(s1 + s2);
      us.insert(s1 + s2r);
      us.insert(s1r + s2);
      us.insert(s1r + s2r);
      us.insert(s2 + s1);
      us.insert(s2 + s1r);
      us.insert(s2r + s1);
      us.insert(s2r + s1r);
    }
    cout << us.size() << endl;

  }
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define INF 9003372036854775807LL
#define mod 1000000007
#define fixed fixed<<setprecision(12)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
lol a[300010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  lol n,m,k,r,x,y,z;
  cin >>n>>m>>x;
  lol ans=0,sum=0;
  for(int i=0;i<m;i++){
    cin >>y;
    if(y<x) ans++;
    else sum++;
  }
  cout <<min(sum,ans)<<'\n';
  return (0);
}


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

int main () {
  int k, a, b;
  cin >> k >> a >> b;
  string ans = "NG";
  for(int i = a; i <= b; i++) {
    if(i % k == 0) {
      ans = "OK";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

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

    int N;
    cin >> N;

    vector<ll> A(N), l(N,0),r(N,0);

    REP(i,N){cin >> A[i];}

    for (int i=0; i<N-1; ++i) l[i+1] = gcd(l[i],A[i]);
    for (int i=N-1; i>=1;--i) r[i-1] = gcd(r[i],A[i]);

    ll ans = 1;
    REP(i,N) ans = max(ans,gcd(l[i],r[i]));

    cout << ans << endl;


    return 0;

}


Measured memory_bytes: 2560
K = int(input())
A, B = tuple(int(x) for x in input().split())

for i in range(A, B+1):
    if i % K == 0:
        print('OK')
        exit(0)

print('NG')

# start = (A // K) * K
# # if start % K == 0:
# #     import ipdb; ipdb.set_trace()
# #     print('OK')
# #     exit(0)

# if start == B or start + K <= B:
#     print('OK')
#     exit(0)

# print('NG')


Measured memory_bytes: 9164
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
static const int MAX = 100;

static const int di[8] = {0, -1, -1, -1, 0, 1, 1, 1};
static const int dj[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int G[MAX+2][MAX+2];
bool V[MAX+2][MAX+2];
int W, H;
int cnt = 0;

void dfs(int i, int j){
  V[i][j] = true;

  for ( int r = 0; r < 8; r++ ){
    if ( i % 2 == 1 && (r == 3 || r == 5) ) continue;
    if ( i % 2 == 0 && (r == 1 || r == 7) ) continue;

    int ni = i + di[r];
    int nj = j + dj[r];
    if ( ni < 0 || nj < 0 || ni > H+1 || nj > W+1 ) continue;
    if ( G[ni][nj] ){
      cnt++;
    } else {
      if ( !V[ni][nj] ) dfs(ni, nj);
    }
  }
}

main(){
  cin >> W >> H;
  rep(i, H+2) rep(j, W+2) G[i][j] = 0;
  for ( int i = 1; i <= H; i++ )
    for ( int j = 1; j <= W; j++ ) cin >> G[i][j];

  rep(i, H+2) rep(j, W+2) V[i][j] = false;

  dfs(0, 0);

  cout << cnt << endl;
}

Measured memory_bytes: 1492
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readlines
def main():
    lines = input()

    n, l = list(map(int, lines[0].split()))

    Sum_ = int( n * (l - 1) + n * (n+1) / 2 )

    if l >= 0:
        print(Sum_ - l)
        return
    else:
        if n+l-1 <= 0:
            print(Sum_ - (l+n-1))
        else:
            print(Sum_)


main()

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
bool is_prime(int X){
    int div=0;
    for(int i=2;i<X;i++)
    {if(X%i==0){div++;}}
    if(div>0){return false;}
    else{return true;}
    
    
}

int main() {
    int X;
    cin>>X;
    if(X==2){cout<<2<<endl;}
    if(X>2){
        while (is_prime(X)==false)
        {X++;}
        cout<<X<<endl;
    }
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
string s[200010];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		mp[s]++;
	}
	map<string, int>::iterator iter;
	int maxn=0;
	for(iter=mp.begin();iter!=mp.end();iter++) {
        maxn=max(iter->second,maxn);
    }
    int p=0;
    for(iter=mp.begin();iter!=mp.end();iter++) {
        if(maxn==iter->second){
        	s[p++]=iter->first;
		}
    }
    sort(s,s+p);
    for(int i=0;i<p;i++){
    	cout<<s[i]<<endl;
	}
}

Measured memory_bytes: 28672
#include<cstdio>
#include<iostream>
#include<cctype>
#define RI register int
#define CI const int&
using namespace std;
typedef long long LL;
int n,c[100][100],lim2,lim5; LL ans,ret; double x;
int main()
{
	RI i,j,p,q; for (scanf("%d\n",&n),i=1;i<=n;++i)
	{
		char ch; LL v=0; while (isdigit(ch=getchar())) v=v*10+ch-'0';
		if (ch=='\n') v*=(LL)1e9; else
		{
			int p=0; while (isdigit(ch=getchar())) v=v*10+ch-'0',++p;
			while (p<9) v*=10LL,++p;
		}
		int c2=0,c5=0;
		while (v%2==0) v/=2,++c2; while (v%5==0) v/=5,++c5;
		++c[c2][c5]; lim2=max(lim2,c2); lim5=max(lim5,c5);
		//printf("%d %d\n",c2,c5);
	}
	for (i=0;i<=lim2;++i) for (j=0;j<=lim5;++j)
	for (p=0;p<=lim2;++p) for (q=0;q<=lim5;++q)
	if (i+p>=18&&j+q>=18) 
	{
		if (i!=p||j!=q) ans+=1LL*c[i][j]*c[p][q];
		else ret+=(1LL*c[i][j]*(c[i][j]-1)>>1LL);
	}
	return printf("%lld",(ans>>1LL)+ret),0;
}

Measured memory_bytes: 3820
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MAX = 510000;
const int MOD = 1000000007;
const int inf = 1<<31-1;
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; }
int main(void) {
    int n, m; cin >> n >> m;
    vector<ll> x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];
    ll X= 0,Y = 0;
    rep(i, n) {
        X += ((i * x[i])%MOD - ((n - 1 - i) * x[i])%MOD);
        X += MOD; X %= MOD;
    }
    rep(i, m) {
        Y += (((i * y[i])%MOD) - ((m - 1 - i) * y[i]) % MOD);
        Y += MOD; Y %= MOD;
    }
    cout << (X * Y) % MOD << endl;
}

Measured memory_bytes: 4748
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc109_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            var cities = ReadLine().Split().Select(int.Parse).ToList();

            var max = Abs(input[1]-cities[0]);

            for (int i = 0; i < input[0]; i++)
            {
                max = gcd(max, Abs(input[1]-cities[i]));
            }
            WriteLine(max);
        }

        static int gcd(int a, int b)
        {
            if (a < b)
            {
                return gcd(b, a);
            }

            while (b > 0)
            {
                var r = a % b;
                a = b;
                b = r;
            }

            return a;
        }
    }
}


Measured memory_bytes: 21344
#include <stdio.h>

int main (int argc, char* argv[]) {
  int a, b;
  scanf("%d %d", &a, &b);

  int c = 0;
  for (int i = 1; i <= 2; i++) {
    if (a >= b) {
      c += a;
      a--;
    } else if (b > a) {
      c += b;
      b--;
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
# coding: utf-8
# Your code here!

import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

d = I()
contest = LI()
mylist = [LI() for i in range(d)]
day = [0] * 26
result = 0

for i in range(d):
    temp = I()
    result += mylist[i][temp-1]
    day = [j+1 for j in day]
    day[temp-1] = 0
    for k in range(26):
        result -= day[k] * contest[k]
    print(result)

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

struct train{
	ll c,s,f;
};

int main(){
	int n;
	cin >> n;
	vector<train> t(n-1);
	rep(i,n-1){
		cin >> t[i].c >> t[i].s >> t[i].f;
	}
	rep(i,n-1){
		ll time = 0;
		//駅iから出発する。
		for (int j = i; j < n-1; ++j) {
			if(time < t[j].s){
				time += t[j].c + t[j].s - time;
			}else{
				if(time % t[j].f == 0){
					time += t[j].c;
				}else{
					time += t[j].f - (time % t[j].f) + t[j].c;
				}
			}
		}
		cout << time << endl;
	}
	cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> d(n, -1);
    vector<int> ans(n, -1);
    queue<int> que;
    que.push(0);
    d[0] = 0;
    while(!que.empty()) {
        int now = que.front();
        que.pop();
        for(auto next : edge[now]) {
            if(d[next] == -1) {
                d[next] = d[now] + 1;
                que.push(next);
                ans[next] = now;
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++) {
        cout << ans[i] + 1 << endl;
    }
}


Measured memory_bytes: 10648
#include <iostream>
#include <vector>

using namespace std;
long long int MOD = 998244353LL;

int main() {
  
  int n, s; cin >> n >> s;
  
  vector<long long> F(s + 1, 0); // F[i] は x^i の係数

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    F[0]++;
    for (int i = s - a; i >= 0; i--) {
      (F[i + a] += F[i]) %= MOD;
    }

    (ans += F[s]) %= MOD;
  }

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


Measured memory_bytes: 256
import bisect
n=input()
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
ans=0
for B in b:
  ans+=(bisect.bisect_left(a,B))*(len(c)-(bisect.bisect_right(c,B)))
print(ans)

Measured memory_bytes: 107108
#include<stdio.h>

int main(){
    int m, f, b;
    scanf("%d %d %d", &m, &f, &b);
    if( m >= b ) printf("0\n");
    else if( m + f >= b ) printf("%d\n", b-m);
    else printf("NA\n");
    
    return 0;
    
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t x, a;
    cin >> x >> a;

    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
struct node{
	int id;
	int val;
	bool operator<(node b) const
	{
		return val<b.val;
	}
};
node nn[262144];
bool vis[131072];
int main()
{
	int n;
	scanf("%d",&n);
	long long ans1=0,ans2=0;
	for(int i=0;i<(n<<1);i++)
	{
		scanf("%d",&nn[i].val);
		nn[i].id=(i>>1);
		if(i&1)
		{
			ans1+=nn[i].val;
		}
		else
		{
			ans2+=nn[i].val;
		}
	}
	sort(nn,nn+(n<<1));
	long long ans=0;
	bool ok=false;
	for(int i=0;i<n;i++)
	{
		ans+=nn[i].val;
		if(vis[nn[i].id])
		{
			ok=true;
		}
		vis[nn[i].id]=true;
	}
	if(ok)
	{
		printf("%lld\n",ans);
		return 0;
	}
	ans-=nn[n-1].val;
	if(nn[n-1].id!=nn[n].id)
	{
		ans+=nn[n].val;
	}
	else
	{
		ans-=nn[n-2].val;
		if(nn[n-2].val+nn[n+1].val<nn[n-1].val+nn[n].val)
		{
			ans+=nn[n-2].val+nn[n+1].val;
		}
		else
		{
			ans+=nn[n-1].val+nn[n].val;
		}
	}
	if(ans1<ans)
	{
		ans=ans1;
	}
	if(ans2<ans)
	{
		ans=ans2;
	}
	printf("%lld\n",ans);
	return 0;
}

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


string ume_c="89605+32471-*";
string ume[13][5]={
    {//8
    "111",
    "101",
    "111",
	"101",
    "111"
    },

	{
    "111",
    "101",
    "111",
	"001",
    "111"
    },
	
	{
    "111",
    "100",
    "111",
	"101",
    "111"
    },
	
	{
    "111",
    "101",
    "101",
	"101",
    "111"
    },
	
	{
    "111",
    "100",
    "111",
	"001",
    "111"
    },
	
	{
    "000",
    "010",
    "111",
	"010",
    "000"
    },
	
	{
    "111",
    "001",
    "111",
	"001",
    "111"
    },
	
	{
    "111",
    "001",
    "111",
	"100",
    "111"
    },
	
	{
    "101",
    "101",
    "111",
	"001",
    "001"
    },
	
	{
    "111",
    "001",
    "001",
	"001",
    "001"
    },
	{
    "001",
    "001",
    "001",
	"001",
    "001"
    },
	{
    "000",
    "000",
    "111",
	"000",
    "000"
    },
	{
    "000",
    "000",
    "010",
	"000",
    "000"
    }
	
	
};


string S;
int pos;

int expr();
int term();
int num();

int expr(){
	int res = term();
	while(1){
		if(S[pos]=='+'){
			pos++;
			res += term();
		}else if(S[pos]=='-'){
			pos++;
			res -= term();
		}else{
			break;
		}
	}
	return res;
}

int term(){
	int res = num();
	while(1){
		if(S[pos]=='*'){
			pos++;
			res *= num();
		}else{
			break;
		}
	}
	return res;
}

int num(){
	int c = S[pos++]-'0';
	while('0' <= S[pos] && S[pos] <= '9'){
		c *= 10;
		c += S[pos++]-'0';
	}
	return c;
}

int main(){
	int n;
	cin>>n;
	int mp[321][321]={0};
	char s[322]={};
	for(int i=0;i<321;i++)s[i]=' ';
	
	for(int i=0;i<n;i++){
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		x1 += 20;
		y1 += 20;
		x2 += 20;
		y2 += 20;
		
		if(x1==x2){
			if( y1 > y2 ) swap(y1,y2);
			for(int j=y1;j<=y2;j++){
				mp[x1][j]=1;
			}
		}else{
			if( x1 > x2 ) swap(x1,x2);
			for(int j=x1;j<=x2;j++){
				mp[j][y1]=1;
			}
		}
	}
	for(int i=0;i<ume_c.size();i++){
		for(int j=0;j<=300;j++){
			for(int k=0;k<=300;k++){
				int t=1;
				int minx = 1e9;
				for(int l=0;l<=4;l++){
					for(int m=0;m<=2;m++){
						if(ume[i][l][m]=='1'){
							minx = min(minx,k+m);
							if(mp[k+m][j+l]==0){
								
								t=0;
							}
						}
					}
				}
				if(t==1){
					s[minx]=ume_c[i];
					for(int l=0;l<=4;l++){
						for(int m=0;m<=2;m++){
							if(ume[i][l][m]=='1'){
								mp[k+m][j+l]=0;
							}
						}
					}
				}
			}
		}
	}
	S = string(s);
	S.erase(remove(S.begin(),S.end(),' '),S.end());
	pos = 0;
	S += "~";
	cout<<expr()<<endl;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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 main()
{
    int H,W;
    cin >> H >> W;

    vector<string> C(H);
    rep(i,H) cin >> C[i];

    rep(i,H)
    {
        cout << C[i] << endl;
        cout << C[i] << endl;
    }

}


Measured memory_bytes: 256
# coding: utf-8

n = input()
xs = map(float, input().split())
ys = map(float, input().split())
abs_d = [abs(x - y) for (x, y) in zip(xs, ys)]
d = [sum([i ** p for i in abs_d]) ** (1 / p) for p in range(1, 4)]
d.append(max(abs_d))

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


Measured memory_bytes: 5652
#include <bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i, a, n) for (int i = a; i < n; i++)
using namespace std;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n; cin>>n;
    set<string> s;
    f(i,0,n) {
        string x;
        cin>>x;
        s.insert(x);
    }
    cout<<len(s);
    return 0;
}

Measured memory_bytes: 19216
#include <iostream>
#include <vector>

using ll = long long int;
using namespace std;
ll H, W, K;

#define NTH_BIT(bits, i) ((((bits) >> (i) & 1)))

int main()
{
  // 1 <= H <= 100, 1 <= K <= W <= 8
  cin >> H >> W >> K;

  ll dp[9][101] = {};
  dp[0][0] = 1;

  for (int h = 1; h <= H; h++) {
    for (int bits = 0; bits < (1 << (W - 1)); bits++) {
      for (int w = 0; w < W - 1; w++) {
        if (NTH_BIT(bits, w) != 0 && NTH_BIT(bits, w + 1) != 0) {
          goto next; // 条件に合わなかったのでやりなおし
        }
      }

      for (int w = 0; w < W; w++) {
        if (0 < w && NTH_BIT(bits, w - 1)) {
          dp[w][h] += dp[w - 1][h - 1];
        } else if (w < W - 1 && NTH_BIT(bits, w)) {
          dp[w][h] += dp[w + 1][h - 1];
        } else {
          dp[w][h] += dp[w][h - 1];
        }
      }

      next: ;
    }
    for (int w = 0; w < W; w++) {
      dp[w][h] %= 1000000007;
    }
  }

  cout << dp[K-1][H] << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char c;
    cin>>c;
    if(c>='A' && c<='Z')cout<<"A";
    else cout<<"a";
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for (long i = 0; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<long, long>;

void solve(long N, long H, vector<long> a, vector<long> b) {

  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());

  long count(0);
  // throw Bs
  while (H > 0 && b.size() && b.front() > a.front()) {
    H -= b.front();
    b.erase(b.begin());
    count++;
  }
  // swing A
  if (H > 0)
    count += ceil(H * 1.0 / a.front());

  cout << count << endl;
}

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

  long N, H;
  cin >> N >> H;

  vector<long> a(N);
  vector<long> b(N);
  REP(i, N)
    cin >> a[i] >> b[i];

  solve(N, H, move(a), move(b));

  return 0;
}


Measured memory_bytes: 1792
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

correct_answer = 0

for i in range(N):
    A = list(map(int, input().split()))
    sum_AB = 0
    for j in range(M):
        sum_AB += A[j]*B[j]
    if sum_AB + C > 0:
        correct_answer += 1

print(correct_answer)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i=0, i##_len=(ll)(n); i<i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	string s; cin >> s;

	vb cut(s.size(), false);
	cut[s.size() - 1] = true;
	ll sum = 0;
	function<void(ll)> recur = [&](ll d) {
		if (d == s.size() - 1) {
			ll cur = 0;
			REP(i, s.size()) {
				cur = cur * 10 + (s[i] - '0');
				if (cut[i]) {
					sum += cur;
					cur = 0;
				}
			}
		} else {
			recur(d + 1);
			cut[d] = true;
			recur(d + 1);
			cut[d] = false;
		}
	};
	recur(0);
	cout << sum << endl;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#include<stack>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define D(n,retu) REP(i,n){cin>>retu[i];}
 
using namespace std;
typedef long long ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
 
//------------------変数-----------------------//
ll a[100001], n, cou = 0, saishuu=1000000000000000,zero=0;
typedef pair<ll, ll>p;
//-------------------関数----------------------//
 
int main() {
	cin >> n;//代入
	REP(i, n) {
		cin >> a[i];
	}
	REP(i, n - 1) {
		a[i + 1] += a[i];//累積和
	}
	ll kari[100001];
	REP(z, 2) {
		REP(i, n) { kari[i] = a[i]; }
		ll effect = 0; cou = 0;
		REP(i, n) {
			if (i % 2 == zero) {
				if (kari[i] <= 0) {
					effect += 1 - kari[i];
					cou += 1 - kari[i];
				}
			}
			else {
				if (kari[i] >= 0) {
					effect += -1 - kari[i];
					cou += 1 + kari[i];
				}
			}
			kari[i + 1] += effect;
		}
		zero = 1;
		saishuu = min(saishuu, cou);
	}
	cout << saishuu << endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> L(N);
    rep(i, N){
        cin >> L[i];
    }
    sort(L.begin(),L.end());

    int counter = 0;

    for (int i = 0; i < N - 2; i++){
        for (int j = i + 1; j < N - 1 ; j++){
            int ij = L[i] + L[j];
            int x = lower_bound(L.begin(), L.end(), ij) - L.begin();
            int y = x - (j+1);
            counter += y;
        }
    }

    cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<ll> v(3*N);
  rep(i,3*N)cin >> v[i];
  sort(all(v),greater<ll>());
  ll ans = 0;
  rep(i,N) ans += v[2*i+1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
using System;
using System.Linq;
class Program
{
        static void Main(string[] args)
        {
            // 入力
            int[] N_K = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();


            int[] price = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(price);
            var cnt = 0;
            for (int i=0;i < N_K[1];i++)
            {
                cnt += price[i];
            }
            Console.WriteLine(cnt);
        }
}

Measured memory_bytes: 28500
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

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

		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int C = Integer.parseInt(tokens[2]);
		int D = Integer.parseInt(tokens[3]);

		if (A + B < C + D) {
			System.out.println("Right");
		} else if (A + B > C + D) {
			System.out.println("Left");
		} else {
			System.out.println("Balanced");
		}
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
#define mod 1000000007
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int main(){
    long long a[5],min,ans=0,n;
    vector<long long> v;
    cin>>n;
    rep(i,5){
        cin>>a[i];
        v.push_back(a[i]);
        }
    sort(v.begin(),v.end());
    ans=4+((n+v[0]-1)/v[0]);
    cout<<ans<<endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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);
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    REP(i, S.length()){
        if(i%2 == 0){
            cout << S[i];
        }
    }
    cout << endl;
    return 0;
}

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

int main()
{
    int i, n;
    cin >> n;
    int a[n];
    int count[3] = {0, 0, 0}; 
    for (i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (i = 0; i < n; i++) {
        if (a[i] % 4 == 0){
            count[0]++;
        } else if (a[i] % 2 == 0){
            count[1]++;
        } else {
            count[2]++;
        }
    }
    if (count[1] > 0) {
        if (count[0] >= count[2]) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    } else {
        if (count[0]+1 >= count[2]) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    } 
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, l;
	cin>>n>>l;
	int ans=0;
	for(int i=0; i<n; i++) ans+=(l+i);
	if(l+n-1<=0) ans-=(l+n-1);
	else if(l>=0) ans-=l;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let message = buf.trim();
    let element1: f64 = message.parse().unwrap();

    let area = element1 * element1 * std::f64::consts::PI;
    let circumference = 2.0 * element1 * std::f64::consts::PI;
    println!("{} {}", area, circumference);
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
	while(1)
	{
		int r,n;
		cin >>r >>n;

		if(r==0) break;

		map<int,int> f;
		for(int i=-20; i<=20; ++i) f[i]=0;

		rep(i,n)
		{
			int xl,xr,h;
			cin >>xl >>xr >>h;

			//?????§?????´??°
			for(int j=xl; j<xr; ++j) f[j]=max(f[j],h);
		}

		//????????????
		for(int i=0; i<=r; ++i) f[i]=min(f[i],f[-i-1]);

		double y=100;
		rep(i,r) y=min(y,f[i]-sqrt(r*r-i*i));

		printf("%.10lf\n",y+r);
	}
	return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>

//#include <map>

using namespace std;

void spritStr(string str, vector<string>& v)
{
	while (str.find(' ') != -1)
	{
		v.push_back(str.substr(0, str.find(' ')));
		str.erase(0, str.find(' ') + 1);
	}
	v.push_back(str);
}

int main()
{
	string st;
	getline(cin, st);

	vector<string> vStr;
	spritStr(st, vStr);
	
	int f, t, v;
	f = stoi(vStr[0]);
	t = stoi(vStr[1]);
	v = stoi(vStr[2]);

	int count = 0;

	for (int i = f; i <= t; i++)
	{
		if (v % i == 0)
		{
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int N;
    cin >> N;
    vi H(N);
    REP(i, N) cin >> H[i];

    int M = 0;
    int cur = 0;
    for (int i = N-1; i > 0; i--) {
        if (H[i-1] < H[i]) {
            M = cur > M ? cur : M;
            cur = 0;
        } else {
            cur++;
        }
    }
    M = cur > M ? cur : M;
    cout << M << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
char a[105][105];
int main(){
	int h,w;
	while(~scanf("%d%d",&h,&w)){
		getchar();
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				scanf("%c",&a[i][j]);
			}
			getchar();
		}
	//	printf("1");
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				printf("%c",a[i][j]);
			}
			printf("\n");
			for(int j=1;j<=w;j++){
				printf("%c",a[i][j]);
			}
			printf("\n");
		}
	}
} 

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  vector<int> maxsums, a;
  int n, tmp;

  a.reserve(5000);
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++)
      cin >> a[i];
    for (int i = 0; i < n; i++) {
      tmp = a[i];
      for (int j = i + 1; j < n; j++) {
        tmp += a[j];
        if (tmp > a[i])
          a[i] = tmp;
      }
    }

    int max = a[0];
    for (int i = 0; i < n; i++)
      if (max < a[i])
        max = a[i];
    maxsums.push_back(max);
  }

  for (int i = 0; i < maxsums.size(); i++)
    cout << maxsums[i] << endl;
  return 0;
}

Measured memory_bytes: 1228
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int d = sc.nextInt();
	int x = sc.nextInt();
	int[] a = new int[n];
	for(int i = 0; i < n; i++) {
		a[i] = sc.nextInt();
	}
	int cout = 0;
	int p = 1;
	for(int i = 0; i < n; i++) {
		while((p) * a[i] + 1 <= d) {
			cout++;
			p++;
		}
		p = 1;
	}
	System.out.println(n + cout + x);
}
}


Measured memory_bytes: 23636
# 54
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def ruiseki_xor(n):
    if n % 2 != 0:
        if (n + 1) // 2 % 2 == 0:
            return 0
        else:
            return 1
    # n は偶数
    return ruiseki_xor(n + 1) ^ (n + 1)


a, b = LI()
# a から b の 和 : (bまでの和) - (a - 1 までの和)
ans = ruiseki_xor(b) ^ ruiseki_xor(a - 1)
print(ans)


Measured memory_bytes: 9116
def calc_num_one(num, b):
  res = (num + 1) / 2 ** (b + 1) * 2 ** b
  if (num + 1) >= 2 ** b and ((num + 1) / 2 ** b) % 2 != 0:
    res += (num + 1) % 2 ** b
  return res
A, B = map(int, raw_input().split())
res = 0
for b in range(40):
  num_one_A = calc_num_one(A, b)
  num_one_B = calc_num_one(B, b)
  if A / (2 ** b) % 2 == 0:
    rest = 0
  else:
    rest = 1
  
  num_one_A_B = num_one_B - num_one_A + rest
  if num_one_A_B % 2 == 0:
    continue
  res += 2 ** b
print res

Measured memory_bytes: 2568
#include    <iostream>
#include    <vector>

#define POSSIBLE    1
#define IMPOSSIBLE  0

using namespace std;

int maxsame(vector<int> &, vector<int> &);

int main(void)
{
    int n;
    cin >>  n;
    vector<int> ls, order;
    for (int i = 0; i < n; ++i){
        int tmp;
        cin >>  tmp;
        ls.push_back(tmp);
    }
    maxsame(ls, order);
    if(ls.size() == 0){
        for(int i = order.size()-1; i >= 0; --i){
            cout << order[i] << endl;
        }
    }else{
        cout << -1 << endl;
    }
}

int maxsame(vector<int> &src, vector<int> &rsl)
{
    char flag;
    do{
        flag = 0;
        for(int i = src.size() - 1; i >= 0; --i)
            if(src[i] == i+1){
                rsl.push_back(src[i]);
                src.erase(src.begin() + i);
                flag = 1;
                break;
            }
    }while(flag == 1);
}

Measured memory_bytes: 256
#include <iostream>
#define ll long long
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll int a, b, k, l;
    cin >> a >> b;
    
    l = abs(a - b);
    
    if (l % 2 != 0)
    {
        cout << "IMPOSSIBLE";
        return 0;
    }
    else
    {
        k = (a + b) / 2;
        cout << k;
    }
    
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		String s=sc.next();
		int l=s.length();
		long count=0;
		int add=0;
		for(int i=l-1;i>=0;i--) {
			if(s.charAt(i)=='W') {
				add++;
			
			}
			else if(s.charAt(i)=='B') {
				count=count+add;
			
			}
		}
		System.out.println(count);
	}
		
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N, A, B; cin >> N >> A >> B;
    string S; cin >> S;
    int a = 0;
    int b = 0;
    REP(i, N) {
        if (S[i] == 'a') {
            if (a + b < A + B) {
                cout << "Yes" << "\n";
                a++;
            } else {
                cout << "No" << "\n";
            }
        } else if (S[i] == 'b') {
            if(a + b < A + B && b < B) {
                cout << "Yes" << "\n";
                b++;
            } else {
                cout << "No" << "\n";
            }
        } else {
            cout << "No" << "\n";
        }
    }
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;
  if((A + B) > (C + D))
    cout << "Left" << endl;
  else if ((A + B) < (C + D))
    cout << "Right" <<endl;
  else
    cout << "Balanced" <<endl;
}


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

// 最大公約数を求める
long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long A, B;
    cin >> A >> B;

    // 最大公約数を求める
    long long G = GCD(A, B);

    // G を素因数分解して、「素因数の個数 + 1」が答え
    const auto &pf = prime_factorize(G);
    cout << pf.size() + 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

ll sum[200010];

int main(void){
    ll n,m;
    cin>>n>>m;
    ll s1=0,s2=0;
    for(ll i=1;i<=n;i++){
        ll x;
        cin>>x;
        ll tmp = ((i-1)*x)%N;
        tmp = (tmp-(n-i)*x)%N;
        tmp = (tmp+N)%N;
        s1 = (s1+tmp+N)%N;
    }
    for(ll i=1;i<=m;i++){
        ll y;
        cin>>y;
        ll tmp = ((i-1)*y)%N;
        tmp = (tmp-(m-i)*y)%N;
        tmp = (tmp+N)%N;
        s2 = (s2+tmp+N)%N;
    }
    cout<<(s1*s2)%N<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,cost;
    scanf("%d %d", &A,&B);
    if(A>=13 && A<=100)
        cost=B;
    else if(A<=12 && A>=6)
        cost=B/2;
    else if(A>=0 && A<=5)
        cost=0;

    printf("%d", cost);
    return 0;
}

Measured memory_bytes: 128
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * @author munkhbat
 * Cheese
 * AOJ 0558
 * BFS
 */
public class Main {
	private static int h, w, n;
	private static int sx, sy;
	private static int gx, gy;
	private static char[][] town;
	private static int[] dx = new int[]{0, 0, 1, -1};
	private static int[] dy = new int[]{1, -1, 0, 0};
	private static int distance = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		n = sc.nextInt();

		town = new char[h][w];
		for (int i = 0; i < h; i++) {
			town[i] = sc.next().toCharArray();
			for (int j = 0; j < w; j++) {
				if (town[i][j] == 'S') {
					sx = i;
					sy = j;
				}
			}
		}
		bfs(1);
		System.out.println(distance);
		sc.close();
	}

	public static void bfs(int num) {
		if (num > n) {
			return;
		}

		int[][] d = new int[h][w];

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				d[i][j] = 1 << 20;
			}
		}

		d[sx][sy] = 0;

		Queue<Integer> queue = new LinkedList<Integer>();
		queue.add(getNodeNumber(sx, sy));
		setTargetPos(num);
		boolean found = false;

		while (queue.size() > 0) {
			int node = queue.poll();
			int x = getX(node);
			int y = getY(node);

			for (int i = 0; i < 4; i++) {
				int nx = x + dx[i];
				int ny = y + dy[i];

				if (nx < 0 || nx >= h || ny < 0 || ny >= w || town[nx][ny] == 'X') {
					continue;
				}

				if (d[nx][ny] != 1 << 20) {
					continue;
				}

				if (nx == gx && ny == gy) {
					town[nx][ny] = '.';
					sx = gx;
					sy = gy;
					d[gx][gy] = d[x][y] + 1;
					distance += d[gx][gy];
					found = true;
					break;
				}
				queue.add(getNodeNumber(nx, ny));
				d[nx][ny] = d[x][y] + 1;
			}
			if (found) {
				break;
			}
		}
		bfs(++num);
	}

	private static void setTargetPos(int num) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (town[i][j] == Character.forDigit(num, 10)) {
					gx = i;
					gy = j;
				}
			}
		}
	}

	private static int getNodeNumber(int x, int y) {
		return 10000 * x + y;
	}

	private static int getX(int nodeNumber) {
		return nodeNumber / 10000;
	}

	private static int getY(int nodeNumber) {
		return nodeNumber % 10000;
	}
}

Measured memory_bytes: 100600