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

int a, b, c, d;

int main() {
  scanf("%d %d %d %d", &a, &b, &c, &d);
  int cnt0 = a % d == 0 ? a / d : a / d + 1;  
  int cnt1 = c % b == 0 ? c / b : c / b + 1;
  puts(cnt0 >= cnt1 ? "Yes" : "No");
  return 0;  
}

Measured memory_bytes: 3660
<?php
class Swap0or1  {
    var $N, $p, $cnt;
    
    function __construct() {
        list($this->N) = explode(" ", trim(fgets(STDIN)));
        $this->p = array_map("intval", explode(" ", trim(fgets(STDIN))));
        $this->cnt = 0;
    }
    function __invoke() {
        foreach ($this->p as $key => $val) {
            if ($key + 1 !== $val) {
                $this->cnt++;
            }
        }
        return ($this->cnt === 0 || $this->cnt === 2) ? "YES" : "NO";
    }
}

$Swap0or1 = new Swap0or1();
echo $Swap0or1();

Measured memory_bytes: 4728
#include <cstdio>
using namespace std;

int a, b, c, d, e, f;
int ans[2];
double x=-1;

int main(){
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	for(int i=0; 100*a*i<=f; ++i)
		for(int j=0; 100*a*i+100*b*j<=f; ++j)
			for(int k=0; 100*a*i+100*b*j+c*k<=f; ++k)
				for(int l=0; 100*a*i+100*b*j+c*k+d*l<=f; ++l)
					if(e*(a*i+b*j) >= c*k+d*l && x < (double)100*(c*k+d*l)/(100*(a*i+b*j)+(c*k+d*l))){
						x = (double)100*(c*k+d*l)/(100*(a*i+b*j)+(c*k+d*l));
						ans[0] = 100*(a*i+b*j)+c*k+d*l;
						ans[1] = c*k+d*l;
					}
	printf("%d %d\n", ans[0], ans[1]);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

int main() {
  ll H, W, K;
  cin >> H >> W >> K;

  vector<vector<ll>> dp(H + 1, vector<ll>(W, 0));
  // 1番目からスタート
  dp[0][0] = 1;

  for (ll i = 0; i < H; i++) {
    // 平行線のひき方
    for (ll bit = 0; bit < (1<<(W-1)); bit++) {
      // 隣り合う列に平行にひくのは禁止
      ll invalid = false;
      for (ll k = 1; k <= (W - 1); k++) {
        if (bit & (1 << k) && bit & (1 << (k-1))) {
          invalid = true;
          break;
        }
      }

      if (invalid) continue;

      // cout << "line: " << bit << endl;

      for (ll j = 0; j <= W - 1; j++) {
        ll next = j;
        if (j >= 1 && bit & (1 << (j-1))) {
          next -= 1;
        } else if (j <= (W - 1) && bit & (1 << (j))) {
          next += 1;
        }

        dp[i + 1][next] += dp[i][j];
        dp[i + 1][next] %= MOD;
      }
    }
  }

  cout << dp[H][K-1] % MOD << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N,D;
    cin >> N >> D;
    vector<vector<ll>> X(N,vector<ll>(D));
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin >> X[i][j];
        }
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            double tmp=0;
            for(int l=0;l<D;l++){
                tmp+=(X[i][l]-X[j][l])*(X[i][l]-X[j][l]);
            }
            if(floor(sqrt(tmp))==sqrt(tmp)) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

struct UnionFind{
  vll par;
  vll rank;
  UnionFind(ll n) : par(n), rank(n, 1){
      REP(i, n)
        par[i] = i;
    }

  ll find(ll x){
      if(par[x]==x)
        return x;
      return par[x] = find(par[x]);
    }

  void unite(ll x, ll y){
      x = find(x);
      y = find(y);
      if(x == y)
        return;

      if(rank[x] < rank[y])
        par[x] = y;
      else{
            par[y] = x;
            if(rank[x] == rank[y])
              rank[x]++;
          }
    }

  bool same(ll x, ll y){
      return find(x) == find(y);
    }

  ll size(ll x){
      return rank[x];
    }
};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  vll x(n),y(n);
  REP(i,n)cin>>x[i]>>y[i];

  vpl xp(n),yp(n);
  REP(i,n){
    xp[i].FI=x[i];
    yp[i].FI=y[i];
    xp[i].SE=yp[i].SE=i;
  }

  sort(xp.begin(),xp.end());
  sort(yp.begin(),yp.end());

  vector<pair<ll,pll>> edge;
  REP1(i,n){
    pll l=xp[i-1];
    pll r=xp[i];
    if(l.SE>r.SE)
      swap(l,r);
    ll diff=abs(r.FI-l.FI);
    pll p = pll(l.SE,r.SE);
    edge.push_back(make_pair(diff, p));
  }

  REP1(i,n){
    pll l=yp[i-1];
    pll r=yp[i];
    if(l.SE>r.SE)
      swap(l,r);
    ll diff=abs(r.FI-l.FI);
    pll p = pll(l.SE,r.SE);
    edge.push_back(make_pair(diff, p));
  }

  //prim
  sort(edge.begin(), edge.end());
  UnionFind uf(n);
  ll ans=0;
  for(auto e:edge){
    ll l=e.SE.FI;
    ll r=e.SE.SE;
    ll dist=e.FI;
    if(uf.same(l,r))
      continue;

    ans += dist;
    uf.unite(l,r);
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 13168
using System;

class main
{
    static void Main(string[] args)
    {
        double x=0.0;
        double y=0.0;
        double angle=0.0;
        while (true)
        {
            var str = Console.ReadLine().Split(',');
            var r = int.Parse(str[0]);
            var angle_temp= int.Parse(str[1]);
            if ((r == 0) && (angle_temp == 0))break;
            var sin = Math.Sin(angle * (Math.PI / 180));
            var cos = Math.Cos(angle * (Math.PI / 180));
            x += cos * r;
            y += sin * r;
            angle += angle_temp;
        }
        Console.WriteLine((int)y);
        Console.WriteLine((int)x);
    }
}

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define re          return
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define hell2        1000000009
#define endl        '\n'
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define PI            3.141592653589793l
#define sz(x)       (int)x.size()
#define fill(c,val) memset(c,val,sizeof(c))
#define LB lower_bound
#define UB upper_bound
using namespace std;
typedef long long ll;
const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const ll INF=(1LL<<60)-1;
//v.resize(distance(v.begin(),unique(v.begin(),v.end())));
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){ 
	    float x,y,z;
	    cin>>x>>y>>z;
	    cout<<floor((x-z)/(y+z));
	    cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N, M;
  cin >> N >> M;
  if(N>=10 || M>=10) cout << -1 << endl;
  else cout << N*M << endl;
 
}


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

using namespace std;

int main(){
int a, b, c, d;
cin >> a >> b >> c >> d;
if(a + b > c + d){
    cout <<"Left";
}
else if(a + b < c + d){
    cout <<"Right";
}
else{
    cout <<"Balanced";
}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    string s,t; cin>>s>>t;
    s += s;
    rep(i,t.size()){
        if(s.substr(i,t.size()) == t){cout<<"Yes"<<endl; return 0;}
    }
    cout<<"No"<<endl; return 0;
}


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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// 空白がある位置を二分探索で絞り込んでいく

int main(){
    ll n; cin >> n;
    vector<string> mw(n);

    // 0番目とn-1番目を埋める
    cout << 0 << endl;
    cin >> mw[0];
    if(mw[0] == "Vacant") return 0;
    cout << n-1 << endl;
    cin >> mw[n-1];
    if(mw[n-1] == "Vacant") return 0;


    ll l = 0, r = n-1;
    for(ll i=0; i<20; i++){
        ll mid = (l+r)/2;
        cout << mid << endl;
        cin >> mw[mid];
        if(mw[mid] == "Vacant") return 0;
        if((((mid-l+1)%2 == 0) && (mw[l] == mw[mid])) || (((mid-l+1)%2 == 1) && (mw[l] != mw[mid]))) r = mid;
        else l = mid;
    }
    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  
  int n = min(a,b);
  int m = max(a,b);
  
  for(int i = 0; i < m; i++){
    cout << n;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll n;
    cin >> n;
    if(n == 3){
        printf("2 5 63\n");
        return 0;
    }else if(n == 4){
        printf("2 5 20 63\n");
        return 0;
    }else if(n == 5){
        printf("2 3 4 6 9\n");
        return 0;
    }
    vector<ll> v;
    ll mod = 0;
    ll i = 2;
    for(; i <= 30000 && v.size() < n; i++){
        if(i % 2 && i % 3) continue;
        v.push_back(i);
        mod = (mod + i) % 6;
    }
    switch(mod){
        case 2:
            v.erase(v.begin() + 4);
            for(;; i++){
                if(i % 6 == 0){
                    v.push_back(i);
                    break;
                }
            }
            break;
        case 3:
            v.erase(v.begin() + 5);
            for(;; i++){
                if(i % 6 == 0){
                    v.push_back(i);
                    break;
                }
            }
            break;
        case 5:
            v.erase(v.begin() + 5);
            for(;; i++){
                if(i % 6 == 4){
                    v.push_back(i);
                    break;
                }
            }
            break;
    }
    for(ll u : v) cout << u << " ";
    cout << endl;
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	n = n % 1000;
	if (n == 0)
	{
		cout << n << endl;
		return 0;
	}

	cout << 1000 - n << endl;
	
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cmath>

typedef long long ll;

int main()
{
  ll N, K;

  std::cin >> N >> K;

  ll x = N / K;
  ll ans = (ll)std::pow(x, 3);
  if (K % 2 == 0) {
    ll y = K/2;
    ll cnt = 0;
    while (y <= N) {
      cnt++;
      y += K;
    }
    ans += (ll)std::pow(cnt, 3);
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 384
import sys, math

k = int(sys.stdin.readline().strip())

stored2 =  [[ [0 for i in range(k+1)] for j in range(k+1)] for z in range(k+1)]
stored = [ [0 for i in range(k+1)] for j in range(k+1)]
def get_gcd(x, y):
    x, y = min(x,y), max(x,y)
    if x == 1:
        return 1
    if stored[x][y] == 0:
        stored[x][y] = math.gcd(x,y)
    return stored[x][y]

res = 0
for x in range(1, k+1):
    for y in range(x, k+1):
        for z in range(y, k+1):
            stored2[x][y][z] = get_gcd(x,get_gcd(y,z))

for x in range(1, k+1):
    for y in range(1, k+1):
        for z in range(1, k+1):
            a,b,c = sorted([x,y,z])
            res += stored2[a][b][c]

print(res)

Measured memory_bytes: 137196
def examA():
    bit = 41
    N, K = LI()
    A = LI()
    B = [0]*bit
    for a in A:
        for j in range(bit):
            if a&(1<<j)>0:
                B[j] += 1
    ans = 0
    cnt = 0
    for i in range(bit)[::-1]:
        if N-B[i]<=B[i]:
            ans += (1 << i) * B[i]
        else:
            if cnt+(1<<i)>K:
                ans += (1 << i) * B[i]
            else:
                cnt += (1 << i)
                ans += (1 << i) * (N-B[i])
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 64112
N, X, Y = map(int, input().split())

lists = [0] * (N - 1)

for i in range(1, N):
  for j in range(i + 1, N + 1):
    min_length = min(abs(j-i),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
    lists[min_length - 1] += 1

for k in lists:
  print(k)
        

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
bool M(int n){
  if(n>0 && n<13) return true;
  else return false;
}

int main(){
  string S;
  cin >> S;
  string str1,str2;
  str1 = S.substr(0,2);
  str2 = S.substr(2,2);
  int n1,n2;
  n1=stoi(str1);
  n2=stoi(str2);
  if(M(n1)&&M(n2)) cout << "AMBIGUOUS" << endl;
  else if(M(n1)) cout << "MMYY" << endl;
  else if(M(n2)) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  return 0;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,l,m,n,x,y,z;
	int ans;
	String[] S;

	Main(){
		// 整数の入力
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();

		// 出力
		System.out.println(Math.max(0,c-a+b));
	}

	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 21844
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
   
  		int[] a=new int[n+1];
  		int[] b=new int[n];
		for(int c=0;c<n+1;c++){
    		a[c]=sc.nextInt();
    	}
  		for(int c=0;c<n;c++){
        	b[c]=sc.nextInt();
        }
  		
  		long ans=0;
  		for(int d=0;d<n;d++){
        	if(a[d]<b[d]){
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            }else{
            	ans+=b[d];
            }
        }
    
 	

    	System.out.println(ans);
    }
}



Measured memory_bytes: 63604
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	vector<pair<int, int>> testi[N];
	for (int i = 0; i < N; i++)
	{
		int a; cin >> a;
		for (int j = 0; j < a; j++)
		{
			int x, y; cin >> x >> y;
			x--;
			testi[i].push_back(make_pair(x, y));
		}
	}
	
	int res = 0;
	for (int bit = 0; bit < (1<<N); bit++)
	{
		bool right = true;
		for (int i = 0; i < N; i++)
		{
			for (auto p : testi[i])
			{
				if(bit & (1<<i)) {
					if((bit>>p.first & 1) != p.second) right = false;
				}
			}
		}
		if(right) { 
			res = max(res, __builtin_popcount(bit));
//			cout << bit << endl;
		}
	}
	
	cout << res << endl;
	return 0;
}


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

std::vector<int> edges[2000];

int dfs(int node,int parent,int depth){
  if(depth==0) return 1;
  int cnt=1;
  for(int child:edges[node]){
    if(child!=parent){
      cnt+=dfs(child,node,depth-1);
    }
  }
  return cnt;
}

int main(){
  int N,K;
  std::cin>>N>>K;
  for(int i=0;i<N-1;i++){
    int A,B;
    std::cin>>A>>B;
    A--,B--;
    edges[A].push_back(B);
    edges[B].push_back(A);
  }
  int best=0;
  for(int i=0;i<N;i++){
    for(int j:edges[i]){
      best=std::max(best,dfs(j,i,K/2)+dfs(i,j,(K-1)/2));
    }
  }
  std::cout<<N-best<<std::endl;
  return 0;
}


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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    long long sq1,sq2;
    sq1 = A * B;
    sq2 = C * D;
    if(sq1 > sq2){
        cout << sq1 << endl;
    }else{
        cout << sq2 << endl;
    }
}

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 ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> v(n);
  REP(i, n) cin >> v[i];

  ll ans = 0;
  REP(i, k + 1) REP(j, k + 1) {
    if (i + j > k || i + j > n) continue;
    ll res = k - (i + j);
    vector<ll> get;
    REP(l, i) get.push_back(v[l]);
    REP(r, j) get.push_back(v[n - 1 - r]);
    sort(ALL(get));

    ll sum = 0;
    for (auto x : get) {
      sum += x;
    }

    REP(t, min((ll)get.size(), res)) {
      if (get[t] >= 0) break;
      sum -= get[t];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ll N = 0, T;
    cin >> N >> T;
    vector<ll> A(N,0);
    for(ll i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    ll ans = 0;
    ll s = -1e10;
    ll e = -1e10;
    for(int i = 0; i < N; i++) {
        if(e < A.at(i)) {
            ans += e - s;;
            s = A.at(i);
            e = A.at(i) + T;
            if(i == N - 1) {
                ans += e - s;
            }
        } else {
            e = A.at(i) + T;
            if(i == N - 1) {
                ans += e - s;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4628
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var x = cin.ReadInt;
            var y = cin.ReadInt;
            int[] g = { 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
            if(g[x - 1] == g[y - 1])
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }



        public long C(int X, int Y)
        {

            if (Y == 0 || Y == X)
            {
                return 1;
            }
            if (X < Y)
            {
                return 0;
            }
            var Pascal = new long[X + 1, X + 1];
            for (int i = 0; i <= X; i++)
            {
                Pascal[i, 0] = 1L;
                Pascal[i, i] = 1L;
            }
            for (int i = 2; i <= X; i++)
            {
                for (int j = 1; j < i; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[X, Y];
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<string>

int n,f,s;

bool ym,my;

int main(){

    std::cin>>n;

    f=n/100;
    s=n-f*100;

    if(1<=s&&s<=12)ym=true;
    if(1<=f&&f<=12)my=true;

    if(ym==true&&my==true)
    std::cout<<"AMBIGUOUS"<<std::endl;

    if(ym==true&&my==false)
    std::cout<<"YYMM"<<std::endl;

    if(ym==false&&my==true)
    std::cout<<"MMYY"<<std::endl;

    if(ym==false&&my==false)
    std::cout<<"NA"<<std::endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int x, a, b;
	cin >> x >> a >> b;
	if (b <= a){
		cout << "delicious" << endl;
		return 0;
	}
	else if (b > a){
		if (b - a <= x ){
			cout << "safe" << endl;
		}
		else{
			cout << "dangerous" << endl;
		}
	}
	return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  
  int r = 0;
  
  rep(i, N){
    int x;
    cin >> x;
    
    if(x < K-x){
      r = r + x*2;
    }else{
      r = r + (K-x)*2;
    }
  }
  cout << r << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	int a;

	std::cin >> a;

	if (a % 2 == 0) {
		std::cout << (a / 2)*(a / 2) << std::endl;
	}
	else {

		std::cout << (a / 2)*(a / 2+1) << std::endl;
	}


	return 0;
}

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

using namespace std;

int main(){
    int H,W;
    cin >> H >> W;

    int allow_factor2, allow_odd;
    allow_odd=(H%2)*(W%2);
    allow_factor2=(H%2*W+W%2*H)/2-allow_odd;

    vector<int> num_char(26,0);
    for(int i=0;i<H; i++){
        string a;
        cin >> a;
        for(int j=0; j<a.size(); j++){
            num_char[a[j]-'a']++;
        }
    }

    string ans="Yes";
    for(int i=0; i<num_char.size(); i++){
        if (num_char[i]%4==0)continue;
        else if(num_char[i]%2==0){
            allow_factor2--;
        }else{
            allow_odd--;
        }

        if(allow_factor2<0 || allow_odd<0){
            ans="No";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    final long INF = 1_000_000_000_000L;
    Scanner input = new Scanner(System.in);
    
    while (input.hasNext()) {
      int N = input.nextInt();
      int W = input.nextInt();
      int[] w = new int[N + 1];
      int[] v = new int[N + 1];
      int sumV = 0;
      
      for (int i = 1; i < w.length; ++i) {
        w[i] = input.nextInt();
        v[i] = input.nextInt();
        sumV += v[i];
      }
      
      long[][] dp = new long[N + 1][sumV + 1];
      Arrays.fill(dp[0], INF);
      dp[0][0] = 0;
      for (int i = 1; i < dp.length; ++i) {
        Arrays.fill(dp[i], INF);
        dp[i][0] = 0;
        for (int j = 1; j < dp[i].length; ++j) {
          if (j - v[i] >= 0) {
          	dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
          }
          dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]);
        }
      }
      
      int maxV = 0;
      for (int i = dp[N].length - 1; i >= 0; --i) {
        if (dp[N][i] <= W) {
        	maxV = i;
          	break;
        }
        
      }
      
      System.out.println(maxV);
    }
  }
}

Measured memory_bytes: 131020
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
//#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }//最大公約数
int lcm(int a, int b) { return a * b / gcd(a, b); }	//最小公倍数
#define deg_to_rad(deg) (((deg)/360)*2*PI);
#define rad_to_deg(rad) (((rad)/2/PI)*360);
//template <typename... Args>void IN(Args& ... args) {cin >>args;IN(args...);return;} //まとめて入力　IN(a,b,c,d...)
struct aaa { aaa() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }aaa;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

void Main() {
    int n; cin >> n;
    if (n == 2) {
        cout << 2;
            return;
    }
    if (n % 2 == 0)n++;
    while (!IsPrime(n)) {
        n+=2;
    }
    cout << n;
}

signed main() {
	Main();

	return 0;
}


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

    char s[200000];
    scanf("%s",s);
    long long int i,j1,j2;
    long int d=strlen(s);
    for( i=0;i<d;i++){
            if(s[i]=='A')
            {
                j1=i;break;
            }
    }
    for(i=0;i<d;i++){
        if(s[i]=='Z')j2=i;
    }
    printf("%ld\n",j2-j1+1);
    return 0;
}


Measured memory_bytes: 1924
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,l;
	cin >> n;
	int ans = 0;
	vector<int> a;
	for(int i = 0; i < n; i++) {
		cin >> l;
		ans += l;
		if(l % 10 != 0){
			a.pb(l);
		}
	}
	sort(ALL(a));
	if(ans % 10 == 0 && a.size() == 0){
		ans = 0;
	}
	else if(ans % 10 == 0){
		ans -= a[0];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

struct SCC{//ant p.286
	int V;
	vector< vector<int> > G;
	vector< vector<int> > rG;
	vector<int> vs;
	vector<bool> used;
	vector<int> cmp;
	SCC(int v){
		V = v;
		G.resize(V);
		rG.resize(V);
		used.resize(V,false);
		cmp.resize(V);
	}

	void add_edge(int from,int to){
		G[from].push_back(to);
		rG[to].push_back(from);
	}
	void dfs(int v){
		used[v] = true;
		for(int i=0;i<G[v].size();i++){
			if(!used[G[v][i]])dfs(G[v][i]);
		}
		vs.push_back(v);
	}
	void rdfs(int v,int k){
		used[v] = true;
		cmp[v] = k;
		for(int i = 0; i < rG[v].size(); ++i){
			if(!used[rG[v][i]])rdfs(rG[v][i],k);
		}
	}
	int scc(){
		used = vector<bool>(V,false);
		vs.clear();
		for (int v = 0; v < V; ++v){
			if(!used[v])dfs(v);
		}
		used = vector<bool>(V,false);
		int k = 0;
		for (int i = vs.size() - 1; i >= 0 ; --i){
			if(!used[vs[i]])rdfs(vs[i],k++);
		}
		return k;
	}
	bool is_same(int v1,int v2){
		return cmp[v1]==cmp[v2];
	}
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int V,E,Q;
	cin >> V >> E;
	SCC g(V);
	FOR(i,0,E){
		int f,t;
		cin >> f >> t;
		g.add_edge(f,t);
	}
	g.scc();
	cin >> Q;
	FOR(i,0,Q){
		int a,b;
		cin >> a >> b;
		if(g.is_same(a,b))cout << 1 << endl;
		else 					cout << 0 << endl;
	}
}



Measured memory_bytes: 4544
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int n;
vector<int> anscandy;
int a, b, c;
int l[8];

void dfs( int x, int y, int z, int k, int mp ){
	if( k == n ){
		if( x != 0 && y != 0 && z != 0 ){
			anscandy.push_back( abs(a-x) + abs(b-y) + abs(c-z) + mp );
		}
		return;
	}
	( x == 0 ) ? dfs( x+l[k], y, z, k+1, mp ) : dfs( x+l[k], y, z, k+1, mp+10 );
	( y == 0 ) ? dfs( x, y+l[k], z, k+1, mp ) : dfs( x, y+l[k], z, k+1, mp+10 );
	( z == 0 ) ? dfs( x, y, z+l[k], k+1, mp ) : dfs( x, y, z+l[k], k+1, mp+10 );
	dfs( x, y, z, k+1, mp );
}

int main(){
	cin >> n >> a >> b >> c;
	for( int i = 0; i < n; ++i ) cin >> l[i];
	dfs( 0, 0, 0, 0, 0 );
	sort( anscandy.begin(), anscandy.end() );
	cout << anscandy[0] << endl;
	return 0;
}

// 18:53

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define se second
#define fr first
using namespace std;

const ll N = 2e5 + 7;
const ll mod = 1e9 + 7;

ll n , m , a , cnt , b , c , ans ;
vector<int>g[N];
set<int>st;
ll used[N];

void dfs( int v ){
used[v] = 1;
cnt ++;
for( auto it:g[v] )
    if( !used[it] )
    dfs(it);
}

int main(){
    cin >> n >> m;
    for( int i = 0;i < m;i ++ ){
        ll x , y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1);
    for( int i = 1;i <= n;i ++ ){
        if( !used[i] ){
            dfs(i);
            ans ++;
        }
    }
    cout << ans;
}



Measured memory_bytes: 12716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int cnt,ans=0;
    for(int i=1;i<n;i++){
        cnt=0;
        for(char j='a';j<='z';j++){
            bool ljadge=0,rjadge=0;
            for(int k=0;k<i;k++){
                if(s[k]==j){
                    ljadge=1;
                }
            }
            for(int k=i;k<n;k++){
                if(s[k]==j){
                    rjadge=1;
                }
            }
            if(ljadge==1 && rjadge==1){
                cnt++;
            }
        }
        ans=max(ans,cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, m;
  cin >> n >> m;
  vector <pair <int, int>> edges;
  vector <vector <int>> g(n);
  vector <int> deg(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    edges.emplace_back(u, v);
    ++deg[u];
    g[u].push_back(i);
    g[v].push_back(i);
  } 
  if (m % 2 == 1) {
    cout << "-1\n";
    return 0;
  }
  vector <int> par(n), par_id(n), used(n), tin(n), tout(n);
  vector <pair <int, int>> who;
  int timer = 0;
  function <int(int, int, int)> dfs = [&] (int u, int p, int p_id) {
    used[u] = 1;
    par[u] = p;
    par_id[u] = p_id;
    tin[u] = timer++;
    vector <int> have;
    for (auto id : g[u]) {
      int v = edges[id].first ^ edges[id].second ^ u;
      if (!used[v]) {
        int ret = dfs(v, u, id);
        if (ret != -1) {
          have.push_back(ret);
        } 
      }
    }
    if (deg[u] % 2 == 1) {
      have.push_back(u);
    }
    for (int i = 1; i < (int)have.size(); i += 2) {
      who.emplace_back(have[i - 1], have[i]);
    }
    tout[u] = timer++;
    if ((int)have.size() % 2 == 1) return have.back();
    else return -1;
  };
  dfs(0, -1, -1);
  auto anc = [&] (int a, int b) {
    return tin[a] <= tin[b] && tout[b] <= tout[a];
  };
  for (auto p : who) {
    int a = p.first, b = p.second;
    int c = a;
    while (!anc(c, b)) {
      int i = par_id[c];
      swap(edges[i].first, edges[i].second);
      c = par[c];
    }
    c = b;
    while (!anc(c, a)) {
      int i = par_id[c];
      swap(edges[i].first, edges[i].second);
      c = par[c];
    }
  }
  for (auto p : edges) {
    cout << p.first + 1 << ' ' << p.second + 1 << '\n';
  }
}



Measured memory_bytes: 19828
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B){
  ll ans = 0;
  vector<vector<ll>> n(N+1);
  for (ll i = 0; i < M; i++) {
    n[A[i]-1].pb(B[i]-1);
    n[B[i]-1].pb(A[i]-1);
  }
  for (ll i = 0; i < N; i++) {
    bool x = true;
    for (auto a : n[i]) {
      if(H[i] <= H[a])x = false;
    }
    if(x)ans++;
  }
  cout << ans << endl;
}

int main(){
    long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	std::vector<long long> H(N);
	for(int i = 0 ; i < N ; i++){
		scanf("%lld",&H[i]);
	}
	std::vector<long long> A(M);
	std::vector<long long> B(M);
	for(int i = 0 ; i < M ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
	}
    solve(N, M, std::move(H), std::move(A), std::move(B));
}


Measured memory_bytes: 11472
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

a,b=get_i
ans=-1
10001.times do|i|
  if (i*0.08).to_i==a and (i*0.1).to_i==b
    ans=i
    break
  end
end
puts ans

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

#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    string s1 = "";
    string s2 = "";
    cin >> n >> s;
    if (n < s.length() || n % 2 != 0) cout << "No" << endl;
    else {
        for (int i = 0; i < (s.length() / 2); ++i) {
            s1 += s[i];
        }
        for (int j = s.length() / 2; j < s.length(); ++j) {
            s2 += s[j];
        }
        if (s1 == s2) cout << "Yes" << endl;
        else cout << "No" << endl;
//            cout << s2;
    }


}






Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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


	int N, K; cin >> N >> K;

	if (K != 1)cout << N - K << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int main() {
  double A, B, H, M, Ans, rad_H, rad_M, th;
  cin >> A >> B >> H >> M;
  rad_H = 2*PI * (60*H+M) / 720;
  rad_M = 2*PI * M / 60;
  th = abs(rad_H-rad_M);
  Ans = sqrt(A*A+B*B-2*A*B*cos(th));
  printf("%.10f\n", Ans);
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    if (n%k) PRINT(1);
    else PRINT(0);
}

Measured memory_bytes: 256
n, m = map(int, input().split())
Pref = [[0,0,0,''] for _ in range(m)]
for i in range(m):
    p,y = map(int,input().split())
    Pref[i] = [i,p,y,'']

Pref = sorted(Pref, key=lambda x: x[2])
Pref = sorted(Pref, key=lambda x: x[1])
c = 0
P = Pref[i][1]
for i in range(m):
    if P != Pref[i][1]:
        c = 1
        P = Pref[i][1]
    else:
        c += 1
    Pref[i][3] = str(Pref[i][1]).zfill(6) + str(c).zfill(6)

Pref = sorted(Pref, key=lambda x: x[0])
for i in range(m):
    print(Pref[i][3])

Measured memory_bytes: 37340
import sys

az = [0 for i in range(26)]
s = sys.stdin.read().lower()
l = [ord(i) for i in s]

for i in range(len(l)):
    c = l[i] - 97
    if(c >= 0 and c <= 26):
        az[c] += 1

for i in range(26):
    print('{} : {}'.format(chr(i + 97),az[i]))

Measured memory_bytes: 7440
from sys import stdin
S = stdin.readline().rstrip()
# print(S)
n = len(S)
ans = 0
agct = {'A','G','C','T'}
bin_s = ''
for s in S:
    if s in agct:
        bin_s += '1'
    else:
        bin_s += '0'

right = 0
cnt = 0
for left in range(n):
    # print(bin_s[right])
    while (right < n and bin_s[right] == '1'):
        cnt += 1
        # // ex: sum += a[right];
        right += 1
    ans = max(ans, cnt)

    if (right == left):
        right += 1  
    cnt = 0
    # ex: else sum -= a[left];
print(ans)

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

int main(){
    int num[3];
    for(int i=0; i<3; i++){
        cin >> num[i];
    }

    sort(num, num+3);
    for(int i=0; i<3; i++){
        if(i==2){
            cout << num[i] << endl;
        }
        else{
            cout << num[i] << " ";
        }
    }
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ULL = unsigned long long;

// N!の約数の個数の%MODを求める
ULL FactorsOfFactorial(ULL n) {

  const ULL MOD = 1000000007;

  ULL result = 1;
  vector<ULL> v(n + 1);

  // N!なのでNまでループ
  for (ULL i = 2; i <= n; i++) {
    ULL x = i;

    // 素因数分解結果を配列に記録
    for (ULL j = 2; 1 < x; j++) {
      while (x % j == 0) {
        v.at(j)++;
        x /= j;
      }
    }
  }

  // (n1+1)(n2+1)(n3+1)...%MOD
  for (ULL i = 2; i <= n; i++) {
    result = (result * (v.at(i) + 1)) % MOD;
  }

  return result;
}

int main() {
  ULL N;
  cin >> N;
  cout << FactorsOfFactorial(N) << endl;
  getchar();
}

// int型,unsigned型では正解が出ない

// 入出力例
// 3
// 4

// 6
// 30

// 1000
// 972926972

Measured memory_bytes: 3616
/**************erik****************/
#include<bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  int ll;
typedef unsigned long long int ull;
//map<ll,ll> mp1;
//set<int> s1;
//set<int>::iterator it;
#define maxm(a,b,c)  max(a,max(c,b))
#define minm(a,b,c)  min(a,min(c,b))
#define f(i,n)  for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
    int n;
    cin>>n;
    ll a[n];
    map<ll,ll> mp;
    f(i,n){
        cin>>a[i];
        mp[i+1+a[i]]++;
    }
    ll ct=0;
    f(i,n){
        int k = (i+1-a[i]);
        if(mp.find(k)!=mp.end()){
            ct+=mp[k];
        }
    }
    
    cout<<ct<<endl;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;

int main() {
	cin >> s;
	
	int ans = 1000;
	inc(i, s.size()) {
		string t = s + s[i];
		int ma = 0, l = 0;
		inc(j, t.size()) {
			if(t[j] == s[i]) { setmax(ma, l); l = 0; } else { l++; }
		}
		setmin(ans, ma);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
int32_t main()
{
  int  i=1,j,s;
vector<int> v; v. push_back(0);
while(i<=50)
{
  j=(i*(i+1))/2;v.push_back(j);i++;}
int n; cin>>n; 
vector<int> v1;
for(i=2;i*i<=n; i++)
 {
  if(n%i==0)
  {s=0;
   while(n%i==0)
   { n=n/i;s++;}
 v1.push_back(s);}
}
if(n!=1) v1.push_back(1);s=0;
for(i=0;i<v1.size();i++)
 {
  j=upper_bound(v.begin(),v. end(),v1[i])-v. begin();
j--;
s+=j; }
cout<<s; 
}

Measured memory_bytes: 3624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
ll s[MAXN];
struct anode{ ll x,y; } a[MAXN];
int compare(anode x,anode y){ return x.x<y.x; }
int main()
{
	int n=read(),S=read();
	for (int i=1;i<=n;i++) a[i]=(anode){read(),read()};
	sort(a+1,a+n+1,compare);
	int l=1,r=n,flag=-1;
	while (a[l].x<S&&a[r].x>S)
	{
		if (a[l].y>=a[r].y) a[l].y+=a[r].y,s[l]+=s[r]+((flag!=1)?(a[r].x-a[l].x):0),flag=1,r--;
		else a[r].y+=a[l].y,s[r]+=s[l]+((flag!=0)?(a[r].x-a[l].x):0),flag=0,l++;
	}
	printf("%lld\n",(a[l].x>S)?s[r]+a[r].x-S:s[l]+S-a[l].x);
	return 0;
}

Measured memory_bytes: 3840