akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()

int main() {
    int n,l;
    cin>>n;
    l=n/2;
    vector<int>e(l),o(l);
    rep(i,l)cin>>e[i]>>o[i];
    sort(all(e));
    sort(all(o));
    int cnte=1,cnto=1,emax,omax;
    vector<int>eren(1),oren(1);
    rep(i,l-1){
    	if(e[i]==e[i+1])cnte++;
    	else{
    		eren.push_back(cnte);
    		cnte=1;
    	}
    	if(o[i]==o[i+1])cnto++;
    	else{
    		oren.push_back(cnto);
    		cnto=1;
    	}
    }
    eren.push_back(cnte);
    oren.push_back(cnto);
    sort(all(eren),greater<int>());
    sort(all(oren),greater<int>());
    //cout<<eren[0]<<oren[0];
    cnte=1;cnto=1;
    rep(i,l-1){
    	if(e[i]==e[i+1])cnte++;
    	else{
    		if(cnte==eren[0])emax=e[i];
    		cnte=1;
    	}
    	if(o[i]==o[i+1])cnto++;
    	else{
    		if(cnto==oren[0])omax=o[i];
    		cnto=1;
    	}
    }
    //cout<<emax<<omax;
    if(cnte==eren[0])emax=e[l-1];
    if(cnto==oren[0])omax=o[l-1];
    //cout<<emax<<omax;
    if(emax!=omax)cout<<n-eren[0]-oren[0];
    else cout<<n-max(eren[0]+oren[1],eren[1]+oren[0]);
    return 0;
}

Measured memory_bytes: 1276
n,m=map(int,input().split())
a=set(int(input()) for i in range(m))
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if 1 not in a:
    dp[1]=1

for i in range(2,n+1):
    if i not in a:
        dp[i]+=(dp[i-2]+dp[i-1])%mod
print(dp[-1])

    

Measured memory_bytes: 58328
import math
x = int(input())

n = 10**6
s = int(math.sqrt(n)) + 1
p = [True]*(n+1)
p[0] = False
p[1] = False

for i in range(4, n+1, 2):
  p[i] = False
  
for i in range(3, s+1, 2):
  if p[i]:
    for j in range(i+i, n+1, i):
      p[j] = False
      
while True:
  if p[x] == True:
    print(x)
    break
  x += 1

Measured memory_bytes: 10868
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n;
	cin >> n;
	print(n*(n - 1) / 2);
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const ll mod=1e9+7;
const int N=1e6+4;

int main()
{
	int x; scn(x); pri(x^1);
}

Measured memory_bytes: 3760
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

vector<int>to[200005];
vector<int>ans;
void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p)continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, q; cin >> n >> q;
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		to[a].push_back(b); to[b].push_back(a);
	}
	ans.resize(n);
	rep(i, q) {
		int p, x; cin >> p >> x; p--;
		ans[p] += x;
	}
	dfs(0);
	rep(i, n) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

//ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y,ll M){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll n; cin>>n;
	string s; cin>>s;
	ll cc = 0;
	forn(i,n) if(s[i]=='1') cc++;
	ll p1 = cc+1, p2 = cc-1;
	if(p2<0) p2 = p1;
	ll curr1 = 0, curr2 = 0;
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='0') continue;
		ll h = n-1-i;
		curr1 += powerm((ll)2,h,p1);
		curr1 %= p1;
		if(p2==0) continue;
		curr2 += powerm((ll)2,h,p2);
		curr2 %= p2;
		//cout<<i<<':'<<curr1<<':'<<curr2<<endl;
	}
	ll pre[n+10];
	pre[0] = 0;
	forn1(i,n)
	{
		ll f = __builtin_popcountll(i);
		pre[i] = pre[i%f] + 1;
	}
	//forn1(i,n) cout<<pre[i]<<' '; cout<<endl;
	//cout<<curr1<<":"<<curr2<<endl;
	forn(i,n)
	{
		if(s[i]=='0')
		{
			ll r = n-1-i;
			ll d = curr1 + powerm((ll)2,r,p1);
			d %= p1;
			cout<<1 + pre[d]<<'\n';
		}
		else
		{
			if(p2==0){ cout<<0<<'\n'; continue; }
			ll r = n-1-i;
			ll d = curr2 - powerm((ll)2,r,p2) + p2;
			d %= p2;
			cout<<1 + pre[d]<<'\n';
		}
		
	}

	return 0;
}

Measured memory_bytes: 5312
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define f(i,n)          for(int i=0;i<n;i++)
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
typedef tree<pii, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
int32_t main()
{
	g_b();
	int n, d; cin >> n >> d;
	int ans = 0;
	while (n--)
	{
		int x, y; cin >> x >> y;
		long double dis = sqrt(x * x + y * y);
		if (dis <= d)ans++;
	}
	cout << ans;
	return 0;

}



Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) \
  it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
// vim: cc=60 ts=2 sts=2 sw=2:

int main()
{
    ios_base::sync_with_stdio(false);

    int n;
    ll x;
    cin >> n >> x;
    vector<ll> arr(n);
    rep(i,0,n) cin >> arr[i], arr[i]-=x;
    ll g = 0;
    rep(i,0,n) g = abs(gcd(g, arr[i]));
    cout << g << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while (!(str = br.readLine()).equals("END OF INPUT")) {
				String[] ward = str.split(" ", -1);
				for (int i = 0; i < ward.length; i++) {
					System.out.print(ward[i].length());
				}
				System.out.println();
			}
		} catch (Exception e) {
			System.out.println(e);
		}
	}

}



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

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

    ll ans = 0;
    ll atack_num = 1;
    while(H>0){
        ans += atack_num;
        H/=2;
        atack_num*=2;
    }

	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn = 1e6+10;
typedef long long LL;
LL a[maxn],prime[maxn],k,vis[maxn];
int n,flag = 0;
bool isprime[maxn];
void Prime()
{
    fill(isprime,isprime+maxn,1);
    k = 0;
    prime[1] = 0;
    for(LL i = 2; i<maxn; ++i)
    {
        if(isprime[i])
        {
            prime[k++] = i;
            for(LL j = 2; i*j<maxn; ++j)
            {
                isprime[i*j] = 0;
            }
        }
    }
}
void solve(LL n)
{
    for(LL i = 0; i<k&&prime[i]*prime[i]<=n; ++i)
    {
        if(n%prime[i]==0)
        {
            if(vis[prime[i]]==0) vis[prime[i]]=1;
            else
            {
                flag = 1;
                return;
            }
            while(n%prime[i]==0)
            {
                n/=prime[i];
            }
        }
    }
    if(n>1)
    {
        if(vis[n]==0) vis[n] =1;
        else
        {
            flag = 1;
            return;
        }
    }
}

int main()
{
    Prime();
    cin >> n;
    LL GCD = 0;
    for(int i = 0; i<n; ++i)
    {
        scanf("%lld",&a[i]);
        if(!flag) solve(a[i]);
        if(GCD == 0) GCD=a[i];
        else GCD = __gcd(GCD,a[i]);
    }
    if(!flag) printf("pairwise coprime");
    else if(flag&&GCD==1) printf("setwise coprime");
    else printf("not coprime");
    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    int ch, cw, dh, dw; cin >> ch >> cw >> dh >> dw;
    int dist[h][w];
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            dist[i][j] = 1000000000;
        }
    }
    dist[ch-1][cw-1] = 0;
    string S[h];
    for (int i = 0; i < h; i++) cin >> S[i];
    set<pair<pair<int, int>, int> > q;
    q.insert({{ch-1, cw-1}, 0});
    while (!q.empty()){
        pair<int,int> point = q.begin()->first;
        q.erase(q.begin());
        int a = point.first; int b = point.second;
        if (a > 0 && S[a-1][b] == '.'){
            if (dist[a-1][b] > dist[a][b]){
                q.erase({{a-1, b}, dist[a-1][b]});
                dist[a-1][b] = dist[a][b];
                q.insert({{a-1, b}, dist[a-1][b]});
            }
        }
        if (a < h-1 && S[a+1][b] == '.'){
            if (dist[a+1][b] > dist[a][b]){
                q.erase({{a+1, b}, dist[a+1][b]});
                dist[a+1][b] = dist[a][b];
                q.insert({{a+1, b}, dist[a+1][b]});
            }
        }
        if (b > 0 && S[a][b-1] == '.'){
            if (dist[a][b-1] > dist[a][b]){
                q.erase({{a, b-1}, dist[a][b-1]});
                dist[a][b-1] = dist[a][b];
                q.insert({{a, b-1}, dist[a][b-1]});
            }
        }
        if (b < w-1 && S[a][b+1] == '.'){
            if (dist[a][b+1] > dist[a][b]){
                q.erase({{a, b+1}, dist[a][b+1]});
                dist[a][b+1] = dist[a][b];
                q.insert({{a, b+1}, dist[a][b+1]});
            }
        }
        for (int i = max(0, a-2); i <= min(h-1, a+2); i++){
            for (int j = max(0, b-2); j <= min(w-1, b+2); j++){
                if (dist[i][j] > dist[a][b] + 1 && S[i][j] == '.'){
                    q.erase({{i, j}, dist[i][j]});
                    dist[i][j] = dist[a][b] + 1;
                    q.insert({{i, j}, dist[i][j]});
                }
            }
        }
    }
    if (dist[dh-1][dw-1] == 1000000000){
        cout << -1 << '\n';
    }else{
        cout << dist[dh-1][dw-1] << '\n';
    }
    return 0;
}

Measured memory_bytes: 8600
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String x = sc.next();
		String y = sc.next();
		
		if(x.charAt(0) > y.charAt(0)) {
			System.out.println('>');
		}else if(x.charAt(0) < y.charAt(0)) {
			System.out.println('<');
		}else {
			System.out.println('=');
		}
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}



int main(){
    string s;cin >> s;
    
    for(int i=0;i<s.length();i++){
        cout << 'x';
    }

    cout << endl;

}



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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){

	ll a,b;
	cin>>a>>b;
	for(int i=0;i<b+2;i++) cout<<"#";
	cout<<"\n";
	for(int i=0;i<a;i++) {
		cout<<"#";
		string s;cin>>s;cout<<s<<"#\n";
	}

	for(int i=0;i<b+2;i++) cout<<"#";

}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	long long a,b,c,d,i,j,k,l,min;
	while(~scanf("%lld",&a)&&a>0)
	{	min=100000000000000000;
		for(i=1;i<sqrt(a+0.5);i++)
		{
			b=a%i;c=a/i;
			if(b==0)
			{
				min=min>(c+i)?(c+i):min;
			}
		}
		min-=2;
		printf("%lld\n",min);
	}
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  if(n % 2 == 0) cout << n << endl;
  else cout << 2*n << endl;
}

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

int main() {
    int n;
    cin>>n;
    map<pair<string,int>,int> mp;
    for (int i=0;i<n;i++) {
        string s;
        int p;
        cin>>s>>p;
        mp[{s,-p}]=i+1;
    }
    for (auto p:mp)
        cout<<p.second<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()

{
    int a, b, c;
   
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
       
    else
        cout << b << " " << a << " " << c << endl;
   
    return 0;
}



Measured memory_bytes: 3100
x, y = map(int, input().split())
ans = 0
if x * y >= 0:
    if x > y:
        ans = x - y + 2
        if x * y == 0:
            ans = x - y + 1
    else:
        ans = abs(y - x)
else:
    ans = abs(abs(x) - abs(y)) + 1
print(ans)

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

int a,b,n;
struct cross{
  bool isbuilding;
  int access;
};
cross map[100][100];

void read()
{
  cin>>n;
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      map[i][j].isbuilding=false;
      map[i][j].access=0;
    }
  }

  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    map[x][y].isbuilding=true;
  }
  map[0][0].access=1;
  return;
}

void dp_a(int crossa,int crossb)
{
  if(crossa+1==a){return;}
  if(map[crossa+1][crossb].isbuilding){return;}
  map[crossa+1][crossb].access+=map[crossa][crossb].access;
  return;
}

void dp_b(int crossa,int crossb)
{
  if(crossb+1==b){return;}
  if(map[crossa][crossb+1].isbuilding){return;}
  map[crossa][crossb+1].access+=map[crossa][crossb].access;
  return;
}

void solve()
{
  for(int i=0;i<a+b-2;i++){
    int times;
    if(i<(a<b)?a:b){
      times=i+1;
    }
    else if(i<=(a>b)?a:b){
      times=(a<b)?a:b;
    }
    else{
      times=a+b-i-1;
      
    }
    
    for(int j=0;j<times;j++){
      dp_a(j,i-j);
      dp_b(j,i-j);
    }
  }
  return;
}

int main()
{
  while(1){
    cin>>a>>b;
    if(!a&&!b){break;}
    read();
    solve();
    cout<<map[a-1][b-1].access<<endl;
  }
  return 0;
}

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

int main() {
  int a;
  cin >> a;
  if(a < 1000){
    cout << "ABC";
  }
  else{
    cout << "ABD";
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int l = sc.nextInt();
			int[][] matrixA = new  int[n][m];
			int[][] matrixB = new  int[m][l];

			IntStream.range(0, n).forEachOrdered(i -> {
				IntStream.range(0, m).forEachOrdered(j -> matrixA[i][j] = sc.nextInt());
			});
			IntStream.range(0, m).forEachOrdered(i -> {
				IntStream.range(0, l).forEachOrdered(j -> matrixB[i][j] = sc.nextInt());
			});
			
			for (int i = 0; i < n; i++) {
				StringBuilder sb = new StringBuilder();
				for (int j = 0; j < l; j++) {
					long sum = 0;
					for (int k = 0; k < m;k++) {
						sum += matrixA[i][k] * matrixB[k][j];
					}
					sb.append(sum + " ");
				}
				System.out.println(sb.toString().trim());
			}
			
		}
	}
}


Measured memory_bytes: 57928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(1){
		ll n,r;
		cin >> n >> r;
		if(n==0&&r==0)break;
		vector<ll> card(n);
		FOR(i,0,n)card[i]=i+1;
		FOR(i,0,r){
			ll p,c;
			cin >> p >> c;
			rotate(card.end()-p-c+1,card.end()-p+1,card.end());
		}
		cout << card[n-1] << endl;
	}
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define y1 dfsdsfsdfsd
#define next fdsfsdfjkl
#define int long long
#define endl "\n"
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
double pi = acos(-1.0);
int mod = 1e9+7;
const double eps = (double)1e-9;
const ll INF = 1e18+7;
/////////////////////////////////////////
 
 
int n,k;
 
main(){speed;
    int cnt  = 0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        if(i%2!=0) {
            cnt++;
        }
    }

    double ans = (cnt) / double(n);
    cout<<fixed << setprecision(10) << ans;
}

Measured memory_bytes: 256
def tax(p,x):
    return x * (100+p) // 100
def solve(p,q,x):
    ans = 0
    m = (x * 100) // (100 + p)
    for i in range(m,x+1): #税抜き合計価格
        for j in range(1, i // 2 + 1): #安い方の商品の税抜き価格
            k = i - j #もう一つの商品の税抜き価格
            if tax(p,j) + tax(p,k) == x:
                ans = max(ans,tax(q,j) + tax(q,k))
    return print(ans)
while True:
    p, q, x = map(int, input().split())
    if (p, q, x) == (0, 0, 0):
        break
    solve(p, q, x)



Measured memory_bytes: 5604
A,B,C,D,E,F = map(int,input().split())
W = []
S = []
for a in range(F//100+1):
    for b in range(F//100+1):
        w = A*a+B*b
        if 1 < 100*w < F:
            W.append(w)
            slist = []
            for c in range((F-100*w)//C+1):
                for d in range((F-100*w)//D+1):
                    if C*c+D*d <= F-100*w:
                        slist.append(C*c+D*d)
            S.append(slist)
maxs = [100*A,0]
rel = 0
for w in range(len(W)):
    for s in range(len(S[w])-1,-1,-1):
        if E*W[w] >= S[w][s]:
            if rel < 100*S[w][s]/(W[w]+S[w][s]):
                maxs = [100*W[w]+S[w][s],S[w][s]]
                rel = 100*S[w][s]/(W[w]+S[w][s])
print(*maxs)

Measured memory_bytes: 52236
n = gets.to_i
c1 = gets.split.map(&:to_s)
c2 = Marshal.load(Marshal.dump(c1))

def bubble_sort(c, n)
  for i in 0..n-1
    (n-1).downto(i+1) do |j|
      if c[j][1] < c[j-1][1]
        tmp = c[j]
        c[j] = c[j-1]
        c[j-1] = tmp
      end
    end
  end
  c
end

def selection_sort(c, n)
  for i in 0..n-1
    minj = i

    for j in i..n-1
      if c[j][1] < c[minj][1]
        minj = j
      end
    end
    tmp = c[i]
    c[i] = c[minj]
    c[minj] = tmp
  end
  c
end

bs = bubble_sort(c1, n).join(' ')
ss = selection_sort(c2, n).join(' ')

puts bs
puts 'Stable'
puts ss
puts (bs == ss) ? 'Stable' : 'Not stable'


Measured memory_bytes: 6908
import java.util.*;

public class Main {
	public static void main(String[] args) {

		try {

			Scanner scanner = new Scanner(System.in);
			int n = scanner.nextInt();
			List<Integer> lengthList = new ArrayList<Integer>();
			int counter = 0;


			for (int i = 0; i < n; i++) {
				lengthList.add(scanner.nextInt());
			}
			scanner.close();

			int longestLength = Collections.max(lengthList);
			for (int length : lengthList) {
				counter++;
				if (length == longestLength) {
					break;
				}
			}

			lengthList.remove(counter - 1);

			int sum = 0;
			for (int remainLengths : lengthList) {
				sum += remainLengths;
			}

			if (longestLength < sum) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		} catch(Exception e) {
			System.out.println("Exception thrown : " + e);
		}
	}
}

Measured memory_bytes: 23892
import bisect

abq = input().split()
a = int(abq[0])
b = int(abq[1])
q = int(abq[2])
slist = [int(input()) for i in range(a)]
slist.sort()
tlist = [int(input()) for i in range(b)]
tlist.sort()
xlist = [int(input()) for i in range(q)]


def get_nears(list_search, idx, val):
    if idx == 0:
        return (None, list_search[idx])

    try:
        list_search[idx]
    except IndexError:
        return (list_search[idx - 1], None)

    return (list_search[idx - 1], list_search[idx])


def get_min_distance(x, anear, bnear, mindis):
    if anear is None or bnear is None:
        return mindis

    dis = abs(x - anear)
    dis += abs(anear - bnear)

    if mindis is None:
        return dis
    return min(dis, mindis)


for x in xlist:
    sidx = bisect.bisect_left(slist, x)
    tidx = bisect.bisect_left(tlist, x)

    snear1, snear2 = get_nears(slist, sidx, x)
    tnear1, tnear2 = get_nears(tlist, tidx, x)

    mindis = None
    mindis = get_min_distance(x, snear1, tnear1, mindis)
    mindis = get_min_distance(x, snear1, tnear2, mindis)
    mindis = get_min_distance(x, snear2, tnear1, mindis)
    mindis = get_min_distance(x, snear2, tnear2, mindis)
    mindis = get_min_distance(x, tnear1, snear1, mindis)
    mindis = get_min_distance(x, tnear1, snear2, mindis)
    mindis = get_min_distance(x, tnear2, snear1, mindis)
    mindis = get_min_distance(x, tnear2, snear2, mindis)

    print(mindis)


Measured memory_bytes: 117592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<int,int> mp;
    int N; cin >> N;
    REP(i,N){
        int A; cin >> A;
        if(i == 0) mp[A]++;
        else{
            dump(i)
            auto it= mp.lower_bound(A);
            if(it == mp.begin()){
                dump("add")
                dump(A)
                mp[A]++;
            }
            else{
                it--;
                if(it->second > 1) {
                    //mp.erase(it->first);
                    dump("mid")
                    dump(it->first)
                    dump(A)
                    mp[it->first]--;
                    mp[A]++;
                }
                else{
                    mp.erase(it->first);
                    mp[A]++;
                    dump("erase")
                    dump(it->first)
                    dump(A)
                }
            }

        }
    }
    int ans = 0;
    for(auto e : mp){
        ans += e.second;
        dump(e.first)
        dump(e.second)
    }
    cout << ans << endl;


}


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

int main()
{
  string S;
  cin >> S;
  int nissu = 1;
  
  if (S == "RRR") nissu = 3;
  if (S == "SSS") nissu = 0;
  if (S == "RRS" || S == "SRR") nissu = 2;
  
  cout << nissu;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;
typedef int64_t ll;

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

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; }

using namespace std;


class C {
	int n;
public:
	C()
	{
		cin >> n;
	}

	void solve()
	{
		int ans{ 0 };
		int a;

		REP(i, n)
		{
			cin >> a;
			ans += a;
			--ans;
		}
		cout << ans << endl;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

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

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

	int h, w;
	int judge = 0;
	cin >> h >> w;
	while(h != 0 || w != 0){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (1 <= i && i <= h - 2 && 1 <= j && j <= w - 2){
					cout << '.';
				}
				else{
					cout << '#';
				}
			}
			cout << '\n';
		}
		cout << '\n';
		cin >> h >> w;
	} 

	return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
using ll = long long;


template<class T>inline bool chmax(T& a, T b){if(a<b) { a=b;return true; } return false;}
template<class T>inline bool chmin(T& a, T b){if(a>b) { a=b;return true; } return false;}

int main(){
	int n;
	cin >> n;
	vector<ll> l(n+10);
	for(int i=0;i<n;i++) cin >> l.at(i);
	int cnt = 0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				//cout << i << j << k << endl;
				if(l[i]!=l[k] && l[k]!=l[j] && l[j]!=l[i] && l[i]+l[k]>l[j] && l[k]+l[j]>l[i] && l[i]+l[j]>l[k]){
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int X;
  cin >> X;

  int ans = 0;
  rep(a, A + 1) {
    rep(b, B + 1) {
      rep(c, C + 1) {
        int sum = 500 * a + 100 * b + 50 * c;
        if (sum == X) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut red_v: Vec<(usize, usize)> = Vec::new();
    let mut blue_v: Vec<(usize, usize)> = Vec::new();
    for _ in 0..n {
        red_v.push(get!(usize, usize));
    }
    for _ in 0..n {
        let tmp = get!(usize, usize);
        if !(tmp.0 == 0 || tmp.1 == 0) {
            blue_v.push(tmp);
        }
    }
    red_v.sort_by(|a, b| a.1.cmp(&b.1));
    red_v.reverse();
    blue_v.sort();
    let mut count = 0;
    for i in 0..blue_v.len() {
        for j in 0..red_v.len() {
            if red_v[j].0 < blue_v[i].0 && red_v[j].1 < blue_v[i].1 {
                count += 1;
                red_v.remove(j);
                break;
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int H = NextInt();
        int W = NextInt();
        Dictionary<char, int> d = new Dictionary<char, int>();
        for (int i = 0; i < H; i++)
        {
            foreach (var c in NextString())
            {
                if (!d.ContainsKey(c)) d[c] = 0;
                d[c]++;
            }
        }
        if (H % 2 == 0 && W % 2 == 0)
        {
            //必ず上下左右の回文に使われるので4つないといけない
            Console.WriteLine(d.All(v => v.Value % 4 == 0) ? "Yes" : "No");
        }
        else if (H % 2 == 1 && W % 2 == 1)
        {
            //中心が1つ、中心を通る文字は2個あってもよい
            //(H-1)/2個+(W-1)/2個までok
            if (d.Count(v => v.Value % 2 == 1) > 1)
            {
                Console.WriteLine("No");
                return;
            }
            int two_c = 0;
            foreach (var e in d)
                if (e.Value % 4 != 0 && e.Value % 2 == 0) two_c++;
            Console.WriteLine(two_c <= (H + W) / 2 - 1 ? "Yes" : "No");
        }
        else
        {
            //奇数列の中央は横回文1度しか使わないため2個でもよい
            //2個が許されるのは偶数/2個まで
            if (d.Count(v => v.Value % 2 == 1) > 1)
            {
                Console.WriteLine("No");
                return;
            }
            int two_c = 0;
            foreach (var e in d)
                if (e.Value % 4 != 0 && e.Value % 2 == 0) two_c++;
            if (H % 2 == 0)
            {
                int tmp = H;
                H = W;
                W = tmp;
            }
            Console.WriteLine(two_c <= (W / 2) ? "Yes" : "No");
        }
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13408
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <math.h>
#define LL long long
using namespace std;
int main()
{
    LL a[200001],sum=0;
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]>i||i>0&&(a[i]-1>a[i-1]))
        {
            printf("-1\n");
            return 0;
        }
        if(a[i]-1==a[i-1]&&i>0)
            sum++;
        else
            sum+=a[i];
    }
    printf("%lld\n",sum);

    return 0;
}

Measured memory_bytes: 1920
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
//

#pragma endregion

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int a, b;
	a = b = 0;
	for(int i = 0; i < n; ++i){
		if(s[i] == 'R') a++;
		else ++b;
	}
	if(a > b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

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

    return gcd(b, a % b);
}

int main()
{
    ll A, B;
    cin >> A >> B;
    ll ans = A * B / gcd(A, B);

    cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = { 0, 1, -1, 0 };
const int dy[] = { 1, 0, 0, -1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(ll base, ll power){
	if (power == 1) return base;
	if (power % 2 == 0) return fast_power((base*base), power / 2);
	else return(base*fast_power((base*base), power / 2));
}
//#pragma warning (disable : 4996)
void Qalbaz()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	cout << fixed << setprecision(2);
}

int main(){
	//Qalbaz();
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	int a, b, ans = 0, x;
	cin >> a >> b;
	for (int i = min(a, b); i <= max(a, b); i++)
		ans += i;
	x = abs(a - b) + 1;
	double y = (double)ans / x;
	cout << (int)(y + .5);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) For(i,s,x+1)
#define FoR(i,s,x) for(i=s-1;i>=x;i--)
#define ForE(i,s,x) FoR(i,s+1,x)
#define fi(i,s,x) for(int i=s;i<x;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define prA(a,m,n) fi(z,m,n+1) pr(a[i]); nl 
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define mod 1000000007
#define MAX 100005

int main() {
    FASTIO;
    ll t=1, i, j, k, l;
    // cin>>t;
    W(t--) {
        ll n, M;
        cin>>n>>M;
        vll dp(MAX,1000000000000);
        dp[0]=0;
        ll w, v, ans=0;
        For(i,0,n) {
            cin>>w>>v;
            FoR(j,MAX,v)
                if(dp[j-v]!=MAX&&dp[j-v]+w<=M)
                    dp[j]=min(dp[j],dp[j-v]+w);
        }
        FoR(i,MAX,0) { if(dp[i]!=1000000000000) { ans=i; break; } }
        cout<<ans;
        nl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int A, B;
    cin >> A >> B;

    vector<vector<char>> ans(100, vector<char>(100, '#'));
    REP(h, 50) {
        REP(w, 100) {
            ans[h][w] = '.';
        }
    }

    --A; --B;
    // black
    int h = 1;
    int w = 1;
    REP(b, B) {
        ans[h][w] = '#';
        w += 2;
        if (w >= 99) {
            w = 1;
            h += 2;
        }
    }

    // white
    h = 51;
    w = 1;
    REP(a, A) {
        ans[h][w] = '.';
        w += 2;
        if (w >= 99) {
            w = 1;
            h += 2;
        }
    }

    cout << "100 100" << endl;
    REP(h, 100) {
        REP(w, 100) {
            cout << ans[h][w];
        }
        cout << endl;
    }

    return 0;
}


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

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

  if (1 != A && 1 != B) {
    cout << "1" << endl;
  } 
  else if (2 != A && 2 != B) {
    cout << "2" << endl;
  }
  else {
    cout << "3" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

int main(){
	int n; scanf("%d",&n);
	int h[500];
	rep(i,n) scanf("%d",h+i), h[i]++;

	ll ans=0;
	int cnt[1000]={};
	rep(i,n){
		ans+=max(h[i]-1000,0);
		h[i]=min(h[i],1000);
		rep(j,h[i]) cnt[j]++;
	}
	rep(i,1000) ans+=min(cnt[i],i==0?1:4*i);

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

	return 0;
}

Measured memory_bytes: 1032
def main(r, c, inputs):
    csum = [0]*(c+1)
    for input in inputs:
        input.append(sum(input))
        for i in range(len(input)):
            csum[i] += input[i]
    inputs.append(csum)
    row = [" ".join(map(str, i)) for i in inputs]
    return '\n'.join(map(str, row))


if __name__ == "__main__":
    r, c = map(int, input().split())
    inputs = [list(map(int, input().split())) for i in range(r)]
    print(main(r, c, inputs))



Measured memory_bytes: 5788
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int N;
  cin >> N;
  vll A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  vll lgcd(N), rgcd(N);
  lgcd.at(0) = A.at(0);
  rgcd.at(N-1) = A.at(N-1);
  for(int i = 1; i < N; i++){
    lgcd.at(i) = __gcd(lgcd.at(i-1), A.at(i));
    rgcd.at(N-1-i) = __gcd(rgcd.at(N-i), A.at(N-1-i));
  }
  vll num(N, -1);
  for(int i = 0; i < N; i++){
    if(i == 0) num.at(i) = rgcd.at(i+1);
    else if(i == N-1) num.at(i) = lgcd.at(i-1);
    else{
      num.at(i) = __gcd(lgcd.at(i-1), rgcd.at(i+1));
    }
    if(num.at(i) == -1) cout << "aa" << endl;
  }
  sort(ALL(num));
  cout << num.at(N-1) << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];


int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3,range;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    a=a1=a2=a3=a4=a5=a6=0;
    //float f,g,h;
    //string s,s1;
    //priority_queue<long long int> pq;
    //stack<int> stk;
    //vector<pair<ll,ll>> vint;
    //vector<ll> vtime;
    //map<pair<ll,ll>,ll> mp;
    //list<int> li;
    //set<int> sint;
    //char now,pre,c;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        a1=a;
        cin>>a;
        num[i]=a;
        sum+=abs(a-a1);
    }
    sum+=abs(a);
    //cout<<sum;
    for(i=1;i<=n;i++)
    {
        n1=abs(num[i]-num[i-1])+abs(num[i]-num[i+1]);
        n2=abs(num[i-1]-num[i+1]);
        sum2=sum-n1+n2;
        cout<<sum2<<endl;
    }
    return 0;
}



Measured memory_bytes: 2048