akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


ll cal(ll a,ll b){
    ll res=0;
    while(a>0){
        if(a%b==0){
            a/=b;res++;
        }else{
            break;
        }
    }
    return res;
}

int main(){fastio
    ll n;cin>>n;
    ll f[n+1];
    rep(i,1,n)f[i]=1;
    bool used[n+1];memset(used,false,sizeof(used));
    rep(i,2,n){
        if(used[i])continue;
        for(ll j=i*2;j<=n;j+=i)used[j]=true;
    }
 //   rep(i,1,n)cout<<used[i]<<" ";cout<<endl;
    
    rep(i,2,n){
        
        if(used[i])continue;
        if(i*i>n){
            for(ll j=i;j<=n;j+=i){
                f[j]*=2;
            }
            continue;
        }
        for(ll j=i;j<=n;j+=i){
            ll c=cal(j,i);
            f[j]*=c+1;
        }
        
        /*map<ll,ll>mp;
        ll s=i;
        while(s<=n){
            for(ll j=s;j<=n;j+=s){
                mp[j]++;
            }
            s*=i;
        }
        
        for(auto x:mp){
            f[x.fi]*=x.se+1;
        }*/
    }
    ll ans=0;
  //  rep(i,1,n)cout<<f[i]<<" ";cout<<endl;
    
    rep(i,1,n){
        ans+=i*f[i];
    }
    cout<<ans;
    
    
    return 0;
}



Measured memory_bytes: 91516
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
import collections


# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, Vi):
    V1 = Vi[::2]
    V2 = Vi[1::2]
    c_V1 = dict(collections.Counter(V1))
    c_V2 = dict(collections.Counter(V2))
    c_V1 = sorted(c_V1.items(), key=lambda x: x[1], reverse=True)
    c_V2 = sorted(c_V2.items(), key=lambda x: x[1], reverse=True)
    c_V1.append((-1, 0))
    c_V2.append((-1, 0))
    ans = 0
    if c_V1[0][0] == c_V2[0][0]:
        ans = min(len(V1) - c_V1[0][1] + len(V2) - c_V2[1][1],
                  len(V1) - c_V1[1][1] + len(V2) - c_V2[0][1])
    else:
        ans = len(V1) - c_V1[0][1] + len(V2) - c_V2[0][1]
    print(ans)


if __name__ == '__main__':
    N = int(input())
    Vi = [int(i) for i in input().split()]
    solve(N, Vi)

    # # test
    # from random import randint
    # from func import random_str



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

int main()
{

int a[10000001],i,j;

cin >> a[1];

for(i=2;i<1000001;i++)
{
      if(a[i-1]%2==0)
      {
          a[i]=a[i-1]/2;
      }else
      {
          a[i]=3*a[i-1]+1;
      }
      for(j=1;j<i;j++)
      {
          if(a[j]==a[i])
          {
              cout << i << endl;
              return 0;
          }
      }

}
return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import io
import sys
import math

def solve(s):
    # implement process
    a,b = "",""
    cnt = 0
    # process
    for c in s:
        if a == "":
            a = c
            cnt += 1
        elif a == c:
            cnt += 1
        elif b == "":
            b = c
        elif b != c:
            return False
    return cnt == 2

def main():
    # input
    s = input()

    ans = "Yes" if solve(s) else "No"
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
FFEE
"""
_EXPECTED = """\
Yes
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 9104
#include<stdio.h>
#include<math.h>

int main()
{
  int N[10000];
  int n;
  int i, j, k;

  //Read N
  scanf("%d", &n);
  for(j=0; j<n; j++)scanf("%d", &N[j]);

  k=0;
  for(i=0; i<n; i++)
    {
      //check
      for(j=2; j<=sqrt(N[i]); j++)
	{
	  //if N%j==0, N is not a prime number.
	  if(N[i]%j==0 && N[i]!=2)
	    {
	      k++;
	      break;
	    }
	}
    }

  //print
  printf("%d\n", n-k);

  return 0;
}

Measured memory_bytes: 400
N,K = map(int,input().split())
P = list(map(int,input().split()))
EXP = [(p+1)/2 for p in P]
values = [sum(EXP[:K])]
for i in range(K,N):
    values.append(values[-1]-EXP[i-K]+EXP[i])
print(max(values))

Measured memory_bytes: 77448
#include<bits/stdc++.h>
	using namespace std;
	#define int long long 
	#define rep(i,n) for(int i=0;i<n;i++)
	void printv(vector<char> v){
		for(int i=0;i<v.size();i++){
			cout<<v[i];
		}
		cout<<endl;
	}
	bool comp(pair<int,int>a,pair<int,int> b){
		return a.second<b.second;
	}
	bool check(int x){
		while(x!=1){
			if(x%2){
				return 0;
			}
			else x/=2;
		}
		return 1;
	}
	int tcpow(int x) {
		int pow=0;
		while(x!=0){
			x/=2;
			pow++;
		}
		return pow;
	}	
	int d,k,a,b,t;
	int funt(int y){
		if(y%k || y==0)	return a*y + (y/k)*t +b*(d-y);
		else return a*y + (y/k -1)*t +b*(d-y);
	}
	int minn=1e18;
	int findy(int start,int end){
		if(start==end) return funt(start);
		if(start>end) return INT_MAX;
		if(funt((start+end)/2)>minn) return minn;
		int a=findy(start,(start+end)/2);
		//cout<<a<<endl;
		int b=findy((start+end)/2+1,end);
		//cout<<b<<endl;
		if(minn>min(a,b)) minn=min(a,b);
		return min(a,b);

	}
	signed main(){
		int tt=1;
		//cin>>tt;
		while(tt--){
			string s,t;
			cin>>s>>t;
			int c=0;
			for(int i=0;i<s.length();i++){
				if(s[i]!=t[i]) c++;
			}
			cout<<c<<endl;
		}

	}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define forn(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define for1(i, n) for (long long i = 1; i <= (long long)(n); ++i)
#define fore(i, l, r) for (long long i = (long long)(l); i <= (long long)(r); ++i)
#define fordn(i, n) for (long long i = (long long)(n) - 1; i >= 0; --i)
#define ford1(i, n) for (long long i = (long long)(n); i >= 1; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s, t;
    cin >> s >> t;
    string ss = s, tt = t;
    reverse(all(ss));
    reverse(all(tt));
    if(s == tt && t == ss) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, A, B;
    cin >> N >> A >> B;

    if((B-A)%2==0){
    	cout << (B-A)/2 << endl;
    }else{
    	ll X = (A-1) + 1 + (B-A-1)/2;
    	ll Y = (N-B) + 1 + (B-A-1)/2;
    	cout << min(X, Y) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,K = map(int, input().split())

count=0

c = [0] * (N+1)

for i in range(K):
    d = int(input())
    a = [int(d) for d in input().split()]
    for j in a:
        c[j] += 1

for i in c:
    if (i == 0):
        count+=1

print(count-1)

Measured memory_bytes: 9128
#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int i, x;
	i = a;
	x = 0 ;
	while ( i <= b )
	{
		if (c % i == 0)
		{
			x++;
		}
		i += 1;
	}
	cout << x << endl;
}

Measured memory_bytes: 1160
import sys
n,m=map(int,input().split())
l=[-1]*(n)
for i in range(m):
    s,c=map(int,input().split())
    if l[s-1]==-1 or l[s-1]==c:
        l[s-1]=c
    else:
        print(-1)
        sys.exit()
if l[0]==0 and len(l)!=1:
    print(-1)
    sys.exit()
for i in range(n):
    if l[i]==-1:
        l[i]=0
if l[0]==0 and len(l)!=1:
    l[0]=1

if l[0]==0 and len(l)==1:
    print(0)
else:
    for i in range(n):
        print(l[i],end="")

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        (mut x, mut k, d): (i64, i64, i64),
    }

    // 座標はマイナスからはじまることもある
    if x < 0 {
        x *= -1;
    }

    // 最低限、 x/d 分は確実に移動できるはず
    let min = x / d;

    if min < k {
        // ターン数が余っている場合
        x = x - (d * min);
        k = k - min;
        if k % 2 == 0 {
            // 偶数ならば行ったり来たりしてやり過ごせる
            println!("{}", x.abs());
        } else {
            // 奇数ならば一つ進む or 一つ戻る
            println!("{}", (x - d).abs().min((x + d).abs()));
        }
    } else {
        // ターン数を使い切れる場合
        println!("{}", x - (d * k));
    }
}


Measured memory_bytes: 2160
#include<iostream>
#include<string>
#include<regex>
using namespace std;

int main (){
    regex re("A?KIHA?BA?RA?");
    string s;
    cin >> s;
    bool res = regex_match(s, re);
    cout << (res ? "YES" : "NO" ) << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    char number[10001];
    while(1){
        scanf("%s",number);
        
        if(number[0]=='0')break;
        
        int sum=0;
        for(int i=0;number[i]!='\0';i++)sum+=number[i]-'0';
        
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3244
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
using namespace std ;
using ll = long long ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using pll = pair<ll,ll> ;

void chmin(ll &a,ll b){if(a>b) a = b ;}

int main(){
	ll n ; cin >> n ;
	vvll d1(n,vll(n)) ;
	for(auto &i:d1) for(auto &j:i) cin >> j ;
	vvll d2 = d1 ;
	for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) chmin(d2[i][j],d2[i][k]+d2[k][j]) ;
	if(d1!=d2){
		cout << -1 << endl ;
		return 0 ;
	}
	ll ans = 0 ;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) ans += d1[i][j] ;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) for(int k=0;k<n;k++){
		if(k==i||k==j) continue ;
		if(d1[i][k]+d1[k][j]==d1[i][j]){
			ans -= d1[i][j] ;
			break ;
		}
	}
	cout << ans/2 << endl ;
}

Measured memory_bytes: 5048
if __name__ == '__main__':
    n, m = map(int, input().split())
    c = list(map(int, input().split()))

    dp = [float('inf')] * (n + 1)
    dp[0] = 0
    for i in range(1, n + 1):
        for j in range(m):
            if i >= c[j]:
                dp[i] = min(dp[i - c[j]] + 1, dp[i])
    print(dp[n])


Measured memory_bytes: 7268
#include<iostream>
#include<vector>
#include<cmath>
#define REP(i,n) for(int i = 0; i < n; i++)
using namespace std;

struct point{
    int x,y,t;
};
int distance(point point1, point point2){
    int x, y;
    x = fabs(point1.x - point2.x);
    y = fabs(point1.y - point2.y);
    return x + y;
}

int main(){
    int n;
    cin >> n;
    point point1, point2;
    point1.x = 0;point1.y = 0;point1.t = 0;
    bool flag = true;
    REP(i,n){
        point2 = point1;
        cin >> point1.t >> point1.x >> point1.y;
        int dis = distance(point1,point2);
        int t = fabs(point1.t - point2.t);
        if(dis % 2 == t % 2 && dis <= t);
        else flag = false;
    }
    if(flag) cout << "Yes\n";
    else cout << "No\n";
    
}

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

int main() {
    int N;
    cin >> N;
    int d1 = N / 1000, d2 = N%1000/100, d3 = N%100/10, d4 = N%10;
    if ((d1 == d2 && d2 == d3) || (d2 == d3 && d3 == d4)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int MAXN = (int)1e2 + 10;

int n;
vector<int> g[MAXN];
int vis[MAXN];
int dep[MAXN];

void BFS(){
    int d=0;
    queue<int> q;
    for(int i=1;i<=n;i++) dep[i]=-1;
    dep[1]=0;
    q.push(1);
    vis[1]=1;
    while(!q.empty()){
        int u=q.front(); q.pop();
        for(int i=0;i<g[u].size();i++){
            int v=g[u][i];
            if(vis[v]) continue;
            dep[v]=dep[u]+1;
            vis[v]=1;
            q.push(v);
        }
    }
}

void work(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int u,k; scanf("%d%d",&u,&k);
        while(k--){
            int v; scanf("%d",&v);
            g[u].push_back(v);
        }
        sort(g[u].begin(),g[u].end());
    }
    BFS();
    for(int i=1;i<=n;i++) printf("%d %d\n",i,dep[i]);
}

int main(){
    work();
    return 0;
}




Measured memory_bytes: 2772
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
int main()
{
	string str;
	string item;
	vector<string> list;
	int valueInt[3];
	getline(cin, str);
	stringstream ss(str);
	while (getline(ss, item, ' ') && !item.empty()) {
		list.push_back(item);
	}
	for (int i = 0; i < 3; i++)
	{
		valueInt[i] = 0;
	}
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (list[i] == list[j])
			{
				valueInt[i]++;
			}
		}
	}
	for (int i = 0; i < 3; i++)
	{
		if (valueInt[i] == 1)
		{
			cout << list[i] << endl;
			break;

		}
		
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    
    vector<int> L(K), R(K);
    int now = 0;
    rep(i, K) {
        while (S[now] == 'x') ++now;
        L[i] = now;
        now += C + 1;
    }
    now = N - 1;
    for (int i = K - 1; i >= 0; --i) {
        while (S[now] == 'x') --now;
        R[i] = now;
        now -= C + 1;
    }
    rep(i, K) {
        if (L[i] == R[i]) cout << L[i] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define MOD 1000000007
#define f(i,a,n) for(lli i = a; i < n; i++)
#define fb(i,a,n) for(lli i=n-1;i>=a;i--)
 
#define p64 pair<lli,lli>
#define v64 vector<lli>
#define p32 pair<int,int>
#define v32 vector<int>
#define vp64 vector<pair<lli , lli >>
#define vp32 vector<pair<int , int>>
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--){
        lli n,k; cin>>n>>k;
        lli arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        sort(arr,arr+n,greater<int>());
        lli ans = 0;
        for(int i=k;i<n;i++){
            ans+=arr[i];
        }
        cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = new int[num];
        for (var i = 0; i < num; i++)
            ar[i] = ToInt32(ReadLine());
        var min = Min(ar[0],ar[1]);
        var res = ar[1]-ar[0];
        for(var i = 2; i < num; i++)
        {
            res = Max(ar[i] - min, res);
            min = Min(min, ar[i]);
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}



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

using namespace std;
using iii = tuple<int, int, int>;
using mii = map<int, int>;
using vi = vector<int>;
using viii = vector<iii>;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q, a, b;
  cin >> n >> q;
  vi x(n);
  mii m;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    if (m.count(y)) x[i] = m[y];
    else x[i] = m.size(), m[y] = x[i];
  }
  viii y(q);
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    y[i] = {a-1, b, i};
  }
  int k = sqrt(n);
  sort(y.begin(), y.end(), [&](iii x, iii y) -> bool {
    int a1, b1, i1, a2, b2, i2;
    tie(a1, b1, i1) = x;
    tie(a2, b2, i2) = y;
    int a1q = a1/k, a2q = a2/k;
    if (a1q < a2q) return true;
    if (a1q > a2q) return false;
    return b1 < b2;
  });
  vi res(q);
  vi count(m.size());
  int l = 0, r = 0, ans = 0;
  for (iii z : y) {
    int i;
    tie(a, b, i) = z;
    while (r < b) if (++count[x[r++]] == 1) ans++;
    while (r > b) if (--count[x[--r]] == 0) ans--;
    while (l < a) if (--count[x[l++]] == 0) ans--;
    while (l > a) if (++count[x[--l]] == 1) ans++;
    res[i] = ans;
  }
  for (int z : res) cout << z << '\n';
}

Measured memory_bytes: 39000
#include<bits/stdc++.h>
#define R register int 
#define ll long long
#define inf 2147483647
using namespace std;
const int N=500000;
int n,las;char S[N];
int gi(){
    R x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x;
}
int main(){
	scanf("%s",S+1),n=strlen(S+1);
	if(S[1]=='0')puts("-1"),exit(0);
	if(S[n]=='1')puts("-1"),exit(0);
	for(R i=2;i<n;++i)
		if(S[i]!=S[n-i])puts("-1"),exit(0);
	las=2;
	puts("1 2");
	for(R i=3;i<=n;++i){
		if(S[i-1]=='0')printf("%d %d\n",i,las);
		else printf("%d %d\n",i,las),las=i;
	}
	return 0;
}


Measured memory_bytes: 1536
///B-Battle

#include <stdio.h>

#define A 100
#define B 100
#define C 100
#define D 100 ///これいけるのかぁ？ わーい

void battle(int *a, int b, int *c, int d, int t); /* voidじゃいかんでしょ */
void winORlose(int a, int c);/* 勝敗 */

int main()
{
  int a; /* 高橋の体力 */
  int b; /* 高橋の攻撃力 */
  int c; /* 青木の体力 */
  int d; /* 青木の攻撃力 */

  int t = 0;/* カウンター ，ターン */

  /* 入力 */
  scanf("%d%d",&a,&b);/* 高橋の体力と攻撃力 */
  scanf("%d%d",&c,&d);/* 青木の体力と攻撃力 */

  while( 0<a && 0<c)///////高橋 H:10 A:9  青木 H:10 A 10
  {
    t++;
    battle(&a,b,&c,d,t);
  }
  return 0;
}

void battle(int *a, int b, int *c, int d, int t)
{
  if(t%2 != 0){ /* 高橋くんが攻撃するとき 奇数ターン */
    *c = *c - b;}
  else{/* 青木くんが攻撃するとき 　偶数ターン*/
    *a = *a - d;}

  // printf("ターン数 ＝ %d",t);
  winORlose(*a,*c);

}

void winORlose(int a, int c)
{
  if(a<=0){
    printf("\nNo\n");
      // printf("高橋=%d,青木=%d\n",a,c);
  }
  else if(c<=0){
    printf("\nYes\n");
    // printf("高橋=%d,青木=%d\n",a,c);
  }
  else
  {
  // printf("勝負はまだついてない!");
    // printf("高橋=%d,青木=%d\n",a,c);
  }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n;
    cin>>n;
    vector<int> a(n,0);
    for(int i=0;i<n;i++) cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if(i%2==0 && a[i]%2==1) ans++;
    }
    cout<<ans<<"\n";
}


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 3652
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        a: usize,
        s: String
    }

    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }

}


Measured memory_bytes: 4352
#include<stdio.h>
#define MAX 100000
#define SEN 2000000000

struct Card{
  char suit;
  int value;
};



struct Card L[MAX/2+2],R[MAX/2+2];

void mer(struct Card A[],int n,int l,int m,int r){
  int i,j,k;
  int n1=m-l;
  int n2=r-m;
  for(i=0;i<n1;i++) L[i]=A[l+i];
  for(i=0;i<n2;i++) R[i]=A[m+i];
  L[n1].value=R[n2].value=SEN;
  i=j=0;
  for(k=l;k<r;k++){
    if(L[i].value<=R[j].value){
    A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}



void mS(struct Card A[],int n,int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    mS(A,n,l,m);
    mS(A,n,m,r);
    mer(A,n,l,m,r);
  }
}


int par(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}


void qS(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=par(A,n,p,r);
    qS(A,n,p,q-1);
    qS(A,n,q+1,r);
  }
}



int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }

  mS(A,n,0,n);
  qS(B,n,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit) stable=0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}



Measured memory_bytes: 4204
#include <cstdio>
#include <algorithm>

using namespace std;

int v[200010],vaz[200010];

int main()
{
   // freopen("file.in","r",stdin);
   // freopen("file.out","w",stdout);
    int n,sol=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&v[i]);
        v[i]++;
        vaz[v[i]]++;
        vaz[v[i]+1]++;
        vaz[v[i]-1]++;
        sol=max(sol,vaz[v[i]]);
        sol=max(sol,vaz[v[i]+1]);
        sol=max(sol,vaz[v[i]-1]);
    }
    printf("%d",sol);
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,count=0,k1=0,k2=0;
  cin >>n;
  int p[n],q[n],a[n];
  for(int i=0;i<n;i++)a[i]=i+1;
  for(int i=0;i<n;i++)cin >> p[i];
  for(int i=0;i<n;i++)cin >> q[i];
  do{
    int cnt=0,cnt2=0;
    count++;
      for(int j=0;j<n;j++){
        if(a[j]==p[j])cnt++;
        if(a[j]==q[j])cnt2++;
      }
    if(cnt==n)k1=count;
      if(cnt2==n)k2=count;
  }while(next_permutation(a,a+n));
  cout << abs(k1-k2) << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;



int main() {
    ios_base::sync_with_stdio(false); 

    int n,m;
    cin >> n >> m;
    vector<vector<int>> r(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        r[a-1].push_back(b-1);
        r[b-1].push_back(a-1);
    }
    queue<int> q;
    q.push(0);
    vector<int> cost(n,INF),par(n);
    cost[0]=0;
    while (!q.empty()) {
        int now=q.front();
        q.pop();
        rep(i,r[now].size()) {
            int next=r[now][i];
            if (cost[next]>cost[now]+1) {
                cost[next]=cost[now]+1;
                par[next]=now;
                q.push(next);
            }
        }
    }
    cout << "Yes" << endl;
    rep(i,n-1) cout << par[i+1]+1 << endl;
    

    return 0;
}


Measured memory_bytes: 10708
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	
	int64 n, a, b;
	cin >> n >> a >> b;
	if (a > b) swap(a, b);
	if (a % 2 == b % 2) {
	   cout << (b - a) / 2 << endl;
       return 0;	   
	}
	
	int64 first = a + (b - a - 1) / 2;
	int64 last = (n - b + 1) + (b - a - 1) / 2;
	
	cout << min(first, last) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int h, w;
  cin >> h >> w;
  char a[h][w];
  rep(i, h) {
    rep(j, w) {
      cin >> a[i][j];
    }
  }

  vector<bool> l(h, false), r(w, false);
  rep(i, h) {
    rep(j, w) {
      if (a[i][j] == '#') {
        l[i] = true;
        r[j] = true;
      }
    }
  }

  rep(i, h) {
    if (!l[i]) continue;
    rep(j, w) {
      if (!r[j]) continue;
      cout << a[i][j];
    }
    cout << endl;
  }


  
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

#define ll long long
#define INF 100000000000000000L


ll Solve(int n,int k,const std::vector< ll >& h){
  std::vector< ll > dp(n,INF);
  dp[n-1] = 0;
  for(int i = n - 2; i >= 0; i--){
    for(int j = 1; (j <= k) && (j + i < n); j++ )
      dp[i] = std::min(dp[i], dp[i+j] + std::abs(h[i] - h[i+j]));
  }  
  return(dp[0]);
}


int main() {
  int n,k;
  std::cin >> n >> k;
  std::vector< ll > h(n);
  for(int i = 0; i < n; i++) std::cin >> h[i]; 
  std::cout << Solve(n,k,h) << "\n";    
  return 0;
}


Measured memory_bytes: 1792
s = list(input())

s01 = []
s10 = []

for i in range(len(s)):
    if i % 2 == 0:
        s01.append('0')
        s10.append('1')
    else:
        s01.append('1')
        s10.append('0')

count01 = 0
count10 = 0

for i in range(len(s)):
    if s[i] != s01[i]:
        count01 += 1
    if s[i] != s10[i]:
        count10 += 1

print(min(count01, count10))


Measured memory_bytes: 5512
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>
#include <vector>
#define mod 1000000007
#define ll long long
#define pi acos(-1)
using namespace std;
const double INF = 1e20;

int main(){
	ios::sync_with_stdio(false);
	ll n, k;
	cin>>n>>k;
	n=n%k;
	n=(n<k-n)?n:k-n;
	cout<<n;
	
	return 0;
}

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

#define endl '\n'

void solvetask(){
    int n,k; cin >> n >> k;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=k; i<n; i++){
        if (a[i] > a[i-k]) cout << "Yes\n";
        else cout << "No\n";
    }
}

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

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

int main()
{
    char s[5];
    char a,b;
    int flag=0;
    scanf("%s",s);
    if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])flag=1;
    if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])flag=1;
    if(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1])flag=1;

    if(flag)printf("Yes");
    else printf("No");
}



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

int main() {
	int a[30];
	a[0] = 1;
	a[1] = 1;
	a[2] = 2;
	for ( int i = 3; i <= 30; i++ )
		a[i] = a[i - 1] + a[i - 2] + a[i - 3];
	while (1) {
		int n;
		cin >> n;
		if ( n == 0 ) break;
		if ( a[n] % 3650 == 0 ) cout << ( a[n] / 3650 ) << endl;
		else cout << ( a[n] / 3650 + 1 ) << endl;
	}
}

Measured memory_bytes: 1160
A = []
for i in [0]*3:
    A.append(list(map(int,input().split())))
N = int(input())
B = []
for i in [0]*N:
    B.append(int(input()))

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = -1

#ヨコ
for i in range(3):
    if A[i] == [-1,-1,-1]:
        print("Yes")
        exit()
#タテ
for i in range(3):
    if [A[0][i],A[1][i],A[2][i]] == [-1,-1,-1]:
        print("Yes")
        exit()
#ナナメ
if [A[0][0],A[1][1],A[2][2]] == [-1,-1,-1]:
    print("Yes")
    exit()
if [A[0][2],A[1][1],A[2][0]] == [-1,-1,-1]:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 9212
# 整数の入力
N = int(input())
# スペース区切りの整数の入力
#N, M = map(int, input().split())

#A_list = list(map(int, input().split()))

# 文字列の入力
#S = input()

# 改行無視して全部リストとして読み込む
#N, *l=map(int, open(0).read().split())

print(N+N**2+N**3)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

vl<ll> divisor(ll n)
{
    vl<ll> v;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0) 
        {
            if(n/i==i) v.pb(i);
            else
            {
                v.pb(i);
                v.pb(n/i);
            }
        }
    }
    return v;
}

int main()
{
    ll a,b,i,j,n,m,k,t;
    cin>>n>>m;
    priority_queue<ll> q;
    for(i=0;i<n;i++)
    {
        cin>>a;
        q.push(a);
    }
    for(i=0;i<m;i++)
    {
        a=q.top();
        q.pop();
        a/=2;
        q.push(a);
    }
    ll ans=0;
    while(!q.empty())
    {
        a=q.top();
        ans+=a;
        q.pop();
    }
    cout<<ans;
}

Measured memory_bytes: 4304
s = gets.to_i
ss = s/2
a = gets.split.map(&:to_i)
array1 = 0
array2 = 0
t = 0
sa = 1000000000

ss.times do
  array1 = a[0..ss + t].inject(:+)
  array2 = a[ss + 1 + t..s].inject(:+)
  if array1 >= array2
    	if sa >= array1 - array2
    		sa = array1 - array2
        end
    t = t - 1
  elsif array2 >= array1
    	if sa >= array2 - array1
          	sa = array2 - array1
        end
    t = t + 1
  end
end
puts sa

Measured memory_bytes: 1788
import sys

K, S = [int(_) for _ in sys.stdin.readlines()[0].strip().split(' ')]
total_pattern = 0

for x in range(K+1):
  for y in range(K+1):
    if 0 <= S - (x + y) <= K:
      total_pattern += 1
      
print(total_pattern)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<int> suff(n);
    int sum= 0;
    int base = 1;
    revrep(i, n) {
        sum += (s[i] - '0') * base;
        sum %= 2019;
        suff[i] = sum;
        base = base * 10 % 2019;
    }

    ll res = 0;
    vector<ll> cnt(2020);
    cnt[0] = 1;
    rep(i, n) {
        res += cnt[suff[i]];
        cnt[suff[i]]++;
    }
    cout << res << endl;
}

Measured memory_bytes: 4364
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;



int main() {
	int n,c;
	cin >> n >> c;
	int d[c][c];
	int ct[c][3];
	rep(i,c) rep(j,3) { ct[i][j] = 0;}

	rep(i,c) rep(j,c) { cin >> d[i][j];}
	rep(i,n) rep(j,n) {
		int t;
		cin >> t;
		t--;
		ct[t][(i + j) % 3]++;
	}
	int ans = 1e9;


	rep(i, c) {
		int cur0 = 0;
		rep(l, c) {
			cur0 += d[l][i] * ct[l][0];
		}
		rep(j,c) {
			if (i == j) continue;
			int cur1 = cur0; 

			rep(l, c) {
				cur1 += d[l][j] * ct[l][1];
			}

			rep(k,c) {
				if (i == k || j == k) continue;
				int cur2 = cur1; 

				rep(l, c) {
					cur2 += d[l][k] * ct[l][2];
					//cout << "l:" << l << " d:" << d[l][k] << " ct:" <<  ct[l][2] << endl;
				}
				/*
				cout << "i:" << i << " " << cur0 << " ";
				cout << "j:" << j << " " << cur1 - cur0 << " ";
				cout << "k:" << k << " " << cur2 - cur1 << " " ;
				cout << "cur2:" << k << " " << cur2 << " " ;
				cout << endl;
				*/
				ans = min(cur2,ans);

			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
    string s;
    cin>>s;
    if(s[1]=='B')
    cout<<"ARC";
    else
        cout<<"ABC";
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double *arr = new double[n];
  int i=0;
  for(i=0;i<n;i++){
   cin>>arr[i]; 
  }
  sort(arr,arr+n);
  double sum= arr[0];
  i=1;
  while(i<n){
    sum = (sum + arr[i])/2;
    i++;
  }
  cout<<sum<<endl;
  delete []arr;
 return 0; 
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt()
    val p = readListOfInt()
    val sortedP = p.sorted()
    var cnt = 0
    for(i in 0 until n) {
        if(p[i]!=sortedP[i]) {
            cnt++
        }
    }
    println(if(cnt <=2) "YES" else "NO")
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    (a * b) / gcd(a, b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 38032
#!/usr/bin/env python
"""AtCoder Beginner Contest 173: C - H and V
https://atcoder.jp/contests/abc173/tasks/abc173_c
"""

import copy


def count_black(cells):
    count = 0
    for col in cells:
        count += col.count('#')
    return count


def draw_red_and_count(cells, xs, ys):
    for x in xs:
        for col in cells:
            col[x] = '@'
    for y in ys:
        for i in range(len(cells[y])):
            cells[y][i] = '@'
    return count_black(cells)


def main():
    H, W, K = list(map(int, input().split()))
    cells = [[0 for j in range(W)] for i in range(H)]
    for x in range(H):
        Cs = list(input())
        for y in range(W):
            cells[x][y] = Cs[y]

    Xs = []
    for i in range(2 ** W):
        Xs.append([j for j in range(W) if (i >> j) & 1])
    Ys = []
    for i in range(2 ** H):
        Ys.append([j for j in range(H) if (i >> j) & 1])

    ans = 0
    for xs in Xs:
        for ys in Ys:
            black_count = draw_red_and_count(copy.deepcopy(cells), xs, ys)
            if black_count == K:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
  int N, T;
  std::cin >> N >> T;
  std::vector<int> t(N);
  for (int i = 0; i < N; i++) std::cin >> t.at(i);
  long long ans = 0;
  long long start = 0, end = T;
  for (int i = 1; i < N; i++)
  {
    if (t.at(i) <= end) end = t.at(i) + T;
    else
    {
      ans += end - start;
      start = t.at(i);
      end = t.at(i) + T;
    }
  }
  ans += end - start;
  std::cout << ans << std::endl;
}


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

#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M 1000000007
#define mp make_pair
#define pb push_back
#define PB pop_back
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define lcase(a) (char)tolower(a)
#define ucase(a) (char)toupper(a)
#define precise(a) fixed<<setprecision(a)<<
#define F first
#define S second
#define I insert
#define pii pair<int,int>
#define trav(a, x) for(auto& a : x)
#define rep(n) for(int i = 0;i<n;i++)
#define rrep(n) for(int i = n-1;i>=0;i--)
#define time cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" "; cout<<endl;
#define ingrid(data,n,commands) for(int i = 0; i<n; i++){cin>>data[i];commands}
#define section(a,b,w) set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w) set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define copy(a,w) copy(a.begin(), a.end(),back_inserter(w));
#define all(data) data.begin(), data.end()
#define PI 3.14159265358979323844
#define endl '\n'
#define last(a) a[sz(a)-1]
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
 
// Graph DFS
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
 
//primes for hashing 937,991,1013,1409,1741
 
//Returns index of first element not less than key and more than key respectively
#define lb(data,key) lower_bound(all(data),key) - data.begin();
#define up(data,key) upper_bound(all(data),key) - data.begin();
#define fnd(data,key) find(all(data),key) - data.begin();
/* Long Long Int */
#define int long long int
const int N = 1e7+1e5;


int n, wt;
int dp[150][1000000];
int w[150], v[150];

int calc(int curr, int currwt){
    if(currwt > wt) return -M;
    if(curr == n) return 0;
    

    int &ans  = dp[curr][currwt];

    if(ans) return ans;

    ans = v[curr]+ calc(curr+1, currwt+w[curr]);
    ans = max(ans, calc(curr+1, currwt+0));

    return ans;
}
 

void solve(){
   cin>>n>>wt;
   // memset(dp, -1, sizeof(dp));
   for (int i = 0; i < n; ++i)
   {
       cin>>w[i]>>v[i];
   }

   cout<<calc(0, 0);


}

signed main()
{
    FAST
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;

return 0;
}

Measured memory_bytes: 280832
{-# LANGUAGE OverloadedStrings #-}
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe
import Data.String
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as BS
---------------------------------------------------------------------------------
main = do
  x<-getLine
  putStrLn $ if x=="0" then "1" else "0"
  
  
  
---------------------------------------------------------------------------------

{-ByteString関連-}
--IO
getLine' = BS.getLine
getContents' = BS.getContents
getLineList = BS.words <$> getLine'
getContentList = BS.words <$> getContents'
getInt' = fst . fromJust . BS.readInt <$> getLine'
getIntListw' = map (fst . fromJust. BS.readInt) .BS.words <$> getLine'
getIntListl' = map (fst . fromJust. BS.readInt) .BS.lines <$> getContents'
getInteger' = fst . fromJust. BS.readInteger <$> getLine'
putStr' = BS.putStr
putStrLn' = BS.putStrLn
--演算子
bs1 |++| bs2 = BS.append bs1 bs2
chr |:+| bs2 = BS.cons chr bs2
bs1 |+:| chr = BS.snoc bs1 chr

{-elem関連-}
--elemの第一引数をリストにしたもの。
--elemList "abc" "atcoder" -> [True,False,True]
elemList [] _ = []
elemList (x:xs) list  = elem x list : elemList xs list

--elemIndexの第一引数をリストにしたもの。
elemIndexList [] list = []
elemIndexList (x:xs) list  = elemIndex x list : elemIndexList xs list

--elemIndicesの第一引数をリストにしたもの。
elemIndicesList [] list = []
elemIndicesList (x:xs) list  = elemIndices x list : elemIndicesList xs list

--length . nubの代わり
count _ [] c = c
count [] (y:ys) c = count [y] ys (c+1)
count (x:xs) (y:ys) c
  |y==x = count (y:x:xs) ys c
  |y/=x = count (y:x:xs) ys (c+1)

Measured memory_bytes: 3692
function main(input) {
  const arr = input.split("\n").map(v => parseInt(v));
  const par = arr.map(v => v % 10).filter(v => v !== 0);
  console.log(arr.map(v => Math.ceil(v / 10) * 10).reduce((a,b) => a+b) - (par.length ? Math.max(...(par.map(v => 10 - v))) : 0 ));
}
main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7372