akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <map>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
    char b;
    map<char, char> a;
    a.insert(make_pair('A', 'T'));
    a.insert(make_pair('T', 'A'));
    a.insert(make_pair('C', 'G'));
    a.insert(make_pair('G', 'C'));

    cin >> b;

    cout << a[b] << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        bool cont = true;
        while (cont) cont = Sub();
    }
    static bool Sub()
    {
        string[] raw1 = Console.ReadLine().Split(' ');
        if (raw1[0] == "0") return false;
        int n = int.Parse(raw1[0]);
        int k = int.Parse(raw1[1]);
        string[] rawS = Console.ReadLine().Split(' ');
        int[] s = new int[k];
        for (int i = 0; i < k; i++) s[i] = int.Parse(rawS[i]);
        int[] sum = new int[k];
        for (int i = 0; i < n; i++)
        {
            string[] rawB = Console.ReadLine().Split(' ');
            for (int j = 0; j < k; j++) sum[j] += int.Parse(rawB[j]);
        }
        for (int i = 0; i < k; i++)
        {
            if (sum[i] > s[i])
            {
                Console.WriteLine("No");
                return true;
            }
        }
        Console.WriteLine("Yes");
        return true;
    }
}
                

Measured memory_bytes: 6068
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<double, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,m,i,j,k,cnt[26],r,b;
	char d[2][20];
	ll dp[20][20],ans=0ll;
	string s;
	fill(cnt,cnt+26,0);
	cin >> n;
	cin >> s;
	m = (1<<n);
	for(i=0; i<m; ++i){
		r = 0; b = 0;
		for(j=0; j<n; ++j){
			if((i&(1<<j))){
				d[0][r] = s[j];
				++r;
			}else{
				d[1][b] = s[j];
				++b;
			}
		}
		fill(dp[0],dp[20],0ll);
		dp[r][b] = 1ll;
		for(j=r; j>=0; --j){
			for(k=b; k>=0; --k){
				if(j > 0 && s[n+j+k-1] == d[0][r-j]){
					dp[j-1][k] += dp[j][k];
				}
				if(k > 0 && s[n+j+k-1] == d[1][b-k]){
					dp[j][k-1] += dp[j][k];
				}
			}
		}
		ans += dp[0][0];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b,d,r;
    double f;
    cin >> a >> b ;
    d=a/b;
    r=a%b;
    f=(double)a/b;
    cout << d <<" "<< r <<" ";
    cout << fixed << setprecision(5) << f << endl;
    
}


Measured memory_bytes: 3276
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
S = input()[:-1]
if S == "ABC":
    print("ARC")
else:
    print("ABC")

Measured memory_bytes: 9036
# include <iostream>
# include <vector>
# include <cstring>
# define DIM 2010
# define INF 1000000000
using namespace std;
vector<int> Lista[DIM];
int Marcat[DIM],n,k,x,y,i,j,r,sol,nr;
void dfs(int nc){
    for(int i=0;i<Lista[nc].size();i++){
        int nv=Lista[nc][i];
        if(!Marcat[nv]){
            Marcat[nv]=Marcat[nc]+1;
            dfs(nv);
        }
    }
}
int main () {
    cin>>n>>k;
    for(i=1;i<n;i++){
        cin>>x>>y;
        Lista[x].push_back(y);
        Lista[y].push_back(x);
    }
    sol=INF;
    for(i=1;i<=n;i++){
        memset(Marcat,0,sizeof(Marcat));
        Marcat[i]=1;
        dfs(i);
        nr=0;
        for(j=1;j<=n;j++)
            if(2*Marcat[j]-2>k)
                nr++;
        sol=min(sol,nr);
    }
    for(i=1;i<=n;i++)
        for(r=0;r<Lista[i].size();i++){
            memset(Marcat,0,sizeof(Marcat));
            Marcat[i]=1;
            Marcat[Lista[i][r]]=1;
            dfs(i);
            dfs(Lista[i][r]);
            nr=0;
            for(j=1;j<=n;j++)
                if(2*Marcat[j]-2>k-1)
                    nr++;
            sol=min(sol,nr);
        }
    cout<<sol<<"\n";
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main(){
 
    ull a,b;
	string s;
 
    cin>>a>>s;
    b=(s[0]-'0')*100+(s[2]-'0')*10+s[3]-'0';
    cout<<a*b/100<<endl;
 
   
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int a,b,c,x,y;
cin >> a >>b >> c>> x >> y;
ll ans = 10e17;
for(int i=0;i<=max(x,y);i++){
   if(i>x){
ll che =(y-i)*b+2*c*i;
  chmin(ans,che); 
   }
   else if(i>y){
      ll che = (x-i)*a+2*c*i;
      chmin(ans,che);
   }
   else {ll che = (x-i)*a+(y-i)*b+2*c*i;
   chmin(ans,che);
   }
}
cout << ans << endl;
}





Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    vector<string> scs{"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s; cin >> s;
    auto itr = find(scs.begin(),scs.end(),s);
    int i =itr-scs.begin();
    cout << 7-i << endl;
    return 0;
}

Measured memory_bytes: 3128
#include<iostream>
#include<vector>
#include<list>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
int main() {
	int x, y, s;
	while (cin >> x >> y >> s&&x + y + s != 0) {
		int sum = 0;
		for (int i = 1; i < s; i++) {
			for (int j = 1; j < s; j++) {
				if (i*(100 + x) / 100 + j*(100 + x) / 100 == s) {
					int c = i*(100 + y) / 100;
					int d = j*(100 + y) / 100;
					sum = max(sum, c + d);
				}
			}
		}
		cout << sum << endl;
	}
} 

Measured memory_bytes: 2972
#include<bits/stdc++.h>
using namespace std;
#define  rep(i,n) for(int i=0; i<n;i++)
int h,w;
bool inrage(int x,int y){return (0<=x&&x<w&&0<=y&&y<h);}
typedef pair<int,int>pii;
int main(){
    cin>>h>>w;
    vector<string>v(h); rep(i,h)cin>>v[i];
    int d[]={0,1,-1};
    int ans=0;
    rep(i,h){
        if(!i)continue;
        rep(j,v[i].size()){
            bool flag=true;
            if(v[i][j]!='-'){flag=false;continue;}
            rep(dx,3)rep(dy,3){
                if(d[dx]==0&&d[dy]==0)continue;
                if(!inrage(j+d[dx],i+d[dy]))continue;
                if((d[dy]==0&&d[dx]==1)||(d[dy]==0&&d[dx]==-1)){
                    if(v[i+d[dy]][j+d[dx]]!='-'){flag=false;}
                }
                if(v[i+d[dy]][j+d[dx]]=='x'){flag=false;}
            }
            if(flag)ans++;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
    clock_t cTimeStart, cTimeEnd;
    cTimeStart = clock();           // 現在時刻
    int H[3];
    int N,total;
    cin>>N;
    for(int i=0;i<N;++i){
    	cin>>H[0]>>H[1]>>H[2];
    	sort(H,H+3);
    	total=H[2]*H[2]-(H[1]*H[1]+H[0]*H[0]);
    	if(total==0){
    		cout<<"YES"<<endl;
    	}else{
    		cout<<"NO"<<endl;

    	}
    }

    cTimeEnd = clock();           // 現在時刻
//    cout<< "処理時間:" <<(cTimeEnd - cTimeStart)/1000 << "[ms]" << endl;

	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int N; cin >> N;
  vector<ll> A(N); REP(i,N) cin >> A[i];

  RSORT(A);

  ll x1 = 0, x2 = 0;
  REP(i,N-1) {
    if (A[i]==A[i+1]) {
      if (x1 == 0) {
        x1 = A[i];
        ++i;
      }
      else {
        x2 = A[i];
        break;
      }
    }
  }
  
  cout << x1*x2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll a,b;
     cin>>a>>b;
     cout<<a*b<<"\n";
   }
}


Measured memory_bytes: 3692
N = int(input())
for i in range(N) :
    a, b, c = map(int, input().split())
    if a**2 == b**2 + c**2 or b**2 == c**2 + a**2 or c**2 == a**2 + b**2 :
        print("YES")
    else :
        print("NO")


Measured memory_bytes: 5596
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <queue>
#include <functional>
#include <vector>
#include <utility>
#include <unordered_set>
#include <limits>

using i64 = std::int64_t;

// (cost, x)
using Pair = std::pair<i64, i64>;

i64 mul(i64 x, i64 y) {
	constexpr i64 Inf = std::numeric_limits<i64>::max();
	return (y <= Inf / x ? x * y : Inf);
}

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

	std::vector<Pair> buf;
	buf.reserve(1000000);
	std::unordered_set<i64> visited;
	while (t--) {
		i64 n, a, b, c, d;
		std::cin >> n >> a >> b >> c >> d;

		std::priority_queue pque(std::greater<>{}, buf);
		pque.emplace(0, n);
		while (!pque.empty()) {
			auto [cost, x] = pque.top();
			pque.pop();

			if (x == 1) {
				std::cout << cost + d << std::endl;
				break;
			}
			if (visited.count(x))
				continue;

			visited.insert(x);

			auto push = [&](i64 c, i64 nx) {
				if (!visited.count(nx))
					pque.emplace(c, nx);
			};

			for (auto [t, u] : { Pair(a, 2), Pair(b, 3), Pair(c, 5) }) {
				if (x % u == 0) {
					push(cost + std::min(t, mul(d, x - x / u)), x / u);
					continue;
				}

				push(cost + std::min(t + d * (u - x % u), mul(d, x - (x + u - 1) / u)), (x + u - 1) / u);
				if (x >= u)
					push(cost + std::min(t + d * (x % u), mul(d, x - x / u)), x / u);
			}
		}

		visited.clear();
	}
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int k;cin >> k;
    ll sum = 0;
    for(int i=1;i<=k;++i){
        for(int j=1;j<=k;++j){
            for(int l=1;l<=k;++l){
                sum += gcd(i, gcd(j,l));
            }
        }
    }
    cout << sum << endl;
}

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


int main(){
    ll w, h, w2,h2;
    cin >> w >> h;
    w2 = w/2;
    h2 = h/2;

    if(w==1 or h==1){
        cout << 1 << endl;
    }
    else if(h%2==1){
        if(w%2==1) w2+=1;
        cout << w*h2 + w2 << endl;
    }
    else cout << w*h2 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ab = []
cd = []
for i in range(n):
    ab.append(tuple(map(int,input().split())))

for g in range(n):
    cd.append(tuple(map(int,input().split())))

ab.sort(key=lambda x: x[1], reverse = True)
cd.sort()
used = [False]*n

ans = 0
for i in range(n):
    for g in range(n):
        if ab[i][0] < cd[g][0] and ab[i][1] < cd[g][1] and not used[g]:
            used[g] = True
            ans += 1
            break
print(ans)

Measured memory_bytes: 9216
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        num = n // i
        ans += i*num*(num+1)//2
    

    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 69716
#include <stdio.h>
int main(void) {

	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(b<a){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=readln.split.to!(int[]);

  auto pos=new int[](n+1);
  foreach(int i; 0..n) pos[a[i]]=(i+1);
  auto tree=new SquareRootDecomposition(n);
  long sum=0;
  for(int v=n; v>=1; v--){
    int i=pos[v];
    tree.merge(i);
    auto seq=tree.get(i);
    auto l=seq.left, r=seq.right,
         dl=(i-l+1).to!(long), dr=(r-i+1).to!(long);
    sum+=dl*dr*v;
  }
  writeln(sum);
}

struct Seq{int left, right;}

class SquareRootDecomposition{
  import std.algorithm;
  int D=1, inf=1_000_000_000;
  int[] left, right;
  int[] buc_left, buc_right;
  this(int n){
    while(D*D<n) D++;
    left.length=right.length=(D*D+1);
    buc_left.length=buc_right.length=(D+1);
    fill(left, inf); fill(right, -inf);
    fill(buc_left, -1); fill(buc_right, -1);
  }
  void merge(int i){
    int l=i, r=i;
    if(buc_left[(i-1)/D+1]>=0) chmin(l, buc_left[(i-1)/D+1]);
    if(buc_right[(i-1)/D+1]>=0) chmax(r, buc_right[(i-1)/D+1]);
    if(i-1>=1){
      chmin(l, left[i-1]);
      if(buc_left[(i-1-1)/D+1]>=0) chmin(l, buc_left[(i-1-1)/D+1]);
    }
    if(i+1<=D*D){
      chmax(r, right[i+1]); 
      if(buc_right[(i+1-1)/D+1]>=0) chmax(r, buc_right[(i+1-1)/D+1]);
    }
    int bl=(l-1)/D+1, br=(r-1)/D+1;
    if(br-bl<=1){
      eachUpdate(l, r, l, r);
    }else{
      eachUpdate(l, bl*D, l, r);
      buc_left[(bl+1)..br]=l;
      buc_right[(bl+1)..br]=r;
      eachUpdate((br-1)*D+1, r, l, r);
    }
  }
  void eachUpdate(int st, int ed, int l, int r){ // j in [st, ed], left[j]<-l, right[j]<-r
    push((st-1)/D+1); push((ed-1)/D+1); // ここらへん、頭使わないといけないので、よくない
    for(int j=st; j<=ed; j++) left[j]=l, right[j]=r;
  }
  void push(int k){
    if(buc_left[k]>=0){
      for(int j=(k-1)*D+1; j<=k*D; j++) left[j]=buc_left[k];
      buc_left[k]=-1;
    }
    if(buc_right[k]>=0){
      for(int j=(k-1)*D+1; j<=k*D; j++) right[j]=buc_right[k];
      buc_right[k]=-1;
    }
  }
  Seq get(int i){
    auto ret=Seq(i, i);
    if(buc_left[(i-1)/D+1]>=0) chmin(ret.left, buc_left[(i-1)/D+1]);
    else chmin(ret.left, left[i]);
    if(buc_right[(i-1)/D+1]>=0) chmax(ret.right, buc_right[(i-1)/D+1]);
    else chmax(ret.right, right[i]);
    return ret;
  }
  void show(){
    import std.stdio;
    writeln(left);
    // writeln(buc_left);
    writeln(right);
  }
}

void chmin(T)(ref T l, T r){if(l>r)l=r;}
void chmax(T)(ref T l, T r){if(l<r)l=r;}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 11024
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int X, Y; cin >> X >> Y;
	bool flag = false;
	for (int i = 0; i <= X;i++) {
		if (4 * i + 2 * (X - i) == Y) {
			flag = true;
			break;
		}
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    ll N;
    cin >> N;
    ll p[N];
    ll ans = 0;
    ll min = 1LL << 60;
    for (ll i=0; i<N; ++i)
    {
        cin >> p[i];
        if(p[i]<=min)
        {
            ++ans;
            min = p[i];
        }
    }

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

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

int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  if(a+b<c){
  if(2*a*b+2*b*c+2*c*a < a*a+b*b+c*c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  }
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
require 'pp'

n, k = gets.split.map(&:to_i)
a_n = gets.split.map(&:to_i)

#pp sum
0.upto(n-1-k) do |i|
    if a_n[i] < a_n[i+k]
        puts "Yes"
    else
        puts "No"
    end


    #pp sum
end


Measured memory_bytes: 33752
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

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

	string result;

    int white = 0;
    int black = 0;

    vector<int> w(n), b(n);

    REP(i,n){
        if( s[i] == '.' ){
            white++;
        }
        else{
            black++;
        }
        w[i] = white;
        b[i] = black;
    }

    int min = 1e9;
    REP(i,n){
        if( n-1 <= i ) break;
        string w_b;
        int tmp = 0;
        tmp += b[i]; // 左側の黒の数
        tmp += w[n-1] - w[i]; // 右の白の数
        // ここでtmpはそこ起点で白連続、黒連続の塊にした文字列を作るための変更数
        if( min > tmp){
            min = tmp;
        }
        
    }

    if( min < white && min < black ){
        cout << min << endl;
    }
    else if( white < black ){
        cout << white << endl;
    }
    else {
        cout << black << endl;
    }
	
	return 0;
}


Measured memory_bytes: 2180
#35 C - Anti-Division　
import math
A,B,C,D = map(int,input().split())

# C と D の最小公倍数の個数
lcm = C*D//math.gcd(C,D)
cnt_lcm = B//lcm - (A-1)//lcm

# C の倍数の個数
cnt_C = B//C - (A-1)//C 

# D の倍数の個数
cnt_D = B//D - (A-1)//D

# (範囲内の整数) - (C の倍数 + D の倍数 - C,D の公倍数)
ans = (B - A + 1) - (cnt_C + cnt_D - cnt_lcm)

# 範囲が 1 しかないとき
if A == B:
    # C でも D でも割り切れるとき
    if A%C == 0 and A%D == 0:
        print(0)
    else:
        print(1)
else:
    print(ans)

Measured memory_bytes: 9196
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };

int w, h;
int cnt = 0;
char s[55][55];
void dfs(int y, int x) {

	s[y][x] = '#';
	cnt++;

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

		if (0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == '.') {
			dfs(ny, nx);
		}


	}


}



int main() {
	int sy ;
	int	sx ;
	while (cin >> w >> h) {
		if (w == 0)break;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> s[i][j];
			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '@') {
					sy = i;
					sx = j;
				}
			}
		}

		dfs(sy, sx);

		cout << cnt << endl;
		cnt = 0;

	}



	return 0;
}



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cassert>
#include<cctype>
#include<stdio.h>
using namespace std;

string S="4*(8+4+3)";
size_t cur=0;

int expression(); //????????£?¨?

//??°????????\???
int digit(){
	assert(isdigit(S[cur]));
	int n=S[cur++]-'0';
	return n;
}

//??°?????\???
int number(){
	int n= digit();
	while(cur<S.size() && isdigit(S[cur])) n=n*10+digit();
	return n;
}

//()???????¨????
int factor(){
	if(S[cur] !='(' ) return number();
	else{
		cur++;
		int n=expression();
		assert(S[cur]==')');
		cur++;
		return n;
	}
}

//*,/????????????????¨????
int term(){
	int a=factor();
	while(cur<S.size() && (S[cur]=='*' || S[cur]=='/')){
		char op=S[cur++];
		int b=factor();
		if(op=='*') a *=b;
		else if(op=='/') a /=b;
	}
	return a;
}

//+,-????¨????
int expression(){
	int sum=term();
	while(S[cur]=='+' || S[cur]=='-'){
		char op=S[cur++];
		int b=term();
		if(op=='+') sum+=b;
		else if(op=='-') sum -=b;
	}
	return sum;
}

int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		cur =0;
		cin >> S;
		S.resize(S.size()-1); //?????????=?????????
		cout<< expression() <<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
N,M=map(int,input().split())
hl=list(map(int,input().split()))

ans={}
for i in range(M):
    a,b=map(int,input().split())
    if hl[a-1]<=hl[b-1]:
        ans[a]=False
    if hl[a-1]>=hl[b-1]:
        ans[b]=False
    #print(ans)

print(N-len(ans))


Measured memory_bytes: 19960
N,X=map(int,input().split())
def burgerLength(n):
    return(pow(2,n+2)-3)
def allpatNum(level):
    return(pow(2,level+1)-1)
def pat(level,x):
    if level == 0:
        if x==0:
            return(0)
        else:
            return(1)
    L = burgerLength(level-1)
    if x == 1:
        ans = 0
    elif x <= 1 + L:
        ans = pat(level-1,x-1)
    elif x == 2 + L:
        ans = allpatNum(level-1) + 1
    elif x < 2 + L + L:
        ans = allpatNum(level-1) + 1 + pat(level-1,x-(2+L))
    else:
        ans = allpatNum(level)
    return(ans)
print(pat(N,X))

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    h,w,d=map(int,input().split())
    grid=[]
    cnt=0
    for i in range(h):
        for j,a in enumerate(map(int,input().split())):
            a-=1
            grid.append((a,(i,j)))
    grid.sort()

    n=h*w
    A=list(map(lambda x:x[1],grid))
    C=[0]*n
    for r in range(d):
        for x in range(r,n-d,d):
            C[x+d]=C[x]+abs(A[x+d][0]-A[x][0])+abs(A[x+d][1]-A[x][1])

    for _ in range(int(input())):
        l,r=map(int,input().split())
        l-=1; r-=1
        print(C[r]-C[l])
resolve()

Measured memory_bytes: 62556
import * as fs from 'fs';

namespace AtCoder.abc072 {

    const args: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const [x, t]: number[] = args[0].split(' ').map(Number);

    if (x >= t) {
        console.log(x - t);
    } else {
        console.log(0);
    }
}

Measured memory_bytes: 7500
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
string st1,st2,st3="";
int main()
{
  cin>>st1>>st2;
  for(int i=0;i<min(st1.size(),st2.size());i++)
	cout<<st1[i]<<st2[i];
  if(st1.size()!=st2.size())  cout<<st1[st1.size()-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
# AB = [list(map(int, input().split())) for i in range(M)]
root = [[] for _ in range(N+1)]

# AB = []
for i in range(M):
    a, b = map(int, input().split())
    root[a].append(b)
    root[b].append(a)
    # if a > b:
    #     a, b = b, a
    # AB.append((a, b))

# ans = [(float('inf'), 0)] * (N+1)
ans = [10**9] * (N+1)
ans[0] = 0
ans[1] = 0
# ans[0] = (0, 0)
# ans[1] = (0, 0)
# # done = [set() for _ in range(N+1)]

# print(root)
from collections import deque
q = deque([1])

while q:
    p = q.popleft()
    for i in root[p]:
        if ans[i] == 10**9:
            # ans[i] = ans[p]+1
            ans[i] = p
            q.append(i)
            # print(q)
            # print(i, ans)

# print(ans)

if 10**9 in set(ans):
    print('No')
else:
    print('Yes')
    for i in range(2, N+1):
        print(ans[i])

Measured memory_bytes: 97180
N, M = map(int,input().split())
data = []
for i in range(N):
    if i == 0:
        list_KA = list(map(int,input().split()))
        list_KA.pop(0)
    else:
        list_A = list(map(int,input().split()))
        list_A.pop(0)
        list_KA.extend(list_A)
l = set(list_KA)
ans = 0
for x in l:
    c = list_KA.count(x)
    if N == c:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	ll s = 0;
	vl a(n); rep(i,n) cin >> a[i], s ^= a[i];
	rep(i,n) cout << (s ^ a[i]) << " ";
	cout << "\n";
}


Measured memory_bytes: 4796
/*
Template for vjudge.net

	Author: Iqbal Hossain Rasel
	CodeForces: The_Silent_Man
	AtCoder   : IHR57
	TopCoder  : IHR57

*/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 1005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

ll dp[MAX][MAX];
char ch[MAX][MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    int h, w;

    cin>>h>>w;

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin>>ch[i][j];
        }
    }

    for(int i = 1; i <= h; i++){
        if(ch[i][1] == '#'){
            break;
        }
        else
            dp[i][1] = 1;
    }
    for(int i = 1; i <= w; i++){
        if(ch[1][i] == '#')
            break;
        dp[1][i] = 1;
    }
    dp[1][1] = 0;
    for(int i = 2; i <= h; i++){
        for(int j = 2; j <= w; j++){
            if(ch[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
        }
    }

    cout<<dp[h][w]<<endl;


    return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int a,b; cin >> a >> b;
  int g = __gcd(a,b);
  int ans = (a*b)/g;
  cout << ans << '\n';

  

  return 0;
}

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m;
  int a[100];
  for(int i=0;i<n;i++){
    cin >>a[i];
  }
  lol ans=0;
  lol a1=0;
  lol a2=1;
  for(int i=0;i<n;i++){
    if(a[i]&1){
      lol num=a1;
      a1+=a2;
      a2+=num;
    }else{
      a1*=2;
      a2*=2;
    }
  }
  if(m==0) cout <<a2<<'\n';
  else cout <<a1<<'\n';
  return (0);
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN,"%d %d %d",$a[0],$a[1],$a[2]);
  sort($a);
  if ($a[0] === 5 && $a[1] === 5 && $a[2] ===7) {
    echo "YES";
  } else {
    echo "NO";
  }

Measured memory_bytes: 4604
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
void add(int &a,int b){
	a += b;
	if(a >= mod)a -= mod;
}
const int maxn = 21;
int dp[(1<<maxn)];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin>>n;
	int a[n][n];
	rep(i,n){
		rep(j,n){
			cin>>a[i][j];
		}
	}	
	rep(mask,(1<<n)){
		rep(j,n){
			dp[mask] = 0;
		}
	}
	// rep(i,n){
		rep(mask,(1<<n)){
			int i = __builtin_popcount(mask);
			rep(j,n){
				if(mask & (1<<j))continue;
				if(a[i][j] == 0)continue;
				if(i)add(dp[mask | (1<<j)],dp[mask]);
				else dp[mask | (1<<j)] = 1;
			}
		}
	// }
	cout<<dp[(1<<n) - 1];
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, M;
pii AB[100100];

signed main() {
    cin >> N >> M;
    rep(i, N) {
        cin >> AB[i].first >> AB[i].second;
    }
    sort(AB, AB + N);
    priority_queue<int> pque;
    int k = 0;
    int ans = 0;
    for (int i = 1; i <= M; ++i) {
        //i日前
        while (k < N && AB[k].first <= i) {
            pque.push(AB[k].second);
            k++;
        }
        if (!pque.empty()) {
            ans += pque.top();
            pque.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2936
#!/bin/env python

MOD = 1000000007

pattern = [0] * 10
pattern[0] = 1
pattern[1] = 1
for i in xrange(2, 8 + 1):
    pattern[i] = pattern[i-1] + pattern[i-2]

def single_down(idx_from, idx_to, W):
    if idx_from == idx_to:
        return pattern[idx_from - 1] * pattern[W - idx_from]
    else:
        left = min(idx_from, idx_to) - 1
        right = W - max(idx_from, idx_to)
        return pattern[left] * pattern[right]

def main():
    H, W, K = map(int, raw_input().split(" "))

    ptn = [[0] * W]
    ptn[0][0] = 1
    for h in xrange(1, H + 1):
        ptn.append([])
        ptn[h] = [0] * W
        for w in xrange(0, W):
            ptn[h][w] = ptn[h-1][w] * single_down(w+1, w+1, W) % MOD
            if w > 0:
                ptn[h][w] += ptn[h-1][w-1] * single_down(w, w+1, W) % MOD
            if w < W-1:
                ptn[h][w] += ptn[h-1][w+1] * single_down(w+2, w+1, W) % MOD
            ptn[h][w] %= MOD

    print ptn[H][K-1]

if __name__ == '__main__':
    main()


Measured memory_bytes: 2696
N,M= list(map(int , input().split()))
A = sorted(map(int,input().split()),reverse=True)
sou = sum(A)
saitei = sou /(4*M)
B = A[0:M]
C = min(B)
if C >= saitei:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Wed Mar 18 18:21:12 JST 2020
 **/

signed main() {
    string s;
    cin >> s;
    map<char, int> cnt;
    for (char c : s) {
        cnt[c]++;
    }
    cout << (cnt.size() == 2 && cnt.begin()->second == 2 ? "Yes" : "No") << endl;
}


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

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> a(n,0),b(n,0),c(m,0),d(m,0);
	for(int i = 0;i < n;i++)
	{
		cin >> a.at(i) >> b.at(i);
	}
	for(int i = 0;i < m;i++)
	{
		cin >> c.at(i) >> d.at(i);
	}
	for(int i = 0;i < n;i++)
	{
		int mn = pow(10,9),idx = 0;
		for(int j = m-1;j >= 0;j--)
		{
			mn = min(mn,abs(a.at(i)-c.at(j)) + abs(b.at(i)-d.at(j)));
			if(mn == abs(a.at(i)-c.at(j)) + abs(b.at(i)-d.at(j)))
			{
				idx = j;
			}
		}
		cout << idx + 1 << endl;
	}
}


Measured memory_bytes: 256
#n,x,t=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
hantei=a[0]
ans=0
for i in range(n):
  if hantei>a[i]:
    ans+=(hantei-a[i])
  else:
    hantei=a[i]
print(ans)

Measured memory_bytes: 32344
/*
    Author: isaf27 (Ivan Safonov)
*/

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define what_is(x) cerr << #x << " is " << x << endl
#define solve_system int number; cin >> number; for (int i = 0; i < number; i++) solve()
#define solve_system_scanf int number; scanf("%d", &number); for (int i = 0; i < number; i++) solve()

//permanent constants
const ld pi = acos(-1.0);
const ld log23 = 1.58496250072115618145373894394781;
const ld eps = 1e-8;
const ll INF = 1e18 + 239;
const ll prost = 239;
const int two = 2;
const int th = 3;
const ll MOD = 1e9 + 7; //998244353;
const ll MOD2 = MOD * MOD;
const int BIG = 1e9 + 239;
const int alf = 26;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxb[4] = {-1, 1, 1, -1};
const int dyb[4] = {-1, 1, -1, 1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dig = 10;
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const ll bt = 30;

//easy functions
template< typename T >
inline T gcd(T a, T b)
{
    while (a)
    {
        b %= a;
        swap(a, b);
    }
    return b;
}
template< typename T >
inline T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
inline bool is_down(char x) { return ('a' <= x && x <= 'z'); }
inline bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
inline bool is_digit(char x) { return ('0' <= x && x <= '9'); }

//random
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd(239);

//constants
const int M = 2e5 + 239;
const int N = (2 * M);
const int L = 20;
const int T = (1 << 20);
const int B = trunc(sqrt(M)) + 1;
const int X = 1e4 + 239;

ll a, b, c;

int main()
{
    #ifdef ONPC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b >> c;
    c = min(c, a + b + 1);
    cout << (c + b);
    return 0;
}


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

using ll = long long int;

void chmax(ll &a, ll b){
    a = max(a,b);
}

int solve(){
    int n;
    cin >> n;
    if(n == 0) return 1;
    vector<int> v(n), t(n);
    for(int i=0;i<n;i++){
        int m;
        cin >> m >> v[i];
        for(int j=0;j<m;j++){
            int s, e;
            cin >> s >> e;
            s-=6; e-=6;
            for(int k=s;k<e;k++){
                t[i] |= 1<<k;
            }
        }
    }
    const int T_MAX = 1<<16;
    ll dp[T_MAX]{};
    for(int i=0;i<n;i++){
        for(int S=0;S<T_MAX;S++){
            if((S&t[i])==0){
                chmax(dp[S|t[i]], dp[S]+v[i]);
            }
        }
    }
    cout << dp[T_MAX-1] << endl;
    return 0;
}


int main(){
    while(solve()==0);
    return 0;
}



Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int k,int t){
  if(k>t)return t;
  else return k;
}
  

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0) enqueue(u);
   else{
    printf("%s %d\n",u.name,elaps);
  }
}
  
  return 0;
}



Measured memory_bytes: 11856
// Snake Toy

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;
	int l[N];
	for (int i = 0; i < N; ++i)
		cin >> l[i];

	sort(l, l+N);
	reverse(l, l+N);

	int res = 0;

	for (int i = 0; i < K; ++i)
		res += l[i];

	cout << res << endl;
	return 0;
}


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

const int MAXN = 1e6+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

int a[MAXN],dp[MAXN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    int n,k;cin >> n >> k;
    for(int i=1;i<=n;++i) cin >> a[i];

    dp[0] = false;
    for(int i=1;i<=k;++i){
        for(int j=1;j<=n;++j){
            if(i >= a[j]) dp[i] |= !dp[i-a[j]];
        }
    }
    if(dp[k]) cout << "First";
    else cout << "Second";
}


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

struct BIT {
    int N;
    vector<int> bit;

    void init(int _n){
        N = _n;
        bit.resize(_n+1, 0);
    }

    int getSum(int i) {  // i番目までの要素の和を求める(1-index)
        int sum = 0;
        while (i > 0) {
            sum += bit[i];
            i -= i & -i;
        }
        return sum;
    }

    void add(int i, int x) {  // i番目の要素にxを加算
        while (i <= N) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

int main(){
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<BIT> bit(26);
    for(int i=0;i<26;i++){
        bit[i].init(n);
    }
    for(int i=0;i<n;i++){
        int c = s[i]-'a';
        bit[c].add(i+1,1);
    }
    for(int t=0;t<q;t++){
        int k;
        cin >> k;
        if(k==1){
            int i, j;
            char c;
            cin >> i >> c;
            j = c-'a';
            bit[s[i-1]-'a'].add(i,-1);
            bit[j].add(i,1);
            s[i-1] = c;
        }else{
            int l, r, cnt = 0;
            cin >> l >> r;
            for(int i=0;i<26;i++){
                if(bit[i].getSum(r)-bit[i].getSum(l-1) > 0) cnt++;
            }
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 53764
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll h, w, i, j, conec=1;
char c;
ll color[405][405], whis[405][405];
ll bla[164000]={0}, wit[164000]={0};
bool vis[405][405];
ll xc[4]={1,0,-1,0}, yc[4]={0,1,0,-1};

void dfs(ll x, ll y){
    vis[x][y]=true;
    (color[x][y])? bla[conec]++:wit[conec]++;
    //cout<< x<< " "<< y<< " "<< conec<< endl;
    whis[x][y]=conec;
    for(ll r=0; r<4; r++){
        if(x+xc[r]<=h && x+xc[r]>=1 && y+yc[r]<=w && y+yc[r]>=1 && color[x+xc[r]][y+yc[r]]!=color[x][y] && !vis[x+xc[r]][y+yc[r]]){
            dfs(x+xc[r],y+yc[r]);
        }
    }
}

int main(){
    cin>> h>> w;
    for(i=1; i<=h; i++){
        for(j=1; j<=w; j++){
            cin>> c;
            (c=='#')? color[i][j]=1:color[i][j]=0;
            vis[i][j]=false;
        }
    }
    for(i=1; i<=h; i++){
        for(j=1; j<=w; j++){
            //printf("%lld,%lld ", i, j);
            if(!vis[i][j]){
                //printf("t  %lld %lld\n", i, j);
                dfs(i,j);
                conec++;
            }
        }
        //cout<< endl;
    }
//    for(i=1; i<=h; i++){
//        for(j=1; j<=w; j++){
//            cout<< whis[i][j]<< " ";
//        }
//        cout<< endl;
//    }
//    cout<< endl;
    ll n=1;
    ll ans=0;
    while(bla[n]||wit[n]){
        //cout<< bla[n]<< " "<< wit[n]<< endl;
        ans+=bla[n]*wit[n];
        n++;
    }
    cout<< ans<< endl;
}


Measured memory_bytes: 11136
s = input()
n = len(s)
mod = 10**9+7
dp = [[0]*13 for i in range(n+5)]#dp[i][j] :=先頭i文字を見たとき、その数字を13で割ったあまりがｊであるような場合の数
dp[0][0] = 1#先頭０文字は”０”　で、１３で割ったあまりは０だから　dp[0][0] = 1
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for d in range(10):
                dp[i+1][(j*10+d)%13] += dp[i][j]
                dp[i+1][(j*10+d)%13] %= mod
                
        else:
            dp[i+1][(j*10+int(s[i]))%13] += dp[i][j]
            dp[i+1][(j*10+int(s[i]))%13] %= mod
ans = dp[n][5]
print(ans)

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

using namespace std;

typedef long long ll;



bool isOK(ll value,int key)
{
  if(value>=key)
    return true;
  else
    return false;
}

int main()
{
  ll N;
  int K;
  cin >> N >> K;

  
  vector<int> h(N);

  int i;
  for(i=0;i<N;i++)
    cin >> h[i]; 

  sort(h.begin(), h.end());
  
  ll left  = -1;
  ll right = N;

  if(h[N-1]<K)
    {
      cout << 0 << endl;
      return 0;
    }

  ll mid;
  while(right-left>1)
    {
      mid = (left+right)/2;

      if(isOK(h[mid], K))
	 right = mid;
      else
	left = mid;
    }

  cout << N-1-left << endl;


  return 0;
}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		String S = in.next();
		String T = in.next();
		long lcm = lcm(M, N);
		long gcd = gcd(M, N);
		long ans = lcm;
		long step = ((long) N / gcd) * ((long) M / gcd);
		for (long i = 0; i < lcm; i += step) {
			if (S.charAt((int) (i * gcd / M)) != T.charAt((int) (i * gcd / N))) {
				ans = -1;
				break;
			}
		}
		System.out.println(ans);
		in.close();

	}

	//最大公約数を求める関数。ｍ＞ｎの必要がある。
	static long gcd(long x, long y) {
		if (x < y) {
			long tmp = y;
			y = x;
			x = tmp;
		}
		if (y == 0) {
			return x;
		}
		return gcd(x % y, y);
	}

	//最小公倍数を求める関数。ｍ＞ｎの必要がある。
	static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}
}

Measured memory_bytes: 27044
from collections import defaultdict

N, K = list(map(int, input().split()))
d = {}
for i in range(1, N+1):
    d[i] = []
for k in range(1, K+1):
    input()
    for i in map(int, input().split()):
        d[i].append(k)
count = 0
for i in range(1, N+1):
    if len(d[i]) == 0:
        count += 1
print(count)


Measured memory_bytes: 9568
#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(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

ll func_xor(ll x)
{
  ll sub = (x%2==0 ? x/2 : x/2+1);
  if(sub%2==0) sub = 0;
  else sub = 1;
  return sub^(x%2==0 ? x : 0);
}

int main()
{
  ll a,b;
  cin >> a >> b;
  ll a_xor = (a>0 ? func_xor(a-1) : 0);
  ll b_xor = func_xor(b);
  ll res = a_xor ^ b_xor;
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256