akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(void){
    int K,A,B;
    cin >> K;
    cin >> A >> B;

    int d = A;
    while(1)
    {
        if(d % K == 0) {
            cout << "OK" << endl;
            return 0;
        } 
        d++;
        if(B < d) {
            cout << "NG" << endl;
            return 0;
        }
        
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 200000 + 5;
int arr[N];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n, k, a;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		arr[a]++;
	}
	vector<int> vec;
	for (int i = 1; i <= n; i++)
	{
		if (arr[i])
			vec.push_back(arr[i]);
	}
	sort(vec.rbegin(), vec.rend());
	int s = 0;
	for (int i = 0; i < min(k, (int) vec.size()); i++)
		s += vec[i];
	cout << n - s << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	
	ll cnt = 0;
	repe(i, n) {
		repe(j, n) {
			int sum = r * i + g * j;
			if (sum == n) {
				cnt++;
			} else if (sum < n) {
				if ((n - sum) % b == 0) cnt++;
			}
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        int total = 0;
        for(int i=0; i<k; i++){
            total += list.get(i);
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 38128
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n,int p)
{
    a %= p;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%p,n/2,p)%p))%p;
    return power((a*a)%p,n/2,p)%p;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2,mod)%mod;//little fermat....
}

void solve(){
    int n,p,ans = 0;
    string s;
    cin >> n >> p >> s;
    if(p == 2 || p == 5){
        FOR(i,0,n){
            if((s[i]-'0')%p)continue;
            ans += i+1;
        }
    }
    else {
        vector<int>cnt(100005);
        cnt[0] = 1;
        int suff = 0;
        RFOR(i,n-1,-1){
            int d = (s[i]-'0')%p;
            int tmp = (((power(10,n-1-i,p)*d)%p)+suff)%p;
            ans += cnt[tmp];
            cnt[tmp]++;
            suff = tmp%p;
        }
    }
    cout << ans << "\n";
}

signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


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

int main(){
    string S;
    cin>>S;
    int count1,count2,t1,t2,s=stoi(S);
    t1=s%100;
    t2=(s-t1)/100;
    rep(i,12){
        if(i+1==t1)count1++;
        if(i+1==t2)count2++;
    }
    if(count1==1&&count2==1)cout<<"AMBIGUOUS";
    else if(count1==1&&count2==0)cout<<"YYMM";
    else if(count1==0&&count2==1)cout<<"MMYY";
    else cout<<"NA";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    ll ans = 1;
    ll a = (ll)(pow(10, 9) + 7);
    for(int i = 1; i <= N; i++){
        ans *= i;
        ans %= a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
cnt = 0
n = int(input())
lst = [int(i) for i in input().split()]
for i in range(n-2):
    a,b,c = lst[i],lst[i+1],lst[i+2]
    if (a<b and b<c) or (c<b and b<a):
        cnt += 1
print(cnt)

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

        using namespace std;
        typedef long long ll;
        void __print(int x) {cerr << x;}
        void __print(long x) {cerr << x;}
        void __print(long long x) {cerr << x;}
        void __print(unsigned x) {cerr << x;}
        void __print(unsigned long x) {cerr << x;}
        void __print(unsigned long long x) {cerr << x;}
        void __print(float x) {cerr << x;}
        void __print(double x) {cerr << x;}
        void __print(long double x) {cerr << x;}
        void __print(char x) {cerr << '\'' << x << '\'';}
        void __print(const char *x) {cerr << '\"' << x << '\"';}
        void __print(const string &x) {cerr << '\"' << x << '\"';}
        void __print(bool x) {cerr << (x ? "true" : "false");}

        template<typename T, typename V>
        void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
        template<typename T>
        void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
        void _print() {cerr << "]\n";}
        template <typename T, typename... V>
        void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
        #ifndef ONLINE_JUDGE
        #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
        #else
        #define debug(x...)
        #endif
        const long long INF  = 1e18;
        int md = 1e9+7;
   
        int main()
        {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            int n;
            cin>>n;
            vector<int>a(n),b(n);
            for(int i=0;i<n;i++)
                cin>>a[i];
            for(int i=0;i<n;i++)
                cin>>b[i];
            int prev = -1;
            int j=0;
            for(int i=0;i<n;i++)
            {
                if(prev!=a[i])
                    j = 0;
                if(a[i]==b[i])
                {
                    for(;j<n;j++)
                    {
                        if(a[i]!=a[j] && b[j]!=a[i])
                        {
                            swap(b[i],b[j]);
                            break;
                        }
                    }
                    
                }
                if(a[i]==b[i])
                {
                    cout<<"No";
                    exit(0);
                }
                prev = a[i];
            }
            cout<<"Yes\n";
            for(int i:b)
                cout<<i<<' ';
        }

        //https://www.youtube.com/watch?v=ZQqccia8bVo

Measured memory_bytes: 5144
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
int main()
{


	int x;
	cin >> x;
	string ans;
	string sz[4] = { "AC","WA","TLE","RE" };
	int lala[4] = {0,0,0,0};
	while (x--)
	{
		cin >> ans;
		for (int i = 0; i < 4; i++)
		{
			if (sz[i] == ans)
			{
				lala[i]++;
			}
		}
	}
	for (int i = 0; i < 4; i++)
	{
		cout << sz[i] << " x " << lala[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3568
using System;

namespace OnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            var a = int.Parse(str[0]);
            var b = int.Parse(str[1]);
            var c = int.Parse(str[2]);

            if(a < b && b < c && a < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 8852
N = int(input())
D = sorted(list(map(int,input().split())))
M = int(input())
T = sorted(list(map(int,input().split())))
cur = 0
flag = 0
for i in range(N):
    if cur<M and D[i]==T[cur]:
        cur += 1
    elif cur<M and D[i]<T[cur]:
        continue
    elif cur==M:
        break
    else:
        flag = 1
        break
if flag==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 35164
N = int(input())
s = input()
fir = True
f = 0
b = len(s)-1
count = 0
while(b > f):
    if(s[f] == "R"):
        f += 1
        continue
    elif(s[b] == "R"):
        count += 1
        f += 1
        b -= 1
        continue
    elif(s[b] == "W"):
        b -= 1
print(count)

Measured memory_bytes: 9424
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    cout << max(a - k, (ll)0) << ' ';
    cout << max(b - max(k - a, (ll)0),(ll)0) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,N,K,ans=inf,res;
  cin>>N>>K;K--;
  vec v(N);
  rep(i,N){
    cin>>v[i];
  }
  rep(i,N-K){
    if(v[i]*v[i+K]<0){
      res=min(-v[i],v[i+K])+v[i+K]-v[i];
    }else{
      res=max(labs(v[i]),labs(v[i+K]));
    }
    chmin(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
/*
  Vivek Rathi
  CSE 3rd Year
  MNNIT
  THUMB RULE - THINK FOR DP FIRST AND THEN GREEDY!!!
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define sz(x)	(ll)x.size()
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#define endl '\n'
//unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
//shuffle (foo.begin(), foo.end(), std::default_random_engine(seed));
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above-----------------------------------------------

int main()
{
	boost
	ll n;
	cin>>n;
	ll a[n+1][2]={0};
	vector<ll> vv[n+1];
	for(ll i=0;i<n-1;i++)
	{
		ll u,v;
		cin>>u>>v;
		if(u>v)
			swap(u,v);
		a[u][0]++;
		a[v][1]++;
		vv[u].pb(v);
	}
	ll net[n+1]={0};
	ll tot=0;
	ll s=0,e=0;
	for(ll i=1;i<=n;i++)
	{
		for(auto it:vv[i])
			tot+=n-it+1;
	}
	ll temp=tot;
	ll tot2=0;
	for(ll i=1;i<=n;i++)
	{
		tot2+=(n-i+1)*(n-i+2)/2;
		for(auto it:vv[i])
		{
			temp-=(n-it+1);
		}
		tot+=temp;
		//debug3(temp,tot2,tot);
	}
	cout<<tot2-tot<<endl;
	return 0;
}

Measured memory_bytes: 19172
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    int x=101, ans=0;
    for(int i=0; i<n-1; i++) {
        if(a[i]==a[i+1]) a[i+1]=x, x++, ans++;
    }
    cout<<ans<<endl;
}

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

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

  int ans = -1;
  int num = 0;
  rep(i, 1100000) {
    num = 10 * num + 7;
    num %= K;
    if (num == 0) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
//Name: Tsuruga Castle
//Level: 1
//Category: 実装
//Note:

/**
 * 年齢 / 10 でビンに分ける。
 * 60歳以上を特別扱いすることに注意。
 */
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

bool solve() {
    int N;
    cin >> N;
    if(!N) return false;

    array<int,7> bins;
    fill(begin(bins), end(bins), 0);

    for(int i = 0; i < N; ++i) {
        int age;
        cin >> age;
        age /= 10;
        if(age > 6) age = 6;
        bins[age]++;
    }
    for(int i = 0; i < 7; ++i) {
        cout << bins[i] << endl;
    }
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1196
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
struct Circle {
    double x,y,r;
    Circle(double x=0,double y=0,double r=0):
        x(x),y(y),r(r){}
};

// c1, c2??????????????????
bool ok(const Circle &c1, const Circle &c2) {
    double d = sqrt((c1.x-c2.x)*(c1.x-c2.x)+(c1.y-c2.y)*(c1.y-c2.y));
    return d > c1.r+c2.r && c1.x < c2.x;
}
double dist(Circle c1, Circle c2) {
    double x=c1.x-c2.x;
    double y=c1.y-c2.y;
    return sqrt(x*x+y*y);
}

int n;
int r[502];
Circle cs[502];

bool ok(int m) {
    if(cs[m].x-cs[m].r<0) return false;
    rep(i,m) {
        //cout<<"comp: "<<i<<", "<<m<<endl;
        if(!ok(cs[i],cs[m])) return false;
    }

    return true;
}

void func(int m) {
    double lb=0,ub=INF;
    rep(i,100) {
        double mid=(lb+ub)/2;
        cs[m].x=mid;
        if(ok(m)) ub=mid;
        else lb=mid;
    }
}

int main() {
    cin>>n;
    rep(i,n) cin>>r[i];
    rep(i,n) cs[i]=Circle(0,r[i],r[i]);
    rep(i,n) func(i);
    double ans=0;
    rep(i,n) ans=max(ans,cs[i].x+cs[i].r);
    printf("%.8f\n",ans);
    return 0;
}

Measured memory_bytes: 1208
var
        i,min,s:longint;
        n,l:int64;
begin
        readln(n);
        min:=maxlongint;
        for i:=trunc(sqrt(n)) downto 1 do
            if n mod i=0 then
            begin
                s:=11;
                l:=10000000000;
                while n div i div l=0 do
                begin
                    l:=l div 10;
                    dec(s);
                end;
                if s<min then min:=s;
            end;
        writeln(min);
end.



Measured memory_bytes: 128
P = 10**9+7
N = 700000 #使う最大値以上にする、値に注意4*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N+1):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b):
    if a<b: return 0 # error
    return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P

n, k = map(int, input().split())

ans = 0
#0が0~min(n-1, k)
num = min(n-1, k) + 1
for i in range(num):
    heya = n - i
    #0
    ret = comb(n, i)
    person = n - heya
    ret = (ret * comb(person+heya-1, person))%P
    ans += ret
print(ans%P)


Measured memory_bytes: 86416
from collections import Counter


def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in c:
        if c[i] < i:
            ans += c[i]
        else:
            ans += c[i] - i
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18676
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0;

int main (){
  int n;    cin >> n;
  vector <int> p(n);
  rep(i,n) {
      cin >> p.at(i);
  }

  for(int i=0;i<n;i++){
     if(p.at(i) != i+1) {
         cnt++;
     }
  }

  if(cnt > 2) {
      cout << "NO" << endl;
      
      return 0;
  }else {
      cout << "YES" << endl;
      
      return 0;
  }
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a;
	a.resize(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if ((i % 2 != 0) && (a[i] % 2 != 0))
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(void){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0 || W == 0){
			break;
		}
		else{
			for(i = 0;i < H;i++){
				printf("#");
				for(j = 1;j < W - 1;j++){
					if(i == 0 || i == H - 1){
						printf("#");
					}
					else{
						printf(".");
					}
				}
				puts("#");
			}
			puts("");
		}
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n,q;
	string s;
	cin>>n>>s>>q;
	for (int i = 0; i < q; ++i)
	{
		int k;
		cin>>k;
		long long d=0LL,m=0LL,cnt=0LL,ans=0LL;
		for (int j = 0; j < k; ++j)
		{
			if (s[j]=='D')
			{
				++d;
			}
			else if (s[j]=='M')
			{
				++m;
				cnt+=d;
			}
			else if (s[j]=='C')
			{
				ans+=cnt;
			}
		}
		for (int j = k; j < n; ++j)
		{
			if (s[j-k]=='D')
			{
				--d;
				cnt-=m;
			}
			else if (s[j-k]=='M')
			{
				--m;
			}
			if (s[j]=='D')
			{
				++d;
			}
			else if (s[j]=='M')
			{
				++m;
				cnt+=d;
			}
			else if (s[j]=='C')
			{
				ans+=cnt;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
    long long sum=0;
    for (int i=0;i<N;i++){
        sum+=A[i];
    }
    if (H<=sum){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


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

int main(){
    int n,b,f,r,v; int a[4][3][10] = {0}; cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> b >> f >> r >> v;
        a[b - 1][f - 1][r - 1] += v;
    }
    for(int i = 0; i < 4; ++i){
        for(int j = 0; j < 3; ++j){
            for(int k = 0; k < 10; ++k){
                cout << " " << a[i][j][k] << flush;
            }
            cout << endl;
        }
        if(i != 3) cout << "####################" << endl;
    }
}

Measured memory_bytes: 3048
S = input()

def even_string(s):
    n = len(s)
    if s[0:n//2] == s[n//2:n]:
        return True
    else:
        return False

for i in range(2,len(S)):
    n = len(S) - i
    comp = S[0:n]
    if even_string(comp):
        print(len(comp))
        quit()


Measured memory_bytes: 2940
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

#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--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;
int const N_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  if (!po[n]) {
    po[0] = 1;
    FOR(i, 1, n + 1) po[i] = po[i - 1] * i % MOD;
  }
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int N, M;
int s[N_MAX + 1];
ll sums[N_MAX + 1];

int main() {
  scanf("%d %d", &N, &M);
  rep(i, M) scanf("%d", &s[i]);

  rep(i, M) sums[s[i]] = -1;

  sums[0] = 1;
  if (sums[1] != -1) sums[1] = 1;
  FOR(i, 2, N + 1) {
    if (sums[i] == -1) continue;
    int bef = sums[i - 1] == -1 ? 0 : sums[i - 1];
    int befbef = sums[i - 2] == -1 ? 0 : sums[i - 2];
    sums[i] = (bef + befbef) % MOD;
  }
  printf("%lld\n", sums[N]);
}


Measured memory_bytes: 1408
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}


int main(){
    string s;
    int a[26]={0};
    cin>>s;
    bool ans=true;
    for(int i=0;i<s.size();++i){
        a[s[i]-'a']++;
        if(a[s[i]-'a']>=2){
            ans=false;
            break;
        }
    }
    if(ans)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}

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

int main(){
    unsigned short b=0;
    unsigned short a[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    cin >> b;
    cout << a[b-1];
    return 0;    
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

const int boardw = 4;

struct BOARD {
    int map[boardw][boardw];
};
 
bool check(BOARD &b) {
    for (int i = 0; i < boardw; ++i) {
        for (int j = 0; j < boardw; ++j) {
            if (b.map[i][j] == 0) continue;
            int tgt = i * boardw + j + 1;
            if (b.map[i][j] != tgt) {
                return false;
            }
        }
    }
    return true;
}

int dfs(BOARD &b, int depth, int dir) {
    if (depth == 0) {
        if (check(b)) {
            return 1;
        } else {
            return -1;
        }
    }

    int px, py;
    for (int i = 0; i < boardw; ++i) {
        for (int j = 0; j < boardw; ++j) {
            if (b.map[i][j] == 0) {
                px = j;
                py = i;
            }
        }
    }
    int est = 0;
    for (int i = 0; i < boardw; ++i) {
        for (int j = 0; j < boardw; ++j) {
            if (i * j == boardw * boardw) continue;
            for (int k = 0; k < boardw; ++k) {
                for (int l = 0; l < boardw; ++l) {
                    if (i * boardw + j + 1 == b.map[k][l]) {
                        est += std::abs(k - i) + std::abs(l - j);
                    }
                }
            }
        }
    }
    if (est > depth) {
        return -1;
    }
    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};
    for (int k = 0; k < 4; k++) {
        if (dir != -1 && k == (dir + 2) % 4) {
            continue;
        }
        int tx = px + dx[k];
        int ty = py + dy[k];
        if (tx < 0 || tx >= boardw || ty < 0 || ty >= boardw) continue;
        int temp = b.map[py][px];
        b.map[py][px] = b.map[ty][tx];
        b.map[ty][tx] = temp;
        
        int ret = dfs(b, depth - 1, k);
        
        temp = b.map[py][px];
        b.map[py][px] = b.map[ty][tx];
        b.map[ty][tx] = temp;
        if (ret != -1) return ret;
    }
    return -1;
}
 
int main(int argc, char const *argv[]) {
    BOARD b;
    for (int i = 0; i < boardw; ++i) {
        for (int j = 0; j < boardw; ++j) {
            cin >> b.map[i][j];
        }
    }
    if (check(b)) {
        cout << 0 << endl;
        return 0;
    }
    int i = 0;
    while(++i) {
        int ret = dfs(b, i, -1);
        if (ret == 1) {
            cout << i << endl;
            return 0;
        }
    }
 
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define endl "\n"
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define ininf(b) memset(b,1000000001,sizeof(b))

 
int main() {
    io;

    ll n,k;
    cin>>n>>k;
    ll arr[n+1]={0};
    rep(i,1,n+1) cin>>arr[i];
    ll dp[n+1]={0};
    ininf(dp);
    dp[1]=0;
    dp[2] = abs(arr[2] - arr[1]);

    rep(i,3,n+1){
        rep(j,1,k+1){
            if(i-j>=0)
        dp[i] = min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
    
        }
    }
    // rep(i,1,n+1)
    cout<<dp[n]<<endl;

 
 
 
    
 
    return 0;
}

Measured memory_bytes: 1792
local mod = 1000000007
local function badd(x, y)
  return (x + y) % mod
end

local h, w = io.read("*n", "*n", "*l")
local t = {}
local cnt = {}
for i = 1, h do
  local str = io.read()
  for j = 1, w do
    local idx = (i - 1) * w + j
    t[idx] = str:sub(j, j) == "."
    cnt[idx] = 0
  end
end
cnt[1] = 1
for i = 1, h do
  for j = 1, w do
    local idx = (i - 1) * w + j
    if t[idx] then
      if j < w then
        cnt[idx + 1] = badd(cnt[idx + 1], cnt[idx])
      end
      if i < h then
        cnt[idx + w] = badd(cnt[idx + w], cnt[idx])
      end
    end
  end
end
print(cnt[h * w])


Measured memory_bytes: 33824
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
const int NR = 1005;
///ifstream in ("date.in");
int di[4] = { 0, -1, 0 , 1 };
int dj[4] = { 1 , 0 , -1 , 0};
int n, m ;
char c ;
bool ok ( int x , int y )   {

    return x && y && x <= n && y <= m ;
}
int sol, new_x, new_y ,d ,a [ NR ][ NR ] , viz [ NR ][ NR ];
pair < int , int > nod ;
deque < pair < int , int > > q;
int main() {
    int i , j ;
   cin >> n >> m ;
   for ( i = 1 ; i <= n ; ++ i )
   for ( j = 1 ;  j <=  m ; ++ j ) {
            cin >> c ;
            if ( c == '.' )
                a [ i ][ j ] = 1 ;
            else
                a [ i ][ j ] = 2 ;
        if ( a [ i ][ j ] == 2 )
        q.push_back( mp ( i , j ) ) ;
   }

   while ( !q.empty() ) {
        nod = q.front();
        q.pop_front();
        for ( d = 0 ; d < 4 ; ++ d ) {
            new_x = nod.first + di [ d ];
            new_y = nod.second + dj [ d ];
            if ( ok ( new_x, new_y ) && a [ new_x ][ new_y ] == 1 && !viz [ new_x ][ new_y ] )  {
                viz [ new_x ][ new_y ] = 1 + viz [ nod.first ][ nod.second ] ;
                sol = max (sol, viz [ new_x ][ new_y ] );
                q.push_back( mp ( new_x, new_y ) );
            }
        }
   }

    cout << sol;
    return 0;
}


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long int ll;
 
int main(){
  int a,b;
  string s="a";
  cin >>a>>b;
  if(a>b) s+=" > b";
  if(a<b) s+=" < b";
  if(a==b) s+=" == b";
  cout <<s<<endl;
}


Measured memory_bytes: 3180
<?php
  $n = trim(fgets(STDIN));
  $town = explode(" ", trim(fgets(STDIN)));
  $sol = explode(" ", trim(fgets(STDIN)));
  for($i=0; $i<$n; $i++){
      $min = min($sol[$i],$town[$i]);
      $sol[$i] -= $min;
      $a += $min;
      $min = min($town[$i+1],$sol[$i]);
      $town[$i+1] -= $min;
      $a += $min;
  }
  echo $a;

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

using namespace std;

int main() {
    int n, i;
    int v[51] = {0, };
    int c[51] = {0, };
    cin >> n;

    for (i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (i = 0; i < n; i++) {
        cin >> c[i];
    }
    int sumValue = 0, sumCost = 0;
    for (i = 0; i < n; i++) {
        if (v[i] > c[i]) {
            sumValue += v[i];
            sumCost += c[i];
        }
    }
    cout << sumValue - sumCost;

    return 0;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int s, w;
	cin >> s >> w;

	if(s > w) cout << "safe";
	else cout << "unsafe";

	return 0;
}

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

int main(){
    int h = 0;
    int n = 0;
    int total = 0;
    cin >> h >> n;
    int at = 0;
    for (int i = 0;i < n; i++){
        cin >> at;
        total += at;
    }
    if ( h > total )
        cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import bisect
MAX_INT = int(10e12)
MIN_NUM = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K,Q = IL()
a = [I() for i in range(Q)]

data = [K-Q]*N
for i in range(Q):
  data[a[i]-1] += 1

for i in range(N):
  if data[i] > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 50140
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int A[1<<20];int n, a, b;

bool possible(int nblast) {

    int x = a-b;

    ll sum = 0;
    for(int i = 0;i < n;i++) {
        ll y = A[i]-nblast*ll(b);
        if(y > 0)
            sum += ceil(y/double(x));
    }

    return sum <= nblast;
}

int main() {
  std::ios::sync_with_stdio(false);
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin>>n>>a>>b;
  rep(i, n) cin>>A[i];
  sort(A,A+n);

  int s = 1, e = int(1e9), mid;
  int ans = e+1;

  while (s <= e) {
      mid = (s+e)/2;
      if(possible(mid)) {
          ans = mid;
          e = mid-1;
      } else s = mid+1;
  }

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


Measured memory_bytes: 640
n,m= map(int, input().split())
par = [i for i in range(n)]

def find(x):
  if par[x] == x:
    return x
  else:
    par[x] = find(par[x])
    return par[x]

def unite(x, y):
  x = find(x)
  y = find(y)
  if x > y:
    par[x] = y
    find(x)
  else:
    par[y] = x
    find(y)

if m > 0:  
  for i in range(m):
    a, b = map(int, input().split())
    unite(a - 1, b - 1)
  
  ans = [0] * n
  Max = 0
  for i in range(n):
    find(i)
  for i in par:
    ans[i] += 1
  for i in ans:
    if i > Max:
      Max = i
  
  print(Max)
else:
  print(1)

Measured memory_bytes: 18384
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
 
 
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
 
 
def lcm(a, b):
    return a * b // gcd(a, b)
 
 
tmp = A[0]
for i in range(1, N):
    tmp = lcm(tmp, A[i])
 
B = [0] * N
for i in range(N):
    B[i] = tmp // A[i]
 
print(sum(B) % mod)

Measured memory_bytes: 262388
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)*}
    };
}

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)*}
    };
}

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        mut v: [(i64, i64); n]
    }
    v.sort_by(|x, y| (x.1 as f64).atan2(x.0 as f64).partial_cmp(&(y.1 as f64).atan2(y.0 as f64)).unwrap());
    let mut ans = 0;
    for i in 0..n {
        let mut x = 0;
        let mut y = 0;
        for j in 0..n {
            x += v[(i + j) % n].0;
            y += v[(i + j) % n].1;
            ans = max(ans, x * x + y * y);
        }
    }
    println!("{}", (ans as f64).sqrt());
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
	int takasa[10];

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

	//????????????
	for (int i = 0; i < 9; i++) {
		for (int j = i+1; j < 10; j++) {
			if (takasa[i] <takasa[j]) {
				swap (takasa[i],takasa[j]);
			}
		}
	}
	
	for (int i = 0; i < 3; i++) {
		cout << takasa[i] << endl;
	}
	return 0;
}

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

lo pro(lo N){
	lo ans = N - 1;
	for(lo i=1;i*i<=N;i++){
		if(N%i == 0 && ans > i + N/i-2)
			ans = i + N/i - 2 ;
	}
return ans;
}
	
int main(){
	lo a;
	scanf("%lld",&a); 
	printf("%lld",pro(a));	
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a[101], n, t, ans = 100*100;
  a[0] = 0;
  cin >> n;
  for(int i=1; i<=n; i++){
    cin >> t; 
    a[i] = a[i-1] + t;
  }
  int total = a[n];
  for(int i=1; i<=n; i++){
    ans = min(ans, abs(total - 2*a[i]));
  }
  cout << ans << endl;
  return 0;
}

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

const double EPS = 1e-10;
const double INF = 1e12;
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) <-EPS) return -1; //cw
    if(dot(b,c) < EPS) return +2; //c-a-b
    if(norm(b) < norm(c)) return -2; //a-b-c
    return 0; //a-c-b
}

int main(){
    double x[4],y[4];
    while(cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3]){
        VP v(4);
        for(int i=0; i<4; i++) v[i] = P(x[i],y[i]);
        if(ccw(v[0], v[1], v[2]) == -1) swap(v[1],v[2]);
        bool flag=true;
        for(int i=0; i<3; i++){
            if(ccw(v[i], v[(i+1)%3], v[3]) == -1){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

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


vector<ll> enumerate_divisors(ll n) {
  vector<ll> div_1, div_2;
  ll e, root_n = (ll)(sqrt(n) + 0.5);
  for (int d = 1; d <= root_n; d++) {
    if (n % d == 0) {
      div_1.push_back(d);
      e = n / d;
      if (e != d) div_2.push_back(e);
    }
  }
  reverse(div_2.begin(), div_2.end());
  div_1.insert(div_1.end(), div_2.begin(), div_2.end());
  return div_1;
}


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

  auto F = [](ll A, ll B) -> int {
    return max(to_string(A).size(), to_string(B).size());
  };

  vector<ll> divisors = enumerate_divisors(N);
  int ans = 1 << 30;
  for (ll d: divisors) {
    ans = min(ans, F(d, N / d));
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
	int N;
	string str;
	scanf("%d", &N);
	cin >> str;
	int ans = 0;
	for (int i = 2; i < N; i++) {
		if (str[i] == 'C' && str[i - 1]  == 'B' && str[i - 2] == 'A') {
			ans++;
		}
	}
	printf("%d\n", ans);
}	

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

using namespace std;

int main() {
  long long N, Y;
  long long a = -1, b = -1, c = -1;
  cin >> N >> Y;
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N - i; ++j) {
      for (int k = 0; k <= N - i - j; ++k) {
        if (i + j + k == N) {
          if (10000 * i + 5000 * j + 1000 * k == Y) {
            cout << i << ' ' << j << ' ' << k << '\n';
            return 0;
          }
        }
      }
    }
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            int[] P = new int[N];
            for (int i = 0; i < N; i++) {
                P[i] = sc.nextInt();
            }

            double[] E = new double[N];
            for (int i = 0; i < N; i++) {
                E[i] = (1 + P[i]) / 2.0;
            }

            double sum = 0;
            for (int i = 0; i < K; i++) {
                sum += E[i];
            }

            double max = sum;
            for (int i = K; i < N; i++) {
                sum += E[i] - E[i - K];
                max = Math.max(max, sum);
            }

            System.out.println(max);
        }
    }

}


Measured memory_bytes: 73992
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int N,K;
	cin>>N>>K;
	
	long long ans = 0;
	
	for(int i=K+1;i<=N;i++){
		int a = i-K;
		int b = N/i;
		ans += (long long) a*b;
		if(K!=0)ans += (long long)max(0,(N%i)+1-K);
		else ans+=(long long)(N%i);
	}
	
	cout<<ans<<endl;
		
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int absl(int n){
  if(n > 0){
    return n;
  }else if(n < 0){
    return -n;
  }else{
    return 0;
  }
}
  
int main(){
  int n = 0;
  int t[100000] = {};
  int x[100000] = {};
  int y[100000] = {};
  int nowx = 0;
  int nowy = 0;
  int nowt = 0;
  
  int i = 0;
  int travelflag = 1;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&t[i],&x[i],&y[i]);
  }
  
  for(i=0;i<n;i++){
    if((absl(x[i]-nowx)+absl(y[i]-nowy)<=t[i]-nowt)&&(((absl(x[i]-nowx)+absl(y[i]-nowy))%2) == ((t[i]-nowt)%2))){
      nowx = x[i];
      nowy = y[i];
      nowt = t[i];
    }else{
      travelflag = 0;
      break;
    }
  }
  
  if(travelflag){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}
      
      

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		for (int i = 111; i < 1000; i+=111) {
			if (i >= n) {
				System.out.println(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 21844
use std::io;

fn main() {
    let Pi : f64 = 3.1415926535 ;
    let R = scan_input().trim().parse::<f64>().unwrap();
    println!("{}", 2.0 * Pi * R);
}

fn scan_input() -> String {
    let mut input = String::new();
    match io::stdin().read_line(&mut input) {
        Ok(_) => input,
        Err(_) => "".to_string(), 
    }
}


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

int main(void) {


	int A, B;
	cin >> A >> B;

	int ans = 0;
	ans = max(ans, A * 2 - 1);
	ans = max(ans, A + B);
	ans = max(ans, B * 2 - 1);

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
def main():
        N, K = map(int, input().split())
        # K: fixed
        ans = 0
        r = N%K

        if N%K==0:
                ans = 0
        else:
                ans = min(r, abs(r-K))

        print("{}".format(ans))

if __name__=="__main__":
        main()

Measured memory_bytes: 9172
import sys
N, M = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for i in range(M)]
ans = [1] * N
for i in range(M):
    a, b = AB[i]
    if H[a - 1] < H[b -1]:
        ans[a -1] = 0
    elif H[a - 1] > H[b - 1]:
        ans[b - 1] = 0
    else:
        ans[a - 1] = 0
        ans[b - 1] = 0
print(ans.count(1))


Measured memory_bytes: 31872
import math

N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for Z in range(-100, 101, 1):
  if X < Z and Z <= Y and max(x) < Z and min(y) >= Z:
    print('No War')
    break
else:
  print('War')


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int intceil(int a, int b) {
	return (a + (b - 1)) / b;
}

int main() {
	cin >> N >> K;
	cout << intceil(N - 1, K - 1) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	//inputは入力値、sは秒を格納、mは分を格納、hは時間を格納
	int input,s,m,h;

	//scanf関数でデータを取得
	scanf("%d",&input);
	
	/*3600秒(60秒×60分)＝1時間
	  秒数を3600秒で割った商が時間数になる*/
	h = input / 3600;
	/*inputを3600秒で割った余りが1時間未満の秒数になる
	  1時間未満の秒数を60で割った商が60分未満の分数になる*/
	m = input % 3600 / 60;
	//inputを3600秒で割った余りをさらに60秒で割った余りが1分未満の秒数になる
	s = input % 3600 % 60;

	//結果の出力
	printf("%d:%d:%d\n",h,m,s);

	return 0;
}


Measured memory_bytes: 1992