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

using namespace std;

const int INF = 1e9;

int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<tuple<long, long>> v;
  for (int i=0; i<n; i++) {
    long a, b;
    cin >> a >> b;
    v.push_back(make_tuple(a, b));
  }
  sort(v.begin(), v.end());
  int n_drink = 0;
  long long money = 0;
  for (vector<tuple<long, long>>::iterator it=v.begin(); it!=v.end(); ++it) {
    long long a = get<0>(*it);
    long long b = get<1>(*it);
    if (n_drink + b >= m) {
      money += a * (m - n_drink);
      break;
    }
    money += a * b;
    n_drink += b;
  }
  cout << money;
}

Measured memory_bytes: 2420
#include <stdio.h>

int main() {
    int N;
    scanf("%d",&N);
    int H[N];
    int ans = 0,count = 0;
    for (int i = 0; i<N; i++) {
        scanf("%d",&H[i]);
    }
    
    for (int i = 0; i<N-1; i++) {
        if (H[i] >= H[i+1]) {
            count++;
            if (ans < count) {
                ans = count;
            }
        }else{
            if (ans < count) {
                ans = count;
            }
            count = 0;
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;
const int INF=0x3f3f3f3f;
int n,m,head[1001],cur[1001],dis[1001],s,t,tot;
char d[205][205];
queue <int> q;
struct data {
    int next,num,w;
}edge[100001];
void add(int u,int v,int w) {
    edge[++tot].next=head[u];
    edge[tot].num=v;
    edge[tot].w=w;
    head[u]=tot;
}
bool BFS() {
    q.push(s);
    memset(dis,0x3f,sizeof(dis));
    dis[s]=0;
    while (!q.empty()) {
        int k=q.front();
        q.pop();
        for (int i=head[k];i!=-1;i=edge[i].next) {
            if (edge[i].w==0) continue;
            int kx=edge[i].num;
            if (dis[k]+1<dis[kx]) {
                dis[kx]=dis[k]+1;
                q.push(kx);
            }
        }
    }
    if (dis[t]==INF) return 0;
    return 1;
}
int DFS(int x,int a) {
    if (x==t) return a;
    if (a==0) return 0;
    int flow=0;
    for (int &i=cur[x];i!=-1;i=edge[i].next) {
        int kx=edge[i].num;
        if (dis[kx]!=dis[x]+1) continue;
        int now=DFS(kx,min(a,edge[i].w));
        flow+=now;
        edge[i].w-=now;
        edge[i^1].w+=now;
        a-=now;
        if (a==0) return flow;
    }
    return flow;
}
int dinic() {
    int flow=0;
    while (BFS()) {
        for (int i=1;i<=n+m+2;i++) cur[i]=head[i];
        flow+=DFS(s,INF);
    }
    return flow;
}
int main() {
    memset(head,-1,sizeof(head));
    tot=-1;
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) scanf("%s",d[i]+1);
    s=n+m+1;
    t=n+m+2;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++) {
            if (d[i][j]=='S') {
                add(s,i,INF);
                add(i,s,0);
                add(s,n+j,INF);
                add(n+j,s,0);
            }
            if (d[i][j]=='T') {
                add(i,t,INF);
                add(t,i,0);
                add(n+j,t,INF);
                add(t,n+j,0);
            }
            if (d[i][j]=='o') {
                add(i,n+j,1);
                add(n+j,i,1);
            }
        }
    int ans=dinic();
    if (ans>1e9) printf("-1\n");
    else printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
ans = 0
cnt = 1
for i in range(n):
    if a[i] == cnt:
        cnt += 1
    else:
        ans += 1
if ans == n:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 20384
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Program{
    public static void Main(){
        TextReader reader;
        string filename = "";
        if(filename.Count()==0) reader = Console.In;
        else reader = new StreamReader(filename);
        /*
        0-1???????????¶????????????
        ???????????§?????????
        */
        var input = reader.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var M = input[1];
        var Products_Weights = new int[N];
        var Products_Values = new int[N];
        var dp = new int[N+1, M+1];
        // dp[i, j]: i???????????§??????????????\???????????????j???????????¨???????????§?????????
        for(int i=0; i<N+1; i++) dp[i, 0] = 0;
        for(int j=0; j<M+1; j++) dp[0, j] = 0;
        //???????????????????????????
        for(int i=0; i<N; i++){
            var info = reader.ReadLine().Split().Select(int.Parse).ToArray();
            Products_Values[i] = info[0];
            Products_Weights[i] = info[1];
        }

        //?????????????????????dp??????????????????????????????
        /*
        dp[i, j] = i????????????????????\?????????, i????????????????????\??????
        ??? dp[i-1, j], dp[i-1, j-Weights[i]]+Values[i]
        */
        for(int i=1; i<dp.GetLength(0); i++){
            for(int j=0; j<dp.GetLength(1); j++){
                //?????§??????M????¶?????????????????????????
                //????????§???j???????????§??????j?????§??\?????????????????§i???????????????????????????j????????§????????¨??????????????\???????????¨?????§?????????
                if(j>=Products_Weights[i-1]){
                    dp[i, j] = Math.Max(dp[i-1, j], dp[i-1, j-Products_Weights[i-1]]+Products_Values[i-1]);
                }else{
                    dp[i, j] = dp[i-1, j];
                }
            }
        }
        Console.WriteLine(dp[N, M]);
    }
}

Measured memory_bytes: 13560
n=int(input())
a=list(map(int,input().split()))

#n=3
#a=[2,2,4]

b=[0]*n
x=[0]*n
bsum=0
for i in range(0,n-1,2):
    bsum+=a[i]-a[i+1]
b[0]=bsum
x[0]=b[0]+a[n-1]
for i in range(1,n):
    b[i]=a[i-1]-b[i-1]-a[(n+i-2)%n]
    x[i]=b[i]+a[(i+n-1)%n]
    
strx=" ".join(str(xi) for xi in x)
print(strx)

Measured memory_bytes: 28748
import itertools
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n=int(input())

a=["M","A","R","C","H"]
cnt=[0]*5
for i in range(n):
    s=input()
    for i in range(5):
        if s[0]==a[i]:
            cnt[i]+=1
ans=0
for i in itertools.combinations(range(5),3):
    ans+=cnt[i[0]]*cnt[i[1]]*cnt[i[2]]
print(ans)

Measured memory_bytes: 3064
object Main extends App {
  import scala.io.StdIn.readLine

  val in = readLine().split(" ").map(_.toInt)
  val a = in(0)
  val b = in(1)

  if (a % 2 == 0 || b % 2 == 0) {
    print("No")
  } else {
    print("Yes")
  }
}

Measured memory_bytes: 25280
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main(){
    int n;
    scanf("%d", &n);
    vector<int> p(n);
    vector<int> q(n);
    vector<int> array(n);
    rep(i, n) scanf("%d", &p[i]);
    rep(i, n) scanf("%d", &q[i]);
    rep(i, n) array[i] = i+1;
    
    int judge1, judge2;
    int index = 0;
    do{
        if (p == array) judge1 = index;
        if (q == array) judge2 = index;
        index++;
    } while(next_permutation(all(array)));
    
    int ans = abs(judge1-judge2);
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;  
 
#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
 
const int MAXN=15;
 
int n,m;
int e[MAXN][MAXN];
 
int sum[1<<MAXN];
int mem[1<<MAXN][MAXN];
 
int go(int left,int at) {
	if(at==n-1) return sum[left|(1<<at)];
	int &ret=mem[left][at];
	if(ret==-1) {
		ret=INT_MIN;
		REP(to,n) if(left&(1<<to)) if(e[at][to]!=-1) {
			int mask=(1<<n)-1-(left-(1<<to));
			for(int g=0;g<(1<<n);g=(g+mask+1)&~mask) {
				assert(((left-(1<<to))&g)==g); assert((g&(1<<to))==0); assert((g&(1<<at))==0); assert(at!=to);
				int cur=go(left-(1<<to)-g,to);
				if(cur==INT_MIN) continue;
				cur+=sum[(1<<at)+g];
				cur+=e[at][to];
				//printf("%x %d: %d->%d g=%x keep=%d (%d,%d)\n",left,at,at+1,to+1,g,cur,sum[(1<<at)+g],e[at][to]);
				if(cur>ret) {
					ret=cur;
				}
			}
		}
		//printf("%x %d: keep=%d\n",left,at,ret);
	}
	return ret;
}
 
void run() {
	scanf("%d%d",&n,&m);
	REP(i,n) REP(j,n) e[i][j]=-1;
	REP(i,m) { int a,b,c; scanf("%d%d%d",&a,&b,&c); --a,--b; e[a][b]=e[b][a]=c; }
 
	REP(i,1<<n) {
		sum[i]=0;
		REP(j,n) FOR(k,j+1,n) if((i&(1<<j))&&(i&(1<<k))&&(e[j][k]!=-1)) sum[i]+=e[j][k];
	}
	memset(mem,-1,sizeof(mem));
	int keep=go((1<<n)-1-(1<<0),0);
	int tot=0; REP(i,n) FOR(j,i+1,n) if(e[i][j]!=-1) tot+=e[i][j];
	//printf("tot=%d\n",tot);
	int ret=tot-keep; printf("%d\n",ret);
}
 
int main() {
	run();
	return 0;
}


Measured memory_bytes: 2304
#include<cstdio>
#include<iostream>
using namespace std;
int main() {
    string s, t;
    cin >> s;
    for(int i = 0; i < s.length(); ++i) {
        if(s[i] == '0') t += '0';
        else if(s[i] == '1') t += '1';
        else if(s[i] == 'B') {
            if(t.length()) t.erase(t.end()-1);
        }
    }
    cout << t << '\n';
return 0;
}

Measured memory_bytes: 3564
#include <iostream>

using namespace std;

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

  int num4 = 0;
  int num2 = 0;
  int num0 = 0;
  
  for (int i = 0; i < n; i++)
  {
	int v;
	cin >> v;
	if (v % 4 == 0) num4++;
	else if (v % 2 == 0) num2++;
	else num0++;
  }

  if (num4 >= num0 || (num2 == 0 && num4 + 1 >= num0))
  {
	cout << "Yes" << endl;
  }
  else
  {
	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

 // void dfs(ll node){
 // 	vis[node]=1;
 // 	res.pb(node);
 //    vector<ll> ans;


 // 	for(auto i:v[node]){
 // 		if(!vis[i]){
 // 			ans.pb(i);

 // 		}
 // 	}
 // 	sort(ans.begin(),ans.end());

 // 	for(auto i:ans){
 // 		if(!vis[i])
 // 			dfs(i);
 // 	}




 // }

void solve(){

ll a,b,c,d;
cin>>a>>b>>c>>d;
ll ans=LONG_LONG_MIN;
ans=max(ans,a*c);
ans=max(ans,a*d);
ans=max(ans,b*d);
ans=max(ans,b*c);
cout<<ans<<endl;



return;
}



int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    

    ll t;
    t=1;
    // cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3688
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def cross3(a, b, c):
    return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])

EPS = -1e-9
def convex_hull(ps):
    qs = []
    n = len(ps)
    for p in ps:
        while len(qs)>1 and cross3(qs[-1], qs[-2], p) > -EPS:
            qs.pop()
        qs.append(p)
    t = len(qs)
    for i in range(n-2, -1, -1):
        p = ps[i]
        while len(qs)>t and cross3(qs[-1], qs[-2], p) > -EPS:
            qs.pop()
        qs.append(p)
    return qs

def solve():
    N = int(readline())
    if N == 0:
        return False
    P = [list(map(float, readline().split(","))) for i in range(N)]
    P.sort()
    Q = convex_hull(P)
    write("%d\n" % (N - len(Q) + 1))
    return True
while solve():
    ...


Measured memory_bytes: 5628
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int K,T;
int A[110];

signed main(){
	cin>>K>>T;
	REP(i,T){
		cin>>A[i];
	}
	int last=-1;
	int cnt=0;
	REP(i,K){
		bool flag=false;
		int M=0;
		int pos=-1;
		REP(j,T){
			if(last!=j&&A[j]>M){
				flag=true;
				pos=j;
				M=A[j];
			}
		}
		if(flag==false){
			break;
		}
		REP(j,T){
			if(pos==j){
				A[j]--;
			}
		}
		DEB(last)END
		last=pos;
		cnt++;
	}
	DEB(cnt)END
	cout<<max(K-cnt,0)<<endl;
	return 0;
}
/*
4 1
2 1 2 3 2 2
*/

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

int main(){
  string s;cin>>s;
  // string t=reverse(s.begin(),s.end());
  int n=s.length();
  int cnt=0;
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1])cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
using namespace  std;
priority_queue<long long int> p;
int main() {

    int n, x;
    cin >> n >> x;
   long long int sum = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        p.push(x);
    }
    int reham=x;
while(reham>0){
int s=p.top();
p.pop();
s=s/2;
p.push(s);
reham--;

}
for(int i=0;i<n;i++){
    sum+=p.top();
    p.pop();

}

cout<<sum;





}





Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  struct XYH { lint x, y, h; };
  vector<XYH> xyh(n);
  rep (i, n) cin >> xyh[i].x >> xyh[i].y >> xyh[i].h;
  sort(all(xyh), [](XYH &a, XYH &b) { return a.h > b.h; });
  rep (CX, 101) {
    rep (CY, 101) {
      lint H  = xyh[0].h != 0 ? xyh[0].h + abs(xyh[0].x - CX) + abs(xyh[0].y - CY) : 1;
      bool ok = true;
      rep (i, 1, n) {
        lint Htmp = xyh[i].h + abs(xyh[i].x - CX) + abs(xyh[i].y - CY);
        if (xyh[i].h != 0) {
          if (H != Htmp) {
            ok = false;
            break;
          }
        } else {
          if (H > Htmp) {
            ok = false;
            break;
          }
        }
      }
      if (ok) {
        cout << CX << " " << CY << " " << H << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
using namespace std;

int main(){

    int n;
    cin>>n;

    int d[n];
    for(int i=0;i<n;i++){
        cin>>d[i];
    }

    int sum=0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            sum+=d[i]*d[j];
        }
    }

    int dif=0;
    for(int i=0;i<n;i++){
        dif+=d[i]*d[i];   
         }

    cout<<(sum-dif)/2<<endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int A, B; cin >> A >> B;
  
  cout << (B+A-3)/(A-1) << endl;
  
  return 0;
}


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


int a[100][100];
bool shortest[100][100],tallest[100][100];

int main(){
	int n;
	while(cin>>n&&n){
		int ans=0;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)cin>>a[i][j];
		memset(shortest,false,sizeof(shortest));
		memset(tallest,false,sizeof(tallest));
		for(int i=0;i<n;i++){
			int minv=1<<30;
			for(int j=0;j<n;j++)minv=min(minv,a[i][j]);
			for(int j=0;j<n;j++)if(a[i][j]==minv)shortest[i][j]=true;
		}
		for(int j=0;j<n;j++){
			int maxv=-1;
			for(int i=0;i<n;i++)maxv=max(maxv,a[i][j]);
			for(int i=0;i<n;i++)if(a[i][j]==maxv)tallest[i][j]=true;
		}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if(shortest[i][j]&&tallest[i][j])ans=a[i][j];
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(){

    int A,V,B,W,T;
    cin >> A >> V >> B >> W >> T;

    double v_sabunn;
    v_sabunn = V-W;
    double sabun;
    sabun = abs(A-B);
    double kyori;
    kyori = v_sabunn*T;

    if (v_sabunn <= 0  ){

        cout << "NO" << endl;

    }
    if (v_sabunn > 0){

        if (sabun <=  kyori){
            cout << "YES" << endl;
        }

        if (sabun >  kyori){
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  vector<vll> ball(n, vll(2));
  for (ll i = 0; i < n; i++) cin >> ball[i][0] >> ball[i][1];

  vector<vll> dxdy(0);
  for (ll i = 0; i < n - 1; i++) {
    for (ll j = i + 1; j < n; j++) {
      vll v = {ball[j][0] - ball[i][0], ball[j][1] - ball[i][1]};
      vll w = {- ball[j][0] + ball[i][0], - ball[j][1] + ball[i][1]};
      dxdy.push_back(v);
      dxdy.push_back(w);
    }
  }
  sort(all(dxdy));

  ll subans = 0, m = dxdy.size();
  for (ll i = 0; i < m; i++) {
    ll cnt = 0;
    vll v = dxdy[i];
    while (i < m && dxdy[i] == v) {
      cnt++;
      i++;
    }
    i--;
    subans = max(subans, cnt);
  }

  cout << n - subans << endl;
}

Measured memory_bytes: 384
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(100);
}
#define int ll
int dp[(1 << 19)][51];
void solve(){
	REP(i, (1 << 19)) {
		REP(q, 51) {
			dp[i][q] = 1e9;
		}
	}
	dp[0][0] = 0;
	int n;
	cin >> n;
	//右に奇数個でBになってる
	vector<pair<int, int>> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(mp(a, 1));
	}
	REP(i, n) {
		cin >> inputs[i].second;
	}
	REP(i, (1 << n)-1) {
		int is_B[20] = {};
		int taken[20] = {};
		REP(q, n) {
			if (((1 << q) & i)) {
				//bit is on
				is_B[q]++;
				taken[q] = 1;
			}
		}
		for (int q = n - 2; q >= 0; --q) {
			is_B[q] += is_B[q + 1];
			is_B[q] %= 2;
		}
		int dist = 0;
		for (int j = 0; j < n; ++j) {
			if (taken[j] == false) {
				int next_go = i + (1 << j);
				int cost = dist;
				int next_value = (is_B[j] + dist) % 2;
				if (next_value == 0) {
					next_value = inputs[j].first;
				}
				else {
					next_value = inputs[j].second;
				}
				REP(q, next_value + 1) {
					dp[next_go][next_value] = min(dp[next_go][next_value], dp[i][q] + cost);
				}
				dist++;
			}
		}
	}
	ll ans = 1e9;
	REP(q, 51) {
		ans = min(ans, dp[(1 << n) - 1][q]);
	}
	if (ans == 1e9)ans = -1;
	cout << ans << endl;
}

#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 209280
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int main() {
  int N;
  cin >> N;
  bool boo = false;
  for(int i=1;i<10;i++){
    if(N/i <=9 && N%i == 0) {
      boo = true;
      break;
  }
  }
  if(boo) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

double value[45];
int size[45];

double get_value(string &pile){
    bool b_can_move = 0, w_can_move = 0;
    double b_max, w_min;
    double last_value = 0;
    for(int i=0;i<pile.length();i++){
        double value;
        if(pile[i]=='B'){
            if(b_can_move){
                b_max = max(b_max,last_value);
            }
            else{
                b_max = last_value;
            }
            b_can_move = 1;
            if(w_can_move){
                value = (b_max + w_min) / 2;
            }
            else{
                value = b_max + 1;
            }
        }
        if(pile[i]=='W'){
            if(w_can_move){
                w_min = min(w_min,last_value);
            }
            else{
                w_min = last_value;
            }
            w_can_move = 1;
            if(b_can_move){
                value = (b_max + w_min) / 2;
            }
            else{
                value = w_min - 1;
            }
        }
        last_value = value;
    }
    return last_value;
}

#define map unordered_map

void enumerate(int st, int ed,map<double,int> &table ,double value_sum = 0, int size_sum = 0){
    if(st==ed){
        if(table.count(value_sum)){
            table[value_sum] = max(table[value_sum], size_sum);
        }
        else{
            table[value_sum] = size_sum;
        }
    }
    else{
        enumerate(st+1, ed, table, value_sum, size_sum);
        enumerate(st+1, ed, table, value_sum + value[st], size_sum + size[st]);
    }
}

int find_zero_value(int st,int ed,map<double,int> &table ,double value_sum = 0, int size_sum = 0){
    if(st==ed){
        if(table.count(-value_sum)){
            return table[-value_sum] + size_sum;
        }
        else return 0;
    }
    else{
        int get1 = find_zero_value(st+1, ed, table, value_sum, size_sum);
        int get2 = find_zero_value(st+1, ed, table, value_sum + value[st], size_sum + size[st]);
        return max(get1, get2);
    }
}

map<double,int> table, table2;

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        string pile;
        cin>>pile;
        size[i] = pile.length();
        value[i] = get_value(pile);
        //printf("%f\n",value[i]);
    }
    if(n<=20){
        enumerate(0,n,table);
        printf("%d\n",table[0]);
    }
    else{
        
        enumerate(0,20,table);
        printf("%d\n",find_zero_value(20,n,table));
        /*
        enumerate(0,20,table);
        enumerate(20,n,table2);
        int ans = 0;
        for(map<double,int>::iterator it = table.begin(); it!=table.end(); it++){
            double my_value = it->first;
            if(table2.count(-my_value)){
                int my_size = table[my_value] + table2[-my_value];
                ans = max(ans,my_size);
            }
        }
        printf("%d\n",ans);
        */
    }

    return 0;
}

Measured memory_bytes: 43932
#include <iostream>
#include <vector>
#include <queue>

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

	std::vector<std::vector<int>> edges(n);
	for (auto&& v : edges) {
		int k;
		std::cin >> k >> k;

		for (int i = 0; i < k; ++i) {
			int u;
			std::cin >> u;
			--u;

			v.push_back(u);
		}
	}

	std::vector<int> depth(n, -1);
	depth[0] = 0;

	std::queue<int> que;
	que.push(0);
	while (!que.empty()) {
		int cur = que.front();
		que.pop();

		for (auto&& dist : edges[cur]) {
			if (depth[dist] == -1) {
				depth[dist] = depth[cur] + 1;
				que.push(dist);
			}
		}
	}

	for (int i = 0; i < n; ++i)
		std::cout << i + 1 << " " << depth[i] << std::endl;
}


Measured memory_bytes: 3160
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
string s;
int dp[100005][3];
void add(int &x,int y){
	(x+=y)%=mod;;
}
void mul(int x){
	dp[x][0]=(ll)dp[x][0]*3ll%mod;
	dp[x][1]=(ll)dp[x][1]*3ll%mod;
	dp[x][2]=(ll)dp[x][2]*3ll%mod;
}
int MUL=1;
signed main(){
	cin>>s;s=" "+s;
	for(int i=1;i<s.size();i++){
		add(dp[i][0],dp[i-1][0]);
		add(dp[i][1],dp[i-1][1]);
		add(dp[i][2],dp[i-1][2]);
		
		if(s[i]=='A'){
			add(dp[i][0],MUL);
		}else if(s[i]=='B'){
			add(dp[i][1],dp[i-1][0]);
		}else if(s[i]=='C'){
			add(dp[i][2],dp[i-1][1]);
		}else{
			mul(i);
			add(dp[i][0],MUL);
			add(dp[i][1],dp[i-1][0]);
			add(dp[i][2],dp[i-1][1]);
		}if(s[i]=='?')(MUL*=3ll)%=mod;
//		cerr<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl; 
	}
	cout<<dp[(int)s.size()-1][2]<<endl;
	return 0;
}

Measured memory_bytes: 2812
N = int(input())
W_i = list(map(int, input().split()))

S1 = [0]*(N-1)
S2 = [0]*(N-1)
diffS = [0]*(N-1)

for i in range(1, N):
  S1[i-1] = sum(W_i[:i])
  S2[i-1] = sum(W_i) - S1[i-1]
  diffS[i-1] = abs(S1[i-1] - S2[i-1])
  
print(min(diffS))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
   int n; cin >> n;
   vector<ll> A(n), B(n); 
   rep(i, n)cin >> A[i]; 
   rep(i, n)cin >> B[i];

   ll xa = 0, xb = 0;
   rep(i, n){
       if(A[i]>B[i]) xb += A[i] - B[i];
       else xa += (B[i] - A[i])/2;
   }
   if(xa >= xb)cout << "Yes" << ln;
   else cout << "No" << ln;
}


Measured memory_bytes: 3804
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a, b, n;
main() {
  file("threesum");
  ios;
  cin >> a >> b >> n;
  ll mx = n;
  if (n % b == 0) --mx;
  if (a % b == 0) return !(cout << a * mx / b - a * (mx / b));
  mx = min(n, b - 1);
  cout << (a * mx) / b - a * (mx / b);
  return 0;
}
/**
a[b] == a[a] + c[i];
*/


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using pp=pair<double,double>;
using ll=long long;

int main() {
  int N;
  cin >> N;
  vector<pp> V(N);
  vector<int> P(N);
  for (int i=0; i<N; i++) {
    cin >> V[i].first >> V[i].second;
    P[i]=i;
  }
  
  double S=0;
  int m=0; 
  do {
    for (int i=0; i<N-1; i++) {
      double x=V[P[i]].first-V[P[i+1]].first, y=V[P[i]].second-V[P[i+1]].second;
      S+=sqrt(x*x+y*y);
    }
    m++;
  } while(next_permutation(P.begin(), P.end()));
  cout << fixed << setprecision(15) << S/m << endl;
}

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

int main() {
    long n;
    long m;
    cin >> n >> m;
    
    if (n <= m/2) {
        cout << n+(m-2*n)/4 << endl;
    }
    else {
        cout << m/2 << endl;
    }
}

Measured memory_bytes: 256
from operator import itemgetter

N = int(input())
book = []

for i in range(N):
    S, P = map(str, input().split())
    book.append([S, int(P), i+1])

book = sorted(book, key=itemgetter(1), reverse=True)
book = sorted(book, key=itemgetter(0))
#print(book)

for ans in book:
    print(ans[2])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[114];
signed main(){
	int n,ansa=0,ansb=0;
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	for(int i=n-1;i>=0;i-=2)ansa+=a[i];
	for(int i=n-2;i>=0;i-=2)ansb+=a[i];
	cout<<ansa-ansb<<endl;
}

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

signed main() {
  int A, B;
  vector<int> count(4);
  for( int i = 0; i < 3; i++ ){
    cin >> A >> B;
    count.at(A-1)++;
    count.at(B-1)++;
  }
  
  for( int i = 0; i < 4; i++ ){
    if( count.at(i) > 2 ){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
      
}



Measured memory_bytes: 256
def count_bomb(x, y):
    cnt = 0
    for i in range(x-1, x+2):
        for j in range(y-1, y+2):
            if 0<=i<w and 0<=j<h:
                if s[j][i] == '#':cnt += 1
    return cnt

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
k = [["0"]*w for _ in range(h)]

for i in range(w):
    for j in range(h):
        if s[j][i] == '#':
            k[j][i] = "#"
        else:
            k[j][i] = str(count_bomb(i, j))

for i in range(h):
    print("".join(k[i]))


Measured memory_bytes: 9132
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int p,r,win=0,fair=0;//p>r;
    int gnu=0,pnu=0;
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    for(char c:s)
    {
        if(c=='g')gnu++;
        else
        if(c=='p')pnu++;
    }
    int n=s.size();
    if(n&1)
    {
        p=n/2;
        r=n/2+1;
    }else
    {
        p=n/2;
        r=n/2;
    }
    if(p>gnu)
    {
        win+=gnu;
        p-=gnu;
        fair=pnu-p;
    }else
    {
        win=p;
        fair=pnu;
    }
    cout<<win-fair<<endl;
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var n = h[0];
		var map = new int[n + 1].Select(_ => new List<int>()).ToArray();
		foreach (var r in new int[h[1]].Select(_ => read()))
		{
			map[r[0]].Add(r[1]);
			map[r[1]].Add(r[0]);
		}

		var c = 0;
		var used = new bool[n + 1];
		var q = new Queue<int>();
		for (int i = 1; i <= n; i++)
		{
			if (used[i]) continue;
			c++;
			q.Enqueue(i);

			while (q.Any())
			{
				var p = q.Dequeue();
				used[p] = true;
				foreach (var np in map[p])
				{
					if (used[np]) continue;
					q.Enqueue(np);
				}
			}
		}
		Console.WriteLine(c);
	}
}


Measured memory_bytes: 31864
#include <iostream>

using namespace std;
int a[40] = {};
int main(){
	int i,j,n,d;
	cin >> n >> d;
	int ans = 0;
	if(n<=d){
		cout << 1 << endl;
		return 0;
	}
	a[0] = 1;
	for(i=1;i<=n + d;i++){
		if(i>=d && a[i-d]==0){
			ans++;
			for(j=i - d;j<=i + d;j++){
				a[j] = 1;
			}
		}
	}
	cout << ans << endl;
}
	

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int cnt = 0;
  while(true){
    if (a > b) break;
    if (c % a == 0) cnt++;
    a++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){
	char s[101];
	ll k;
	scanf("%s %lld", s, &k);

	int len = strlen(s);
	REP(i, len) {
		if (s[i] != '1') {
			if ((ll)i < k) {
				printf("%c\n", s[i]);
				break;
			}
			else {
				PRINTD(1);
				break;
			}
		}
		if (i == len - 1) {
			PRINTD(1);
			break;
		}
	}

}

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


#define PI 3.14159265358979323846264338327950L

int main(void){
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  
  
  long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
  long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *b) * cosl(rad);

  long double D=sqrtl(rsq);
  printf("%20.20Lf\n", sqrtl(rsq));
  return 0;
}
  

Measured memory_bytes: 4148
#include<stdio.h>
#include<stdlib.h>

#define MAX 500001

void merge(int *,int,int,int);
void mergeSort(int *,int,int);
 
int count=0; 
 
int main(){
  int n,i;
  int S[MAX];
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(S[i]<0 || S[i]>1000000000){
      exit(1);
    }
  }
 
  mergeSort(S,0,n);
 
  for(i=0;i<n-1;i++){
    printf("%d ",S[i]);
  }
  printf("%d\n",S[n-1]);
  printf("%d\n",count);
 
  return 0;
}


void merge(int *A,int l,int m,int r){
  int n1=m-l;
  int n2=r-m;
  int i,j,k;
  int *L,*R;
 
  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));
 
  for(i=0;i<=n1-1;i++){
    L[i]=A[l+i];
  }
 
  for(j=0;j<=n2-1;j++){
    R[j]=A[m+j];
  }
 
  L[n1]=1000000000;
  R[n2]=1000000000;
 
  i=0;
  j=0;
 
  for(k=l;k<=r-1;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }else{
      A[k]=R[j];
      j=j+1;
    }
 
    count++;
  }
 
  free(L);
  free(R);
}

void mergeSort(int *A,int left,int right){
  int mid;
 
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4480
c = [list(map(int,input().split())) for i in range(3)]
a1 = 0
a2 = 0
a3 = 0
b1 = 0
b2 = 0
b3 = 0
for i in range(c[0][0]+1):
    b1 = c[0][0]-i
    b2 = c[0][1]-i
    b3 = c[0][2]-i
    a1 = i
    a2 = c[1][0]-b1
    a3 = c[2][0]-b1
    if a2+b2 == c[1][1] and a2 + b3 == c[1][2] and a3 +b2 ==c[2][1] and a3+ b3 ==c[2][2]:
        print("Yes")
        exit()
    else:
        a1 = 0
        a2 = 0
        a3 = 0
        b1 = 0
        b2 = 0
        b3 = 0 
else:
    print("No")

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var d int
	fmt.Scan(&d)
	switch d {
	case 25:
		fmt.Println("Christmas")
	case 24:
		fmt.Println("Christmas Eve")
	case 23:
		fmt.Println("Christmas Eve Eve")
	case 22:
		fmt.Println("Christmas Eve Eve Eve")
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    s.replace(5, 1, " ");
    s.replace(13, 1, " ");
    cout << s << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	m := getNextInt(scanner)
	s := getNextString(scanner)
	t := getNextString(scanner)
	g := gcd(n, m)

	for i := 0; i < g; i++ {
		if s[n/g*i] != t[m/g*i] {
			fmt.Println(-1)
			return
		}
	}

	fmt.Println(int64(n/g) * int64(m))

	writer.Flush()
}

func gcd(n, m int) int {
	if m == 0 {
		return n
	}
	return gcd(m, n%m)
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            int n = ReadAndParseInt();
            int[] d = new int[n];
            for(int i=0;i<n;++i)
            {
                d[i] = ReadAndParseInt();
            }
            var work = new List<int>(d);
            work = work.Distinct().ToList();
            work.Sort();
            work.Reverse();
            Console.WriteLine(work.Count);
        }


        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2==0)COUT((b-a)/2);
    else COUT(min(a-1,n-b)+1+(b-a-1)/2);
    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MOD 998244353
//#define MAX 100100
#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL k;
    cin >> n >> k;
    vector<LL> l(k);
    vector<LL> r(k);
    vector<LL> dp(n);
    dp[0]=1;
    dp[1]=-1;

    for(LL i=0; i<k; i++){
        cin >> l[i] >> r[i];
    }

    for(LL i=0; i<n; i++){
        if(i>0){
            dp[i]=(dp[i]+dp[i-1])%MOD;
        }
        for(LL j=0; j<k; j++){
            if(i+l[j]<n){
                dp[i+l[j]]=(dp[i+l[j]]+dp[i])%MOD;
            }
            if(i+r[j]+1<n){
                dp[i+r[j]+1]=(dp[i+r[j]+1]-dp[i])%MOD;
            }
        }
    }
    while(dp[n-1]<0){
        dp[n-1]+=MOD;
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 4848
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, double> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	string s;
	cin >> s;
	string ans;
	rep(i, s.size()) {
		if (s.at(i) == '0') {
			ans += '0';
		}
		else if (s.at(i) == '1') {
			ans += '1';
		}
		else if (s.at(i) == 'B' && ans.size() != 0) {
			ans.erase(ans.size() - 1);
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include<map>
#include<set>
#include<random>
#include<cassert>
using namespace std;
#define ll long long int
#define ld long double
const ll Mod = 1000000007;
ll CaseN=1;
const ld PI = 22/7.0;

bool mycmp(string s,string t)
{
if(s.size()<t.size())
{
return true;	
}		
return false;
}


void solve()
{
 
  string a,b,c;
 cin>>a>>b>>c;
 
 
 cout<<a[0]<<b[0]<<c[0];
 
 // cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
    
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


Measured memory_bytes: 256
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
import math 
# import collections
# import string
# ===================================
n, k = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
ans = -1
if n <= k:
	ans = 1
else:
	ans = 1 + math.ceil((n-k)/(k-1))
print(ans)


Measured memory_bytes: 13812
def fib(num):
    a, b = 0, 1 
    for _ in range(num - 1):
#         print(a)
        a, b = a + b, a
    return a + b

def culcC(num):
    if num  < 2:
         return 1
    return fib(num) + fib(num-1)
            
n,m = map(int,input().split())
aa = [int(input()) for i in range(m)]

if n == 1:
    print(1)
elif m == 0:
    print(culcC(n) % 1000000007)
else:
    ans = 1
    stand = 0
    for i,a in enumerate(aa):
#        連続穴
        if stand == a:
            ans = 0
            break
        step_num = a - stand - 1
        c = culcC(step_num)
        ans *= c if c > 0 else 1
        stand = a + 1
        
    # 最後のaからnまでで計算
    ans *= culcC(n - aa[-1] - 1)
    
    print(ans % 1000000007)

Measured memory_bytes: 7080
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N =  1e5+5,mod=1e9+7;

ll X[N],Y[N];
int main() {
    int n,m;scanf("%d %d",&n,&m);
    for (int i=1; i<=n; i++) {
        scanf("%lld",X+i);
    }
    for (int i=1; i<=m; i++) {
        scanf("%lld",Y+i);
    }
    sort(X+1,X+1+n);
    sort(Y+1,Y+1+m);
    ll a=0,s=0;
    for (int i=1; i<=n; i++) {
        if(i!=1)    {
            a = (a+((X[i]*(i-1))%mod))%mod;
            a-=s;a%=mod;
        }
        s+=X[i];s%=mod;
    }
    s=0; ll b=a;a=0;
    for (int i=1; i<=m; i++) {
        if(i!=1)    {
            a = (a+((Y[i]*(i-1))%mod))%mod;
            a-=s;a%=mod;
        }
        s+=Y[i];s%=mod;
    }
    ll ans=(a*b)%mod;
    if(ans<0)   ans+=mod;
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int k, x;
  cin >> k >> x;
  int begin = max(-1000000, x - k + 1);
  int i;
  for (i = 0; i < k * 2 - 1; i++) {
    cout << begin + i << ' ';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector< vector<int> > cnt(10, vector<int>(10));
    for(int A=1; A<=N; A++) {
        // 先頭と末尾
        int x = A % 10;
        int T = A;
        while(T >= 10) T /= 10;
        int y = T;
        cnt[x][y]++;
    }

    ll ans = 0;
    for(int A=1; A<=N; A++) {
        // 先頭と末尾
        int x = A % 10;
        int T = A;
        while(T >= 10) T /= 10;
        int y = T;

        ans += cnt[y][x];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256