akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    
template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}       

int main(){
    int c=0,d=0,di=0,n,h,w,l,r,ans=0,ptr=0;
    string s="",s1,s2;
    cin >> n;
    if(n==0){
        s = "0";
    }
    else{
        while(n!=0){
            if(abs(n)%2==1){
                s = "1" + s;
                n = (n-1)/(-2);
            }
            else{
                s = "0" + s;
                n = n/(-2);
            }
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    string s;
    cin>>s;
    rep (i,0,3)
    {
        if (s[i]=='7')
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
}


Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
        BufferedReader br_allc = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            int[] array = createListInt(br_allc);
            int n = array[0];
            int m = array[1];
            int[] weighList = new int[n];
            
            int sum_weigh = 0;
            int maximum   = 0;
            
            for(int i = 0; i < n; i++) {
                weighList[i] = ip(br_allc);
                sum_weigh += weighList[i];
                maximum = Math.max(maximum, weighList[i]);
            }
            
            int lisLeft  = maximum;
            int lisRight = sum_weigh;
            
            while(lisLeft < lisRight) {
                int lisMid = (lisLeft + lisRight) / 2;
                int index  = 0;
                sum_weigh  = 0;
                
                for(int i = 0; i < n; i++) {
                    if(sum_weigh + weighList[i] > lisMid) {
                        sum_weigh = weighList[i];
                        index++;
                    } else {
                        sum_weigh += weighList[i];
                    }
                    
                    if(index == m) {
                        break;
                    }
                }
                if(index == m) {
                    lisLeft = lisMid + 1;
                } else {
                    lisRight = lisMid;
                }
            }
            System.out.println(lisLeft);
            
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
    
    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }
    
    static int[] createListInt(BufferedReader br) throws IOException {
       
        String[] lines = br.readLine().split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while(n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);    
        }
        
        return list;
    }
    
    static int ip(BufferedReader s) throws IOException {
            return Integer.parseInt(s.readLine());
    }
}


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

int main(){
  long long int n,k;
  cin>>n>>k;
  vector<long long int> x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  long long int ans=1e18;
  long long int tmp=0;
  for(int i=0;i<=n-k;i++){
    tmp=0;
    if(x[i]<=0&&x[i+k-1]>=0){
      tmp=abs(x[i])+abs(x[i+k-1])+min(abs(x[i]),abs(x[i+k-1]));
    }else{
      tmp=max(abs(x[i]),abs(x[i+k-1]));
    }
    ans=min(ans,tmp);
  }
  //if(ans==1e18)ans=0;
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
import math

if __name__=="__main__":
    n=int(input())
    s=input()
    s=list(s)
    ##print(n,s)
    mid=n//2
    z=0
    leftcount=0
    rightcount=0
    for i in range(0,n):
        if(s[i]=="R"):
            z+=1
    for i in range(0,z):
        if(s[i]=="R"):
            leftcount+=1
            
    print(z-leftcount)

Measured memory_bytes: 10684
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
char a[N];

int main()
{
	int n;
	while(cin >> n){
		for(int i = 0; i < n; i++)
			cin >> a[i];
		int sum = 1;
		for(int i = 1; i < n; i++){
			if(a[i] != a[i-1])
				sum++;
		}
		cout << sum << endl;
	}
	return 0;
} 

Measured memory_bytes: 384
#include <stdio.h>

int main(void){

    long long int k;
    long long int ans=100;
    int cnt=1;

    scanf("%lld",&k);
    // printf("%lld\n",k);

    while(ans<k){
        // printf("%lld\n",ans);
        ans=ans+ans*0.01;
        if (ans>=k)
            break;
        cnt=cnt+1;
    }

    printf("%d\n",cnt);

    return 0;
}

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

int main() {
  long long a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  
  if(b>=a){
    if((b-a)<=(v-w)*t){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
  else{
    if((a-b)<=(v-w)*t){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }

}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> low, med, hig;
  for(int i = 0; i < n; i++){
    int p;
    cin >> p;
    if(p <= a) low.push_back(p);
    else if(b+1 <= p) hig.push_back(p);
    else med.push_back(p);
  }
  cout << min({low.size(), med.size(), hig.size()}) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    string n; //文字列 
    int m,h;  //シャッフル回数
    
    while(1){
        cin >> n >> m;
        if(n == "-") break;
        //string p = "";
        
        for(int i = 0;i < m; i++){
            cin >> h;
            string atama = n.substr(0,h);
            n.erase(0,h);
            n += atama;
            //cout << n << endl;
        }
        cout << n << endl;
        
    }
    
}




Measured memory_bytes: 3196
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = {'a':list(ns())[::-1],'b':list(ns())[::-1],'c':list(ns())[::-1]}
i = 'a'
while s[i]:
    i = s[i].pop()

print(i.upper())

Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
 
 
int main(){
    int n, k;
    int a = 1;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        if(a + k < 2 * a) a += k;
        else a *= 2;
    }
    cout << a << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    string s[n]; for (int i = 0; i < n; i++) cin >> s[i];
    int ans = 1<<30;
    for (int i = 0; i < n; i++) {
        int c = count(s[i].begin(), s[i].end(), '.');
        if (c < n) ans = min(ans, c+1);
        for (int j = 0; j < n; j++) {
            if (s[j][i] == '#') ans = min(ans, c);
        }
    }
    for (int j = 0; j < n; j++) {
        for (int i = 0; i < n; i++)
            if (s[i][j] =='.') { ans++; break; }
    }
    cout << (ans >= 1<<30 ? -1 : ans) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	int R, C, K;
	cin >> R >> C >> K;
	vvl grid(R, vl(C));
	for (int i = 0; i < K; ++i)
	{
		int r, c;
		ll v;
		cin >> r >> c >> v;
		grid[r - 1][c - 1] = v;
	}

	vector<vvl> dp(4, vvl(R,vl(C)));
	if (grid[0][0] > 0)
		dp[1][0][0] = grid[0][0];
	for (int i = 0; i < R; ++i)
	{
		for (int j = 0; j < C; ++j)
		{
			if(i < R-1)
			for (int k = 0; k <= 3; ++k)
			{
				dp[0][i + 1][j] = max(dp[0][i+1][j], dp[k][i][j]);
				dp[1][i + 1][j] = max(dp[1][i+1][j], dp[k][i][j] + grid[i + 1][j]);
			}
			if(j < C-1)
			for (int k = 0; k <= 3; ++k)
			{
				dp[k][i][j + 1] = max(dp[k][i][j + 1], dp[k][i][j]);
				if (k <= 2)
				{
					dp[k + 1][i][j + 1] = max(dp[k + 1][i][j + 1], dp[k][i][j] + grid[i][j + 1]);
				}
			}
		}

	}
	ll ans = 0;
	for (int k = 0; k < 4; ++k)
		ans = max(ans, dp[k][R - 1][C - 1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 425820
#include<stdio.h>
int main()
{
    int t,i,a,b,n,j;
    while(scanf("%d",&t)!=EOF)
    {
        b=0;
        for(j=0;j<t;j++)
        {
            n=0;
            scanf("%d",&a);
            for(i=2;i*i<=a;i++)
                if(a%i==0){n=1;break;}
            if(n==0)
                b++;
        }
        printf("%d\n",b);
    }
    return 0;
}



Measured memory_bytes: 2092
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int a,t,ans=0;
	cin>>a;
	while(a>0)
	{
		t=a%10;
		a=a/10;
		if(t==1) ans++;
	}
	cout<<ans<<endl;
}

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

struct query{
  int type;
  ll value;
  query(int a=0,ll b=0):type(a),value(b){}
};

#define SZ (1<<17)
struct segtree{
  query s[SZ*2];
  ll t[SZ*2],u[SZ*2];

  void init(){
    for(int i=0;i<SZ*2;i++){
      s[i]=query();
      t[i]=u[i]=0;
    }
  }
  
  void func(int k,int l,int r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(int k,int l,int r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    int m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(int a,int b,query x,int k=0,int l=0,int r=SZ){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      int m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=min(u[k*2+1],u[k*2+2]);
    }
  }

  ll Getsum(int a,int b,int k=0,int l=0,int r=SZ){
    if(b<=l || r<=a)return 0;
    compute(k,l,r);
    if(a<=l && r<=b){
      return t[k];
    }else{
      int m=(l+r)/2;
      ll lv=Getsum(a,b,k*2+1,l,m);
      ll rv=Getsum(a,b,k*2+2,m,r);
      return lv+rv;
    }
  }
};


segtree T,U;
int N;
char str[100005];
int A[100005];

int main(){
  
  scanf("%d",&N);
  scanf("%s",str);

  for(int i=0;i<N;i++)    A[i]=str[i]-'0';


  
  for(int i=0;i<N;i++){
    T.Update(i,i+1,query(2,A[i]));
    if(i+1<N){
      U.Update(i,i+1,query(2,A[i]*A[i+1]));
    }
  }
  int Q;
  scanf("%d",&Q);
  while(Q--){

    
    int l,r,x;
    scanf("%d %d %d",&l,&r,&x);
    l--;
    
    T.Update(l,r, query(2,x));




    if(r-l>1){
      U.Update(l,r-1,query(2,x));
    }



    if(l-1>=0){
      U.Update(l-1,l,query(2,0));


      if(T.Getsum(l-1,l) * T.Getsum(l,l+1) == 1 ){


        U.Update(l-1,l,query(2,1));
      }

      //                  cout<<l<<' '<<r<<' '<<x<<endl;            
    }
    

    
    if(r+1<=N){
      U.Update(r-1,r,query(2,0));
      if(T.Getsum(r-1,r)*T.Getsum(r,r+1) == 1 ){
        U.Update(r-1,r,query(2,1));
      }
    }

    //    cout<<endl;
    printf("%lld\n",T.Getsum(0,SZ)-U.Getsum(0,SZ));
    /*
    for(int i=0;i<N;i++)cout<<T.Getsum(i,i+1);
    cout<<endl;

    for(int i=0;i<N;i++)cout<<U.Getsum(i,i+1);
    cout<<endl;
    */
  }
  return 0;
}

Measured memory_bytes: 18172
n = int(input())
a = [int(i) for i in input().split()]

b = []
count = 0
for i in range(n):
    count += 1 
    gyaku = (n-1) - i
    if count%2 == 1:
        b.append(a[gyaku])

count = 0
if n%2 == 0:
    for i in range(n):
        count += 1
        if count%2 == 1:
            b.append(a[i])
else:
    for i in range(n):
        count += 1
        if count%2 == 0:
            b.append(a[i])

print(" ".join(map(str, b)))

Measured memory_bytes: 29764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<double, double> P;
class Dinic
{
    struct edge
    {
        long long int to, cap, rev;
    };

    int n;
    vector<vector<edge>> G;
    vector<long long int> level;
    vector<long long int> iter;

    void bfs(int s)
    {
        level.assign(n, -1);
        queue<int> que;
        que.push(s);
        level[s] = 0;
        while (que.size())
        {
            int v = que.front();
            que.pop();
            for (int i = 0; i < G[v].size(); i++)
            {
                edge &e = G[v][i];
                if (e.cap > 0 && level[e.to] < 0)
                {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    long long int dfs(int v, int t, long long int f)
    {
        if (v == t)
            return f;
        for (int i = iter[v]; i < G[v].size(); i++)
        {
            edge &e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to])
            {
                long long int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0)
                {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:
    Dinic(int n) : n(n), G(n), level(n), iter(n) {}

    void addEdge(int from, int to, long long int cap)
    {
        G[from].push_back({to, cap, int(G[to].size())});
        G[to].push_back({from, 0, int(G[from].size()) - 1});
    }

    long long int max_flow(int s, int t)
    {
        long long int flow = 0;
        while (1)
        {
            bfs(s);
            if (level[t] < 0)
                return flow;
            iter.assign(n, 0);
            long long int f;
            while ((f = dfs(s, t, 1e18)) > 0)
            {
                flow += f;
            }
        }
    }
};

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

    Dinic d(n + 1);

    for (int i = 0; i < m; i++)
    {
        int a,b,c;
        cin >> a >> b >> c;
        d.addEdge(a,b,c);
    }
    cout << d.max_flow(0, n-1) << endl;
}


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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 2e5 + 10;
const int mod = 1e9 + 7;

char s[N], t[N];
int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (~scanf("%s%s", &s, &t))
    {
        int len = strlen(s);
        int ans = 0;
        for (int i = 0; i < len; i++)
        {
            if (s[i] != t[i]) ans++;
        }
        cout << ans << endl;
    }

    return 0;
}


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

int main(void){
    int d;
    cin >> d;
    vector<int> c(26);
    for (int i = 0; i < 26; i++) cin >> c.at(i);
    
    vector<vector<int>> s (d, vector<int> (26));
    for(int j = 0; j < d; j++) for(int i = 0; i < 26; i++) cin >> s.at(j).at(i);
    
    vector<int> score(d,0), contest(d,-1);
    vector<vector<int>> last(d,vector<int> (26,-1));
    
    for(int i = 0; i < d; i++) {
        int mx;
        for(int j = 0; j < 26; j++) {
            int temp = 0;
            for(int k = 0; k < 26; k++) {
             if(k == j) temp += s.at(i).at(k);
             else temp -= c.at(k) * (i - last.at(i).at(k));
            }
            if(j == 0) {
                mx = temp;
                contest.at(i) = j;
            }
            if(temp > mx) {
                mx = temp;
                contest.at(i) = j;
            }
        }
        if(i == 0) score.at(0) = mx;
        else score.at(i) = score.at(i-1) + mx;
        if(i == d-1) break;
        last.at(i+1) = last.at(i);
        last.at(i+1).at(contest.at(i)) = i;
    }
    for(int i = 0; i < d; i++) cout << contest.at(i)+1 << endl;
}



Measured memory_bytes: 3696
# frozen_string_literal: true

k = gets.to_i
s = gets.chomp
n = s.size

M = (10**9 + 7)

# https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-%E4%BA%8C%E9%A0%85%E4%BF%82%E6%95%B0-ncr
@fac = [1, 1]
@finv = [1, 1]
@inv = [1, 1]

2.upto(k + n) do |i|
  @fac[i] = (@fac[i - 1] * i) % M
  @inv[i] = M - @inv[M % i] * (M / i) % M
  @finv[i] = @finv[i - 1] * @inv[i] % M
end

def nCk(n, k)
  return 0 if n < k || n < 0 || k < 0

  @fac[n] * (@finv[k] * @finv[n - k] % M) % M
end

pow26 = [1]
pow25 = [1]
1.upto(k) do |i|
  pow26[i] = (pow26[i - 1] * 26) % M
  pow25[i] = (pow25[i - 1] * 25) % M
end

ans = 0
0.upto(k) do |i|
  ans += ((pow26[k - i] * pow25[i] % M) * nCk(i + n - 1, i)) % M
  ans %= M
end
puts ans


Measured memory_bytes: 78672
import java.util.Scanner;

class Main {
    private static int calcScore(int[][] a, int down) {

        int count = 0;
        for (int j = 0; j < a[0].length; j++) {
            if (j == down) {
                count += a[0][j];
                count += a[1][j];
            }else if( j < down){
                count += a[0][j];
            }else  if(j > down){
                count += a[1][j];               
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String A1 = sc.nextLine();
        String A2 = sc.nextLine();
        sc.close();
        String[] a1_ary = A1.split(" ");
        String[] a2_ary = A2.split(" ");
        int[] a1 = new int[N];
        int[] a2 = new int[N];
        int[][] a = new int[2][N];
        int max = 0;

        for (int i = 0; i < N; i++) {
            a1[i] = Integer.valueOf(a1_ary[i]);
            a2[i] = Integer.valueOf(a2_ary[i]);
        }
        for (int i = 0; i < N; i++) {
            a[0][i] = a1[i];
        }
        for (int i = 0; i < N; i++) {
            a[1][i] = a2[i];
        }

        for (int i = 0; i < N; i++) {
            max = Math.max(calcScore(a, i), max);
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	N += N % 2;
	cout << N / 2 - 1 << endl;
	return 0;
}



Measured memory_bytes: 256
import numpy as np

N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(list(input()))
B = []
for i in range(M):
    B.append(list(input()))
A = np.array(A)
B = np.array(B)


flag = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if np.all(A[i:i+M, j:j+M]==B):
            flag = True

if flag:
    print('Yes')
else:
    print('No')


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

int main()
{
	string s;
	int count = 0;
	
	cin >> s;
	
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') {
			count++;
		}
	}

	cout << count;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S[100000],U;int n,a,b,c,d,p[100000][2];
int main(){
	while(true){
		cin>>a>>b;if(a==0 && b==0){break;}
		for(int i=0;i<a;i++){
			n=0;cin>>U>>c>>d;
			S[i]=U;
			p[i][0]=d-c+1;
			p[i][1]=d;
		}
		for(int i=0;i<b;i++){
			cin>>c;
			for(int j=0;j<a;j++){
				if(c>=p[j][0] && c<=p[j][1]){
					cout<<S[j]<<' '<<c-p[j][0]+1<<endl;
					goto E;
				}
			}
			cout<<"Unknown"<<endl;
			E:;
		}
	}
}

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

long long N,K;
long long cnt;
long long A[200010];
long long f(long long x){
  cnt=0;
  for(int i=0;i<N;i++){
    if(A[i]<=x) continue;
    cnt+=A[i]/x;
  }
  return cnt;
}
  
int main(){
  cin>>N>>K;
  long long maxA=0;

  for(int i=0;i<N;i++){
    cin>>A[i];
    maxA=max(maxA,A[i]);
  }
  if(K==0){
    cout<<maxA<<endl;
    return 0;
  }
  
  long long l=0;
  long long r=1000000007;
  while(l+1<r){
    long long m=(l+r)/2;
    //cout<<m<<endl;
    if(f(m)<=K){
      r=m;
    }
    else{
      l=m;
    }
  }
  //cout<<l<<" "<<r<<"#"<<endl;
  cout<<r<<endl;
  return 0;
}

    

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

using namespace std;

int a[200002], b[200002];

long long ans = 0;
long long t = 1;

int n;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i <= 29; i++) {
		vector <long long> c;
		vector <long long> d;
		for (int j = 1; j <= n; j++) {
			c.push_back(b[j] % (2 * t));
			d.push_back(a[j] % (2 * t));
		}
		sort(c.begin(), c.end());
		long long aux = 0;
		for (int j = 0; j < n; j++) {
			aux += lower_bound(c.begin(), c.end(), 2 * t - d[j]) - c.begin();
			aux -= lower_bound(c.begin(), c.end(), 1 * t - d[j]) - c.begin();
			aux += lower_bound(c.begin(), c.end(), 4 * t - d[j]) - c.begin();
			aux -= lower_bound(c.begin(), c.end(), 3 * t - d[j]) - c.begin();
		}
		ans += t * (aux % 2);
		t = t * 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6840
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 100000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

ll M = MOD;
ll mpow(ll x, ll n) { //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}

int main() {
	int N; cin >> N;
	ll cnt = 0;
	for (int i = 1; i <= N; i++) {
		string s = to_string(i);
		string t = "";

		if (i % 10 == 0) {
			//cout << i << " " << cnt << endl;
			continue;
		}
		t.push_back(s[s.size() - 1]);
		t.push_back(s[0]);
		if (s[0] == s[s.size() - 1]) {
			cnt++;
		}

		while (t.size() < to_string(N).size()) {
			cnt += mpow(10, t.size() - 2);
			t.insert(1, "0");
		}
		// tの桁数 == Nの桁数

		if (stoi(t) > N) {
			//cout <<  i<< " " << cnt << endl;
			continue;
		}
		//このとき t <= N
		//先頭の桁で場合分け
		if (t[0] < to_string(N)[0]) {
			cnt += mpow(10, t.size() - 2);
		}
		else {//先頭の値が同じ
			if (t[t.size() - 1] <= to_string(N)[to_string(N).size() - 1]) {
				//tの末尾がNの末尾未満->10のpowerでよい
				// t = 1003 N = 1xx4,11xx3
				ll temp = 0;
				if (to_string(N).size() > 2) {
					temp += stoi(to_string(N).substr(1, to_string(N).size() - 2));
				}
				cnt += temp + 1;
			}
			else {
				// t = 1003 N = 1xx2
				ll temp = stoi(to_string(N).substr(1, to_string(N).size() - 2));
				cnt += temp;
			}
		}

		//cout << i << " " << cnt << endl;
	}
	
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  
  if (a+b>c+d){
    cout << "Left" << endl;
  }
  if (a+b<c+d) {
    cout << "Right" << endl;
  }
  if (a+b==c+d){
    cout << "Balanced" << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOR(i,n,m) for (int i=n; i<(int)(m); ++i)
#define ALL(x) x.begin(), x.end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define in(i, n) (0 <= (i) && (i) < (n))
#define on(bit, i) (((bit >> i) & 1) == 1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int INF = 1e9+7;

int N, T;
int a[100000];
map<int, int> mp;

int main(void) {
  cin >> N >> T;
  REP(i, N) cin >> a[i];
  int mx = -1e9 - 7;
  for (int i = N - 1; i >= 0; i--) {
    mp[mx - a[i]]++;
    chmax(mx, a[i]);
  }
  auto it = mp.end(); it--;
  cout << it->second << endl;
  return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
   
    //cin>>t;
    t=1;
    while(t--){
        ll a ,b,c;
        cin>>a>>b>>c;
        if(c<=a+b)cout<<"No";
        else if((c-a-b)*(c-a-b)>4*a*b)cout<<"Yes";
        else cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 256
package main

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

type City struct {
	Ken   int
	Year  int
	Index int
	ID    string
}

func NewLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

type Citys []City

func (c Citys) Len() int           { return len(c) }
func (c Citys) Swap(i, j int)      { c[i], c[j] = c[j], c[i] }
func (c Citys) Less(i, j int) bool { return c[i].Year < c[j].Year }

func main() {
	sc := bufio.NewScanner(os.Stdin)
	line := NewLine(sc)
	words := strings.Fields(line)
	kenLength, _ := strconv.Atoi(words[0])
	cityLength, _ := strconv.Atoi(words[1])
	citys := make([]City, cityLength, cityLength)
	for i := 0; i < cityLength; i++ {
		line = NewLine(sc)
		words = strings.Fields(line)
		ken, _ := strconv.Atoi(words[0])
		year, _ := strconv.Atoi(words[1])
		city := City{
			Ken:   ken,
			Year:  year,
			Index: i,
			ID:    "",
		}
		citys[cityLength-i-1] = city
	}
	sort.Sort(Citys(citys))
	kens := make([]int, kenLength, kenLength)
	ids := make([]int, cityLength, cityLength)
	for _, city := range citys {
		kens[city.Ken-1]++
		ids[city.Index] = city.Ken*1000000 + kens[city.Ken-1]
	}
	for _, id := range ids {
		fmt.Printf("%012d\n", id)
	}
}

Measured memory_bytes: 11392
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    ml = 10 ** 10
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            s = str(i)
            t = str(n // i)
            ml = min(ml, max(len(s), len(t)))
    print(ml)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N,S=0;
  
  cin >> N;
  for(int i=1;i<=N;i++){
  	if(i%3!=0&&i%5!=0){
		S+=i;
     	
    }
    
  }

  cout << S << endl;
  
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n-k){
    if(a[i]<a[k+i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 4840
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n, m;
	cin >> n >> m;
	int x, y;
	vector<int> a, b, c, d;
	REP(i, n){
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}
	REP(i, m){
		cin >> x >> y;
		c.push_back(x);
		d.push_back(y);
	}
	vector<int> an(n);
	REP(i, n){
		tmp = INTINF;
		REP(j, m){
			if(tmp > abs(a[i]- c[j]) + abs(b[i]-d[j])){
				tmp = abs(a[i]- c[j]) + abs(b[i]-d[j]);
				an[i] = j + 1;
			}
		}
	}
	REP(i,n) cout << an[i] << endl;
}

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

// 問題文の形式でvec値を出力
void print_vec(vector<int> vec) {
  cout << "{ ";
  for (int i = 0; i < vec.size(); i++) {
    cout << vec.at(i) << " ";
  }
  cout << "}" << endl;
}

int count_order(vector<int> a) {
    vector<int> b(a.size());
    for(int i = 0; i < a.size(); i++) {
        b.at(i) = i + 1;
    }
    int ans = 1;
    //print_vec(a);
    do {
        bool check = true;
        //print_vec(b);
        for(int i = 0; i < a.size(); i++) {
            if(a.at(i) != b.at(i)) {
                ans++; 
                check = false;
                break;
            }
        }
        if(check) break;
    } while(next_permutation(b.begin(),b.end()));
    return ans;
}

int main() {
    int N; cin >> N;
    vector<int> P(N),Q(N);
    vector<int> a(N),b(N);
    for(int i = 0; i < N; i++) {
        cin >> P.at(i);
    }
    for(int i = 0; i < N; i++) {
        cin >> Q.at(i);
    }

    cout << abs(count_order(P) - count_order(Q)) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

const int MAX_N = 60;
int N, M;
int a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> M;

    rep (i, 1, N) {
        std::cin >> a[i] >> b[i];
    }

    rep (i, 1, M) {
        std::cin >> c[i] >> d[i];
    }

    rep (i, 1, N) {
        int ret = 1;
        int dist = abs(a[i] - c[1]) + abs(b[i] - d[1]);
        rep (j, 2, M) {
            if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < dist) {
                dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                ret = j;
            }
        }
        std::cout << ret << std::endl;
    }
    
    return 0;
}

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

int main(){
	int n, m;
	string s;
	string ss[7] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
	while(cin >> s){
		for(int i = 0; i < 7; i++){
			if(s == ss[i]){
				if(i == 6)
					printf("%d\n",i+1);
				else 
					printf("%d\n",6-i);
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class B2SnukesColoring2ABCEdit {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int h, w, n;
	    in >> w >> h >> n;
        int up = h, down = 0, right = w, left = 0;
        int x, y, a;
        for(int i=0; i<n; i++){
            in >> x >> y >> a;
            if(a == 1){
                chmax(left, x);
            }
            if(a == 2){
                chmin(right, x);
            }
            if(a == 3){
                chmax(down, y);
            }
            if(a == 4){
                chmin(up, y);
            }
        }

        int res = (right-left)*(up-down);
        if(right - left < 0 || up - down < 0) out << 0 << endl;
        else out << res << endl;
	}
};


int main() {
	B2SnukesColoring2ABCEdit solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String S=gs();
	    int K=gi();
	    String[] sa=new String[K];

	    for(int i=0; i<K;i++) {
        	sa[i]=null;
        }

        for(int i=0; i<S.length();i++) {
        	if(sa[K-1] != null && sa[K-1].compareTo(S.substring(i, i+1)) <= 0)continue;
        	for(int j=i+1; j<=S.length();j++) {
            	String s=S.substring(i, j);
            	for(int k=0;k<K;k++) {
            		String s2=sa[k];
            		if(s.equals(s2))break;
            		if(s2==null || s.compareTo(s2) < 0) {
            			for(int l=K-1;l>k;l--) {
                            sa[l]=sa[l-1];
                    	}
            			sa[k]=s;
            			break;
            		}
            	}
            }
        }

		System.out.println(sa[K-1]);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 57140
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main(void) {
  int n, m, c, a;
  cin >> n >> m >> c;
  vector<int> b(m);
  int ans = 0;
  rep(i, m) cin >> b[i];
  rep(i, n) {
    int total = 0;
    rep(j, m) {
      cin >> a;
      total += a * b[j];
    }
    if (total + c > 0) ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

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

		if (a > b) {
			System.out.println("a > b");
		} else if (a < b) {
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}
	}
}


Measured memory_bytes: 26164
N, M = map(int,input().split())
A = []
for i in range(N):
  a, b = map(int,input().split())
  A.append([a, b])
A = sorted(A)
count = 0
answer = 0
for i in range(N):
  count += A[i][1]
  if count > M:
    count -= A[i][1]
    answer += A[i][0] * (M - count)
    break
  else:
    answer += A[i][1] * A[i][0]
print(answer)

Measured memory_bytes: 20816
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



int main() {
    int candidates[] = {1, 2, 4, 8, 16, 32, 64, 128};
    int n;
    cin >> n;

    int i = 0;
    for (; i < 8; i++) {
        if(n < candidates[i]) break;
    }

    cout << candidates[i-1] << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(input())
	k, _ := strconv.Atoi(input())

	cntList := make([]uint, n)
	for i := 0; i < n; i++ {
		score := i + 1
		for score < k {
			score *= 2
			cntList[i]++
		}
	}

	ans := float64(0)
	for i := 0; i < n; i++ {
		d := 1 << cntList[i]
		d *= n
		ans += 1 / float64(d)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
import collections

S = list(map(int, list(input())))[::-1]
S = [(S[i] * pow(10, i, 2019)) % 2019 for i in range(len(S))]
for i in range(1, len(S)):
    S[i] = (S[i] + S[i-1]) % 2019 

C = collections.Counter(S)
ans = 0
for x in C.keys():
    if x == 0:
        ans += C[0] + C[0] * (C[0] - 1) // 2
    else:
        ans += C[x] * (C[x] - 1) // 2
print(ans)

Measured memory_bytes: 18844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
// mint
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n):fact(n+1),ifact(n+1) {
		//assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
	mint p(int n, int k) {
		return fact[n]*ifact[n-k];
	}
} c(10000005);

int main() {
	int n,m;
	cin >> n >> m;
	mint ans = 0;
	rep(i,n+1) {
		mint now = c(n,i);
		now *= c.p(m,n);
		now *= c.p(m-i,n-i);
		if (i&1) now = -now;
		ans += now;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 159356
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string S;cin>>S;
    int ans=700;
    REP(i,3)if(S[i]=='o')ans+=100l;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int main()
{
    ll s;
    cin >> s;
    vector<ll> dp(s + 5);

    for (int i = 0; i < s + 1; i++)
    {
        if (i < 3)
        {
            continue;
        }
        else if (i == 3)
        {
            dp[i] = 1;
            continue;
        }
        dp[i] = dp[i - 1] + dp[i - 3];
        dp[i] %= 1000000007;
    }
    cout << dp[s] << endl;

    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		doIt();

	}
	public static boolean isContain(String s, char c){
		int len = s.length();
		for(int i = 0; i < len; i++){
			//char c1 = ;
			if(s.charAt(i) == c){
				return true;
			}
		}
		return false;

	}
	public static void doIt(){
		String right = "yuiophjklnm";
		boolean isRight = false;
		
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		while(s.equals("#") == false){
			int count = 0;
			int len = s.length();
			//初期化する
			if(isContain(right,s.charAt(0))){
				isRight = true;
			}
			else{
				isRight = false;
			}
			for(int i = 1; i < len; i++){
				char c = s.charAt(i);
				if(isContain(right,c)){
					if(isRight == false){
						count++;
						isRight = true;
					}
				}
				else{
					if(isRight){
						count++;
						isRight = false;
					}
				}
			}
			System.out.println(count);

			s = sc.next();
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000007
typedef long long int lint;

int main() {
  int N,K;
  cin >> N >> K;
  if(N%K == 0){co(0);}
  else{co(1);}
  
  return 0;
}

Measured memory_bytes: 3544
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        int vis[5]={0};
        vis[a]=vis[b]=1;
        if(vis[1]==0)cout<<1<<endl;
        else if(vis[2]==0)cout<<2<<endl;
        else if(vis[3]==0)cout<<3<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

void swap(int a,int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main(void) {
	ll a,b,c;
	cin >> a>>b>>c;

	if (a+b<c) {
		if (4 * a*b < (c - a - b)*(c - a - b)) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3568
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b,c,d=map(int,readline().split())
    flag=0
    while a>=1 and c>=1:
        if flag==0:
            c-=b
            flag=1
        else:
            a-=d
            flag=0
    
    if a>0:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

Measured memory_bytes: 9192
import heapq

n = int(input())
v = list(map(float, input().split()))

heapq.heapify(v)
while len(v) > 1:
    x = heapq.heappop(v)
    y = heapq.heappop(v)
    heapq.heappush(v, (x + y) / 2)

print(v[0])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    int in;
    vector<int> H;
    vector<bool> good;
    for (int i = 0; i < N; i++)
    {
        cin >> in;
        H.emplace_back(in);
        good.emplace_back(true);
    }
    
    int inA, inB;
    
    for (int i = 0; i < M; i++)
    {
        cin >> inA >> inB;
        if (H[inA - 1] < H[inB - 1])
        {
            good[inA - 1] = false;
        }else if (H[inA - 1] > H[inB - 1])
        {
            good[inB - 1] = false;
        }else if (H[inA - 1] == H[inB - 1])
        {
            good[inA - 1] = false;
            good[inB - 1] = false;
        }
        
        
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (good[i]) ans++;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3528