akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

#define INF 1e9
#define EPS 1e-6

typedef complex<double> Point;
typedef pair<Point, Point> Line;
double dis(Point a, Point b){ return abs(a - b); }
double dot(Point a, Point b){ return a.real() * b.real() + a.imag() * b.imag(); }

//テッツシツ津」ツ?、テ」ツ?ョテ」ツδ凖」ツつッテ」ツδ暗」ツδォABテ」ツ?ョテ」ツ?ェテ」ツ?凖ィツァツ津・ツコツヲテ篠クテ」ツつ津ヲツアツづ」ツつ?」ツつ?(テ」ツδ催」ツδε」ツδ暗」ツ?凝」ツつ嘉ヲツ仰セテ」ツ?」テ」ツ?ヲテ」ツ?催」ツ?淌」ツつづ」ツ?ョテ」ツ?ョテ、ツクツクテ」ツつウテ」ツδ?
double AngleOf2Point(Point A, Point B){
  //テ」ツδ凖」ツつッテ」ツδ暗」ツδォAテ」ツ?ィBテ」ツ?ョテゥツ閉キテ」ツ?陛」ツつ津ィツィツ暗ァツョツ療」ツ?療」ツ??
  //テ・ツ??ァツゥツ催」ツ?ィテ」ツδ凖」ツつッテ」ツδ暗」ツδォテゥツ閉キテ」ツ?陛」ツつ津、ツスツソテ」ツ?」テ」ツ?ヲcosテ篠クテ」ツつ津ヲツアツづ」ツつ?」ツつ?
  double length_A = abs(A);
  double length_B = abs(B);
  double cos_sita = dot(A, B) / (length_A * length_B );
  
  //cosテ篠クテ」ツ?凝」ツつ嘉篠クテ」ツつ津ヲツアツづ」ツつ?」ツ??テ」ツ??80テ」ツ?ョティツァツ津・ツコツヲテ」ツ?ォテ・ツ、ツ嘉ヲツ渉?
  double sita = acos( cos_sita );	
  sita = sita * 180.0 / M_PI;
  
  return sita;
}
double AngleOf2Line(Line A, Line B){ return AngleOf2Point(A.first - A.second, B.first - B.second); }


int main(void){
  int n;
  double r, theta;
  cin >> n >> r >> theta;

  int x, y;
  vector<Point> town;
  for(int i = 0; i < n; i++){
    cin >> x >> y;
    town.push_back(Point(x, y));
  }

  // adj[i][j]: jテ」ツ?凝」ツつ永テ」ツ?ォテ」ツ?催」ツ?淌・ツセツ古」ツ?ォテゥツ?キテァツァツサテ」ツ?ァテ」ツ?催」ツつ凝ゥツ?づァツつケテ」ツδェテ」ツつケテ」ツδ?
  vector<vector<vector<int> > > adj(n, vector<vector<int> >(n));
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      for(int k = 0; k < n; k++)
        if(i != j && i != k)
          if(AngleOf2Line(make_pair(town[j], town[i]), make_pair(town[i], town[k])) <= theta + EPS)
            adj[i][j].push_back(k);

  // dp[i][j][k]: jテ」ツ?凝」ツつ永テ」ツ?ォテヲツ敖・テ」ツ?淌ヲツ卍づァツつケテ」ツ?ァテ」ツδ凝」ツδウテ」ツつクテ」ツδウテ」ツつ談+1テヲツ慊ャGETテ」ツ?療」ツ?ヲテ」ツつ凝・ツ?エテ・ツ青暗」ツ?ョテヲツ慊?ァツ淞ュテァツオツ古ィツキツッ
  int int_r = (int)r + 1;
  vector<vector<vector<double> > > dp(n, vector<vector<double> >(n, vector<double>(int_r, INF)));
  for(int now = 1; now < n; now++){ dp[now][0][0] = dis(town[0], town[now]); }
  for(int carrot = 0; carrot < int_r - 1; carrot++){
    for(int now = 0; now < n; now++){
      for(int prev = 0; prev < n; prev++){
        for(size_t i = 0; i < adj[now][prev].size(); i++){
          int next = adj[now][prev][i];
          dp[next][now][carrot + 1] = min(dp[next][now][carrot + 1],
                                          dp[now][prev][carrot] + dis(town[now], town[next]));
        }
      }
    }
  }

  // テァツュツ氾」ツ?暗」ツつ津ィツィツ暗ァツョツ療」ツ?療」ツ?ヲテ・ツ?コテ・ツ環?
  int ans = -1;
  for(int carrot = 0; carrot < int_r; carrot++)
    for(int now = 0; now < n; now++)
      for(int prev = 0; prev < n; prev++)
        if(dp[now][prev][carrot] <= r + EPS)
          ans = carrot;
  
  cout << ans + 1 << endl;
  return 0;
}

Measured memory_bytes: 36244
function Dice( faces ) {
  this.faces = faces;
  this.getFace = function ( id ) {
    return this.faces[id];
  }
  this.roll = function ( cmds ) {
    var t;
    for( var i=0; i<cmds.length; i++ ) {
      if( 'E' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = t;
      } else if( 'S' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = t;
      } else if( 'W' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = t;
      } else if( 'N' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = t;        
      } else if( 'M' == cmds[i] ) {
        t = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = t;        
      }
    }
  }
  this.isEqual = function( other ) {
    var i;
    for( i=Dice.TOP; i<=Dice.BOTTOM; i++ ) {
      if( this.getFace( i ) != other.getFace( i ) ) { break; }
    }
    return  (i==6)?true:false;
  }
}
Dice.TOP = 0;
Dice.FRONT = 1;
Dice.RIGHT = 2;
Dice.LEFT = 3;
Dice.BACK = 4;
Dice.BOTTOM = 5;

var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' );
  var labels = data[0].split( ' ' ).map( Number );
  var dice = new Dice( labels ); 
  var labels2 = data[1].split( ' ' ).map( Number );
  var dice2 = new Dice( labels2 ); 

  var cmds = "NWWWNMMMM";
  var isequal = false;
  for( var i=0; i<cmds.length; i++ ) {
    if( dice2.getFace( Dice.TOP ) == dice.getFace( Dice.TOP ) ) {
      var j;
      for( j=5; j<cmds.length && !isequal; j++ ) {
        if( dice2.getFace( Dice.FRONT ) == dice.getFace( Dice.FRONT ) ) { 
          isequal = dice.isEqual( dice2 );
        }
        dice2.roll( cmds[j] );
      }
    }
    dice2.roll( cmds[i] );
  }
  if( isequal) {
    console.log( "Yes" );
  } else {
    console.log( "No" );
  }
});

Measured memory_bytes: 15672
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define int long long
signed  main(){
  int N,K;
  char dif='A'-'a';
  str S1,S2,S3;
  cin>>S1>>S2>>S3;
  if(S1.at(S1.size()-1)==S2.at(0)&&S2.at(S2.size()-1)==S3.at(0))cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int value[3][101];
int sum[3][101];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> value[1][i];
	for (int i = 1; i <= n; i++) cin >> value[2][i];
	for (int i = 0; i <= 2; i++) sum[i][0] = 0;
	for (int i = 0; i <= n; i++) sum[0][i] = 0;
	for (int i = 1; i <= 2; i++)
		for (int j = 1; j <= n; j++)
			sum[i][j] = max(sum[i][j - 1], sum[i - 1][j]) + value[i][j];
	cout << sum[2][n] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;
#define m 1000000007

ll takbir(ll a, ll b){
    if(a%4==1) a = 1;
    else if(a%4==2) a++;
    else if(a%4==3) a = 0;

    if(b%4==1) b = 1;
    else if(b%4==2) b++;
    else if(b%4==3) b = 0;

    a = a^b;
    return a;
}

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

    ll a, b; cin>>a>>b;
    a = takbir(max(0LL, a-1), b);
    cout<<a<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <math.h>
int main(void){
	int a=0,b,d[2][6],i,j,k,n,x,y;
	char c;

	for(i=0;i<6;i++){
		scanf("%d%*c",&d[0][i] );
	}
	for(i=0;i<6;i++){
		scanf("%d%*c",&d[1][i] );
	}

	for(i=0;i<4;i++){
		n=d[1][0];
		d[1][0]=d[1][2];
		d[1][2]=d[1][5];
		d[1][5]=d[1][3];
		d[1][3]=n;
		for(j=0;j<4;j++){
			n=d[1][0];
			d[1][0]=d[1][1];
			d[1][1]=d[1][5];
			d[1][5]=d[1][4];
			d[1][4]=n;
			for(k=0;k<4;k++){
				n=d[1][1];
				d[1][1]=d[1][3];
				d[1][3]=d[1][4];
				d[1][4]=d[1][2];
				d[1][2]=n;
				for(a=0,b=0;a<6;a++){
					if(d[1][a]==d[0][a])b++;
				}
				if(b==6){
					printf("Yes\n" );
					return 0;
				}
			}
		}
	}printf("No\n" );
	return 0;
}

Measured memory_bytes: 580
from fractions import gcd
class segtree():
    def segfunc(x,y):
        return min(x,y)
    #####単位元######
    ide_ele = -1
    n=1
    init_val=[0]*n
    #num:n以上の最小の2のべき乗
    num =2**(n-1).bit_length()
    seg=[ide_ele]*2*num
    
    def __init__(self,INIT_VAL,SEGFUNC,IDE_ELE):
        self.ide_ele=IDE_ELE
        self.init_val=[i for i in INIT_VAL]
        self.segfunc=SEGFUNC
        self.n=len(self.init_val)
        self.num =2**(self.n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num
 
        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1]=self.init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
        
    def update(self,k,x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
N=int(input())
A=[int(i) for i in input().split()]
B=segtree(A,gcd,0)
C=[gcd(B.query(0,i),B.query(i+1,N+1)) for i in range(N+1)]
print(max(C))


Measured memory_bytes: 16144
import math
a,b=map(int,input().split())
x=max(a,b)
y=min(a,b)
p=abs(x-y)

P = 10**9 + 7
N = 1000000
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

if (x+y)%3!=0:
    print(0)
elif x>y*2:
    print(0)
else:
    n=(x+y)//3
    q=(2*x-y)//3
    r=(2*y-x)//3
    
    #print(math.factorial(q+r)//math.factorial(q)//math.factorial(r)%(10**9+7))
    ans=1
    qq=1
    rr=1
    for i in range(1,q+r+1):
        ans*=i
        ans%=10**9+7
    for i in range(1,q+1):
        ans*=inv_t[i]
        ans%=10**9+7

    P = 10**9 + 7
    N = r+2
    inv_t = [0]+[1]
    for i in range(2,N):
        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

    for i in range(1,r+1):
        ans*=inv_t[i]
        ans%=10**9+7
            
            
    print(ans)


Measured memory_bytes: 44716
#include <bits/stdc++.h>
using namespace std;
long long a[200005];
long long b[200005],c[200005];
int main()
{
    long long n,m,i,j,k,x=0,y,z,t;
    string s,ss;
    cin>>s>>ss;
    cout<<ss<<s<<endl;
}


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

int n;
double p[maxn];
double dp[maxn][maxn];

int main()
{
    cin >> n;
    p[0] = 1;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i];
        for (int j = 0; j <= i; ++j)
        {
            dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
        }
    }
    double ans = 0;
    for (int i = (n + 1) / 2; i <= n; ++i)
    {
        ans += dp[n][i];
    }
    printf("%.16f", ans);
    return 0;
}

Measured memory_bytes: 78464
#include<stdio.h>
#include<vector>

int main(void){
	int i,j,n,m=0;
	scanf("%d",&n);
	std::vector<int> a(n+1,0);
	std::vector<int> b(n+1,0);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	for(i=n;i>0;i--){
		int sum=0;
		for(j=i+i;j<=n;j+=i){
			sum+=b[j];
		}
		if((a[i]-sum)%2){	
			b[i]++;
		}
	}
	for(i=1;i<=n;i++){
		if(b[i]==1) m++;
	}
	printf("%d\n",m);
	if(m!=0){
		for(i=1;i<=n;i++){
			if(b[i]==1) printf("%d ",i);
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long int,int> pli;
const int MAXN = 100005;
const long long int INF = 1000000000000000000ll;
int A[MAXN];
long long int dp[2][MAXN];
int main()
{
	int n,m,k;
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &A[i]);
	memset(dp[0], 0, sizeof dp);
	for (int i = 1; i <= k; ++i)
	{
		int curr = i%2;
		int prev = 1 - curr;
		deque <pli> dq;
		for (int j = 0; j <= n; ++j)
		{
			if(j < i)
				dp[curr][j] = -INF;
			else
				dp[curr][j] = dq[0].first + 1ll*i*A[j];
			while(!dq.empty() && dq.back() < pli(dp[prev][j],j))
				dq.pop_back();
			dq.push_back(pli(dp[prev][j],j));
			while(!dq.empty() && dq[0].second <= j-m)
				dq.pop_front();
		}
	}
	long long int ans = -INF;
	for (int i = 0; i <= n; ++i)
		ans = max(ans, dp[k%2][i]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main(){
 
    int a, b, c;
    cin >> a >> b >> c;

    int hako;

    hako = b;

    b = a;

    a = hako;

    a = c;

    c = hako;
    
    cout << a << " " << b << " " << c;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 5;

ll n, d;

int main() {	
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> n >> d;
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        ll x, y;
        cin >> x >> y;
        ans += (d * d >= x * x + y * y);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3624
a,b,k = map(int,input().split())
l = range(a,b+1)

if b-a+1 > 2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N, M;
	cin >> N >> M;
	pairs(X);
	fx(M) {
		pairsp(X);
	}

	fx(1000) {
		int a[3] = {0,-1,-1};
		int y = x;
		int z = 0;
		while(y>0) {
			a[z++] = y % 10;
			y /= 10;
		}
		bool flag = true;
		fz(M) {
			if (a[N- X[z].first]!= X[z].second) {
				flag = false;
			}
		}

		if (flag) {
			int count = 0;
			fz(3) {
				if (a[z]>=0) {
					count++;
				}
			}
			if (count == N) {
				ce(x)
					return 0;
			}
		}
	}
	ce(-1)
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int H,W;
    cin >> H >> W;
    char S[H][W];
    rep(i,H) cin >> S[i];
    int cnt=0;
    rep(i,H) rep(j,W) if(S[i][j]=='#') cnt++;
    if(cnt==H+W-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();

        double PI = 3.1415926535897932;
        //double PI = 3.14159265;
        double v = 2*R* PI ;

        System.out.println(v);

    }
}

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

int main() {
	int N,M;
	cin >> N >> M;
	
	int a[N], b[N], c[M], d[M];
	
	for(int i=0; i<N; i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0; i<M; i++){
		cin >> c[i] >> d[i];
	}
	
	for(int stu=0; stu<N; stu++){
		int kyori=300000000;
		int p;
		for(int i=0; i<M; i++){
			int x=a[stu]-c[i];
			int y=b[stu]-d[i];
			if(x<0){x*=-1;}
			if(y<0){y*=-1;}
			
			if(kyori>x+y){
				kyori=x+y;
				p=i+1;
			}
		}
		cout<<p<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;

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

    double out=v[0];
    for (int i = 1; i < n; i++) {
      out=(out+v[i])/2.;
    }

    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 300005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n;
char str[MAXN];
int dp[MAXN][8];
//0: nothing
//1: 0
//2: 1
//3: 10
//4: 100
//5: 01
//6: 11
//7: 00
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;}
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
int main()
{
    scanf("%s",str+1);
    n=strlen(str+1);
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<n;i++)
    {
        bool f1=true,f2=true;
        if(str[i+1]=='0') f2=false;
        if(str[i+1]=='1') f1=false;
        if(f1)
        {
            add(dp[i+1][1],dp[i][0]);
            add(dp[i+1][7],dp[i][1]);
            add(dp[i+1][3],dp[i][2]);
            add(dp[i+1][4],dp[i][3]);
            add(dp[i+1][3],dp[i][4]);
            add(dp[i+1][1],dp[i][5]);
            add(dp[i+1][6],dp[i][6]);
            add(dp[i+1][1],dp[i][7]);
        }
        if(f2)
        {
            add(dp[i+1][2],dp[i][0]);
            add(dp[i+1][5],dp[i][1]);
            add(dp[i+1][6],dp[i][2]);
            add(dp[i+1][2],dp[i][3]);
            add(dp[i+1][3],dp[i][4]);
            add(dp[i+1][2],dp[i][5]);
            add(dp[i+1][6],dp[i][6]);
            add(dp[i+1][1],dp[i][7]);
        }
    }
    int ans=dp[n][2];
    add(ans,dp[n][6]);
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 9856
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int total = 0;
    for(int i = 1; i <= n; i++){
      int sum = 0;
        sum += i / 10000;
        sum += (i % 10000) / 1000;
        sum += ((i % 10000) % 1000) / 100;
        sum += (((i % 10000) % 1000) % 100) / 10;
        sum += (((i % 10000) % 1000) % 100) % 10;
  
      if(sum >= a && sum <= b){
        total += i;
      }
    }
    System.out.println(total);
  }
}
      
   


Measured memory_bytes: 23636
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		for (int i = 0; i <= N; ++i) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; ++i) {
			B[i] = sc.nextInt();
		}
		
		long result = 0L;
		for (int i = 0; i < N; ++i) {
			int temp = Math.min(A[i], B[i]);
			A[i] -= temp;
			B[i] -= temp;
			result += temp;
			if (B[i] > 0) {
				int temp2 = Math.min(A[i+1], B[i]);
				A[i+1] -= temp2;
				result += temp2;
			}
		}
		
		System.out.println(result);
		
	}
	
	
	
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

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

const int MAX_W = 22;
const int MAX_H = 22;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int H, W;
int maze[MAX_H+1][MAX_W+1];

inline bool check(int hx, int hy){ return 0 <= hx && hx < H && 0 <= hy && hy < W; }

void dfs(int hx, int hy, int cnt, int& res)
{
  rep(k, 4){
    int nx = hx + dx[k];
    int ny = hy + dy[k];
    if(check(nx, ny) && maze[nx][ny] == 1) continue;
    while(check(nx, ny) && maze[nx][ny] == 0) nx += dx[k],  ny += dy[k];
    if(!check(nx, ny)) continue;
    if(maze[nx][ny] == 3){
      if(res > cnt) res = cnt;
      return;
    }
    if(cnt >= 10) continue;
    maze[nx][ny] = 0;
    dfs(nx - dx[k], ny - dy[k], cnt + 1, res);
    maze[nx][ny] = 1;
  }
}

int main()
{
  while(cin >> W >> H, W){
    rep(i, H) rep(j, W) cin >> maze[i][j];

    int res = 1E9;
    rep(i, H) rep(j, W) if(maze[i][j] == 2){
      maze[i][j] = 0;
      dfs(i, j, 1, res);
    }

    cout << (res >= 1E9 ? -1 : res) << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int N;
int P[200001];
int Q[200001];
int cnt, M;

int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> P[i];
    Q[P[i]] = i;
  }
  cnt = 1;
  M = 1;
  for (int i = 1; i <= N - 1; i++) {
    if (Q[i] < Q[i + 1]) {
      cnt++;
      if (cnt > M) M = cnt;
    } else {
      cnt = 1;
    }
  }
  cout << N - M << endl;
  return 0;
}


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

using namespace std;

#define PB push_back
#define SZ(a) (int)a.size()
#define MP make_pair

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

int main() {

	int N,M;
	scanf("%d%d", &N, &M);

	if(N < M) swap(N,M);

	for(int i = 0; i < N; i++) printf("%d", M);

	printf("\n");

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-6
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<int, int> pr;
typedef pair<int, pair<int, int>> tup;

inline void sol()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c)
	{
		cout << "Yes";
		return;
	}
	else if (a == c && a != b)
	{
		cout << "Yes";
		return;
	}
	else if (b == c && b != a)
	{
		cout << "Yes";
		return;
	}

	cout << "No";
}

inline void solve()
{
	int q = 1;
	//cin >> q;
	while (q--)
	{
		sol();
		cout << '\n';
	}
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 256
from itertools import product

INF = 1000000007

def mat2_mul(X, Y):
	z = [[0, 0], [0, 0]]
	for (i, j, k) in product(range(2), range(2), range(2)):
		z[i][j] += X[i][k] * Y[k][j]
	return z

def mat2_pow(X, n):
	if n == 0:
		return [[1, 0], [0, 1]]
	elif n % 2:
		return mat2_mul(X, mat2_pow(X, n - 1))
	else:
		half_pow = mat2_pow(X, n / 2)
		return mat2_mul(half_pow, half_pow)

def fib(n):
	if n == 0:
		return 0
	else:
		f = [[0, 1], [1, 1]]
	return mat2_pow(f, n - 1)[1][1]


N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
ans, start = 1, 0

for k in a:
	ans *= fib(k - start)
	ans %= INF
	start = k + 1

ans *= fib(N - start + 1)
print(ans % INF)


Measured memory_bytes: 7096
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Tree tree;

int main(void){
	ll n, m;
	cin >> n >> m;
	tree.resize(n);
	Vec d(n);
	rep(i, n) cin >> d[i];
	VecP e(n);
	rep(i, n){
		e[i].fs = d[i];
		e[i].sc = i;
	}
	sort(all(e));

	rep(i, m){
		ll u, v;
		cin >> u >> v;
		u--; v--;
		tree[u].pb({v, i});
		tree[v].pb({u, i});
	}

	Vec color(n, 2);
	Vec cost(m);
	rep(i, n){
		P p = e[i];
		if(color[p.sc] != 2) continue;
		for(P j : tree[p.sc]){
			if(color[j.fs] != 2){
				color[p.sc] = !color[j.fs];
				cost[j.sc] = p.fs;
				break;
			}
		}

		if(color[p.sc] == 2){
			for(P j : tree[p.sc]){
				if(p.fs == d[j.fs]){
					color[p.sc] = 0;
					color[j.fs] = 1;
					cost[j.sc] = p.fs;
					break;
				}
			}
		}

		if(color[p.sc] == 2){
			co(-1);
			return 0;
		}
	}

	rep(i, m) if(!cost[i]) cost[i] = 1e9;
	rep(i, n){
		if(!color[i]) cout << "B";
		else cout << "W";
	}
	cout << endl;
	rep(i, m) co(cost[i]);

	return 0;
}


Measured memory_bytes: 19072
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n) {
	return 0;
}


//最小公倍数を返す関数
int mcd(int n) {
	return 0;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));
}


int main()
{
	int n;
	cin >> n;
	vi h(n);
	for (int i = 0;i < n;i++) {
		cin >> h[i];
		if (i == 0)h[i]--;
	}

	if (n == 1) {
		cout << "Yes" << endl;
		return 0;
	}

	for (int i = 1;i < n;i++) {
		if (h[i] - h[i-1] >= 1 ) h[i] -= 1;
	}

	for (int i = 1;i < n;i++) {
		if (h[i] - h[i-1] < 0) {
			cout << "No" << endl;
			return 0;
		}
	}


	cout << "Yes" << endl;


	system("pause");
	return 0;
}

Measured memory_bytes: 1008
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstdlib>
#include<string>
#include<unordered_map>
#include<vector>
#include<list>
#include<map>
#include<set>
#define fi first
#define se second
#define pb push_back
#define me(a,b) memset(a,b,sizeof(a))
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int MAX_N=200000+5;
const int MAX_M=100000+5;
const int INF=0x7fffffff;
const int inf=1000000000;
const double EPS=1e-6;
const ull base=123;
const ll mod=1e9+7;
const double pi=4*atan(1.0);
int main()
{
    int n;
    cin>>n;
    int k=7;
    int x=k%n;
    int ans=1;
    while(x)
    {
        if(ans>1000000)
            break;
        x=x*10+7;
        x%=n;
        ans++;
    }
    if(!x)
    {
        cout<<ans<<endl;
    }
    else
        cout<<-1<<endl;
}


Measured memory_bytes: 3636
N,K = map(int, input().split())
X = []
idx = 0
for i,x in enumerate(input().split()):
    x = int(x)
    X.append(x)
    if x < 0:
        idx = i + 1
if idx == N:
    idx = N-1
ans = 10**9
for i in range(max(0,idx-K), min(N-K+1,idx+K)):
    ans = min(ans, X[i+K-1] - X[i] + min(abs(X[i]), abs(X[i+K-1])))
print(ans)

Measured memory_bytes: 14480
#editorial https://ami-atcoder.hatenablog.com/entry/20191018/1571386871
n=int(input())
pre=int(input())
if pre!=0:print(-1);exit()
ans=0
for i in range(n-1):
    x=int(input())
    if x==pre+1:ans+=1
    elif pre<x:print(-1);exit()
    else:ans+=x
    pre=x
print(ans)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

map <string,int> mp;
int n,m;
int main() {
	cin >> n;
	for (int i =0;i<n;i++) {
		string xd; cin >> xd;
		mp[xd]++;
	}
	cin >> m;
	for (int j=0;j<m;j++) {
		string xd; cin >> xd;
		mp[xd]--;
	}
	
	int ans = 0;
	for (auto it : mp) {
		ans = max(ans,it.s);
	}
	cout << ans;
	
}


Measured memory_bytes: 256
/*
 * Created by SharpDevelop.
 * User: yog-sothoth
 * Date: 2017/03/20
 * Time: 13:33
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace DefaultNamespace
{
	/// <summary>
	/// Description of Class1.
	/// </summary>
	public class LinerSearch
	{
		/*
		 *  n????????´??°???????????°???  S??¨???q ????????°????????´??°???????????°???  T??????????????????T ?????????????????´??°????????§ 
		 *  S?????????????????????????????° C  ???????????????????????°????????????????????????????????????
		 * ??\???  :???????????? n???????????????S  ?????¨??? n ????????´??°??????????????? q??????????????? T ?????¨??? q ????????´??°????????????????????????
		 * ?????? C???????????????????????????????????????
		 */
		
		public static void Main(String[] args)
		{
			//????????????
			int n=int.Parse(Console.ReadLine());
			string s=Console.ReadLine();
			string[] sTarget=new string[n+1];//????????¨???????´???°??????????¶???????
			Array.Copy( s.Split(),sTarget,n);
			sTarget[n]="-1";//?????????????´?
			
			int q=int.Parse(Console.ReadLine());
			string t=Console.ReadLine();
			string[] tSearch=t.Split();
			
			
			var search=new Searcher(n,sTarget,q,tSearch);
			Console.WriteLine(search.counter);
		}
		
	}
	public class Searcher
	{
		//??????????????£???????????????
		public int counter{get; private set;}
		int num;//??????????´???°
		int qnum;//??????????´???°
		string[] target;
		string[] searchThis;
		public Searcher(int n,string[] s,int q,string[]t)
		{
			counter =0;
			num=n;
			target=s;
			qnum=q;
			searchThis=t;
			search();
		}
		public void search()
		{//??????????????????
		 for(int j=0;j<qnum;j++)
		 {
			int i=0;//????????????????????????
			string key =searchThis[j];
			target[num]=key;//??????
			while(target[i]!=key)
			{ 
				
				
				i++;
			}
			if (i!=num)//target????????????????´??????????????????????????????????????´???§???????????°
			{
				counter++;
			}
	     }
		}
		
		
		
	}
	
}

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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define let const auto
#define USE1(T) template <typename T>
#define USE2(T, U) template <typename T, typename U>
#define I_ inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

USE1(T) using duo = std::pair<T, T>;
USE1(T) using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE2(T,U) I_ bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U) I_ bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int) I_ T in(){T x;std::cin>>x;return x;}
USE1(T=int) I_ vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T) I_ void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts) I_ void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
I_ int re(){int x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
I_ void wr(int x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int N = in();
  vec<duo<int>> A;
  A.reserve(N);
  rep(i, N) { A.emplace_back(in(), i); }

  int ans = 0;
  sort(ALL(A));
  rep(i, N) if (i % 2 != A[i].snd % 2) ans++;
  pr(ans / 2);

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a,&b);
#define loop(i,j) for(int i=0;i<j;i++)
typedef long long ll;
using namespace std;

int main()
{
  int N,K;
  scan2(N,K);
  int v[N];
  loop(i,N) scan1(v[i]);
  sort(v,v+N);
  int mi=INT_MAX;
  loop(i,N-K+1){
    if(mi>v[i+K-1]-v[i]) mi=v[i+K-1]-v[i];
  }
  printf("%d\n",mi);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a,k) distance((v).begin(),(k)+upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a,k) distance((v).begin(),(k)+lower_bound((v).begin(),(v).end(),(a)))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
struct Edge{
  int from;
  int to;
  ll cost;
  Edge(int from,int to,ll cost){
    this->from = from; 
    this->to   = to; 
    this->cost = cost; 
  }
};
void Main(){
  ll N;
  cin>>N;
  vl ans;
  double w;
  srep(i,1,3501){
    ll h = i;
    srep(j,1,3501){
      ll n = j;
      w = (double)(N*h*n)/(double)(4*h*n-N*n-N*h);
      if(w>0.0){
        if(fabs(w-floor(w))<eps ){
          ans = vl{h,n,(int)(floor(w))};
          cout<<ans<<endl;
          return;
        } else if (fabs(w-ceil(w))<eps){
          ans = vl{h,n,(int)(ceil(w))};
          cout<<ans<<endl;
          return;
        }
      }
    }
  }

} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 384
from collections import deque

ans = deque(input())
Q = int(input())
state = True
for _ in range(Q):
    Query = input().split()
    if int(Query[0]) == 1:
        state = not state
    else:
        if int(Query[1]) == 1:
            if state:
                ans.appendleft(Query[2])
            else:
                ans.append(Query[2])
        if int(Query[1]) == 2:
            if state:
                ans.append(Query[2])
            else:
                ans.appendleft(Query[2])

if state:
    print("".join(map(str, ans)))
else:
    print("".join(map(str, reversed(ans))))

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

int main() {
    char ch, b[4];
    int a[4], s1= 0,s2 = 0, i, j, k, m;
    for (i = 0; i < 4; i++) {
        cin >> ch;
        a[i] = ch - '0';
        s1 += a[i];
    }
    if (s1 == 7) {
        cout << a[0];
        for(i = 1; i < 4; i++){
            cout << '+' << a[i];
        }
        cout << "=7" << endl;
    }
    else {
		s2 = a[0];
        for(i = 1; i < 4; i++){
            s2 -= a[i];
        }
        if (s2 == 7) {
            cout << a[0];
            for(i = 1; i < 4; i++){
               cout << '-' << a[i];
            }
          cout << "=7" << endl;
        }
		else {
			for (k = 0; k < 2; k++) {
				for (i = 1; i < 4; i++) {
					for (j = 1; j < 4; j++) {
						if (j == i) k == 0 ? b[j] = '+' : b[j] = '-';
						else k == 0 ? b[j] = '-' : b[j] = '+';
					}
					m = k == 0 ? s2 + 2 * a[i]: s1 - 2 * a[i];
					if (m == 7) { 
					    cout << a[0];
                        for(i = 1; i < 4; i++){
                           cout << b[i] << a[i];
                        }
                        cout << "=7" << endl;
                        exit(0); 
					}
				}
			}
		}   
    }
}

Measured memory_bytes: 256
#include <iostream>
 
int main(){
    int n,x;
     
    while(std::cin >> n >> x){
        if(!n&&!x) break;
         
        int cnt = 0;
        for(int i = 1 ; i <= n ; i++){
            for(int j = i+1 ; j <= n ; j++){
                for(int k = j+1 ; k <= n ; k++){
                    if(i+j+k == x) cnt++;
                }
            }
        }
        std::cout << cnt << std::endl;
    }
 
    return 0;
}


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

long find_false(const vector<bool>& v){
    for(size_t j=0; j<v.size(); j++){
        if(!v[j]){
            return j;
        }
    }
    return -1;
}


int main(void){
    long n;
    cin >> n;
    vector<long> a(n);
    vector<bool> used(10000);
    for(long i=0; i<n; i++){
        cin >> a[i];
    }
    for(long i=0; i<n; i++){
        used[a[i]]=true;
    }
    long count=0;
    for(long i=0; i<n-1; i++){
        if(a[i]==a[i+1]){
            long j=find_false(used);
            a[i+1]=j;
            a[j]=true;
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0 ;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(x) x.begin(),x.end()
#define REVERSE(x) reverse(x.begin(),x.end())
#define SORT(x,n) sort(x,x)
#define P pair<int,int>
typedef long long LL;
const int INF=1000000007;
using namespace std;
int gcd(int a,int b){
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}

int main(){
    LL L,R;
    cin>>L>>R;
    if(R-L>2019){
        cout<<0;
    }
    else{
    LL ans=INF;
    for(LL i=L;i<R;i++){
        for(LL j=i+1;j<=R;j++){
            ans=min(ans,(i*j)%2019);
        }
    }
    cout<<ans;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <vector>;
#include <numeric>
using namespace std;

int main() {
		
	int n, x, t;
	cin >> n >> x >> t;

	int k = n / x;
	if (n % x!= 0)k++;

	cout << k * t << endl;

	return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<unordered_map>
#include<map>
#include<climits>
using namespace std;
using ll = long long;
int main() {
	int a;
	cin >> a;
	cout << 2 * acos(-1) * a;
  	return 0;
}

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

int main() {

    double x,y,b,p,n;

    cin>>n;

    for(int i=0;i<n;i++){

        cin>>x>>y>>b>>p;

        if(b < 5 && p >= 2){
            cout<<min((x*5+y*p)*0.8, x*b+y*p)<<endl;
        }
        else if(b >= 5 && p < 2){
            cout<<min((x*b+y*2)*0.8, x*b+y*p)<<endl;
        }
        else if(b >= 5 && p >= 2){
            cout<<(x*b+y*p)*0.8<<endl;
        }
        else {
            cout<<min((x*5+y*2)*0.8, x*b+y*p)<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3272
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    string s;
    int w;
    cin >> s;
    cin >> w;
    
    for(int i = 0; i<s.size(); i+=w){
        cout << s[i];
    }
    cout << endl;
}   



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <set>

using namespace std;

#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
multiset<string> s; int X, Y, Z; string L, T = "\0";
int main()
{
	X = read(), Y = read(), Z = read();
	for(rint i = 1; i <= X; s.insert("a"), i++);
	for(rint i = 1; i <= Y; s.insert("b"), i++);
	for(rint i = 1; i <= Z; s.insert("c"), i++);
	for(; s.size() >= 2; L = *s.begin()+*--s.end(), s.erase(s.begin()), s.erase(--s.end()), s.insert(L));
	if(s.size()) T = *s.begin(); cout << T << endl; return 0;
}

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

int main(){

    ll N, M, K;
    cin >> N >> M >> K;

    vector<ll> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];

    vector<ll> b(M); 
    for (int i = 0; i < M; i++) cin >> b[i];
    

    vector<ll> v1(N);
    v1[0] = a[0];
    for(int i = 1; i < N; i++){
        v1[i] = v1[i - 1];
        v1[i] += a[i];
    } 
    
    vector<ll> v2(M);
    v2[0] = b[0];
    for(int i = 1; i < M; i++){
        v2[i] = v2[i - 1];
        v2[i] += b[i];
    } 

    ll ans = 0;
    for(int i = 0; i <= N; i++){
        ll book1 = i;
        ll time = K;
        if(i > 0) time -= v1[i - 1];

        if(DEBUG) cout << "time:" << time << endl;
        if(time < 0) continue;

        ll book2 = 0;
        if(v2.back() <= time) book2 = M;
        else if(v2.front() > time ) book2 = 0;
        else{
            auto it = lower_bound(all(v2), time);
            book2 = it - v2.begin();
        }
        if(DEBUG)cout << book1 << book2 << endl;

        ans = max(ans, book1 + book2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
const int N = 100;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back

pii ar[N + 5], br[N + 5];
bool udah[N + 5];
int main(){
  int n;
  scanf("%d", &n);
  for(int i = 0;i < n; ++i) scanf("%d%d", &ar[i].fi, &ar[i].se);
  for(int i = 0;i < n; ++i) scanf("%d%d", &br[i].fi, &br[i].se);
  sort(ar, ar + n);
  sort(br, br + n);
  int tot = 0;
  for(int i = 0;i < n; ++i){
    int maksidx = -1;
    for(int j = 0;j < n && ar[j].fi < br[i].fi; ++j){
      if(udah[j]) continue;
      if(ar[j].se >= br[i].se) continue;
      if(maksidx == -1 || (ar[maksidx].se <= ar[j].se)) maksidx = j;
    }
    if(maksidx > -1) udah[maksidx] = 1, tot++;
  } 
  printf("%d\n", tot);
  return 0;
}

Measured memory_bytes: 256