akhauriyash/Code-Regression huggingface dataset:
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn pow(x: i64, n: i64, mm: i64) -> i64{
    let mut ans = 1;
    let mut b = x;
    for i in 0..63{
        if (n >> i) & 1 == 1{
            ans *= b;
            ans %= mm;
        }
        b = b*b;
        b %= mm;
    }

    return ans;
}

fn main(){
    let line = read_as_vec::<i64>();
    let n = line[0];
    let mm = 1_000_000_007;
    let mut cn = pow(2, n, mm) - 1;
    for i in 1..3{
        let a = line[i];
        let mut x = 1;
        for i in n-a+1..n+1{
            x *= i;
            x %= mm;
        }
        let mut y = 1;
        for i in 1..a+1{
            y *= i;
            y %= mm;
        }
        let w = pow(y, mm-2, mm);
        cn -= (x*w)%mm;
    }

    while cn < 0{
        cn += mm;
    }

    println!("{}", cn);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class CSlimes
    {
        static void Main(string[] args)
        {
            // 1 ≤ N ≤ 10^5
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var sChars = s.ToCharArray();

            int count = 0;
            char before = sChars[0];

            foreach (var sChar in sChars)
            {
                if (before != sChar)
                {
                    count++;
                    before = sChar;
                }
            }
            count++;

            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n, a[9];
int main() {
	cin >> n;
	rep(i, n)a[i] = i + 1;
	do {
		rep(i, n)cout << a[i] << (i == n - 1 ? "\n" : " ");
	} while (next_permutation(a, a + n));
}


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

int main() {
    int M, K;
    cin >> M >> K;
    bool flag = false;
    if (M <= 1 && K == 0) flag = true;
    if (M >= 2 && K < pow(2, M)) flag = true;
    if (!flag) {
        cout << -1 << endl;
        return 0;
    }
  
    if (K == 0) {
        for (int i = 0; i < pow(2, M); i++) {
            cout << i << " " << i;
            if (i != pow(2, M) - 1) cout << " ";
        }
        cout << endl;
        return 0;
    }

    vector<int> v;
    for (int i = 0; i < pow(2, M); i++) {
        if (i == K) continue;
        v.emplace_back(i);
    }
    vector<int> r = v;
    reverse(r.begin(), r.end());
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << K << " ";
    for (int i = 0; i < r.size(); i++) {
        cout << r[i] << " ";
    }
    cout << K << endl;
}

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

using cat = unsigned long long;

constexpr cat mod = 998244353;

cat pw(int a, int e) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2);
	x = x * x % mod;
	if(e%2) x = x * a % mod;
	return x;
}

inline __attribute__((always_inline)) void add(const cat * __restrict A, cat * __restrict res, int L) {
	for(int i = 0; i < L; i++) {
		res[i] += A[i];
		if(res[i] >= mod) res[i] -= mod;
	}
}

inline __attribute__((always_inline)) void sub(const cat * __restrict A, cat * __restrict res, int L) {
	for(int i = 0; i < L; i++) {
		res[i] += mod-A[i];
		if(res[i] >= mod) res[i] -= mod;
	}
}

void karatsuba(const cat * __restrict A, const cat * __restrict B, cat * __restrict res, int L) {
	if(L <= 32) {
		for(int i = 0; i < L; i++) for(int j = 0; j < L; j++) {
			res[i+j] += A[i] * B[j];
			constexpr cat mod2 = 8 * mod * mod;
			if(res[i+j] >= mod2) res[i+j] -= mod2;
		}
		for(int i = 0; i <= 2*L-2; i++) res[i] %= mod;
		return;
	}
	vector<cat> prod_low(2*(L/2)-1, 0), prod_high(2*(L-L/2)-1, 0);
	karatsuba(A, B, &(prod_low[0]), L/2);
	karatsuba(A+L/2, B+L/2, &(prod_high[0]), L-L/2);
	vector<cat> A_comb(L-L/2, 0), B_comb(L-L/2, 0);
	for(int i = 0; i < L/2; i++) {
		A_comb[i] = A[i] + A[i+L/2];
		if(A_comb[i] >= mod) A_comb[i] -= mod;
	}
	for(int i = 0; i < L/2; i++) {
		B_comb[i] = B[i] + B[i+L/2];
		if(B_comb[i] >= mod) B_comb[i] -= mod;
	}
	if(L%2) A_comb[L/2] = A[L-1], B_comb[L/2] = B[L-1];
	vector<cat> res_comb(2*(L-L/2)-1, 0);
	karatsuba(A_comb.data(), B_comb.data(), &(res_comb[0]), L-L/2);
	add(prod_low.data(), res, 2*(L/2)-1);
	add(prod_high.data(), res+2*(L/2), 2*(L-L/2)-1);
	sub(prod_low.data(), &(res_comb[0]), 2*(L/2)-1);
	sub(prod_high.data(), &(res_comb[0]), 2*(L-L/2)-1);
	add(res_comb.data(), res+L/2, 2*(L-L/2)-1);
}

vector<cat> multiply(vector<cat> & A, vector<cat> & B) {
	int N = A.size();
	vector<cat> ret(2*N-1, 0);
	karatsuba(A.data(), B.data(), &(ret[0]), N);
	return ret;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<cat> F(N+3, 1), FI(N+3, 1);
	for(int i = 1; i < N+3; i++) F[i] = F[i-1] * i % mod;
	for(int i = 1; i < N+3; i++) FI[i] = FI[i-1] * pw(i, mod-2) % mod;
	vector< vector<cat> > dp(M+1, vector<cat>(N+3, 0));
	dp[0][0] = 1;
	for(int i = 1; i <= M; i++) {
		static vector<cat> FI_mul = FI;
		FI_mul[0] = FI_mul[1] = FI_mul[2] = FI_mul[3] = 0;
		for(int j = 0; j <= N; j++) dp[i-1][j] = dp[i-1][j] * FI[j] % mod;
		vector<cat> prod = multiply(FI_mul, dp[i-1]);
		for(int j = 0; j <= N; j++) dp[i-1][j] = dp[i-1][j] * F[j] % mod;
		for(int j = 0; j <= N; j++) {
			dp[i][j] = prod[j+2] * F[j+2] % mod;
			if(j > 0)
				dp[i][j] = (dp[i][j] + (1LL*j*(j+1)*(j+2)/6) % mod * dp[i-1][j-1]) % mod;
			dp[i][j] = (dp[i][j] + ((j+1)*j/2+1) * dp[i-1][j]) % mod;
		}
	}
	cat ans = 0;
	for(int i = 0; i <= N; i++) ans = (ans + F[N] * FI[N-i] % mod * FI[i] % mod * dp[M][i]) % mod;
	cout << ans << "\n";
}


Measured memory_bytes: 13680
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=105;
int n,m;
string s[maxn];
int cnt[maxn];

int main(){
	cin>>n>>m;
	rep(i,n)cin>>s[i];
	rep(i,n)rep(j,m)cnt[s[i][j]-'a']++;
	if(m==1){
		int c=0;
		rep(j,26)if(cnt[j]%2==1)c++;
		if(c==n%2)printf("Yes");
		else printf("No");
		return 0;
	}
	int need=(n/2)*(m/2);
	rep(i,26){
		int can=cnt[i]/4;
		if(can<=need)need-=can,cnt[i]-=can*4;
		else cnt[i]-=need*4,need=0;
	}
	if(need){
		printf("No");
		return 0;
	}
	if(n&1){
		int need=m/2;
		rep(i,26){
			int can=cnt[i]/2;
			if(can<=need)need-=can,cnt[i]-=can*2;
			else cnt[i]-=need*2,need=0;
		}
		if(need){
			printf("No");
			return 0;
		}
	}
	if(m&1){
		int need=n/2;
		rep(i,26){
			int can=cnt[i]/2;
			if(can<=need)need-=can,cnt[i]-=can*2;
			else cnt[i]-=need*2,need=0;
		}
		if(need){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int MAX_V=105;
int INF = 1000000000;
struct edge{int to,cost;};
typedef pair <int,int> P;

int V;
vector <edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P> > que;
  fill(d,d+V,INF);
  d[s]=0;
  que.push(P(0,s));
  
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v= p.second;
    if(d[v]<p.first)continue;
    for(int i=0 ;i<G[v].size();i++){
      edge e =G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }
} 
  
int main(){
  int n;
  cin >> n; V=n;
  rep(i,n){
    int u,k;
    cin >> u >> k;
    rep(j,k){
      int to,cost;
      cin >> to >> cost;
      G[u].push_back(edge{to,cost});
    }
  }     

  dijkstra(0);
  rep(i,n){
    cout << i << ' ' << d[i] << endl;
  }
  return 0;
}
 

Measured memory_bytes: 3212
while True:
    m,f,r=map(int,input().split())
    # print(m,f,r)
    temp = m+f
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif 80 <= temp:
        print("A")
    elif 65 <= temp:
        print("B")
    elif 50 <= temp:
        print("C")
    elif 30 <= temp:
        if 50 <= r:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll umax(ll a ,ll b)
{
	if(a<b)return b;return a;
}
ll dp[3001][3001];
int main()
{
	string s,t;cin >> s >> t;
	for(ll i=0;i<=s.size();i++)
	{
		for(ll j =0;j<=t.size();j++)
		{
			if(j==0 and i==0)
				dp[i][j]=0;
			else if(i==0 or j==0)
				dp[i][j]=0;
			else
			{
				if(s[i-1]==t[j-1])
					dp[i][j]=dp[i-1][j-1]+1;
				else
					dp[i][j]=umax(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	ll ans = dp[s.size()][t.size()];
	//cout << ans;
	/*for(ll i=0;i<=s.size();i++)
	{
		for(ll j=0;j<=t.size();j++)
			cout << dp[i][j] << " " ;
		cout << "\n"; 
	}*/
	string s1;ll i=s.size();ll j = t.size();
	while(ans)
	{
		if(s[i-1]==t[j-1])
		{
			s1+=s[i-1];ans--;i--;j--;
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}

	}
	 reverse(s1.begin(),s1.end());
	 cout << s1;
	return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> vecp(n);
    for(int i=0;i<n;i++){
        cin >> vecp.at(i).first >> vecp.at(i).second;
    }
    sort(vecp.begin(),vecp.end());
    for(int i=0;i<n;i++){
        cout << vecp.at(i).first <<" "<< vecp.at(i).second << endl;
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
  using namespace std;
const int N=100000;
int a[N+5],n,x,y;
inline void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;i++)
    scanf("%d",&a[i]);
}
bool cmp(int a,int b){
  return a>b;
}
inline void work(){
  sort(a+1,a+1+n,cmp);
  for (;x<=n&&x+1<=a[x+1];x++);
  for (y=x;y+1<=n&&a[y+1]==x;y++);
}
inline void outo(){
  if (a[x]-x&1||y-x&1) printf("First\n");
  else printf("Second\n");
}
int main(){
  into();
  work();
  outo();
  return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int wa = a[i] + i;
        int sa = i - a[i];
        ans += mp[sa];
        mp[wa]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 21168
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i + 1, f + "+" + abcd[i + 1], sum + int(abcd[i + 1]))
        dfs(i + 1, f + "-" + abcd[i + 1], sum - int(abcd[i + 1]))
abcd = input()
dfs(0, abcd[0], int(abcd[0]))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
int main(){
  int key,S[10001],n,q,T[500],i,j,k,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    S[n]=T[i];
    key=S[n];
    j=0;
    k=0;
    while(S[j]!=key){
      j++;
      if(j==n){
	k++;
	break;
      }
    }
    if(k==0)cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2128
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
S = input()

if c < d:
    while b < d:
        if S[b+1] == '.':
            b += 1
        elif b+2 <= d and S[b+2] == '.':
            b += 2
        else:
            print('No')
            exit()
    while a < c:
        if S[a+1] == '.':
            a += 1
        elif a+2 <= c and S[a+2] == '.':
            a += 2
        else:
            print('No')
            exit()
else:
    while a < c:
        if a+1 == b and S[a+2] == '.' :
            a += 2
        elif a+1 == b and a+3 <= d and S[a+3] == '.':
            b += 2
            a += 1
        elif S[a+1] == '.' and a+1 != b:
            a += 1
        elif a+2 == b and a+3 <= d and S[a+3] == '.':
            a += 2
            b += 1
        elif a+2 == b and a+4 <= d and S[a+4] == '.':
            a += 2
            b += 2
        elif S[a+2] == '.' and a+2 != b:
            a += 2
        else:
            print('No')
            exit()
    while b < d:
        if S[b+1] == '.':
            b += 1
        elif b+2 <= d and S[b+2] == '.':
            b += 2
        else:
            print('No')
            exit()
print('Yes')

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

int32_t main() 
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int e=c/b;
    int f=c%b;
    if(f>0)
    e=e+1;
    int g=a/d;
    int h=a%d;
    if (h>0)
    g=g+1;
    if(e<=g)
    cout<<"Yes";
    else
    cout<<"No";

	
	return 0;
}


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

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

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



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

    if(N%2==0) cout << fixed << setprecision(10) << 0.5 << endl;
    else cout << fixed << setprecision(10) << (N/2 + 1.0)/N << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];
  ll x = 0LL;
  int keta = 0;
  while((k >> keta) > 1) keta++;
  while(keta >= 0) {
    int cnt1 = 0;
    rep(i, n) if((A[i] >> keta) & 1) cnt1++;
    if(cnt1 < (n + 1) / 2 && x + (1LL << keta) <= k)
      x += (1LL << keta);
    keta--;
  }
  ll ans = 0LL;
  rep(i, n) ans += A[i] ^ x;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;cin>>H>>W;
  vector<vector<char>> a(H,vector<char>(W));
  vector<int> tate(H,false);
  vector<int> yoko(W,false);
  for(int x=0; x<H; x++){
    for(int y=0; y<W; y++){
      cin>>a[x][y];
      if(a[x][y]=='#'){
        tate[x]=true;
        yoko[y]=true;
      }
    }
  }
  for(int x=0; x<H; x++){
    for(int y=0; y<W; y++){
      if(tate[x]&&yoko[y])cout<<a[x][y];
    }
    if(tate[x])cout<<endl;
  }
}

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

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

const ll inf = (1ll << 30);

int n, m;
std::vector<P> map[205];
ll dp[205][11][105];

int main(){
	while(true){
		std::cin >> n >> m;
		if(n == 0 && m == 0)break;
		
		for(int i = 0; i < 205; ++i)map[i].clear();
		
		for(int i = 0; i < 205; ++i){
			for(int j = 0; j < 11; ++j){
				for(int k = 0; k < 105; ++k){
					dp[i][j][k] = inf;
				}
			}
		}
		
		map[0].push_back(P(-1, -1));
		for(int i = 1; i <= n; ++i){
			int k;
			std::cin >> k;
			for(int j = 0; j < k; ++j){
				int a, b;
				std::cin >> a >> b;
				map[i].push_back(P(a - 1, b));
			}
		}
		map[n + 1].push_back(P(-1, -1));
		
		dp[0][0][0] = 0;
		for(int i = 0; i <= n; ++i){
			for(int j = 0; j < map[i].size(); ++j){
				for(int k = 0; k <= m; ++k){
					if(dp[i][j][k] == inf)continue;
					
					int v = i + 1;
					for(int p = 0; p < map[v].size(); ++p){
						int cost = (map[i][j].second + map[v][p].second) * std::abs(map[i][j].first - map[v][p].first);
						if(map[i][j].first == -1 || map[v][p].first == -1)cost = 0;
						
						dp[v][p][k] = std::min(dp[v][p][k], dp[i][j][k] + cost);
					}
					
					v = i + 2;
					for(int p = 0; p < map[v].size(); ++p){
						int cost = (map[i][j].second + map[v][p].second) * std::abs(map[i][j].first - map[v][p].first);
						if(map[i][j].first == -1 || map[v][p].first == -1)cost = 0;
						
						dp[v][p][k + 1] = std::min(dp[v][p][k + 1], dp[i][j][k] + cost);
					}
				}
			}
		}
		
		ll ans = inf;
		for(int i = 0; i <= m; ++i){
			ans = std::min(ans, dp[n + 1][0][i]);
		}
		
		std::cout << ans << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 3072
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    *cumsum, = accumulate(A)
    ans = inf
    for c in cumsum[:-1]:
        d = cumsum[-1] - c
        ans = min(ans, abs(d-c))
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 26448
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	cx = 0; cy = 0
	prev_t = 0

	for i in range(I()):
		t, dist_x, dist_y = LI()

		diff = abs(dist_x - cx) + abs(dist_y - cy)		
		spend_time = t - prev_t


		if spend_time >= diff and (spend_time - diff)%2 == 0:
			f = True
		else:
			f = False
			break

		prev_t = t
		cx = dist_x
		cy = dist_y
	
	if f:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

Measured memory_bytes: 3700
def warsha_floyd(d):
    # d[i][j] := iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
                # "今現在求まっているiからjへの最短距離"と"今現在求まっているiからkへの最短距離 + 今現在求まっているkからjへの最短距離 の和"を比較する
    return d


H, W = map(int, input().split())  # H行, W列のgridgraph
N = 10
C = [list(map(int, input().split())) for _ in range(N)]  # 0~9 と 0~9の二重リスト
# C[u][v] := 辺uvのコスト
A = [list(map(int, input().split())) for _ in range(H)]

C = warsha_floyd(C)

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += C[A[i][j]][1]

print(ans)


Measured memory_bytes: 3444
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

const double EPS = 1e-12;
typedef long long int64;

template<typename T>
T abs(T x){
	return x > 0 ? x : -x;
}

vector<double> solveLinearEquations(const vector<vector<double> >& A, const vector<double>& b) {
	const int n = A.size();
	vector< vector<double> > B(n, vector<double>(n + 1, 0.0));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			B[i][j] = A[i][j];
		}
		B[i][n] = b[i];
	}
	for (int i = 0; i < n; ++i) {
		int pivot = i;
		for (int j = i; j < n; ++j) {
			if (abs(B[j][i]) > abs(B[pivot][i])) {
				pivot = j;
			}
		}
		B[i].swap(B[pivot]);
		if (abs(B[i][i]) < EPS) {
			return vector<double>();
		}

		for (int j = i + 1; j <= n; ++j) {
			B[i][j] /= B[i][i];
		}
		for (int j = 0; j < n; ++j) if (i!=j) {
			for (int k = i + 1; k <= n; ++k) {
				B[j][k] -= B[j][i] * B[i][k];
			}
		}
	}
	vector<double> x(n);
	for (int i = 0; i < n; ++i) {
		x[i] = B[i][n];
	}
	return x;
}

int A, B, N, M;

bool init() {
	scanf("%d%d%d%d", &A, &N, &B, &M);
	return A > 0;
}

const int MAX_COMB = 30;
int64 comb[MAX_COMB + 1][MAX_COMB + 1];

void buildCombination() {
	for (int n = 0; n <= MAX_COMB; ++n) {
		comb[n][0] = comb[n][n] = 1;
		for (int k = 1; k < n; ++k) {
			comb[n][k] = (comb[n-1][k-1] + comb[n-1][k]);
		}
	}
}

int64 calcPow(int64 x, int64 n) {
	int64 ret = 1;
	for (; n; n >>= 1, x = x * x) if (n&1) {
		ret = ret * x;
	}
	return ret;
}


inline int toIndex(int n, int m) {
	return n * M + m + 1;
}

void solve() {
	vector< vector<double> > mat(N*M + 1, vector<double>(N*M + 1, 0.0));
	vector<double> b(N*M + 1, 0.0);
	mat[0][0] = 1.0; b[0] = 1.0;
	for (int d = 0; d <= N*M; ++d) {
		for (int k = 0; k <= d; ++k) {
			int64 a = comb[d][k];
			a *= calcPow(A, k/N) * calcPow(B, (d-k)/M);
			mat[toIndex(k%N, (d-k)%M)][d < N*M ? d + 1 : 0] += a;
		}
	}

	vector<double> x = solveLinearEquations(mat, b);

	reverse(x.begin() + 1, x.end());
	for (int i = 0; i <= N*M; ++i) {
		printf("%d%c", int(round(x[i])), i == N*M ? '\n': ' ');
	}
}

int main() {
	buildCombination();
	for (;init();) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1088
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }


int main(void) {
	int N, R;
	cin >> N >> R;

	if (N >= 10) {
		cout << R << endl;
		return 0;
	}

	int ans = R + 100 * (10 - N);
	cout << ans << endl;
	return 0;

}


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

using namespace std;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(int i = 0;i < n;++i)
long long N,Y;
int A[1000000];
int main()
{
  int count=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int j,k;
  sort(A,A+N);
  for(int i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      for(k=j+1;k<N;k++){
        if(A[i]+A[j]>A[k]&&A[i]-A[j]<A[k]&&A[i]!=A[j]&&A[k]!=A[j]&&A[i]!=A[k]){
          //cout<<A[i]<<A[j]<<A[k]<<endl;
          count++;
        }
      }
    }
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3656
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
//const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}

int main() {
	ll N;


	cin >> N;
	vector<ll> A(N), junban(N+1);


	rep(i, N) {
		cin >> A[i];
		junban[A[i]] = i + 1;
	}

	rep(i, N)
		cout << junban[i + 1] << " ";


	return 0;
}

Measured memory_bytes: 2432
S = input()

A = int(S[:2])
B = int(S[2:])

if 1 <= A and A <= 12:
  if 1 <= B and B <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= B and B <= 12:
    print('YYMM')
  else:
    print('NA')

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

#define ll long long

int main() {
	ll n, ret = 0;	cin >> n;
	for (ll i = 1; i <= n; i ++) {
		for (ll j = 1; j <= n; j ++) {
			for (ll k = 1; k <= n; k ++) {
				ret += __gcd(i, __gcd(j, k));
			}
		}
	}
	cout << ret << "\n";
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int maxn=300005;
const long long mod=1000000007;
int n;
long long a[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	long long ans=0;
	for(int i=0;i<=60;i++)
	{
		int cnt=0;
		for(int j=1;j<=n;j++)
			if(a[j]&(1LL<<i))
				cnt++;
		ans=(ans+(1LL<<i)%mod*cnt%mod*(n-cnt)%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

const int MAX_SIZE = 15;
char field[MAX_SIZE+1][MAX_SIZE+3];
int dp[MAX_SIZE+1][MAX_SIZE+3];
int w, h;

bool judge(int i, int j){
	if(j > 0 && j <= w && field[j][i] == '0' && i <= h)
		return true;
	return false;
}

int main(){
	while(cin >> w >> h){
		if(w == 0 && h == 0) break;
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++)
				cin >> field[j][i];
		}
		for(int i = h+1; i <= h+2; i++){
			for(int j = 1; j <= w; j++){
				field[j][i] = '0';
			}
		}
		int pattern = 0;
		for(int i = 0; i < MAX_SIZE+1; i++){
			for(int j = 0; j < MAX_SIZE+3; j++){
				dp[i][j] = 0;
			}
		}
		for(int i = 1; i <= w; i++){
			if(field[i][1] == '0')
				dp[i][1] = 1;
		}
		for(int i = 1; i < h; i++){
			for(int j = 1; j <= w; j++){
				if(field[j][i] == '2' && field[j][i+2] != '1'){
					dp[j][i+2] += dp[j][i];
				}else if(field[j][i] == '0'){
					if(field[j][i+1] != '1') dp[j][i+1] += dp[j][i];
					if(judge(i+1, j-1)) dp[j-1][i+1] += dp[j][i];
					if(judge(i+1, j+1)) dp[j+1][i+1] += dp[j][i];
				}else{
					dp[j][i] = 0;
				}
			}
			
		}
		int count = 0;
		for(int i = h; i <= h+1; i++){
			for(int j = 1; j <= w; j++){
				count += dp[j][i];
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#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++)
#define repi(i,a,b) for(int i = (a); i < (b); 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};

int main(){
	int n;
	int a,b;
	b =1;
	cin>>n;
	for(int i =0; i <n;i++){
		cin>>a;
		b =(a*b)/__gcd(a,b);
	}
	cout <<b<<endl;
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int mean = 0;
  vector <int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    mean += vec.at(i);
  }
  int tmp = 100*n;
  int ans;
  for (int i = 0; i < n; i++) {
    int a = vec.at(i)*n;
    int b = mean;
    if (a < b) {
      int num = a;
      a = b;
      b = num;
    }
    if (a-b < tmp) {
      tmp = a-b;
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    
    int h,w;
    cin >> h >> w;
    int k;
    cin >> k;
    
    string s[h];
    rep(i,0,h)cin >> s[i];
    
    int ans = 0;
    rep(i,0,1 << h){
	rep(j,0,1 << w){
	    int cnt = 0;
	    rep(i2,0,h){
		rep(j2,0,w){
		    if((i >> i2)&1 && (j >> j2)&1){
			if(s[i2][j2] == '#')cnt++;
		    }
		}
	    }
	    if(cnt == k)ans++;
	}
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  int N;cin>>N;
  VI A(N);
  REP(i,N){
    cin>>A[i];
  }
  VI B(N);
  REP(i,N){
    B[A[i]-1]=i;
  }
  REP(i,N){
    cout<<B[i]+1<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 1664
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int X=sc.nextInt();
        int A=sc.nextInt();
        int B=sc.nextInt();
        X=X-A;
        while(X>=B){
            X=X-B;
            if(X<B){System.out.println(X);}
          
        }
        

        


    }
}


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

tsuru = (Y-2*X)/2
kame = X - tsuru

if tsuru >= 0 and kame >=0:
    if tsuru%1 == 0 and kame%1 == 0:
        print("Yes")

    else:
        print("No")

else :
    print("No")

Measured memory_bytes: 9244
#include <iostream>

using namespace std;

int main() {

    int N, D;
    cin >> N >> D;
    int range = 1 + 2 * D;

    int num;
    if (N%range==0) {
        num = N / range;
    } else {
        num = N / range + 1;
    }

    cout << num;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  vector<pii> o(0);
  for(int i=1;i<n-1;i++){
    if(a[i]<0){
      o.push_back(pii(a[n-1],a[i]));
      a[n-1]-=a[i];
    }
    else{
      o.push_back(pii(a[0],a[i]));
      a[0]-=a[i];
    }
  }
  o.push_back(pii(a[n-1],a[0]));
  cout << o[n-2].first-o[n-2].second << endl;
  rep(i,o.size()){
    cout << o[i].first << " " << o[i].second << endl;
  }
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;

int main() {
    int n,k;    cin >> n >> k;
    double *p = new double[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i] = (p[i]+1.0)/2.0;
    }

    double *sum = new double[n];
    sum[0] = p[0];

    for (int i = 1; i < n; i++) {
        sum[i] = sum[i-1] + p[i];
    }

    double ans = sum[k-1];

    for (int i = 0; i < n-k; i++)
        ans = max(ans, sum[k+i] - sum[i]);


    cout <<fixed << setprecision(12) <<  ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
 
using namespace std;
 
long long n, m, i, a[1000000], s;
 
void solve()
{
  cin >> m >> n;
  for(i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for(i = 1; i < n; i++) 
  {
    a[i] = a[i+1] - a[i];
    s += a[i];
  }
  sort(a + 1, a + n);
  i = n - 1;
  //cout << s << endl;
  while(m > 1 && i > 0) 
  {
    s -= a[i];
    m--;
    i--;
  }
  cout << s << endl;
}
 
int main()
{
  solve();
}
    

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int a,b,c,k;
    cin>>a>>b>>c>>k;

    rep(i,8){
        int ta=a;
        a=a<<i;
        rep(j,k-i){
            int tb=b,tc=c;
            tb=tb<<j;
            tc=tc<<(k-i-j);
            if(ta<tb && tb<tc){
                cout<<"Yes\n";
                return 0;
            }
        }
    }

    cout<<"No\n";

    return 0;

}

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


#define INF 1000000000000
  signed main(){
    string s;
    cin>>s;

    int dp[s.size()+1][5];
    rep(i,s.size()+1){
      rep(j,5){
     dp[i][j]=0;
      }
    }
    for(int i=0;i<s.size();i++){
      dp[0][0]=1;
    if(s.at(i)=='?'|| s.at(i)=='C'){dp[i+1][3]+=dp[i][2];dp[i+1][3]%1000000007;}
    if(s.at(i)=='?'||s.at(i)=='B'){dp[i+1][2]+=dp[i][1];dp[i+1][2]%1000000007;}
    if(s.at(i)=='?'||s.at(i)=='A'){dp[i+1][1]+=dp[i][0];dp[i+1][1]%1000000007;}
    rep(j,4){
    dp[i+1][j]+=(s.at(i)=='?')?dp[i][j]*3%1000000007:dp[i][j]%1000000007;
  }


  }
    cout<<dp[s.size()][3]%1000000007;
 }


Measured memory_bytes: 4352
while True:
    d= float(input())
    if d< 0: break
    a= bin(int(d))[2:]
    if len(a)> 8:
        print("NA")
    else:
        a= a.zfill(8)+"."
        b= d-int(d)
        for _ in range(4):
            b*= 2
            if int(b)>= 1:
                a= a+'1'
                b-= 1
            else:
                a= a+'0'
        a= a.ljust(13, '0')
        print("NA" if 1e-10 < b or len(a)> 13 else a)

Measured memory_bytes: 7340
/******************************************************************************

            EYENINE,THE ELDER_WAND!!!
            THE ROOT OVER MINUS EIGHTY ONE!!

*******************************************************************************/

#include<bits/stdc++.h>
#define ALL_UP_WITH return 0
#define vi vector<int>
using namespace std;
int count1=0,n;
int t[102];
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k,d;
    cin>>n>>k;
    while(k--){
        cin>>d;
        while(d--){
            int a;cin>>a;
            t[a]++;
        }
    }
    for(int i=1;i<=n;i++){
        if(t[i]==0){
            count1++;
        }
    }
    cout<<count1<<endl;


    ALL_UP_WITH;
}


Measured memory_bytes: 3652
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
ans = 0 if n%1000==0 else 1000*(n//1000 +1) - n
print(ans)

Measured memory_bytes: 61856
#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std; 
signed
main()
{
long long  x,y;
cin>>x>>y;
int a[y];
long long sum  =  0;
for(int  i = 0 ; i <y; i++)
{cin>>a[i];
sum+=a[i];
}
cout<<(x-sum>=0 ? x-sum:-1);

		
}


Measured memory_bytes: 3644
// inputに入力データ全体が入る, 10)
function Main(input) {
	var nums = input.split(' ');
	nums = nums.map( val => parseInt(val, 10) );

	// num3 <= num2 <= num1
	var num1 = Math.max(...nums);
	nums.splice(nums.indexOf(num1), 1);

	var num2 = Math.max(...nums);
	nums.splice(nums.indexOf(num2), 1);

	var num3 = Math.max(...nums);
	nums.splice(nums.indexOf(num3), 1);
	console.log(parseInt(num1.toString() + num2.toString(), 10) + num3);
}

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std ;
int32_t main()
{
      int n,k;
     cin>>n>>k;
     int ar[n];
     for(int i=0 ; i<n ; ++i)
     cin>>ar[i];

     int prev  ;
     prev=ar[0];
     int i=0 ;
     i+=k;
     for( ; i<n ; ++i)
     {
         if(ar[i]>prev)
         {
             cout<<"Yes\n";
             prev=ar[i-k+1];
         }
         else
         {
             cout<<"No\n";
             prev=ar[i-k+1];
         }
     }

     

    return 0;
}


Measured memory_bytes: 4428
import java.util.*;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a > b) {
			int d = a;
			a = b;
			b = d;
		}
		if (a > c) {
			int d = a;
			a = c;
			c = d;
		}
		if (b > c) {
			int d = b;
			b = c;
			c = d;
		}
		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 17160
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<utility>
#define LL long long
using namespace std;



int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b - 1) / a << endl;

	return 0;
}





Measured memory_bytes: 3080
n = int(input())
H = list(map(int, input().split()))
for i in reversed(range(n)):
    if i == 0:
        print("Yes")
    elif H[i] - H[i - 1] == -1:
        H[i - 1] -= 1
    elif H[i] - H[i - 1] < -1:
        print("No")
        break
    else:
        continue

Measured memory_bytes: 14252
# coding: utf-8
def getLnInputs():
    return input().split()


def getLnIntInputs():
    return list(map(int, getLnInputs()))


def main():
    N = getLnIntInputs()[0]
    A = sorted(getLnIntInputs())

    eatables = []
    eatables_sum = 0

    for c in range(N):
        if len(eatables) <= c:
            eatables.append(A[c])
            eatables_sum += A[c]

        for idx in range(len(eatables), N):
            s = A[idx]
            if s > 2 * eatables_sum:
                break
            eatables.append(s)
            eatables_sum += s

        if len(eatables) == N:
            print(N - c)
            break

    return


main()


Measured memory_bytes: 14512
#include<iostream>

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

int w,h;
int f[20][20];
int ans;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};

void rec(int n,int x, int y){

	if(ans <= n)return;

	int mx,my;

	rep(i,4){
		mx = x + dx[i];
		my = y + dy[i];

		if(f[my][mx] == 1)continue;
		if(mx < 0 || mx >= w)continue;
		if(my < 0 || my >= h)continue;

		while(1){
			if(f[my][mx] == 3){
				if(ans > n)ans = n;
				return;
			}

			mx += dx[i],my += dy[i];
			if(mx < 0 || mx >= w)break;
			if(my < 0 || my >= h)break;

			if(f[my][mx] == 1){
				f[my][mx] = 0;
				rec(n+1,mx-dx[i],my-dy[i]);
				f[my][mx] = 1;
				break;
			}
		}
	}
}

int main(){

	int sx,sy;

	while(std::cin >> w >> h,(w||h)){

		rep(i,h){
			rep(j,w){
				std::cin >> f[i][j];
				if(f[i][j] == 2){
					sx = j;
					sy = i;
				}
			}
		}
		ans = 11;
		rec(1,sx,sy);
		if(ans > 10)ans = -1;
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<queue>

int main()
{
	int n, m, count{}, last = -1;
	std::map<int, std::priority_queue<int>> btoa;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		btoa[b - 1].push(a - 1);
	}
	for (auto& e : btoa)
	{
		if (e.second.top() < last) continue;
		last = e.first;
		count++;
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 7680
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    using ll = long long;
    int n;
    cin >> n;
    ll a, b, c, d;
    a = c = 1e12;
    b = d = -1e12;

    for(int i=0;i<n;i++){
        ll x, y;
        cin >> x >> y;
        a = min(a, x+y);
        b = max(b, x+y);
        c = min(c, x-y);
        d = max(d, x-y);
    }
    cout << max(b-a, d-c) << endl;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  bool ok = false;
  for(int i = a; i <= b; i++) {
    if(i % k == 0) ok = true;
  }
  cout << (ok ? "OK" : "NG") << endl;
}

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

#define MOD 1000000007

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    long long ans = 1;
    for (int i = 0; i < N / 2; i++)
    {
        ans *= 2;
        ans %= MOD;
    }
    if (N % 2 == 0)
    {

        for (int i = 0; i < N; i++)
        {
            if (2 * (i / 2) + 1 != A[i])
            {
                ans = 0;
            }
        }
    }
    else
    {
        for (int i = 0; i < N; i++)
        {
            if (2 * ((i + 1) / 2) != A[i])
            {
                ans = 0;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int N, X; cin >> N >> X;
  vi s(N);
  vi dp(X+1, 0);
  vi ndp(X+1, 0);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  sort(s.rbegin(), s.rend());
  dp[X] = 1;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= X; j++) {
      ndp[j] = dp[j] * (N - i - 1) % MOD; ndp[j] %= MOD;
    }
    for (int j = 0; j <= X; j++) {
      int t = j % s[i];
      ndp[t] += dp[j]; ndp[t] %= MOD;
    }
    dp = ndp;
  }

  ll ans = 0;
  for (int i = 0; i <= X; i++) {
    ans += (dp[i] * i) % MOD;
    ans %= MOD;
  }

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


Measured memory_bytes: 1792
def get_data():
    while True:
        a, b = map(int, input().split())
        if a == b == 0:
            break
        yield a, b


input_data = list(get_data())
for i, data in enumerate(input_data):
    a, b = data
    flg = False
    for x in range(a, b + 1):
        if (x % 4 == 0 and x % 100 != 0) or x % 400 == 0:
            if not flg:
                flg = True
            print(x)
    if not flg:
        print('NA')
    if i != len(input_data) - 1:
        print()

Measured memory_bytes: 7876
//:::: Alien :::://
// Muhammad Eid //
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define prINT pair<int, int>

const int N = 26 +5;
int fr[N];

void Mo35(){ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
Mo35();

    string s; cin>> s;
    int sz = s.size();
    for(int i=0; i<sz; ++i) fr[s[i] - 'a']++;
    for(int i=0; i<26; ++i) if(fr[i]%2 != 0) return cout<< "No", 0;
    cout<< "Yes";

return 0;
}

Measured memory_bytes: 3660