akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, L, ans = 0;

	cin >> N >> L;

	rep(i, N) ans += L + i;

	if (L <= 0 && L + N - 1 >= 0) {}
	else if (L + N - 1 < 0) ans -= L + N - 1;
	else ans -= L;

	cout << ans << endl;

	return 0;
}


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

#define MAX 1000100

bool p1[MAX], p2[MAX];
int a, b;
int A, B;

void makeA(int n){
  for(int i = 2 ; i <= n ; i++){
    while(true){
      if(n % i == 0){
	p1[i] = true;
	n /= i;
	A = max(A, i);
      }
      else break;
    }
  }
}

void makeB(int n){
  for(int i = 2 ; i <= n ; i++){
    while(true){    
      if(n % i == 0){
	p2[i] = true;
	n /= i;
	B = max(B, i);
      }
      else break;
    }
  }
}

void init(){
  memset(p1, false, sizeof(p1));  
  memset(p2, false, sizeof(p2));
  A = 0, B = 0;
}

int main(){
  while(cin >> a >> b){
    if(a == 0 && b == 0) break;
    init();
    makeA(a);
    makeB(b);
         
    int m = A;
    for(int i = 0 ; i < m ; i++){
      if(p1[i]) A -= i;
    }
    m = B;
    for(int i = 0 ; i < m ; i++){
      if(p2[i]) B -= i;
    }
    
    if(A > B) cout << 'a' << endl;
    else cout << 'b' << endl;
  }
  return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384
 
std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}
 
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d)cout<<"Balanced"<<endl;
	else cout<<(a+b>c+d?"Left":"Right")<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N;
    string S;
    cin >> N >> S;

    ll B = 0;
    REP(i, N) B += (S[i] - '0');
    vvl pow2(2, vl(N, 0));

    REP(b, 2){
        ll val = 1;
        ll M = (b==0 ? B+1 : B-1);
        REP(i, N){
            if(M != 0){
                pow2[b][N-i-1] = val;
                val *= 2;
                val %= M;
            }else{
                pow2[b][N-i-1] = 0;
            }
        }
    }

    vl sum(2);
    REP(b, 2){
        ll val = 0;
        ll M = (b==0 ? B+1 : B-1);
        REP(i, N){
            val += (S[i]-'0') * pow2[b][i];
            if(M !=0 ) val %= M;
        }
        sum[b] = val;
    }

    auto G = [](ll x){
        ll cnt = 0;
        while(x>0){
            ll bi = __builtin_popcountll(x);
            x = x % bi;
            cnt++;
        }
        return cnt;
    };

    vector<ll> res(N);
    REP(i, N){
        ll M, X;
        if(S[i]=='0'){
            M = B+1;
            X = sum[0] + pow2[0][i];
            X %= M;
        }else{
            M = B-1;
            if(M != 0){
                X = sum[1] - pow2[1][i];
                X = ((X%M)+M)%M;
            }else{
                X = 0;
            }
        }
        if(S[i]=='1' and B==1) res[i] = 0;
        else res[i] = G(X) + 1;
    }

    REP(i, N) cout << res[i] << endl;

    return 0;
}

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

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define sort_v(a) sort(a.begin(), a.end())

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

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

    rep(i, 0, 26)
    {
        rep(j, 0, 26)
        {
            if (i * 4 + j * 7 == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
from itertools import accumulate

N, Q = map(int, input().split(" "))
S = input()
LR = [list(map(int, input().split(" "))) for _ in range(Q)]

p = (S[i:i+2]=="AC" for i in range(N))
p = [0] + list(accumulate(p))

# print(p)

for l, r in LR:
    l, r = l-1, r
    # print(S[l:r], l, r)
    print(p[r-1]-p[l])

Measured memory_bytes: 32344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int oo = 1e9;
const int MOD = 1000000007;
const int BASE = 26;
const int N = 200001;
#define pb push_back
#define mp make_pair
#define x first
#define y second

int n,a[N];
ll pre[N],sn[N];
char op[N],tmp[10];

int main() {
	scanf("%d",&n);
	scanf("%d",&a[1]);
	pre[1] = sn[1] = a[1];
	for(int i = 2; i <= n ; ++i){
		scanf("%s%d",tmp,&a[i]);
		op[i] = tmp[0];
		pre[i] = a[i] + pre[i-1];
		sn[i] = (tmp[0]=='-'?-1:1)*a[i]+sn[i-1];
		
	}
	ll mx = sn[n];
	int last = -1;
	for(int i = n; i >= 1 ; --i){
		if(op[i]=='-'){
			if(last != -1){
				mx = max(mx,sn[i-1]-(pre[last-1]-pre[i-1])+(pre[n]-pre[last-1]));
			}
			last = i;
		}
	}
	cout << mx << endl;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

bool isM(int x) {
  if (x >= 1 && x <= 12) return true;
  return false;
}

int main() {
  string s;
  cin >> s;
  
  string s1 = s.substr(0, 2);
  string s2 = s.substr(2, 4);
  int i1 = stoi(s1);
  int i2 = stoi(s2);

  if (isM(i1) && isM(i2)) {
    cout << "AMBIGUOUS" << endl;
  } else if (isM(i1)) {
    cout << "MMYY" << endl;
  } else if (isM(i2)) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}

int main() {
	while (1) {

		int N, M, K; cin >> N >> M>>K;
		if (!N)break;
		double ans = 0;
		for (int i = 0; i < powint(M, N); ++i) {
			vector<int>pips;
			int num = i;
			for (int i = 0; i < N; ++i) {
				pips.push_back(num%M+1);
				num /= M;
			}
			double bill = max(accumulate(pips.begin(), pips.end(), 0) - K, 1);
			ans += bill / (powint(M, N));
		}
		cout << setprecision(22)<<fixed<<ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int K = 2019;

int main() {
  string s;
  cin >> s;

  ll r = 0;
  vector<ll> v(K);
  for (auto e : s) {
    vector<ll> u(K);
    int d = e - '0';
    u[d] += 1;
    for (int i = 0; i < K; i++) {
      u[(10 * i + d) % K] += v[i];
    }
    r += u[0];
    v = u;
  }
  cout << r << endl;
}


Measured memory_bytes: 3760
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{   cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
      string s;
      cin >> s;
      for(int i=0;i<(int)s.size();i++)
      {
          if(s[i]=='?')
          {
              s[i]='D';
          }
      }
      cout << s <<endl;
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    if ( s[3] == '7' ) s[3] = '8';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int n, x1, y1, z1, w1, x2, y2, z2, w2, x3, y3, z3, w3;
	
	while (cin >> n, n)
	{
		REP(n)
		{
			cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;
			x3 = x1*x2 - y1*y2 - z1*z2 - w1*w2;
			y3 = x1*y2 + y1*x2 + z1*w2 - w1*z2;
			z3 = x1*z2 - y1*w2 + z1*x2 + w1*y2;
			w3 = x1*w2 + y1*z2 - z1*y2 + w1*x2;
			cout << x3 << " " << y3 << " " << z3 << " " << w3 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  int w;
  cin >> s >> w;
  for(int i=0; i<s.size(); i+=w) cout << s[i];ln;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();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 < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

int main(){
    ll a, b;
    while(cin >> a >> b){
        ll d = abs(abs(a) - abs(b));
        ll ans = 1e18;
        rep(S, 10){
            ll cur = a;
            ll k = 0;
            rep(i, 10){
                if(cur == b){
                    ans = min(ans, k);
                }
                if(S>>i&1){
                    cur += d;
                    k += d;
                } else {
                    cur = -cur;
                    k += 1;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=200005;
int n,a[Maxn];
LL k;
vector<int> pos[Maxn];
int FindNxt(int val,int p){
	if (pos[val].back()<p) return -1;
	return pos[val][lower_bound(pos[val].begin(),pos[val].end(),p)-pos[val].begin()];
}
int lstr[Maxn];
vector<int> ans,res;
map<int,int> ss; 
void S(){
	for (int i=0;i<ans.size();i++){
		if (ss[ans[i]]==0){
			
			res.pb(ans[i]);
			ss[ans[i]]=res.size();
		} 
		else{
			while (1){
				int x=res.back();
				ss[x]=0;
				res.pop_back();
				if (x==ans[i]) break;
			}
		}
	}
	for (int i=0;i<res.size();i++){
		printf("%d ",res[i]);
	}
	printf("\n");
}
int main(){
	scanf("%d %lld",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		pos[a[i]].pb(i);
	}
	int p=1;
	LL rnd=0;
	for (int i=0;i<Maxn;i++) lstr[i]=-1;
	
	while(1){
		if (lstr[p]!=-1){
			int cq=rnd-lstr[p];
			rnd+=(k-rnd-1)/cq*cq;
			break;
		}
		lstr[p]=rnd;
		int np=FindNxt(a[p],p+1);
		if (np==-1){
			rnd++;
			if (rnd==k){
				for (int i=p;i<=n;i++){
					ans.pb(a[i]);
				}
				S();
				return 0;
			}
			np=FindNxt(a[p],0);
		} 
		p=np+1;
		if (p>n){
			rnd++;
			if (rnd==k){
				return 0;
			}
			p=1;
		}
	}
	while (1){
		int np=FindNxt(a[p],p+1);
		if (np==-1){
			rnd++;
			if (rnd==k){
				for (int i=p;i<=n;i++){
					ans.pb(a[i]);
				}
				S();
				return 0;
			}
			np=FindNxt(a[p],0);
		} 
		p=np+1;
		if (p>n){
			rnd++;
			if (rnd==k){
				return 0;
			}
			p=1;
		}
	}
	
}

Measured memory_bytes: 24952
import numpy as np
def main():
  A=[]
  for i in range(3):
    A.append(list(map(int, input().split())))
  N=int(input().split()[0])
  B=[]
  for i in range(N):
    B.append(int(input().split()[0]))

  A= np.array(A)
  A_clear = np.zeros_like(A)
  for b in B:
    A_clear += 1* (A==b)
#  print(A)
#  print(A_clear)
  bingo_c(A_clear)
  
def bingo_c(arr):
  if (np.sum(arr, axis=0)==3).any():
    print('Yes')
  elif (np.sum(arr, axis=1)==3).any():
    print('Yes')
  elif arr[0,0]+arr[1,1]+arr[2,2]==3:
    print('Yes')
  elif arr[0,2]+arr[1,1]+arr[2,0]==3:
    print('Yes')
  else:
    print('No')
  
if __name__=="__main__":
  main()

Measured memory_bytes: 21056
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>

using namespace std;

int H, W;
int table[500][500];
bool ans;

int main() {
	int N;
	cin >> N;
	string str[100];
	for (int i = 0; i < N; i++) {
		cin >> str[i];
		if (i != 0) {
			if (str[i][0] != str[i - 1][str[i - 1].length() - 1]) {
				ans = true;
				goto END;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (str[i] == str[j]) {
				ans = true;
				goto END;
			}
		}
	}
END:
	if (ans) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    nxts = [int(input()) - 1 for _ in range(n)]

    history = set()
    current = 0
    count = 0
    while current != 1:
        if current in history:
            return -1
        history.add(current)
        count += 1
        current = nxts[current]

    return count

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 56076
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
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;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  ll L, R, d;
  cin >> L >> R >> d;
  ll counter = 0;
  for(int i = L; i <= R; i++){
    if(i % d == 0) counter++;
  }
  cout << counter << endl;
}

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

typedef bool B;
typedef long double D;
typedef complex<D> P;
typedef vector<P> VP;
typedef struct {P s,t;} L;
typedef vector<L> VL;
typedef struct {P c;D r;} C;
typedef vector <C> VC;

const D eps=1.0e-10;
const D pi=acos(-1.0);
template<class T> bool operator==(T a, T b){return abs(a-b)< eps;}
template<class T> bool operator< (T a, T b){return a < b-eps;}
template<class T> bool operator<=(T a, T b){return a < b+eps;}
template<class T> int sig(T r) {return (r==0||r==-0) ? 0 : r > 0 ? 1 : -1;}
#define X real()
#define Y imag()

D ip(P a, P b) {return a.X * b.X + a.Y * b.Y;}
D ep(P a, P b) {return a.X * b.Y - a.Y * b.X;}
D sq(D a) {return sqrt(max(a, (D)0));}
P vec(L l){return l.t-l.s;}
inline P input(){D x,y;cin >> x >> y; return P(x,y);}
// ???????????¬????????¨???

// ???????????? verify AOJ CGL_1_C
enum CCW{
	LEFT = 1,
	RIGHT = 2,
	BACK = 4,
	FRONT = 8,
	MID = 16,
	ON=FRONT|BACK|MID
};

inline int ccw(P base, P a, P b) {              //???a??¨???b???????????????????????????
	a -= base; b -= base;
	if (ep(a, b) > 0)
		return LEFT;    // counter clockwise
	if (ep(a, b) < 0)
		return RIGHT;   // clockwise
	if (ip(a, b) < 0)
		return BACK;    // b--base--a on line
	if (norm(a) < norm(b))
		return FRONT;   // base--a--b on line
	// otherwise
	return MID;      // base--b--a on line  a??¨b????????????????????????
}

// ??????
// verify AOJ CGL_2_C
P pLL(L a,L b){ return a.s+vec(a)*ep(vec(b),b.s-a.s)/ep(vec(b),vec(a));}


// ??????????????????
inline B cmp_x(const P &a,const P &b){
	return (abs(a.X-b.X)<eps ) ?  a.Y<b.Y : a.X<b.X;
}  // base x
inline B cmp_y(const P &a,const P &b){
	return (abs(a.Y-b.Y)<eps ) ?  a.X<b.X : a.Y<b.Y;
}  // base y
inline B cmp_a(const P &a,const P &b){
	return (abs(arg(a)-arg(b))<eps ) ?  norm(a) < norm(b) : arg(a)<arg(b);
} // base arg

// ????§???¢

// ????§???¢

// ??¢???
// Verify AOJ 1100
// verify CGL_3_A
D area(VP pol){
	int n=pol.size();
	D sum=0.0;
	rep(i,n){
		D x=pol[i%n].X-pol[(i+1)%n].X;
		D y=pol[i%n].Y+pol[(i+1)%n].Y;
		sum+=x*y;
	}
	return abs(sum/2.0);
}

VP convex_cut(const VP& pol, const L& l) {
	VP res;
	int n=pol.size();
	rep(i,n){
		P a = pol[i], b = pol[(i+1)%n];
		if(ccw(l.s, l.t, a) != RIGHT) res.push_back(a);
		if((ccw(l.s, l.t, a)|ccw(l.s, l.t, b))==(LEFT|RIGHT))
			res.push_back(pLL({a,b}, l));
	}
	return res;
}

int main(void){
	int n;
	cin >> n;
	VP pol;
	rep(i,n) pol.push_back(input());
	int q;
	cin >> q;
	cout.precision(10);
	rep(i,q){
		L line;
		line.s=input();
		line.t=input();
		cout << fixed << area(convex_cut(pol,line)) << endl;
	}
	return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
//#define int ll
#define int long long
 
signed main()
{
  
  int n;cin>>n;int t;cin>>t;
  int x{},y{},z{};
  int sum{};
  int man = 10000;int higuti = 5000;int noguti = 1000;
  
  for(int i = 0; i <= n; ++i){
    for(int j = 0; j+i <= n ; ++j){
      int k = n-(i+j);
      sum = man*k+higuti*j+noguti*i;
      if(sum == t && i+j+k == n){
        cout << k << " " << j << " " << i << endl;
        return 0;
      }
      
    } 
  }
 
    cout << "-1 -1 -1" << endl;
  
 
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int T = sc.nextInt();

            int[] A = new int[N + 1];
            int[] B = new int[N + 1];
            for (int i = 1; i <= N; i++) {
                A[i] = sc.nextInt();
                B[i] = sc.nextInt();
            }

            long[][][] dp = new long[2][N + 1][T + 1];
            for (int i = 1; i <= N; i++) {
                for (int j = 0; j <= T; j++) {
                    if (j < A[i]) {
                        dp[0][i][j] = dp[0][i - 1][j];
                    } else {
                        dp[0][i][j] = Math.max(dp[0][i - 1][j], dp[0][i - 1][j - A[i]] + B[i]);
                    }

                    if (j < 1) {
                        dp[1][i][j] = dp[1][i - 1][j];
                    } else if (j >= 1 && j < A[i]) {
                        dp[1][i][j] = Math.max(dp[1][i - 1][j], dp[0][i - 1][j - 1] + B[i]);
                    } else {
                        dp[1][i][j] = Math.max(Math.max(dp[1][i - 1][j], dp[1][i - 1][j - A[i]] + B[i]),
                                dp[0][i - 1][j - 1] + B[i]);
                    }
                }
            }

            long ans = dp[1][N][T];

            System.out.println(ans);
        }
    }

}


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

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

    vector<int> b(m);
    rep (i, m)
        cin >> b[i];

    int ans = 0;
    rep (i, n)
    {
        int sum = 0;
        rep (j, m)
        {
            int a;
            cin >> a;
            sum += a * b[j];
        }
        if (sum + c > 0)
            ans++;
    }

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

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int s[55];
	int x[55556]={1,1};
	int i,j,k,l;
	int n;

	for(i=2;i<250;i++){
		if(x[i]==0){
			for(j=i*2;j<=55555;j+=i){
				x[j]=1;
			}
		}
	}

	scanf("%d",&n);
	j=-7;
	for(i=0;i<n;i++){
		j+=10;
		while(x[j]==1) j+=10;		
		s[i]=j;
	}

	printf("%d",s[0]);
	for(i=1;i<n;i++){
		printf(" %d",s[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 384
H,W = map(int,input().split())

grid = [None] * H

for i in range(H):
    grid[i] = input()

dp = [[0] * (W+1) for i in range(H+1)]

dp[1][1] = 1
M = 10 ** 9 + 7

for L in range(1,H + 1):
    for C in range(1,W + 1):
        if L == 1 and C == 1:
            continue
        else:
            if grid[L-1][C-1] == ".":
                dp[L][C] = dp[L][C-1] + dp[L-1][C]
                dp[L][C] %= M

print(dp[H][W])


Measured memory_bytes: 74616
#include <iostream>
#include <string>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <sstream> 
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <functional>
#pragma GCC optimize("O3")
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sp system("pause");
#define MOD 998244353 
#define mxN 2005
#define MXINT 1e9+5


void solve()
{
	string s, t;

	cin >> s >> t;

	vector<vector<pair<ll,char>>> dp(s.length()+1);

	for (int i = 0; i < s.length() +1; i++)
		dp[i].resize(t.length() + 1);
	ll n = s.length() + 1, m = t.length() + 1;
	//k-koso
	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j < m; j++)
		{
			if (s[i - 1] == t[j - 1]) {
				dp[i][j].second = 'k';
				dp[i][j].first = dp[i - 1][j - 1].first + 1;
			}
			else
			{
				if (dp[i - 1][j].first > dp[i][j - 1].first)
				{
					dp[i][j].first = dp[i - 1][j].first;
					dp[i][j].second = 'g';
				}
				else
				{
					dp[i][j].first = dp[i][j-1].first;
					dp[i][j].second = 'l';
				}
			}
		}
	}
	

	int i = n-1, j = m-1;
	stringstream ss;
	while (i > 0 && j > 0)
	{
		if (dp[i][j].second == 'k')
		{
			ss << (s[i-1]);
			i--;
			j--;
		}
		else
		{
			if (dp[i][j].second == 'g')
			{
				i--;
			}
			else
				j--;
		}
	}
	string sd(ss.str());
	reverse(sd.begin(), sd.end());
	cout << sd;
}

int main()
{
	fast;
	solve();

	return 0;
}



Measured memory_bytes: 141056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());

		/**
		 *  アルゴリズムの方針
		 *  1) 全て奇数or偶数のケース、1つだけ異なるケースの判定を行う
		 *  2) 全て奇数or偶数の場合、a,b,cの中で最大の数と他の2つの数との差を求め、その半分が操作回数となる
		 *  3a) 1つだけ異なる場合、まず一致する2数の差を求め、その半分を操作回数の一部とする
		 *  3b) 次にその2数のうち大きい方の数に+1し、残りの数との差の絶対値を求める
		 *  3c) (3b)の結果の半分+1を(3a)の結果と足すと操作回数となる
		 */
		int even[];
		even = new int[3];
		even[0] = a % 2;
		even[1] = b % 2;
		even[2] = c % 2;

		int count = 0;
		if(even[0] + even[1] + even[2] == 0 || even[0] + even[1] + even[2] == 3) {
			int max = a;
			int imax = 0;
			if(max < b) {
				max = b;
				imax = 1;
			}
			if(max < c) {
				max = c;
				imax = 2;
			}

			int sum = 0;
			if(imax == 0) {
				sum += max - b;
				sum += max - c;
			}else if(imax == 1) {
				sum += max - a;
				sum += max - c;
			}else {
				sum += max - a;
				sum += max - b;
			}
			count = sum / 2;
		}else if(even[0] + even[1] + even[2] == 1) {
			if(even[0] == 1) {
				if(b > c) {
					count += (b - c) / 2;
					count += Math.abs(a - (b + 1)) / 2 + 1;
				}else {
					count += (c - b) / 2;
					count += Math.abs(a - (c + 1)) / 2 + 1;
				}
			}else if(even[1] == 1) {
				if(a > c) {
					count += (a - c) / 2;
					count += Math.abs(b - (a + 1)) / 2 + 1;
				}else {
					count += (c - a) / 2;
					count += Math.abs(b - (c + 1)) / 2 + 1;
				}
			}else {
				if(a > b) {
					count += (a - b) / 2;
					count += Math.abs(c - (a + 1)) / 2 + 1;
				}else {
					count += (b - a) / 2;
					count += Math.abs(c - (b + 1)) / 2 + 1;
				}
			}
		}else {
			if(even[0] == 0) {
				if(b > c) {
					count += (b - c) / 2;
					count += Math.abs(a - (b + 1)) / 2 + 1;
				}else {
					count += (c - b) / 2;
					count += Math.abs(a - (c + 1)) / 2 + 1;
				}
			}else if(even[1] == 0) {
				if(a > c) {
					count += (a - c) / 2;
					count += Math.abs(b - (a + 1)) + 1;
				}else {
					count += (c - a) / 2;
					count += Math.abs(b - (c + 1)) / 2 + 1;
				}
			}else {
				if(a > b) {
					count += (a - b) / 2;
					count += Math.abs(c - (a + 1)) / 2 + 1;
				}else {
					count += (b - a) / 2;
					count += Math.abs(c - (b + 1)) / 2 + 1;
				}
			}
		}

		System.out.println(count);
	}

}


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

int main(){
  int n,a[2][110];
  cin>>n;
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  }
  int max=a[0][0];
  for(int i=0;i<n;i++){
    max+=a[1][i];
  }
  int arr=1;
  for(int i=0;i<n;i++){
    int cnt=0,sum=0;
    bool flag=true;
    if(arr>=n-1) break;
    for(int j=0;j<n;j++){
      if(j==arr && flag){
        sum+=a[cnt][j];
        cnt=1;
        arr++;
        flag=false;
      }
      sum+=a[cnt][j];
      if(sum>max) max=sum;
    }
  }
  cout<<max;

}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
work = []
temp = []
for k, v in sorted(counter.items(), key=lambda x:x[0], reverse=True):
    if v >= 4:
        temp.append(k)
    if v >= 2:
        work.append(k)
        if len(work)==2:
            break   
if len(work) < 2:
    if len(temp)==0:
        result = 0
    else:
        result = temp[0]**2
else:
    if len(temp)==0:
        result = work[0]*work[1]
    else:
        result = work[0]*work[1] if work[0]*work[1]>temp[0]**2 else temp[0]**2
print(result)

Measured memory_bytes: 22436
n = int(input())

for i in range(1, n + 1):
    if i % 3 == 0 or i % 10 == 3 or '3' in str(i):
        print('',i,end='')      #改行なしで出力したい時に「end=''」を使います。
    else:
        print(end='')
print()



Measured memory_bytes: 6288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str[]=sc.nextLine().split(" "),ans1,ans2;
		int max=0;
		ans1=ans2="";
		
		for(int i=0;i<str.length;i++){
			if(max<str[i].length()){
				max=str[i].length();
				ans1=str[i];
			}
		}
		
		int count;
		max=0;
		for(int i=0;i<str.length;i++){
			count=0;
			for(int j=0;j<str.length;j++){
				if(str[j].equals(str[i])){
					count++;
				}
			}
			if(max < count){
				max=count;
				ans2=str[i];
			}
		}
		System.out.println(ans2+" "+ans1);
	}
}

Measured memory_bytes: 11000
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
        for(int i=0;i<a;i++)
            cout<<b;
    else
        for(int i=0;i<b;i++)
            cout<<a;
    cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	if(a>b)swap(a,b);
	n--;
	for(ll i=1;i<=n;i++){
		ll x1=a+c*i,x2=a+d*i,x3=a-c*i,x4=a-d*i;
		ll y1=b+c*(n-i),y2=b+d*(n-i),y3=b-c*(n-i),y4=b-d*(n-i);
		if((x2<y1||x1>y2)&&(x2<y4||x1>y3)&&(x3<y1||x4>y2)&&(x3<y4||x4>y3))continue;
		puts("YES");
		return 0;
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
s = input()
k_list = []
cnt = 0
one = ""

for i in s:
  if len(k_list) == 0:
    k_list.append(i)
    cnt += 1
  elif k_list[cnt-1] == one + i:
    one += i
    pass
  else:
    k_list.append(one + i)
    one = ""
    cnt += 1
  
print(len(k_list))

Measured memory_bytes: 8368
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	final int _intMax = Integer.MAX_VALUE; //=2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; //=9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int[] a = readNums();
		int m = (int)pow(10, 9) + 7;
		Arrays.sort(a);
		if (n % 2 == 1) {
			if (a[0] != 0) {
				pln("0");
				return;
			}
			int v = 2;
			int ans = 1;
			for (int i=1; i<n; i+=2) {
				if (a[i] != v || a[i+1] != v) {
					pln("0");
					return;
				}
				v += 2;
				ans = ans * 2 % m;
			}
			pln(ans);
		} else {
			int v = 1;
			int ans = 1;
			for (int i=0; i<n; i+=2) {
				if (a[i] != v || a[i+1] != v) {
					pln("0");
					return;
				}
				v += 2;
				ans = ans * 2 % m;
			}
			pln(ans);
		}
	}

	long pow(long n, long p) {
		return (long)Math.pow(n, p);
	}
	int pint(String s) {
		return Integer.parseInt(s);
	}
	long plong(String s) {
		return Long.parseLong(s);
	}
	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	int readNum() {
		String line = readLine();
		return pint(line);
	}
	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}
	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i=0; i<flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}
	void p(char c) {
		_out.print(c);
	}
	void pln(char c) {
		_out.println(c);
	}
	void p(double d) {
		_out.print(d);
	}
	void pln(double d) {
		_out.println(d);
	}
	void p(long l) {
		_out.print(l);
	}
	void pln(long l) {
		_out.println(l);
	}
	void p(String s) {
		_out.print(s);
	}
	void pln(String s) {
		_out.println(s);
	}
	static BufferedReader _in;
	static PrintWriter _out;
	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end-start) + "ms");
		}
	}
}


Measured memory_bytes: 25120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <ext/rope>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=1e5+10;
const int dis[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
using namespace std;
using namespace __gnu_cxx;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,a[maxn]={0,1},now[maxn],ans;
int main()
{
    int i,j,k,t;
    scanf("%d%d",&n,&m);
    rep(i,1,m)
    {
        scanf("%d%d",&j,&k);
        a[k]|=a[j];
        now[k]++,now[j]--;
        if(now[j]==-1)a[j]=0;
    }
    rep(i,1,n)if(now[i]>=0&&a[i])ans++;
    printf("%d\n",ans);
    //system ("pause");
    return 0;
}


Measured memory_bytes: 1024
MOD = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))

ans = 0
m = 1
for i in range(60):
    bits = sum((a & m for a in A))
    bits //= m
    ans += (bits * (N - bits) * m)
    ans %= MOD
    m <<= 1
print(ans % MOD)


Measured memory_bytes: 42212
#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
#include<cmath>

#define mod 1000000007
#define pa(a,b) make_pair(a,b)
#define LL  long long int

using namespace std;
int main()
{
    int n ; cin>>n; n*=2; int ans=0; int a[300];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=n-1;i>=0;i-=2)ans+=min(a[i],a[i-1]);
    cout<<ans;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)

s = int(input())
mod = pow(10, 9)+7
d = dict()

def solve(n):
    if n in d.keys():
        return d[n]
    cnt = 0
    for i in range(3, n+1):
        if n-i >= 3:
            cnt += solve(n-i)
        else:
            if n-i == 0:
                cnt += 1
    d[n] = cnt%mod
    return d[n]

print(solve(s)%mod)


Measured memory_bytes: 9380
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SimpleKnapsack solver = new SimpleKnapsack();
        solver.solve(1, in, out);
        out.close();
    }

    static class SimpleKnapsack {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long w = in.nextLong();

            long[] weights = new long[n];
            long[] values = new long[n];

            //  選んだ個数 | weightの和
            long[][] dp = new long[n + 1][3 * n + 1];
            for (int i = 0; i < n; i++) {
                weights[i] = Long.parseLong(in.next());
                values[i] = Long.parseLong(in.next());
            }

            int sum = 0;
            for (int i = 0; i < n; i++) {
                int diff = (int) (weights[i] - weights[0]);
                for (int j = i; 0 <= j; j--) {
                    for (int k = sum; 0 <= k; k--) {
                        dp[j + 1][k + diff] = Math.max(dp[j + 1][k + diff], dp[j][k] + values[i]);
                    }
                }
                sum += diff;
            }
            long result = 0;
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= sum; j++) {
                    if (w < i * weights[0] + j) {
                        continue;
                    }
                    result = Math.max(result, dp[i][j]);
                }
            }

            out.println(result);

        }

    }
}



Measured memory_bytes: 37420
n = int(input())
a = []
for _ in range(n):
    c0, c1 = map(int, input().split())
    a.append([c0-c1, c0+c1])
a.sort(key=lambda x: x[1])
ans, b = 1, a[0][1]
for i in a[1:]:
    if b <= i[0]:
        b = i[1]
        ans += 1
print(ans)


Measured memory_bytes: 25416
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    for (int i = 0; i < n; i++) std::cin >> b[i];
    long long u = 0, v = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] <= b[i]) u += (b[i] - a[i]) / 2;
        else v += a[i] - b[i];
    }
    if (u >= v) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	FOR (i, 1, 5)
	{
	    read(x);
	    if (!x)
	    {
	        cout << i;
	        return 0;
	    }
	}
}



















Measured memory_bytes: 3608
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	int a, b;
	char op;
	cin >> a >> op >> b;

	if (op == '+'){
		cout << a+b << endl;
	}
	else{
		cout << a-b << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
 
int main(){
  ll H;
  cin>>H;
  ll ans=0;
  for(int i=0;H>=1;i++){
    ans+=pow(2,i);
    H/=2;
  }
  cout<<ans<<endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
const int MX = (int) 1e5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(15);
//srand(time(0));

int a[maxn], c[111][111], n, m, k;

int main()
{
//    fin("t.in");
    sync;
    cin >> n >> m >> k;
    fi(1, k)
    {
    	cin >> a[i];
    }
    int x = 1, y = 1;
    clean(c);
    fi(1, k)
    {
    	while (a[i] > 0)
    	{
    		--a[i];
    		c[x][y] = i;
    		if (x & 1)
    			++y;
    		else
    			--y;
    		if (y == 0)
    		{
    			++x;
    			y = 1;
    		}
    		else
    		if (y == m + 1)
    		{
    			++x;
    			y = m;
    		}
    	}
    }
    fi(1, n)
    {
    	fj(1, m)
    	{
    		cout << c[i][j] << " ";
    	}
    	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    String[] S = new String[N];

    for (int i = 0; i < N; i++) {
      S[i] = sc.next() + "/" + (1100 - sc.nextInt() + "/" + (i + 1));
    }

    sc.close();

    Arrays.sort(S);

    for (int i = 0; i < N; i++) {
      String[] s_ = S[i].split("/");
      System.out.println(s_[2]);
    }

  }

}

Measured memory_bytes: 21204
n = int(input())
a = list(map(int, input().split()))
x = [0]*n

#determine x[0]
for i in range(n):
    if int(i % 2) == 0:
        x[0] = x[0] + a[i]
    else:
        x[0] = x[0] - a[i]

for i in range(1, n):
    x[i] = (2 * a[i - 1]) - x[i - 1]

print(*x)

Measured memory_bytes: 14092
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
const int N=1e4+50;
const long long INF=0x3f3f3f3f3f3f3f3f;
typedef long long ll;
long double length[N][N];
long double d[N];
bool vis[N];
int n;
struct circular
{
   int x,y;
   int r=0;
}c[N];
void dijkstra(int s)
{
    for(int i=0;i<=n+1;i++)
        d[i]=INF;
    d[s]=0;
    while(1)
    {
        int v=-1;
        for(int i=0;i<=n+1;i++)
        {
            if(!vis[i]&&(v==-1||d[i]<d[v]))
                v=i;
        }
        if(v==-1)
         break;
        vis[v]=1;
        for(int i=0;i<=n+1;i++)
        d[i]=min(d[i],d[v]+length[v][i]);
    }
}
int main()
{
    int x1,y1;
    scanf("%d%d%d%d",&c[0].x,&c[0].y,&x1,&y1);
    scanf("%d",&n);
    c[n+1].x=x1;
    c[n+1].y=y1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&c[i].x,&c[i].y,&c[i].r);
    }
    for(int i=0;i<=n+1;i++)
    {
        for(int j=i+1;j<=n+1;j++)
        {
           length[i][j]=(long double)sqrt((long double)(c[i].x-c[j].x)*(c[i].x-c[j].x)+(long double)(c[i].y-c[j].y)*(c[i].y-c[j].y));
            length[i][j]-=c[i].r+c[j].r;
            if(length[i][j]<0)
             length[i][j]=0;
            length[j][i]=length[i][j];
        }
    }
    dijkstra(0);
    printf("%.9Lf\n",d[n+1]);
    return 0;
}

Measured memory_bytes: 156288
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W;
long long A[200005] = {};
long long B[200005] = {};
long long C[200005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <pl>vpl[20];
vector <string> vs[20];
set<ll> llset;

struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;

int main() {


	cin >> N;
	
	a = 0;
	f = false;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] > 0) {
			a += A[i] / 2;
			if (A[i] % 2 == 1) {
				if (f == false) {
					f = true;
				}
				else {
					a++;
					f = false;
				}
			}
		
		}
		else {
			f = false;
		}
	}
	cout << a << endl;
	
	return 0;

}


Measured memory_bytes: 5120
#include "bits/stdc++.h"
using namespace std;

int main(){
int n;
cin >> n;
vector<long long>a(n);
int ans =0;
for(int i=0;i<n;i++){
  cin >> a.at(i);
  
}
for(int i=0;i<n;i++){
if(a.at(i)%2 == 0){
    while(a.at(i)%2 !=1){
      ans++;
      a.at(i)/=2;
    }
  }
}
cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1000000000000000000;
int main()
{
 	long long a[5],b[5],c[5],k,cnt;
 	long long sum=6;
 	long long ans;
 	cin>>a[1]>>b[1]>>c[1]>>k;
 	a[2]=b[1]+c[1];
 	b[2]=a[1]+c[1];
 	c[1]=a[1]+b[1];
 	if(k%2==0) ans=a[1]-b[1];
 	else ans=a[2]-b[2];
 	if(abs(ans)>maxn) printf("Unfair");
 	else printf("%lld",ans);
 	return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

string S;

int main(void){
    
    cin >> S;
    if(S[0] - '0' == 9 || S[1] - '0' == 9) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
using namespace std;
int main (){
    int N, A, B;
    cin >> N >> A >> B;
    if (A*N>B){
      cout << B;
    }
    else {
      cout << N*A;
    }
}

Measured memory_bytes: 256