akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long int ll;
//const int mx=1e5+7;
//int n,m;
//vector<int> a(mx),b(mx);
// vector<int> g[mx];
// int deg[mx];
//vector<int> adj[mx];
//vector<int> ans;
//---dfs--
// bool visited[mx];
// vector<ll> val(mx,0);

// void dfs(int s,int e,int c1,int c2){
// 	if(a[s]^c1!=b[s]) {ans.push_back(s), c1^=1;}
// 	for(auto u:adj[s]){
// 		if(u!=e){
// 			dfs(u,s,c2,c1);
// 		}
// 	}
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int t=1;
	//cin>>t;
	while(t--){
		int k;
		cin>>k;
		int ans=-1;
		ll num=7;
		if(k%2==1){
			for(int i=1;i<=k;i++){
				int x=num%k;
				//cout<<x<<"\n";
				if(x==0) {ans=i; break;}
				else{
					num=x*10;
					num+=7;
				}
			}
		}
		cout<<ans<<"\n";
 	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    ll l,r; cin>>l>>r;
    ll mod=2019;
    ll mini=INF;
    int cnt=0;
    for(ll i=l; i<r; i++){
        for(ll j=i+1; j<=r; j++){
            ll x=i%mod;
            ll y=j%mod;
            ll e=i*j%mod;
            mini=min(mini, e);
            cnt++;
            if(cnt>2019*2019){
                cout<<mini<<endl;
                return 0;
                 
  }
        }
    }
    cout << mini << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int h,w;
    int n;
    int c[10090];
    cin>>h>>w>>n;
    int last=1;
    int map[103][103];
    for(int i=1;i<=n;i++)
    {
        cin>>c[i];
    }
    for(int i=0;i<h;i++)
    {
        if(i%2==0)
        {

            for(int j=0;j<w-1;j++)
            {
                if(c[last]--){map[i][j]=last;if(c[last]==0)last++;}
            }
            if(c[last]--){map[i][w-1]=last;if(c[last]==0)last++;}
        }
        else
        {
            for(int j=w-1;j>0;j--)if(c[last]--){map[i][j]=last;if(c[last]==0)last++;}
            if(c[last]--){map[i][0]=last;if(c[last]==0)last++;}
        }
    }
    for(int i=0;i<h;i++)
    {

            for(int j=0;j<w-1;j++)cout<<map[i][j]<<" ";
            cout<<map[i][w-1]<<endl;


    }
    return 0;
}




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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
  int64_t n;
  cin >> n;

  for (auto _ : irange(0L, n)) {
    int64_t a;
    cin >> a;

    if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }

  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;
int n,k;
int main(){
	scanf("%d%d",&n,&k);
	if(k==0)return printf("%lld\n",1ll*n*n),0;
	LL ans=0;
	for(int i=k+1;i<=n;i++){
		ans += 1ll*n/i*(i-k);
//		if(n%i != 0){
		int ni = n-n/i*i;
		ans += ni-k+1>=0?ni-k+1:0;
//		}
//		printf("   %lld %d\n",ans,ni);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007

int main() {
	ll a, b, c, k;
	cin>>a>>b>>c>>k;
	ll sum = 0;
	if (k <= a) sum = k;
	else { //k > a
		if (k - a <= b) sum = a; // k <= a+b
		else sum = a - (k - a - b); //k > a + b
	}  
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3624
def main():
     N = int(input())
     dic = {}
     for i in range(N):
         try:
             entry = list(map(int,input().split(" ")))
             dic[entry[0]] = [entry[1],entry[2]]
         except Exception:
             entry = list(map(int,input().split(" ")))
             dic[entry[0]] = [entry[1],entry[2]]
     f = False
     index = 0
     coordinate = [0,0]
     for j in dic.items():
             distance = abs(j[1][0]-coordinate[0])+abs(j[1][1]-coordinate[1])
             if j[0]-index>=distance and (j[0]-index)%2==distance%2:
                 continue
             else:
                 print('No')
                 exit()
     print('Yes')


if __name__=="__main__":
    main()

Measured memory_bytes: 26324
from collections import Counter

N, M = map(int, input().split())
*A, = map(int, input().split())
ac = [0]*(N+1)

for i in range(1, N+1):
    ac[i] = (ac[i-1]+A[i-1])%M

c = Counter(ac)
ans = 0
for i in c.values():
    ans += i*(i-1)//2
print(ans)


Measured memory_bytes: 21200
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
using Graph = vector<vector<int>>;

ll beki(ll x, ll n){
  ll res = 1;
  while(n > 0){
    if(n & 1) res = res * x % MOD;
    x = x * x % MOD;
n >>= 1;
}
return res;
}

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

  ll n, m; cin >> n >> m;
  ll x = 1900*m + 100*(n-m);
  ll p = beki(2, m);

  cout << x * p << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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;
using P=pair<ll,ll>;
string s;
int a[4];

P letter(int p);

P hash_(int p){
    //cout<<p<<endl;
    if(s[p]=='+'){
        p++;
        P ret1 = letter(p);
        p = ret1.second;
        P ret2 = letter(p);
        p=ret2.second;
        return {ret1.first | ret2.first,p};
    }else if(s[p]=='*'){
        p++;
        P ret1 = letter(p);
        p = ret1.second;
        P ret2 = letter(p);
        p=ret2.second;
        return {ret1.first & ret2.first,p};
    }else{
        p++;
        P ret1 = letter(p);
        p = ret1.second;
        P ret2 = letter(p);
        p=ret2.second;
        //cout<<p<<" "<<ret1.first<<endl;
        return {ret1.first ^ ret2.first,p};
    }
}

P letter(int p){
    if(s[p]=='['){
        p++;
        P ret1 = hash_(p);
        p=ret1.second;
        p++;//skip ']'
        return {ret1.first, p};
    }else{
        return {a[s[p]-'a'], p+1};
    }
}


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

    while(cin>>s){
        if(s==".") break;
        string t;
        cin>>t;
        REP(i,4) a[i]=t[i]-'0';
        P ret = letter(0);
        ll ans=ret.first;

        ll con=0;
        REP(i,10000){
            int x=i;
            REP(j,4){
                a[j] = x%10;
                x/=10;
            }
            
            P ret2 = letter(0);
            if(ret2.first==ans) con++;
        }
        cout<<ans<<" "<<con<<"\n";

    }
    return 0;
}


Measured memory_bytes: 3212
import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()

n, m = map(int, input().split())
graph = [list() for _ in range(n)]
deg = [0] * n

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    graph[a].append(b)
    deg[b] += 1

q = deque(i for i in range(n) if deg[i] == 0)
t = []

while q:
    v = q.popleft()
    t.append(v)
    for nv in graph[v]:
        deg[nv] -= 1
        if deg[nv] == 0:
            q.append(nv)

dp = [0] * n
for v in t:
    for nv in graph[v]:
        dp[nv] = max(dp[nv], dp[v]+1)

print(dp[t[-1]])


Measured memory_bytes: 62768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

int a,b,c,d;
cin >> a >> b >> c >> d;
chmin(a, b); chmin(c, d);
cout << a + c << endl;

return 0;
}

Measured memory_bytes: 256
n = int(input())
nums = list(map(int, input().split()))

nums1 = nums[0::2]
nums2 = nums[1::2]

bug1 = [0] * 100001
bug2 = [0] * 100001

for num in nums1:
    bug1[num] += 1

for num in nums2:
    bug2[num] += 1

max_v_1 = max(bug1)
max_i_1 = bug1.index(max_v_1)
max_v_2 = max(bug2)
max_i_2 = bug2.index(max_v_2)

if max_i_1 == max_i_2:
    bug1[max_i_1] = 0
    bug2[max_i_2] = 0
    sec_max_v_1 = max(bug1)
    sec_max_v_2 = max(bug2)
    print(n - min(max_v_1, max_v_2) - max(sec_max_v_1, sec_max_v_2))
else:
    print(n - max_v_1 - max_v_2)

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

ll calc(ll a, ll b, ll x) {
    return (a*x)/b - a*(x/b);
}

int main() 
{
    ll a, b, n; cin >> a >> b >> n;
    if (n % b == b-1) {
        cout << calc(a,b,n) << '\n';
        return 0;
    }
    else {
        ll ans = (n/b)*b-1;
        if (ans != -1) {
            cout << calc(a,b,ans) << '\n';
        }
        else {
            cout << calc(a,b,n) << '\n';
        }
    }
}


Measured memory_bytes: 3520
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(void){
	int N,M;
	int ans = 0;
	int length;
	scanf("%d %d",&N,&M);
	int X[M];
	int Y[M-1];
	int i;
	for(i=0;i<M;i++){
		scanf("%d",&X[i]);
	}
	qsort(X,M,sizeof(int),compare_int);
	for(i=0;i<M;i++){
		if(i>0){
			Y[i-1]=abs(X[i]-X[i-1]);
		}
	}
	qsort(Y,M-1,sizeof(int),compare_int);
	length = abs(X[0]-X[M-1]);
	ans = length;
	int temp = M-2;
	for(i=0;i<N-1;i++){
		ans -=Y[temp];
		temp --;
	}
	if(N>M){
		printf("0");
		return 0;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1396
# -*- coding:utf-8 -*-
"""解説
GCD, DP, 累積和

「一つを選んで好きな数字に変えられる」とあるが、今回のケースでは「その数字を消す」と同じ。

すべてのGCDを試す

4 6 7 8 10 12 14

という数列が与えられたとき、

・4を消して、ほかの数字のGCDを計算

6 7 8 10 12 14

・6を消して、ほかの数字のGCDを計算

4 7 8 10 12 14

・7を消して、……

というのを全列挙するが、N=10**5なので、O(N**2)では計算が間に合わない。

なのでこれをもう少し高速でやりたい。

GCDは計算順序を問わない性質を利用する。

たとえば、8を消した場合

4 6 7 8 10 12 14
| 左 |× |   右  |

・左のGCD
・右のGCD
を計算し、GCD(左のGCD, 右のGCD)をやってもよい。

・左のGCDを考える
GCD(4) = L[1]
GCD(4 6) = L[2] = GCD(L[1], 6)
GCD(4 6 7) = L[3] = GCD(L[2], 7)
GCD(4 6 7 8) = L[4] = GCD(L[3], 8)
GCD(4 6 7 8 10) = L[5] = GCD(L[4], 10)

みたいな感じで計算できる。

・右のGCDについても同様に計算してやる。

この前計算ができたら、あとは累積和のように、どの数字を削除したときがGCDが最大になるのかを計算する。

"""
import copy

def solve():
    N = int(input())
    A = list(map(int, input().split()))

    def gcd(x, y):
        """ 最大公約数を求める """
        # x > y にしたい
        if y > x:
            x, y = y, x
        if y == 0:
            return x
        return gcd(x%y, y)

    # L[i] := A[i]が消されたときの左側のGCD
    L = [0]*(N+1)
    L[1] = A[0]
    for i in range(2, N):
        L[i] = gcd(L[i-1], A[i-1])

    # R[i] := A[i]が消されたときの右側のGCD
    R = [0]*(N+1)
    R[N-1] = 0
    R[N-2] = A[N-1]
    for i in range(N-3, -1, -1):
        R[i] = gcd(R[i+1], A[i+1])
    
    # 任意の数字を消したときの最大のGCDを求める
    ans = 0
    for i in range(N):
        tmp = gcd(L[i], R[i])
        ans = max(ans, tmp)

    print(ans)

if __name__ == "__main__":
    solve()


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;


int N;
void dfs(string s, char k){
    if(s.size()==N){
        cout << s << endl;
        return;
    }

    for(char  c = 'a';c <= k; c++ ){
        if(c==k){
            dfs(s+c, (char) k+1);
        }else{
            dfs(s+c, k);
        }   
    }

}

int main() {
    cin >> N;
    dfs("",'a');
    return 0;
}

Measured memory_bytes: 1536
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int n;
    cin>>n;
    vector<int>x,y;
    x.pb(0);y.pb(0);
    f(i,1,n)
    {
        int u,v;
        cin>>u>>v;
        x.pb(u);y.pb(v);
    }
    sort(y.begin(),y.end());
    sort(x.rbegin(),x.rend());
    int ses=0;
    f(i,0,n)
    {
        if(x[i]>y[i])
        {
            ses+=2*(x[i]-y[i]);
        }
    }
    cout<<ses<<endl;
    return 0;

}














Measured memory_bytes: 2036
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int ans = 0;
            while (a.All(i => i % 2 == 0))
            {
                a = a.Select(i => i / 2).ToArray();
                ans++;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
dataset = input().split(" ")
r = int(dataset[0])
c = int(dataset[1])

table = []
for i in range(r):
    table.append([])
    dataset = input().split(" ")
    for j in range(c):
        table[i].append(int(dataset[j]))

# 最終列の計算
for i in range(r):
    sum = 0
    for j in range(c):
        sum += table[i][j]
    table[i].append(sum)

# 最終行の計算
table.append([])
for x in range(c+1):
    sum = 0
    for y in range(r):
        sum += table[y][x]
    table[r].append(sum)

'''
for i in range(r+1):
    print(table[i])
'''

for row in range(r+1):
    for col in range(c+1):
        if col != c:
            print("%d " % table[row][col], end="")
        else:
            print("%d" % table[row][col])





Measured memory_bytes: 6200
#include<stdio.h>
#include<stdlib.h>
#define N 100

void push(int);
int pop(void);
int stack[N];
int top = 0;

int main(){
    int a,b,num = 0;
    char c[N];
    
    while(scanf("%s",c) != -1){
        if(c[0] == '+'){
         a = pop();
         b = pop();
        num = a + b;
        push(num);
      }else if(c[0] == '-'){
          a = pop();
          b = pop();
          num = b - a;
          push(num);
      }else if(c[0] == '*'){
          a = pop();
          b = pop();
          num = a * b;
          push(num);
      }else push(atoi(c));
    }
    printf("%d\n",pop());
    return 0;
}
void push(int a)
{
    top++;
    stack[top] = a;
}
int pop(void){
    top--;
    return stack[top+1];
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int A,B,C,X;
    int res=0;

    cin >> A >> B >> C >> X;

    for (int i=0;i<=A;i++){
        for (int j=0;j<=B;j++){
            for (int k=0;k<=C;k++){
                int total = 500*i + 100*j + 50*k;
                if(total==X)res++;
            }
        }
    }
    cout<<res;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n,j, a[200600], ans;
bool cond;
char c;
string s;
int main()
{
    //I am Monim, a tiny creature of Allah
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    if(n==1)
        cout << 0 << endl;
    else
        cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		boolean[] primes = new boolean[1000000];
		int[] counts = new int[1000000];

		for (int i = 2; i < 1000000 / 2 + 1; i++) {
			if (!primes[i]) {
				for (int j = 2; j < 999999 / i + 1; j++) {
					primes[i * j] = true;
				}
			}
		}
		int count = 0;
		for (int i = 2; i < 1000000; i++) {
			if (!primes[i]) {
				count++;
			}
			counts[i] = count;
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			System.out.println(counts[Integer.parseInt(line)]);
		}
	}
}

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

#define EPS 1e-10

int main(){
  int n;
  double ax,ay,bx,by,cx,cy,dx,dy;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
    if( abs(ax-bx)<EPS && abs(cx-dx)<EPS )cout << "YES\n";
    else if( abs(ax-bx)<EPS || abs(cx-dx)<EPS )cout << "NO\n";
    else if( abs( (ay-by)/(ax-bx) - (cy-dy)/(cx-dx) ) < EPS)cout << "YES\n";
    else cout << "NO\n";
  }
}

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

using namespace std;

int main() {
  const int n = 4, m = 3;
  vector<int> deg(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    deg[u]++;
    deg[v]++;
  }
  bool ok = true;
  for (int i = 0; i < n; i++) {
    ok &= (deg[i] == 1 || deg[i] == 2);
  }
  puts(ok ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            upper_divisors.append(n//i)
        i += 1
    return lower_divisors, upper_divisors


n = int(input())
low, up = make_divisors(n)
if len(low) != 1:
    # ans = low[0] + up[0]
    # for i in range(1, len(low)):
    #     tmp = low[i] + up[i]
    #     if tmp < ans:
    #         ans = tmp
    print(low[-1] + up[-1] - 2)
else:
    print(n - 1)


Measured memory_bytes: 9172
import sys
from bisect import bisect_right as bsr
from collections import Counter as cnt
from collections import defaultdict as dd
from collections import deque
from fractions import gcd
from itertools import permutations as perm
from math import ceil, factorial, floor
from operator import itemgetter as ig

sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    R = input(int)
    print(R ** 2)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 5168
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 1; i < n; i++){
        cout << a[n - i] << " ";
    }
    cout << a[0] << endl;
}

Measured memory_bytes: 1160
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int even[100010] = {};
int odd[100010] = {};

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

  int N;
  cin >> N;
  REP(i, N) {
    int v;
    cin >> v;
    if (i % 2 == 0) {
      even[v]++;
    } else {
      odd[v]++;
    }
  }
  int emax1 = 0;
  int emax2 = 0;
  int omax1 = 0;
  int omax2 = 0;
  REP(i, 100010) {
    if (even[emax1] <= even[i]) {
      emax2 = emax1;
      emax1 = i;
    } else if (even[emax2] <= even[i]) {
      emax2 = i;
    }
    if (odd[omax1] <= odd[i]) {
      omax2 = omax1;
      omax1 = i;
    } else if (odd[omax2] <= odd[i]) {
      omax2 = i;
    }
  }
  // cout << emax1 << " " << omax1 << endl;
  if (emax1 != omax1) {
    cout << N - even[emax1] - odd[omax1] << endl;
  } else {
    cout << min(N - even[emax1] - odd[omax2],
                N - even[emax2] - odd[omax1]) << endl;
  }
  return 0;
}


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


int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if((a!=b && b!=c && a!=c) || (a==b && b==c)) cout << "No" << endl;
    else cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

void zero(double*);

int main(){
  int a,b,c,d,e,f;
  double x,y;

  while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f) != EOF){
    x = (double)(c*e-b*f)/(double)(a*e-d*b);
    y = ((double)c-(double)a*x)/(double)b;
    zero(&x);
    zero(&y);
    printf("%.3f %.3f\n",x,y);
  }

  return 0;
}

void zero(double *x){
  if(*x == 0.0){
    *x = 0.0;
  }
}



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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int ans = 0;
  int n; cin>>n;
  while (n--) {
    int l,r; cin>>l>>r;
    ans += r-l+1;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  scanf("%d",&k);
  printf("%d\n",a[k-1]);
  return 0;
}


Measured memory_bytes: 128
n,t=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=map(int,input().split())
dp1=[[0]*t for _ in range(n+1)]
dp2=[[0]*t for _ in range(n+1)]
for i in range(n):
  for j in range(t):
    if j>=a[i]:dp1[i+1][j]=max(dp1[i][j],dp1[i][j-a[i]]+b[i])
    else:dp1[i+1][j]=dp1[i][j]
for i in range(n-1,-1,-1):
  for j in range(t-1):
    if j>=a[i]:dp2[i][j]=max(dp2[i+1][j],dp2[i+1][j-a[i]]+b[i])
    else:dp2[i][j]=dp2[i+1][j]
ans=0
for i in range(n):
  for j in range(t):
    ans=max(ans,dp1[i][j]+dp2[i+1][t-j-1]+b[i])
print(ans)

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

int main(){
    int n; cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    int ans=0;
    int minj=1e9;//最初を無限にする
    rep(i,n){
        minj=min(minj,p[i]);
        if(minj==p[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;

}


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

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N, K = readInts()
  S = input()
  s = list(S)
  s[K-1] = s[K-1].lower()
  print("".join(s))

if __name__ == "__main__":
  main()


Measured memory_bytes: 2940
#include <cstdio>

using namespace std;

int strlen(char s[]) {
	int l = 0;

	for(; s[l] != '\0'; l++)
		continue;

	return --l;
}

int main(void) {
	char s[1001];

	scanf("%s", s);

	int l = strlen(s);

	if (s[l] != 's')
		printf("%ss", s);
	else if (s[l] == 's')
		printf("%ses", s);

	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=10000010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int dp[1010][1010];
int main(){
	int W;
	int c=1;
	while(cin>>W,W){
		int n;cin>>n;
		int v[1010],w[1010];
		memset(dp,0,sizeof(dp));
		for(int i=0;i<n;i++)scanf("%d,%d",&v[i],&w[i]);
		for(int i=0;i<n;i++){
			for(int j=0;j<=W;j++){
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				if(j+w[i]<=W){
					dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
				}
			}
		}
		int ans=0;
		int m=0;
		for(int i=0;i<=W;i++){
			if(ans<dp[n][i]){
				ans=dp[n][i];
				m=i;
			}
		}
		cout<<"Case "<<c<<":"<<endl;
		cout<<ans<<endl;
		cout<<m<<endl;
		c++;
	}
}



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

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = min(k, a);
    k -= min(k, a);
    if(k > 0ll){
        k -= b;
    }
    if(k > 0ll){
        ans -= min(k, c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  vi x(5);
  rep(i,5) cin >> x[i];
  string s;
  rep(i,5){
    if(x[i]==0) cout << i+1;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

void solve(){
    int n, k;
    read(n, k);
    vi h(n);
    REP(i,n) read(h[i]);
    sort(h.begin(), h.end());
    int min_diff = h[n-1] - h[0];
    for(int i = k - 1 ; i < n ; i++){
        int diff = h[i] - h[ i - k + 1];
        if( diff < min_diff){
            min_diff = diff;
        }
    }
    write(min_diff);
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  constexpr int inf = 1e9;

  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> dp(1 << n, inf);
  dp[0] = 0;
  while (m--) {
    int a, b; cin >> a >> b;
    int T = 0;
    while (b--) {
      int c; cin >> c, --c;
      T |= 1 << c;
    }
    for (int S = 0; S < 1 << n; ++S) if (dp[S] < inf) {
      dp[S | T] = min(dp[S | T], dp[S] + a);
    }
  }
  if (dp.back() < inf) {
    cout << dp.back() << '\n';
  } else {
    cout << -1 << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

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; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N;
  cin>>N;
  if (N/10 == 9 || N%10 == 9){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
ans = [0]*(N+1)
for i in range(N):
    ans[i+1] = ans[i]
    if S[i: i+2] == 'AC':
        ans[i+1] += 1
for _ in range(Q):
    start, end = map(int, input().split())
    cnt = ans[end-1] - ans[start-1]
    print(cnt)


Measured memory_bytes: 11608
/**
 * code generated by Junayed Kader
 * Student of Computer Science
 * @author
 */
///Bismillahir Rahmanir Rahim///
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;
using namespace __gnu_pbds;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007


template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;//*(x.find_by_order(i)),x.order_of_key(k)

/*************** #Template FUNCTIONS# **************/


#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

/// Check all 8 direction co-ordinates.
/// N, NE, E, SE, S, SW, W, NW
static int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
static int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

ll gcd ( ll a, ll b )
{
    return __gcd ( a, b );
}
ll lcm ( ll a, ll b )
{
    return a * ( b / gcd ( a, b ) );
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}
ll min(ll a,ll b)
{
    return a<b?a:b;
}
/********************** START **********************/

void _case()
{
   ll n , d;
   cin>>n>>d;
   ll cnt = 0;
   double total = 0;
   for(int i = 0; i<n;i++)
   {
       ll x , y;
       cin>>x>>y;
       x=x*x;
       y= y*y;
       total = (double)sqrt(x+ y);
       if(total<=d)
       {
           cnt++;
       }

   }
   cout<<cnt<<endl;

}
int main()
{
    optimize();
    _case();

    return 0;
}
/*****************  ALHAMDULILLAH  *****************/


Measured memory_bytes: 3708
//H and V
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(void){
    // Your code here!
    int h,w,k;
    cin >> h >> w >> k;

    char c[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> c[i][j];
        }
    }
    

    
    int ans = 0;
    int black_num = 0;

    for(int i=0;i < (1 << h);i++){//赤にする行を選択
        for(int j=0;j < (1 << w);j++){//赤にする列を選択
            black_num = 0;
            for(int l=0;l<h;l++){
                for(int m=0;m<w;m++){
                    if((((i >> l) & 1) == 0) && (((j >> m) & 1) == 0) && (c[l][m] == '#')){
                        black_num++;
                    }
                }
            }
            if(black_num == k){
                ans++;
            }
        }
    }

    cout << ans << endl;
    
    
    
    
}

Measured memory_bytes: 3592
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	p := scanInts(n+1)
	ans := 0
	t := 0

	for i := 0; i < n+1; i++ {
		if p[i] == i+1 {
			t++
		} else {
			ans += (t + 1) / 2
			t = 0
		}
	}
	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 3120
n,a=map(int,input().split())
x=list(map(int,input().split()))
ans=0
dp=[[[0]*(sum(x)+1) for i in range(n+1)] for j in range(n+1)]
dp[0][0][0]=1
for i in range(n+1):
  for j in range(i+1):
    for k in range(sum(x)+1):
      if i>=1 and k>=x[i-1] and j>=1:
        dp[i][j][k]=dp[i-1][j-1][k-x[i-1]]+dp[i-1][j][k]
      elif i>=1:
        dp[i][j][k]=dp[i-1][j][k]
for j in range(1,n+1):
  for k in range(sum(x)+1):
    if k%j==0 and k//j==a:
      ans+=dp[n][j][k]
print(ans)


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

const int INF = 1001001001;
int a[12][12];

int main(){
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> c(n);
	rep(i,n){
		cin >> c[i];
		rep(j,m) cin >> a[i][j];
	}

	int ans = INF;
	rep(s,1<<n){
		int cost = 0;
		vector<int> d(m);
		rep(i,n){
			if (s>>i & 1){////iけた目が１かどうか
				cost += c[i];
				rep(j,m) d[j] += a[i][j];
			}
		}
		bool ok = true;
		rep(j,m) if (d[j]<x) ok = false;
		if(ok) ans =min(ans ,cost);
	}
	if (ans == INF) cout << -1 << endl;
	else cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3612
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = []
d2 = []
for i in range(3):
  if a[i] < b[i]: d1.append((a[i], b[i]))
  if a[i] > b[i]: d2.append((b[i], a[i]))

dp = [0] * (N + 1)

for i in range(N, -1, -1):
  for t in d1:
    x = t[0]
    y = t[1]
    if i - x >= 0:
      dp[i - x] = max(dp[i - x], y + dp[i])
for i in range(N + 1): dp[i] += i

def calc(x, r1):
  z = r1 - d2[0][0] * x
  return (z // d2[1][0]) * d2[1][1] + z % d2[1][0] + d2[0][1] * x

res1 = max(dp)
if len(d2) == 0:
  print(res1)
if len(d2) == 1:
  x, y = d2.pop()
  print((res1 // x) * y + (res1 % x))
if len(d2) == 2:
  x0 = 0
  x3 = res1 // d2[0][0]
  res2 = res1 + 0
  for x in range(x0, x3 + 1):
    res2 = max(res2, calc(x, res1))
  print(res2)

if len(d2) == 3:
  dp2 = [0] * (res1 + 1)
  for i in range(res1, -1, -1):
    for t in d2:
      x = t[0]
      y = t[1]
      if i - x >= 0:
        dp2[i - x] = max(dp2[i - x], y + dp2[i])
  for i in range(res1 + 1): dp2[i] += i
  print(max(dp2))

Measured memory_bytes: 41068
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Node{
public:
	int color{-1};
	int room{-1};
};

class Edge{
public:
	int start,end;
	int sc,ec;
};

vector<Edge> edge;

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

bool DFS(vector<Node>& node,ConnectNodeInfo& connect,int index){
	bool result = true;
	int color = node[index].color==1? 0 : 1;
	for(int i=0,ei=connect[index].size();i<ei;i++){
		int connect_index = connect[index][i].first;
		//node[connect_index].color = color;
		if(node[connect_index].color!=-1 && node[connect_index].color==node[index].color){
			return false;
		}
		if(node[connect_index].color==-1){
			Edge e;
			e.start=index,e.end=connect_index;
			edge.emplace_back(e);
			node[connect_index].color = color;
			result &= DFS(node,connect,connect_index);
		}
	}
	return result;
}

class WarshallFloyd{
	vector<vector<ll>> dist;
public:
	void CalcShortestPath(ConnectNodeInfo& connect){
		int V = connect.size();
		dist.resize(V,vector<ll>(V,1LL<<60));

		REP(i,V){
			dist[i][i]=0;
			int U = connect[i].size();
			REP(j,U){
				dist[i][connect[i][j].first] = connect[i][j].second;
			}
		}

		REP(k,V){
			REP(i,V){
				REP(j,V){
					dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}
	}
	ll CalcDiameter(){
		ll diameter = -(1LL<<60);
		int V = dist.size();
		REP(i,V){
			REP(j,V){
				if(dist[i][j]<1LL<<60){
					diameter = max(diameter,dist[i][j]);
				}
			}
		}
		return diameter;
	}
	ll GetDistance(int i,int j){
		return dist[i][j];
	}
};

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

	int N=in();
	ConnectNodeInfo connect(N);
	REP(i,N){
		int u=in(),k=in();
		REP(j,k){
			int v=in(),w=in();
			connect.AddDirectionalConnection(u,v,w);
		}
	}

	WarshallFloyd WF;
	WF.CalcShortestPath(connect);

	REP(i,N){
		out(i,WF.GetDistance(0,i));
	}
	return 0;
}



Measured memory_bytes: 3240
#include <stdio.h>
using namespace std;
int main(void)
{
    int n;
    bool flag=0;
    scanf("%d",&n);
    for(int i=1;i<10;i++)
    {
        if(n%i==0&&n/i<10)
        {
            flag=1;
            
            break;
        }
    }
    if(flag==1)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    
     return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
  int main(){
    int a,b;
    scanf("%d %d",&a,&b);

    if(a < b) printf("a < b\n");
    else if(a > b) printf("a > b\n");
    else if(a == b)printf("a == b\n");
    return 0;
  }



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

#define ll long long

int main() {
	int n, k;
	int d,wo;
	int i, j;
	int a[100][100];
	int count = 0;
	cin >> n >> k;
	vector<int>s(n);
	for (i = 1; i <= k; i++) {
		cin >> d;
		for (j = 1; j <= d; j++) {
			cin >> wo;
			s[wo-1]++;
		}
	}
	for (i = 0; i < n; i++) {
		if (s[i] == 0)count++;
	}
	cout << count;

	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main(void){
  int n,i;
  char j[8]="JPY";
  scanf("%d",&n);
  double x[n],ans=0;
  char u[n][8];
  for(i=0;i<n;i++){
    scanf("%lf %s",&x[i],u[i]);
    if(strcmp(u[i],j)==0) ans+=x[i];
    else ans+=380000.0*x[i];
  }
  printf("%f\n",ans);
  return 0;
}

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


int main(){
  int l, r, d, ans = 0; cin >> l >> r >> d;
  for(int i = l; i <= r; i++){
    if(i % d == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

using ll=long long int;

constexpr int MAX_N=(int)1e5+10;

int n;

int a[3][MAX_N];

int b[MAX_N];
ll c[MAX_N];

int main() {

    std::cin>>n;

    for(int i=0;i<3;++i){
        for(int j=0;j<n;++j)
            std::cin>>a[i][j];
    }

    for(int i=0;i<3;++i)
        std::sort(a[i],a[i]+n);

    for(int i=0;i<n;++i)
        b[i]=std::upper_bound(a[1],a[1]+n,a[0][i])-a[1];

    for(int i=0;i<n;++i){
        c[i]=std::upper_bound(a[2],a[2]+n,a[1][i])-a[2];
        c[i]=n-c[i];
    }

    for(int i=n-2;i>=0;--i)
        c[i]+=c[i+1];

    ll ans=0;

    for(int i=0;i<n;++i)
        ans+=c[b[i]];

    std::cout<<ans<<std::endl;

    return 0;
}

Measured memory_bytes: 2560
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  (n : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    next :: Maybe Digits -> Maybe (String, Maybe Digits)
    next = fmap next'
      where
        next' :: Digits -> (String, Maybe Digits)
        next' = (,) <$> showDs <*> succDs
  mapM_ putStrLn . unfoldr next . Just . zeroes $ n

type Digits = [(Int, Int)]

extend :: Digits -> Digits
extend [] = (1, 0) : []
extend ds@((m, k) : _) = (max m (succ k), 0) : ds

zeroes :: Int -> Digits
zeroes 1 = []
zeroes l  = extend . zeroes . pred $ l

succDs :: Digits -> Maybe Digits
succDs [] = Nothing
succDs ((m, k) : ds) | k < m = Just ((m, succ k) : ds)
succDs (_ : ds) = extend <$> succDs ds

showDs :: Digits -> String
showDs = map toLEL . (0 :) . map snd . reverse

toLEL :: Int -> Char
toLEL = toEnum . (fromEnum 'a' +)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 2172
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, K; cin >> n >> K;
    vi a(n); for(auto& e : a) cin >> e;

    int res = 0;
    for(auto& e : a){
        if(e >= K) res++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }

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

	for(int r, c; cin >> r >> c, r | c;) {
		vector<vector<int> > a(r, vector<int>(c));
		for(int i = 0; i < r; ++i)
			for(int j = 0; j < c; ++j)
				cin >> a[i][j];

		int ans = 0;
		for(int i = 0; i < (1 << r); ++i) {
			vector<vector<int> > tmp(a);
			for(int j = 0; j < r; ++j) if(i & (1 << j)) {
				for(int k = 0; k < c; ++k)
					tmp[j][k] = !tmp[j][k];
			}

			int cnt = 0;
			for(int j = 0; j < c; ++j) {
				int buf = 0;
				for(int k = 0; k < r; ++k)
					if(tmp[k][j])
						++buf;

				cnt += max(buf, r - buf);
			}

			chmax(ans, cnt);
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

typedef long long int Int;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}



int main()
{
    Int n;
    cin>>n;
    Int a[n];
    Int i,j;
    
    for(i=0; i<n; i++) cin>>a[i];
    
    Int c[n];
    
    for(i = 0; i<n; i++) c[i] = 0;
    
    if ( n > 0 ) c[1] = abs( a[1] - a[0] );
    Int d1,d2;
    for( i = 2; i<n; i++ )
    {
        d1 = abs( a[i-1] - a[i] ) + c[i-1];
        d2 = abs( a[i-2] - a[i] ) + c[i-2];
        if ( d1 > d2 ) c[i] =  d2;
        else c[i] = d1;
    }
    cout<<c[n-1]<<'\n';
    
}

Measured memory_bytes: 1792