akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        x: usize
    }
    
    let mut nums : Vec<usize> = vec![0; n + 1];
    
    nums[0] = 1;
    for i in 0..n {
        nums[i + 1] = 2 * nums[i] + 3;
    }
    
    let mut patty_nums : Vec<usize> = vec![0; n + 1];
    
    patty_nums[0] = 1;
    for i in 0..n {
        patty_nums[i + 1] = 2 * patty_nums[i] + 1;   
    }
    
    fn count(n: usize, x: usize, nums: &Vec<usize>, patty_nums: &Vec<usize>) -> usize {
        if x == 0 {
            return 0;
        }
        
        if n == 0 {
            return 1;
        }
        
        if x == (nums[n] + 1) / 2 {
            1 + patty_nums[n - 1]
        } else if x < (nums[n] + 1) / 2 {
            count(n - 1, x - 1, nums, patty_nums)
        } else {
            1 + patty_nums[n - 1] + count(n - 1, x - 2 - nums[n - 1], nums, patty_nums)
        }
    }
        
    println!("{}", count(n, x, &nums, &patty_nums));
}

Measured memory_bytes: 4352
import sys
# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def cn(n):
  i=1
  count=0
  while n >= i:
    n=n-i
    count+=1
    i+=1
  return count;


#1入力
N=int(input())
#X,Y=(int(x) for x in input().split())
#print(N)
#複数入力
#A=input().split()
#A_int = [int(s) for s in A]
#print(A_int)
#print(N)
check=prime_factorize(N)
#print(check)
#print(check[0])
ans=0;

#ここからループ
while check:
  get=check[0]
  num=check.count(get)
  del check[:num]
  #print(check)
  #print(get,num)
  ans+=cn(num)
  
print(ans)


Measured memory_bytes: 9148
import math


def read_input():
    n = int(input())

    ratios = []
    for i in range(n):
        t, a = map(int, input().split())
        ratios.append((t, a))

    return n, ratios


def get_votes(ex_votes, ratio):
    def check_votes(a, b):
        return a[0] <= b[0] and a[1] <= b[1]

    def div_ceil(a, b):
        if a % b == 0:
            return a //b
        else:
            return a // b + 1

    base = div_ceil(sum(ex_votes), (ratio[0] + ratio[1]))
    base = int(base)
    while True:
        test_votes = (ratio[0] * base, ratio[1] * base)
        if check_votes(ex_votes, test_votes):
            return test_votes
        else:
            diff_votes = (test_votes[0] - ex_votes[0], test_votes[1] - ex_votes[1])
            if diff_votes[0]/ratio[0] < diff_votes[1]/ratio[1]:
                base += div_ceil(-diff_votes[0], ratio[0])
            else:
                base += div_ceil(-diff_votes[1], ratio[1])
            base = int(base)


def submit():
    n, ratios = read_input()

    votes = ratios[0]
    for ratio in ratios[1:]:
        votes = get_votes(votes, ratio)

    print(sum(votes))


if __name__ == '__main__':
    submit()


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <stdio.h>

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


int main(){
    double a,b,x; cin >> a >> b >> x;
    double S = x/a;
    double PI = acos(-1);
    
    double ans=0;

    if (a*b/2 <= S) {
        double h = 2*(a*b-S)/a;
        double sita = atan(h/a);
        ans = sita/(2*PI)*360;


    }else{
        double h = S*2/b;
        double sita = atan(b/h);
        ans = sita/(2*PI)*360;

    }
    printf("%.10f\n", ans);
    

     
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
	int PreX=0,PreY=0,PreT=0,step,t,x,y;
	scanf("%d",&step);
	while(step--)
	{
		scanf("%d %d %d",&t,&x,&y);
		if((abs(PreX-x)+abs(PreY-y)>abs(PreT-t))||(abs(PreT-t)%(abs(PreX-x)+abs(PreY-y))!=0))
		{
			printf("No");
			return 0;
		}
		PreX=x;PreY=y;PreT=t;
	}
	printf("Yes");
    return 0;
 }

Measured memory_bytes: 128
import java.util.*;

public class Main {

    static int mod = 1_000_000_007;

    static long[][] mul(long[][] A, long[][] B) {
        long[][] C = new long[A.length][B[0].length];
        for (int i=0;i<A.length;i++) {
            for (int k=0;k<B.length;k++) {
                for (int j=0;j<B[0].length;j++) {
                    C[i][j] = (C[i][j]+A[i][k]*B[k][j])%mod;
                }
            }
        }
        return C;
    }

    static long[][] pow(long[][] A, long n) {
        long[][] B = new long[A.length][A.length];
        for (int i=0;i<A.length;i++) {
            B[i][i]=1;
        }
        while (n>0) {
            if ((n&1)==1) {
                B = mul(B, A);
            }
            A = mul(A, A);
            n>>=1;
        }
        return B;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long K = sc.nextLong();
        long[][] a = new long[N][N];
        for (int i=0;i<N;i++) {
            for (int j=0;j<N;j++) {
                a[i][j] = Integer.parseInt(sc.next());
            }
        }
        a = pow(a, K);
        long ans = 0;
        for (int i=0;i<N;i++) {
            for (int j=0;j<N;j++) {
                ans = (ans + a[i][j]) % mod;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 28568
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int Maxn=15;
int n,m,ans;
int s[Maxn+10][Maxn+10];
bool vis[Maxn+10];
int cnt[Maxn+10];
void dfs(int x,int tot)
{
	if(x==n+1)
	{
		bool flag=1;
		for(int i=1;i<=n;i++)
		{	
            if(vis[i])
			{
                for(int j=1;j<=n;j++)
			    	if((s[i][j]==1&&!vis[j])||(s[i][j]==0&&vis[j])) flag=0;
            }
        }
        if(flag) ans=max(ans,tot);
		return;
	}
	vis[x]=1,dfs(x+1,tot+1);
	vis[x]=0,dfs(x+1,tot);
}
void Solve()
{
    scanf("%d",&n);
	for(int i=1;i<=15;i++)
		for(int j=1;j<=15;j++) s[i][j]=-1;
    int a,b;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&m);
		for(int j=1;j<=m;j++) scanf("%d%d",&a,&b),s[i][a]=b;
	}
	dfs(1,0);
	printf("%d",ans);
}
int main()
{
    Solve();
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h> 
#include <math.h>
int main(void)
{
	int i, r;
	double n[1000], sum = 0,ave;

	while (1)
	{
		scanf("%d", &r);
		if (r == 0)
		{
			break;
		}
		for (i = 0;i < r;i++)
		{
			scanf("%lf", &n[i]);
			sum = sum + n[i];
		}
		ave = sum / r;
		sum = 0;

		for (i = 0;i < r;i++)
		{
			sum = sum + (n[i] - ave)*(n[i] - ave);
		}
		sum = sum / r;
		printf("%lf\n", sqrt(sum));
		sum = 0;
	}
	return 0;
}

Measured memory_bytes: 664
#include <iostream>
#include <cassert>
#include <algorithm>
#include <string>
#include <initializer_list>
#define N int(3e3+1)
using namespace std;
int maxid(initializer_list<int> lst,int& mx)
{
    int ret=-1;
    mx=0;
    for(int i=0;i<lst.size();++i){
        if(*(lst.begin()+i)>mx){
            mx=*(lst.begin()+i),ret=i;
        }
    }
    return ret;
}
int dp[N][N];
int pre[N][N];
int main(int argc,char ** argv)
{
    string s,t,ans;
    cin>>s>>t;
    for(int i=0;i<s.length();++i){
        for(int j=0;j<t.length();++j){
            pre[i+1][j+1]=maxid({dp[i][j+1],dp[i+1][j],s[i]==t[j]?dp[i][j]+1:0},dp[i+1][j+1]);
        }
    }
    int mlen=dp[s.length()][t.length()],si=s.length(),ti=t.length();
    cerr<<mlen<<endl;
    ans.resize(mlen);
    while(mlen){
        int mid=pre[si][ti];
        switch(mid){
            case 0:
                --si;
                break;
            case 1:
                --ti;
                break;
            case 2:
                ans[--mlen]=s[--si];
                assert(s[si]==t[--ti]);
                break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 73984
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define int long long 
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;



int power(int x, int y) 
{ 
   int res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  
 
        y = y>>1; 
 
        if (x<=100000000)
        x = (long long)(x*x);
 
        //cout<<x<<'\n'; 
    } 
    return res; 
} 

int gcd (int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}






void solve()
{
    string s;
    string t;
    cin>>s>>t;
    int count=0;
    for(int i=0;i<(int)s.size();i++){
        if(s[i]!=t[i])
            count++;
    }

    cout<<count<<endl;

    return;
}




int32_t main()
{
    IOS;

    solve();
    return 0;
}

Measured memory_bytes: 3768
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let mut a = read::<i64>();
  let mut b = read::<i64>();
  let mut c = read::<i64>();
  let a_is_even = a % 2 == 0;
  let b_is_even = b % 2 == 0;
  let c_is_even = c % 2 == 0;
  let mut ans = 0;

  if !a_is_even && !b_is_even && !c_is_even {
    a -= 1;
    b -= 1;
    c -= 1;
  } else {
    if !a_is_even {
      ans += 1;
      a -= 1;
    }
    if !b_is_even {
      ans += 1;
      b -= 1;
    }
    if !c_is_even {
      ans += 1;
      c -= 1;
    }
  }


  let max_v = max(a, max(b, c));
  println!(
    "{}",
    ans + ((max_v - b) / 2) + ((max_v - c) / 2) + ((max_v - a) / 2)
  );
}



Measured memory_bytes: 4352
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]


A.sort()

def calc(A):
    ans = 0
    tmp1 = A[0]
    tmp2 = A[0]

    count = 1
    flag = True
    i = 1
    j = 1
    while True:
        if flag:
            if tmp1 > tmp2:
                tmp1, tmp2 = tmp2, tmp1
        else:
            if tmp1 < tmp2:
                tmp1, tmp2 = tmp2, tmp1


        if count == N:
            break
        if flag:
            ans += abs(tmp1 - A[-i])
            tmp1 = A[-i]
            i += 1
        else:
            ans += abs(tmp1 - A[j])
            tmp1 = A[j]
            j += 1

        count += 1

        if count == N:
            break
        if flag:
            ans += abs(tmp2 - A[-i])
            tmp2 = A[-i]
            i += 1
        else:
            ans += abs(tmp2 - A[j])
            tmp2 = A[j]
            j += 1
        
        count += 1

        flag = not flag
        # print ('A', ans)
    return ans

# print (i, j)
print (max(calc(A[::-1]), calc(A)))


Measured memory_bytes: 7892
#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 << "Right" << endl;
    }else if(A + B > C + D){
        cout << "Left" << endl;
    }else{
        cout << "Balanced" << endl;
    }

}

Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,k,sum=0,i,j,fac[4005],invfac[4005],cnt;
const ll mod=998244353; 
//a>0&&i-a>0,1<=a<=min(k,i-1) 1<=i-a<=k
ll pow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
ll C(ll n,ll m){return fac[n]*invfac[m]%mod*invfac[n-m]%mod;} 
ll neg(ll n){return (n%2)?(-1LL):1LL;}
ll sv(ll n,ll m){return C(n+m-1LL,m-1LL);}
int main()
{
	fac[0]=1;
	for(i=1;i<=4000;i++)fac[i]=fac[i-1]*i%mod;
	invfac[4000]=pow(fac[4000],mod-2LL);
	for(i=3999;i>=0;i--)invfac[i]=invfac[i+1]*(i+1)%mod;
	scanf("%lld%lld",&k,&n);
	for(i=2;i<=2*k;i++)
	{
		sum=0;
		cnt=(min(k,i-1)-max(1LL,i-k)+2)/2;
		for(j=0;j<=cnt;j++)
		{
			if(2*j<=n)sum=(sum+C(cnt,j)*neg(j)*sv(n-2*j,k)%mod+mod)%mod;
		}
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

double PI=acos(-1.0);
#define eps (1e-7)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(Point p) {return Point(x*p.x-y*p.y,x*p.y+y*p.x);}
    Point operator*(double k){return Point(x*k,y*k);}
    Point operator/(double k){return Point(x/k,y/k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}
    double arg(){return atan2(y,x);}
    double dot(Point p){return x*p.x+y*p.y;}
    double det(Point p){return x*p.y-y*p.x;}
};
struct Circle{
    double r;
    Point p;
    Circle(){}
    Circle(Point p,double r):p(p),r(r){}
};
bool isIntersectCC(Circle c1,Circle c2){
    return (c1.p-c2.p).abs()<=c1.r+c2.r+eps;
}
pair<Point,Point> CrossPointsCC(Circle c1,Circle c2){
    assert(isIntersectCC(c1,c2));
    double d=(c1.p-c2.p).abs();
    double k=acos((d*d+c1.r*c1.r-c2.r*c2.r)/(c1.r*d*2));
    return make_pair(c1.p+(c2.p-c1.p)*Point(cos(k),sin(k))*(c1.r/d),c1.p+(c2.p-c1.p)*Point(cos(-k),sin(-k))*(c1.r/d));
}
double x[11],y[11],r[11];
vector<Point> po;
Circle c[11];
double mx;
int n;
bool test(double d){
    po.clear();
    rep(i,n){
        double dist=r[i]*r[i]-d*d;
        if(dist<0) return false;
        c[i]=Circle(Point(x[i],y[i]),sqrt(dist));
        po.pb(c[i].p);
    }
    rep(i,n)FOR(j,i+1,n){
        if(!isIntersectCC(c[i],c[j])){
            continue;
            if((c[i].p-c[j].p).abs()>c[i].r+c[j].r) return false;
            else{
                continue;
            }
        }
        if(abs(c[i].r-c[j].r)+eps>(c[i].p-c[j].p).abs()) continue;
        pair<Point,Point> pp=CrossPointsCC(c[i],c[j]);
        po.pb(pp.first);po.pb(pp.second);
    }
    int sz=po.size();
    rep(i,sz){
        bool flag=true;
        rep(j,n){
            if((po[i]-c[j].p).abs()>c[j].r+eps) flag=false;
        }
        if(flag) return true;
    }
    return false;
}
int main(){
    while(cin>>n,n){
        mx=0;
        rep(i,n){
            cin>>x[i]>>y[i]>>r[i];
            mx=max(mx,r[i]);
        }
        double lb=0,ub=300;
        while(ub-lb>eps){
            double mid=(ub+lb)/2;
            if(test(mid)) lb=mid;
            else ub=mid;
        }
        cout<<fixed<<setprecision(12)<<lb<<endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int x;
  cin >> x;

  cout << ceil((-1 + sqrt(1 + 8 * x)) / 2) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
ll a[maxn];
int  main(){
 //   ios::sync_with_stdio(false);
    ll n  , m;cin >> n >> m;
    ll sum = 0;
    for (int i = 1 ; i <= m ; i++) cin >> a[i] , sum += a[i];
    cout << max(-1ll , n - sum) << endl;
    return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define mod 1000000007
int n;
vector<int>a;
int dp[100010][2]={{0}};
bool game(int k,bool role){
if(dp[k][role]!=-1)return dp[k][role];
bool z=1;
for(int i=0;i<n;i++){
    if(a[i]<=k){
        z&=game(k-a[i],!role);
    }
}
return dp[k][role]=!z;
}
int main(){
memset(dp,-1,sizeof dp);
int k;
cin>>n;
cin>>k;
a=vector<int>(n);
for(int i=0;i<n;i++)cin>>a[i];
bool is=game(k,0);
cout<<(is?"First":"Second")<<'\n';
return 0;}


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

int main() {
  int A, B;
  cin >> A >> B;
  for (int i = 1; i < 1100; i++) {
    if (i * 8 / 100 == A && i * 10 / 100 == B) {
      cout << i << endl;
      break;
    }
    else if (i > 1000) {
      cout << -1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
#define el '\n'
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
const ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

template<typename Type>
struct matrix: public vector< vector <Type> >{
    using T=Type;
    long long MODULO=1e9+7;
    matrix(int r, int c, T val=0){(*this).assign(r,vector<T>(c,val));}
    matrix(const vector<vector<T>> m){
        auto& self=*this;
        self.resize(m.size(), vector<T>(m[0].size()));
        copy(m.begin(), m.end(), self.begin());
    }
    matrix operator*(const matrix& m){
        auto& self=*this; assert(m.size() == self[0].size());
        int rows=self.size(), col=self[0].size();
        matrix<T> ret(rows,col,0);
        for(int i=0;i<rows;++i) for(int j=0;j<(int)m[0].size();++j) for(int k=0;k<col;++k){
                ret[i][j]=(ret[i][j]+1LL*(self[i][k]%MODULO)*(m[k][j]%MODULO))%MODULO;
            }
        return move(ret);
    }
    matrix identity(int rows){
        matrix ret(rows,rows,0); for(int i=0;i<rows;++i) ret[i][i]=1;
        return move(ret);
    }
    matrix operator^(long long n){
        int rows=(*this).size(), col=(*this)[0].size();
        matrix temp=*this;
        assert(rows==col);
        matrix<T> ret=identity(rows);
        while(n){
            if(n&1) ret=ret*temp;
            n>>=1; temp=temp*temp;
        }
        return move(ret);
    }
};


///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());


ll n,k; cin>>n>>k;
vv<vv<ll>> mat(n,vv<ll>(n));
for(int i=0;i<n;++i) for(int j=0;j<n;++j) cin>>mat[i][j];
matrix<ll> dp(mat);
dp=dp^k;
ll ans=0;
for(int i=0;i<n;++i) for(int j=0;j<n;++j) ans=(ans+dp[i][j])%MOD;
cout<<ans<<el;

return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s; cin >> s;
    s.push_back('E');
    vector<pair<char, int>> compress;
    char c = s[0];
    int cnt = 1;
    for (int i = 1; i < s.length(); i++) {
        if (c == s[i]) {
            cnt++;
        } else {
            compress.push_back({c, cnt});
            c = s[i];
            cnt = 1;
        }
    }
    
    vector<int> ans(s.length()-1);
    int dist_from_left = 1;
    int crt_seg = 0;
    for (int i = 0; i < s.length()-1; i++) {
        if (compress[crt_seg].second < dist_from_left) {
            crt_seg++;
            dist_from_left = 1;
        }
        if (crt_seg == compress.size()) break;
        
        if (compress[crt_seg].first == 'R') {
            int move_parity = (compress[crt_seg].second - dist_from_left) % 2;
            if (move_parity) {
                ans[i + compress[crt_seg].second - dist_from_left + 1]++;
            } else {
                ans[i + compress[crt_seg].second - dist_from_left]++;
            }
        } else {
            int move_parity = (dist_from_left - 1) % 2;
            if (move_parity) {
                ans[i - dist_from_left]++;
            } else {
                ans[i - dist_from_left + 1]++;
            }
        }
        
        dist_from_left++;
    }
    
    for (auto &i : ans) {
        cout << i << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 100005

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    string s;
    cin>>s;
    reverse(all(s));
    int n = s.length();
    int c = 0;
    int val = 0;
    ll ans = 0;
    int p = 1;
    int f[2019] = {0};
    for(int i=0;i<n;i++){
        int d = s[i]-'0';
        val = (val + d*p)%2019;
        p = p*10%2019;
        f[val]++;
        if(val==0) ans++;
        ans += f[val]-1;
    }
    cout<<ans;
}


Measured memory_bytes: 3792
#include<stdio.h>
#include<string.h>
int main(void){
  char S[4];
  int i,cnt;
  scanf("%s",S);
  for(i=1;i<4;i++){
    if(S[0]==S[i])cnt++;
  }
  if(cnt != 1){
    printf("No");
    return 0;
  }
  cnt = 0;
  for(i=2;i<4;i++){
    if(S[1]==S[i])cnt++;
  }
  if(cnt == 0){
    if(S[2]==S[3])printf("Yes");
    else printf("No");
  }
  else if(cnt == 1){
    printf("Yes");
  }
  else if(cnt == 2){
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
use std::io::BufRead;
use std::str::{self, FromStr};

pub struct StdinReader<R: BufRead> {
    reader: R,
    buf: Vec<u8>,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(reader: R) -> StdinReader<R> {
        StdinReader {
            reader: reader,
            buf: Vec::new(),
        }
    }

    pub fn reads<T: FromStr>(&mut self) -> T {
        self.read_until(b' ')
    }

    pub fn readl<T: FromStr>(&mut self) -> T {
        self.read_until(b'\n')
    }

    pub fn read_until<T: FromStr>(&mut self, delim: u8) -> T {
        loop {
            self.buf.clear();
            let len = self.reader
                .read_until(delim, &mut self.buf)
                .expect("failed reading bytes");
            match len {
                0 => panic!("early eof"),
                1 if self.buf[0] == delim => (),
                _ => {
                    if self.buf[len - 1] == delim {
                        self.buf.truncate(len - 1);
                    }
                    break;
                }
            }
        }

        let elem = str::from_utf8(&self.buf).expect("invalid utf-8 string");
        elem.parse()
            .unwrap_or_else(|_| panic!(format!("failed parsing: {}", elem)))
    }
}

fn solution<R: BufRead>(mut r: StdinReader<R>) -> String {
    let x: u64 = r.reads();
    let y: u64 = r.readl();
    let mut tmp: u64 = x;
    let mut ans: u64 = 0;
    while tmp <= y {
        ans += 1;
        tmp *= 2;
    }
    format!("{}", ans)
}

fn main() {
    use std::io::stdin;
    let stdin = stdin();
    let r = StdinReader::new(stdin.lock());
    println!("{}", solution(r));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll n,a,b;
	cin >> n >> a >> b;
	vector<vector<ll>> to(n);
	to[a-1].push_back(b-1);
	to[b-1].push_back(a-1);
	rep(i,n-1){
		to[i].push_back(i+1);
		to[i+1].push_back(i);
	}

	vector<vector<ll>> dist(n,vector<ll>(n,1e9));

	rep(i,n){
		// start from i
		queue<ll> q;
		q.push(i);
		dist[i][i] = 0;

		while(!q.empty()){
			ll now = q.front(); q.pop();

			for(ll next : to[now]){
				if(dist[i][next] == 1e9){
					dist[i][next] = dist[i][now] + 1;
					q.push(next);
				}
			}
		}

	}

	vector<ll> res(n-1);
	rep(i,n){
		for(ll j = i+1; j < n; j++){
			assert(dist[i][j] > 0);
			assert(dist[i][j] <= n);
			res[dist[i][j] - 1]++;
		}
	}

	rep(i,n-1) cout << res[i] << endl;
	return 0;

	
}

int main(){

	return mainsolve();
}

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

int main(){

    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++)
    {
        cin >> X.at(i);
    }

    int ans =999999999;
    for(int i=1;i<101;i++){
        int sum =0;
        for(int j =0;j<N;j++){
            sum += pow((X.at(j)-i),2);
        }
        ans = min(ans,sum);
    }


    cout << ans << endl;


}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int blood[4] = {0};
	char bl[3];
	while(scanf("%*d,%s" , bl)!=EOF){
		bl[1] == 'A';
		if(bl[0] == 'B') blood[1]++;
		if(bl[0] == 'O') blood[3]++;
		if(bl[0] == 'A'){
			if(bl[1] == 'B') blood[2]++;
			else blood[0]++;
		}
	}
	printf("%d\n%d\n%d\n%d\n" , blood[0] , blood[1] , blood[2] , blood[3]);
	return 0;
}

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

int main() {
    long long w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(10) << w * h / 2.0 << " " << (x + x == w && y + y == h) << endl;
    return 0;
}

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

int main(){
	// おまじない
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int K,X;
	// 出入力
	cin >> K>>X;
    if(500*K>=X){
        cout<<"Yes"<<"\n";
    }else{
        cout<<"No"<<"\n";
    }


	// cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    long A,B,C,D;
    private long lcm(long x,long y) {
        return x * y / gcd(x,y);
    }
    private long gcd(long x,long y) {
        return y == 0 ? x : gcd(y, x%y);
    }
    private void solve() {
        A = nextLong() - 1;
        B = nextLong();
        C = nextLong();
        D = nextLong();

        long ac = A / C;
        long ad = A / D;
        long acd = A / lcm(C,D);
        long bc = B / C;
        long bd = B / D;
        long bcd = B / lcm(C,D);

        long a = ac + ad - acd;
        long aa = A - a;
        long b = bc + bd - bcd;
        long bb = B - b;
        out.println(bb - aa);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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


int main() {
  int n;
  cin>>n;
  long long a[n];
  bool flg=1;
  for(int i=0;i<n;i++){
  	cin>>a[i];
    if(i==0){if(a[i]!=0) flg=0;}
    if(i){if(a[i]-a[i-1]>1) flg=0;}
  }
  long long ans=0,count=0;
  if(flg){
    for(int i=1;i<n;i++){
      
      if(a[i]>a[i-1]){
        count++;
        ans++;
      }
      else if(a[i]==a[i-1]){
      	ans+=count;
      }
      else{
        count=a[i];
        ans+=count;
      } 
    }
    cout<<ans<<endl;
  }
  else cout<<-1<<endl;
}

Measured memory_bytes: 1792
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	sum := 0
	wr := bufio.NewWriter(os.Stdout)
	for i := 1; ; i++ {
		sum += i
		if d := sum - n; d > 0 {
			for j := 1; j <= i; j++ {
				if j == d {
					continue
				}
				wr.WriteString(strconv.Itoa(j) + "\n")
			}
			wr.Flush()
			return
		}
	}
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		System.out.println(a*a);
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,Q;
  cin >>N>>M>>Q;
  vector <int> L(M);
  vector <int> R(M);
  vector <vector <int>> cnt(N+1,vector <int> (N+1));
  vector <vector <int>> sum(N+1,vector <int> (N+1));
  vector <int> p(M);
  vector <int> q(M);
  for(int i = 0;i<M;i++){
    cin >> L.at(i) >> R.at(i);
    cnt[L.at(i)][R.at(i)]++;
  }  
  for(int i = 0;i<Q;i++){
    cin >> p.at(i) >> q.at(i);
  }
  for(int i = 1;i<N+1;i++){
    for(int k = 1;k<N+1;k++){
      sum[i][k] = sum[i][k-1] + cnt[i][k];
    }
  }
  for(int k = 0;k<Q;k++){
    int ans = 0;
    for(int i = p.at(k);i <= q.at(k); i++){
      ans = ans + sum[i][q.at(k)] - sum[i][i-1];
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 7552
#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>;

const int INF = 1001001001;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    --x1; --y1; --x2; --y2;
    vector<string> C(h);
    rep(i, h) cin >> C[i];
    
    vector<vector<vector<P>>> dist(h, vector<vector<P>>(w, vector<P>(4)));
    rep(i, h) rep(j, w) rep(dir, 4) dist[i][j][dir] = P(INF, INF);
    priority_queue<tuple<int, int, int, int, int>, vector<tuple<int, int, int, int, int>>, greater<tuple<int, int, int, int, int>>> q;
    rep(dir, 4) {
        dist[x1][y1][dir] = P(0, 0);
        q.push(make_tuple(0, 0, dir, x1, y1));
    }
    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, 1, 0, -1};
    
    while (!q.empty()) {
        auto t = q.top(); q.pop();
        int d1, d2, dir, x, y;
        tie(d1, d2, dir, x, y) = t;
        P d = P(d1, d2);
        if (dist[x][y][dir] < d) continue;
        rep(i, 4) {
            if (i == dir) continue;
            int nd1 = d1;
            if (d2 != 0) nd1++;
            P nd = P(nd1, 0);
            if (dist[x][y][i] > nd) {
                dist[x][y][i] = nd;
                q.push(make_tuple(nd1, 0, i, x, y));
            }
        }

        int nx = x + dx[dir];
        int ny = y + dy[dir];
        if (nx < 0 || nx >= h || ny < 0 || ny >= w || C[nx][ny]=='@') continue;
        int nd1 = d1;
        int nd2 = d2 + 1;
        if (nd2 >= k) {
            nd2 = 0;
            nd1++;
        }
        P nd = P(nd1, nd2);
        if (dist[nx][ny][dir] > nd) {
            dist[nx][ny][dir] = nd;
            q.push(make_tuple(nd1, nd2, dir, nx, ny));
        }
    }
    int ans = INF;
    rep(i, 4) ans = min(ans, dist[x2][y2][i].first+(dist[x2][y2][i].second+k-1)/k);
    if (ans == INF) ans = -1;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 144864
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long a = scan.nextInt();
        long b = scan.nextInt();
        long c = scan.nextInt();
        long d = scan.nextInt();
        scan.close();
        long max = a * c;
        
        max = Math.max(max, a * d);
        max = Math.max(max, b * c);
        max = Math.max(max, b * d);

        System.out.println(max);
    }
    
}

Measured memory_bytes: 35780
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    sols = []
    for _ in range(GI()):
        x, y, h = LGIS()
        if h:
            sols.append((x, y, h))

    if len(sols) == 1:
        print(*sols[0])
        return

    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                return

main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b && b==c)
        cout<<"No"<<endl;
   else if (a==b && b!=c)
            cout<<"Yes"<<endl;
   else if (a==c && c!=b)
    cout<<"Yes"<<endl;
   else if (b==c && b!=a)
    cout<<"Yes"<<endl;
   else if (a!=b&&b!=c)
   cout<<"No"<<endl;

}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<ll> pow2(200001, 1);
    rep(i, 200000) pow2[i+1] = pow2[i]*2 % mod;
    map<pair<ll, ll>, int> mp;

    int N; cin >> N;
    ll zerovec = 0;
    rep(i, N){
        ll a, b; cin >> a >> b;
        if(a < 0){
            a = -a; b = -b;
        }
        if(a == 0 && b == 0) zerovec++;
        else if(a == 0){
            b = 1;
            mp[make_pair(a, b)]++;
        }
        else if(b == 0){
            a = 1;
            mp[make_pair(a, b)]++;
        }
        else{
            ll g = __gcd(a, abs(b));
            mp[make_pair(a/g, b/g)]++;
        }
    }

    ll ans = 1;
    for(auto op: mp){
        ll a = op.first.first, b = op.first.second;
        ll cnt = op.second;
        ll pcnt;
        //(a + bi)i = -b + ai, (a + bi)(-i) = b -ai
        if(a == 0){
            pcnt = mp[pair<ll, ll>(1, 0)];
            ans = (ans * ((pow2[cnt] + pow2[pcnt] - 1) % mod)) % mod;
            mp[pair<ll, ll>(0, 1)] = mp[pair<ll, ll>(1, 0)] = 0;
        }
        else if(b == 0){
            pcnt = mp[pair<ll, ll>(0, 1)];
            ans = (ans * ((pow2[cnt] + pow2[pcnt] - 1) % mod)) % mod;
            mp[pair<ll, ll>(0, 1)] = mp[pair<ll, ll>(1, 0)] = 0;
        }
        else if(b < 0){
            ll pa = -b, pb = a;
            pcnt = mp[pair<ll, ll>(pa, pb)];
            ans = (ans * ((pow2[cnt] + pow2[pcnt] - 1) % mod)) % mod;
            mp[pair<ll, ll>(a, b)] = mp[pair<ll, ll>(pa, pb)] = 0;
        }
        else{
            ll pa = b, pb = -a;
            pcnt = mp[pair<ll, ll>(pa, pb)];
            ans = (ans * ((pow2[cnt] + pow2[pcnt] - 1) % mod)) % mod;
            mp[pair<ll, ll>(a, b)] = mp[pair<ll, ll>(pa, pb)] = 0;
        }
    }
    ans = ans - 1 + zerovec; //-1は何も選ばなかった時
    if(ans < 0) ans += mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 29768
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

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

	int ans = 0;
	while (1) {
		if (N == 0)
			break;
		N /= K;
		ans++;
	}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vpii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
    
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        int n;cin>>n;
        int a[n];rep(i,n)cin>>a[i];
        int ans=0;
        rep(i,n){
            if(i%2==0){
                if(a[i]%2)ans++;
            }
        }
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3616
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;

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

  double a, b;
  cin >> a >> b;
  for(double i = 0.00; i <= 1009.00; i++) {
    int i_8 = (int)(i * 0.08);
    int i_10 = (int)(i * 0.10);
    //rcout << i << " " << i_8 << " " << i_10 << endl;
    if(i_8 == a && i_10 == b) {
      cout << (int)i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count=0;
		while(sc.hasNext()) {
			String s = sc.next();
			if(s.equals("0")) {
				break;
			}
			count=0;
			for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			}
			System.out.printf("%d\n", count);
		}
	}
}



Measured memory_bytes: 26980
def bubbleSort(A, N):
    c = 0
    flag = 1
    while flag:
        flag = 0
        for j in range(1, N):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                c += 1
                flag = 1
    print " ".join(map(str, A))
    print c


N = int(raw_input())
L = map(int, raw_input().split())

bubbleSort(L, N)

Measured memory_bytes: 6468
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int A,B;
    cin>>A>>B;
    cout<<max(0ll,A-B-B)<<endl;
}


Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 100000
using namespace std;
typedef long long LL;
vector<int> vec;
LL sum[MAXN+5],sum2[MAXN+5],a[MAXN+5];
int n;
bool dec[MAXN+5];
char str[5];
int main()
{
	scanf("%d",&n);
	scanf("%lld",&a[1]);
	for(int i=2;i<=n;i++)
	{
		scanf("%s %lld",str,&a[i]);
		if(str[0]=='-')
			vec.push_back(i),dec[i]=true;
	}
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	for(int i=1;i<=n;i++)
		if(dec[i]==true)
			sum2[i]=sum2[i-1]-a[i];
		else
			sum2[i]=sum2[i-1]+a[i];
	LL ans=sum2[n];
	int pos1,pos2;
	for(int i=0;i<(int)vec.size()-1;i++)
	{
		pos1=vec[i],pos2=vec[i+1];
		ans=max(ans,sum2[pos1]-(sum[pos2-1]-sum[pos1])+(sum[n]-sum[pos2-1]));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3192