akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
import itertools

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

def d(x1, y1, x2, y2):
    x = abs(x1-x2)
    y = abs(y1-y2)
    return (x*x + y*y) ** 0.5

N = i_i()
xy = [i_l() for x in range(N)]
p = itertools.permutations(xy, N)
arr = list(p)

acc = 0
for a in arr:
    tmp = 0
    for i in range(N-1):
        tmp += d(a[i][0], a[i][1], a[i+1][0], a[i+1][1])
    acc += tmp
    tmp = 0

print(acc/ len(arr))

Measured memory_bytes: 8052
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(void){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0){break;}
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    
}


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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long A, long long B, long long C, long long K) {
    if (K <= A + B) {
        cout << min(A, K) << endl;
    } else {
        cout << A - (K - (A + B)) << endl;
    }
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long K;
    scanf("%lld", &K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	int n;
	cin >> n;
	map<ll, ll> x;
	int a[n];
	rep(i, n){
		cin >> a[i];
		x[a[i]]++;
	}
	ll res = 0;
	for(auto it : x){
		res += 1ll * (it.S) *(it.S - 1) / 2;
	}
	rep(i, n){
			ll curres = res;
			curres -= x[a[i]] * (x[a[i]] - 1) / 2;
			curres += (x[a[i]] - 1) * (x[a[i]] - 2) / 2;
			cout << curres << endl;
		
	}
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int A[N], B[N];
    for(int i = 0; i < N; i++) {
        B[i] = 0;
    }
    for(int i = 1; i < N; i++) {
        cin >> A[i];
        B[--A[i]]++;
    }
    for(int i = 0; i < N; i++) {
        cout << B[i] << endl;
    }
}

Measured memory_bytes: 5168
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n;cin>>n;
	vector<ll> S,T;
	rep(i,1<<n){
		ll s;cin>>s;
		S.push_back(s);
	}
	sort(all(S));
	reverse(all(S));
	T.push_back(S[0]);
	S[0] = -1;
	sort(all(S));
	reverse(all(S));
	rep(i,n){
		int si = 0, ti = 0;
		vector<ll> U;
		while(ti < T.size()){
			while(S[si] != -1 && T[ti] <= S[si]){
				si++;
			}
			if(S[si] == -1){
				cout<<"No"<<endl;
				return 0;
			}
			U.push_back(S[si]);
			S[si] = -1;
			si++;
			ti++;
		}
		rep(ui, U.size()){
			T.push_back(U[ui]);
		}
		sort(all(S));
		reverse(all(S));
		sort(all(T));
		reverse(all(T));
	}
	cout<<"Yes"<<endl;

	return 0;
}


Measured memory_bytes: 8432
#include <iostream>
using namespace std;
int main(void){
    int A,B,m;
    cin>>A>>B;
    if(A<B){
        m=B*2-1;
    }
    if(A>B){
        m=A*2-1;
    }
    if(A==B){
        m=A*2;
    }
    cout<<m<<endl;
}


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

int main()
{
    const int kMaxNum = 100;
    int column=1, row=1;
    cin >> column >> row;

    int matrixA[kMaxNum][kMaxNum];
    for (int i=0; i<column; ++i)
    {
        for (int j=0; j<row; ++j)
        {
            cin >> matrixA[i][j];
        }
    }
    int matrixB[kMaxNum];
    for (int i=0; i<row; ++i)
    {
        cin >> matrixB[i];
    }
    
    int answerMatrix[kMaxNum] = {0};
    for (int i=0; i<column; ++i)
    {
        for (int j=0; j<row; ++j)
        {
            answerMatrix[i] += matrixA[i][j] * matrixB[j];
        }
        cout << answerMatrix[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1196
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int m, d;

	while(scanf("%d%d", &m, &d)==2)
	{
		int ans=0;
		for(int i=1;i<=m;i++)
		{
			for(int j=1;j<=d;j++)
			{
				int d1=j%10;
				int d10=j/10;
				if(d1<2 || d10<2) continue;
				if(i==(j/10)*(j%10))
				{
//					printf("%d %d\n", i, j);
					ans++;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
now = 1
res = 0
for i in a:
    if i == now:
        now += 1
    else:
        res += 1
if now == 1:
    print(-1)
else:
    print(res)

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

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] map = new char[h][w];
        for (int i = 0; i < h; i++) {
            map[i] = sc.next().toCharArray();
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (map[i][j] == '.') {
                    int count = count(map, i, j);
                    System.out.print(count);
                } else {
                    System.out.print(map[i][j]);
                }
            }

            System.out.println();
        }
    }

    int count(char[][] map, int y, int x) {
        int count = 0;
        for (int i = -1; i <= 1; i++) {
            for (int j = -1; j <= 1; j++) {
                if (y == 0 && i == -1
                    || x == 0 && j == -1
                    || y == map.length - 1 && i == 1
                    || x == map[y +i].length - 1 &&j == 1) {
                    continue;
                }

                if (map[y + i][x +j] == '#') {
                    count++;
                }
            }
        }
        return count;
    }
}

Measured memory_bytes: 22100
import sys

N, M = map(int, input().split())
card = [1, N]
for i in range(M):
#    gate.append([int(x) for x in input().split()])
    gate = [int(x) for x in input().split()]
    card[0] = max(card[0], gate[0])
    card[1] = min(card[1], gate[1])
    if(card[0] > card[1]):
        print(0)
        sys.exit()
        
print(card[1] - card[0] + 1)

Measured memory_bytes: 3064
n = int(input())
a = [int(item) for item in input().split()]

for i in range(n):
  a[i] -= i+1

a = sorted(a)
med = a[n//2]

b1, b2, b3 = 0, 0, 0
for i in range(n):
  b1 += abs(a[i] - med - 1)
  b2 += abs(a[i] - med)
  b3 += abs(a[i] - med + 1)
  
print(min([b1, b2, b3]))

Measured memory_bytes: 25748
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, K;
    cin >> N >> M >> K;
    //set<int> st[101010];
    UnionFind uf(N);
    vector<int> ans(N);
    vector<int> friends(N);
    REP(i,M){
        int A, B;
        cin >> A >> B;
        A--, B--;
        uf.unite(A, B);
        friends[A]++;
        friends[B]++;
    }

    REP(i,N) ans[i] = uf.size(i) - 1 - friends[i];

    REP(i,K){
        int A, B;
        cin >> A >> B;
        A--, B--;
        if(uf.issame(A, B)) ans[A]--, ans[B]--;
    }

    REP(i,N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define maxn 1000001
vector<ll>spf(maxn);
void sieve()
{
    for(int i=0;i<maxn;i++)
    {
        spf[i]=i;
    }
    for(int i=2;i*i<maxn;i++)
    {
        if(spf[i]==i)
        {
            for(int j=i*i;j<maxn;j+=i)
            {
                spf[j]=i;
            }
        }
    }
}
map<ll,ll> factor(ll x)
{
    map<ll,ll>m;
    while(x!=1)
    {
        m[spf[x]]++;
        x/=spf[x];
    }
    return m;
}
ll power(ll a,ll n)
{
    ll p;
    if(n==0)
    {
        return 1;
    }
    p=power(a,n/2);
    p*=p;
    if(n%2==1)
    {
        p*=a;
    }
    return p;
}
int main()
{
    fastIO;
    sieve();
    ll n;
    cin>>n;
    ll x,y,val,val1,ans=0;
    for(int i=1;i<n;i++)
    {
        val=n-i;
        map<ll,ll>m=factor(val);
        if(m.size()==0)
        {
            ans++;
        }
        else
        {   
            val1=1;
            for(auto itr:m)
            {
                val1*=(itr.se+1);
            }
            ans+=val1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 10996
import java.util.*;
public class Main {
    public static void main(String[] args ){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int mod = (int)1e9 + 7;

        if (Math.abs(m-n) > 1) {
            System.out.println(0);
            return;
        }
        long ans = 1;
        for (int i = 2; i <= n; i++) {
            ans *= i;
            ans %= mod;
        }
        for (int i = 2; i <= m; i++) {
            ans *= i;
            ans %= mod;
        }
        System.out.println(n == m ? 2 * ans % mod: ans);
    }

}

Measured memory_bytes: 35788
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

bool check(int x, int y) {
    while(x % y == 0)
        x /= y;
    return x % y == 1;
}

int count(int n) {
    int cnt = 0;
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            cnt++;
            if(i * i != n)
                cnt++;
        }
    }
    return max(cnt, 1LL);
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;

        int ans = 0;
        for(int i = 2; i * i <= n; i++) {
            if(n % i == 0) {
                ans += check(n, i);
                if(i * i != n)
                    ans += check(n, n / i);
            }
        }
        ans += count(n - 1);

        cout << ans << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 3644
<?php
$N = (int)fgets(STDIN);
$pt = $px = $py = 0;
for ($i = 0; $i < $N; $i++) {
    list($t, $x, $y) = array_map('intval', explode(' ', fgets(STDIN)));
    $dx = abs($x - $px);
    list($t, $pt) = array($t - $pt - $dx, $t);
    if ($dx >= 0 && $t >= 0) {
        $dy = abs($y - $py);
        $t -= $dy;
        if ($t < 0 || $t % 2 !== 0) {
            print "No\n";
            exit;
        }
    } else {
        print "No\n";
        exit;
    }
    $px = $x; $py = $y;
}
print "Yes\n";

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define ll long long
int main(){
	int a,b; cin>>a>>b;
	if(a<b){
		while(b--) cout<<a;
	}else{
		while(a--) cout<<b;
	}
}


Measured memory_bytes: 3576
n=int(input())
a=list(map(int,input().split()))

num=[i for i in range(1,n+1)]

order=dict(zip(num,a))

order2=sorted(order.items(),key=lambda x:x[1])

ans=[]

for i in range(n):
  ans.append(order2[i][0])

print(' '.join([str(n) for n in ans]))

Measured memory_bytes: 37984
n=int(input())
a=list(map(int,input().split()))
for _ in range(n):
  a[_]=a[_]-_-1
a.sort()
m=int((n-1)/2)
b=a[m]
s=0
for _ in range(m+1):
  s=s+b-a[_]
for _ in range(m+1,n):
  s=s+a[_]-b
print(s)

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int>& vec) {
    for (auto& e : vec) {
        cout << e << " ";
    }
    cout << endl;
}

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

int func(long long n, long long k, long long q, std::vector<long long> a) {
    // cout << fixed << setprecision(8);

    // printVec(point);
    vll point(n, 0);
    rep(i, q) { point[a[i] - 1]++; }
    rep(i, n) {
        if (point[i] > (q - k)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

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

    func(N, K, Q, std::move(A));

    return 0;
}


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

int main(){
  string s;
  char c1,c2;
  int i1,i2=0;
  cin>>s;
  c1=s[0];
  i1=1;
  bool f=0;
  for(int i=1;i<4;i++){
    if(c1==s[i]) i1++;
    else if(f==0){
      c2=s[i];
      f=1;
      i2++;
    }
    else if(c2==s[i]) i2++;
  }
  if(i1==2&&i2==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
y = [0 for i in range(n)]

y[0] = a[0]
for i in range(1, n, 2):
    y[0] += -a[i] + a[i + 1]


for i in range(1, n):
    y[i] = 2 * a[i - 1] - y[i - 1]
    
y = [str(i) for i in y]
print(" ".join(y))

Measured memory_bytes: 19548
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();

    UnionFind uf = new UnionFind(N);

    for (int i = 0; i < M; i++) {
      int left = scanner.nextInt() - 1;
      int right = scanner.nextInt() - 1;
      int dist = scanner.nextInt();

      Result lr = uf.find(left);
      Result rr = uf.find(right);

      if (lr.root == rr.root) {
        if (rr.dist - lr.dist != dist) {
          System.out.println("No");
          return;
        }
      } else {
        uf.union(left, right, dist);
      }
    }

    System.out.println("Yes");
  }

  static class UnionFind {
    private final int[] table;
    private final int[] delta;
    private final int[] ranks;

    UnionFind(int size) {
      this.table = new int[size];
      this.delta = new int[size];
      this.ranks = new int[size];
      for (int i = 0; i < size; i++) {
        table[i] = i;
      }
    }

    Result find(int x) {
      if (table[x] != x) {
        Result parentRes = find(table[x]);
        return new Result(parentRes.root, parentRes.dist + delta[x]);
      }
      return new Result(x, 0);
    }

    void union(int x, int y, int dist) {
      Result xRoot = find(x);
      Result yRoot = find(y);
      if (xRoot.root == yRoot.root) return;

      if (ranks[xRoot.root] < ranks[yRoot.root]) {
        Result tmp = xRoot;
        xRoot = yRoot;
        yRoot = tmp;
        dist = -dist;
      }

      table[yRoot.root] = xRoot.root;
      delta[yRoot.root] = xRoot.dist + dist - yRoot.dist;
      if (ranks[xRoot.root] == ranks[yRoot.root]) ranks[xRoot.root]++;
    }
  }

  static class Result {
    public final int root;
    public final int dist;

    Result(int root, int dist) {
      this.root = root;
      this.dist = dist;
    }
  }
}


Measured memory_bytes: 151404
#include<stdio.h>
using namespace std;
int main(){
    int a,b;
    while(true){
        scanf("%d %d",&a,&b);
        if(a == b && b == 0) break;
        if(a > b) printf("%d %d\n",b,a);
        else{
            printf("%d %d\n",a,b);
        }
    }
}


Measured memory_bytes: 2596
#include <stdio.h>

int main(int argc, char *args[])
{
	int W,H,x,y,r = 0;

	scanf("%d %d %d %d %d", &W,&H,&x,&y,&r );

	if( ((x - r) >= 0 && (x + r) <= W ) && ((y - r) >= 0 && (y + r) <= H ) ) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll ans = n - 1;
    for (ll i = 1; i * i <= n; ++i)
        ans = min(ans, n % i ? n - 1 : i + n / i - 2);
    cout << ans;
}


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

int main() {
    string str;
    cin >> str;
    vector<int> alphabet(26, 0);
    rep(i, str.length()) alphabet.at(str.at(i) - 'a')++;
    bool flag = true;
    rep(i, 26) if(alphabet.at(i) % 2) flag = false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
class combination:
    def __init__(self, n, mod):
        fact = [0]*(n+1)
        ifact = [0]*(n+1)
        fact[0] = 1
        for i in range(1, n+1):
            fact[i] = (fact[i-1]*i) % mod
        # 1/n!を逆元で求める
        ifact[n] = pow(fact[n], mod-2, mod)
        for i in range(n, 0, -1):
            ifact[i-1] = (ifact[i]*i) % mod

        self.n = n
        self.mod = mod
        self.fact = fact
        self.ifact = ifact

    def choose(self, n, r):
        if r < 0 or r > n:
            return 0
        ret = (self.fact[n]*self.ifact[r]) % self.mod
        return (ret*self.ifact[n-r]) % self.mod


n, k = map(int, input().split())
k = min([n-1, k])
MOD = 10**9+7
c = combination(n, MOD)
ans = 0
for i in range(k+1):
    ans += c.choose(n, i) * c.choose(n-1, i)
    ans %= MOD
print(ans)


Measured memory_bytes: 43376
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    private static ArrayList<Table> alt;
    
    public static void main(String[] args) {
        int n;
        while((n = scn.nextInt()) > 0) {
            alt = createList(n);
            System.out.println(calcSize());
        }
    }
    
    public static ArrayList<Table> createList(int n) {
        ArrayList<Table> list = new ArrayList<>();
        list.add(new Table());
        for(int i = 1; i < n; i++) {
            Table tbl = list.get(scn.nextInt());
            int x = tbl.getX(), y = tbl.getY();
            int dir = scn.nextInt();
            if(dir % 2 > 0) {
                y += dir < 2 ? -1 : 1;
            } else {
                x += dir < 2 ? -1 : 1;
            }
            list.add(new Table(x, y));
        }
        return list;
    }
    
    public static String calcSize() {
        int maxx = 0, minx = 0;
        int maxy = 0, miny = 0;
        for(Table elm : alt) {
            int x = elm.getX();
            int y = elm.getY();
            if(maxx < x) {
                maxx = x;
            }
            if(minx > x) {
                minx = x;
            }
            if(maxy < y) {
                maxy = y;
            }
            if(miny > y) {
                miny = y;
            }
        }
        return (maxx - minx + 1) + " " + (maxy - miny + 1);
    }
}

class Table {
    private int x_, y_;
    
    public Table() {
        this(0, 0);
    }
    
    public Table(int x, int y) {
        x_ = x;
        y_ = y;
    }
    
    public int getX() {
        return x_;
    }
    
    public int getY() {
        return y_;
    }
}

Measured memory_bytes: 41752
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
int main(){
	int n;
	cin>>n;
	vector<int>dp(3);
	for(int day=0;day<n;day++){
		vector<int>new_dp(3,-1);
		vector<int>C(3);
		for(int i=0;i<3;i++){
			cin>>C[i];
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(i!=j)
					new_dp[j]=max(new_dp[j],dp[i]+C[j]);
			}
		}
		dp=new_dp;
	}
	sort(dp.begin(),dp.end());
	cout<<dp[dp.size()-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    const int Mod = 1e9+7;
    ll AA(ll x){
    	ll ans = 1, i = 1;
    	while(i <= x){
    		ans = (ans*i)%Mod;
    		i++;
    	}
    	return ans%Mod;
    }
    int main(){
    	ll n,m;
    	//cout << AA(100000) << endl;
    	cin >> n >> m;
    	if(abs(n-m) > 1){
    		cout << 0 << endl;
    		return 0;
    	}
    	if(abs(n-m) == 1){
    		cout << (AA(n)*AA(m))%Mod << endl;
    	}else {
    		cout << ((AA(n)*2%Mod)*AA(m))%Mod << endl;
    	}
    	return 0;
    }

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

char s[202000];
int n,f[202000],nex[202000][26],z,c;

void dfs(int x,int aim){
  if (aim<0) return;
  for (int i=0;i<26;++i)
    if (f[nex[x][i]+1]<aim){
      printf("%c",i+'a');
      dfs(nex[x][i]+1,aim-1);
      return;
    }
}

int main(){
  cin>>s+1;
  n=strlen(s+1);
  for (int i=0;i<26;++i) nex[n+1][i]=n+1;
  z=0,c=0; f[n+2]=-1;
  for (int i=n;i;--i){
    z|=1<<(s[i]-'a');
    if (z==(1<<26)-1) ++c, z=0;
    f[i]=c;
    memcpy(nex[i],nex[i+1],sizeof nex[i]);
    nex[i][s[i]-'a']=i;
  }
  dfs(1,f[1]);
  puts("");
}


Measured memory_bytes: 21760
#include<bits/stdc++.h>
using namespace std;
int main (){
	long NUM_R,NUM_G,R,G,M;
  	cin >> NUM_R >> NUM_G >> R >> G >> M;
  	vector<long>rData(R),gData(G),mData(M + NUM_R + NUM_G);
  	for(int i = 0;i < R;i++){
    	cin >> rData[i];
    }
  	for(int i = 0;i < G;i++){
    	cin >> gData[i];
    }
 	for(int i = 0;i < M;i++){
    	cin >> mData[i];
   	}
  
  	sort(rData.begin(),rData.end(),greater<int>());
  	sort(gData.begin(),gData.end(),greater<int>());
  	//sort(mData.begin(),mData.end(),greater<int>());
  
  	//vector<int>rEat(NUM_R),gEat(NUM_G);
  	//vector<int>sumEat(NUM_R + NUM_G);
  	for(int i = 0;i < NUM_R;i++){
    	mData[i + M] = rData[i];
    }
  	for(int i = 0;i < NUM_G;i++){
    	mData[i+M+NUM_R] = gData[i];
    }
  	sort(mData.begin(),mData.end(),greater<int>());
  	
  	long sum  =0;
    for(int i = 0;i < NUM_R + NUM_G;i++){
    	sum += mData[i];
    }
  	
  cout << sum<<endl;
}


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

vector<string> split(string in, char d){
    istringstream is(in);
    string s;
    vector<string> v;
    while(getline(is,s,d)){
        v.push_back(s);
    }
    return v;
}

int main(void){
    // Your code here!
    int n;
    while(cin>>n,n){
        string s;
        set<string> ss;
        cin>>s;
        for(int i=0;i<s.length();i++){
            if(s[i]==':'){
                s.erase(0,i+1);
            }
        }
        s=s.substr(0,s.size()-1);
        for(auto str:split(s,',')){
            //cout<<"~"<<str<<"~"<<endl;
            ss.insert(str);
        }
        vector<vector<string>> vs(n-1);
        for(int i=0;i<n-1;i++){
            cin>>s;
            s=s.substr(0,s.size()-1);
            for(int j=0;j<s.length();j++){
                if(s[j]==':'){
                    string tmp=s;
                    tmp.erase(j);
                    vs[i].emplace_back(tmp);
                    s.erase(0,j+1);
                    break;
                }
            }
            for(auto str:split(s,',')){
                vs[i].emplace_back(str);
            }
        }
        bool flag=true;
        while(flag){
            flag=false;
            for(auto s:ss){
                // for(auto p:ss){
                //     cout<<p<<" ";
                // }
                // cout<<endl;
                for(int i=0;i<n-1;i++){
                    if(s==vs[i][0]){
                        //vs[i][0]="";
                        ss.erase(s);
                        flag=true;
                        for(int j=1;j<vs[i].size();j++){
                            //cout<<"~"<<vs[i][j]<<"~"<<endl;
                            ss.insert(vs[i][j]);
                        }
                        break;
                    }
                }
            }
        }
        // for(auto s:ss){
        //     cout<<s<<" ";
        // }
        cout<<ss.size()<<endl;
    }
}



Measured memory_bytes: 3288
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int num[101][3];
    for(int i=0;i!=n;i++)
    {
        cin>>num[i][0]>>num[i][1]>>num[i][2];
    }
    for(int i=0;i!=101;i++)
    {
        for(int j=0;j!=101;j++)
        {
            int first_non_zero_h=0;
            while(num[first_non_zero_h][2]==0)
            {
                first_non_zero_h++;
            }
            int h=abs(num[first_non_zero_h][0]-i)+abs(num[first_non_zero_h][1]-j)+num[first_non_zero_h][2];
            for(int k=0;k!=n;k++)
            {
                if(max(0,h-abs(num[k][0]-i)-abs(num[k][1]-j))!=num[k][2]) break;
                if(k==n-1)
                {
                    cout<<i<<' '<<j<<' '<<h;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 3576
#define _GLIBCXX_DEBUG //test only

#include<bits/stdc++.h>
using namespace std;

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
typedef pair<int,int> P;
#define INF 1020304050

int main()
{
  int n,m,p;
  cin >> n >> m >> p;
  vector<int> a(m);
  vector<int> b(m);
  vector<int> c(m);
  int i,j;
  rep(i,m)
  {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    c[i] -= p;
    c[i] *= -1; //コイン最大化=マイナスの値を最小化
  }
  vector<int> d(n,INF);
  d[0] = 0;
  vector<int> kans1(n);
  vector<int> kans2(n);
  rep(i,n*3)
  {
    rep(j,m)
    {
      if(d[a[j]]+c[j] < d[b[j]])
      {
        d[b[j]] = d[a[j]]+c[j];
      }
    }
    if(i == n-1)
    {
      rep(j,n)
      {
        kans1[j] = d[j];
      }
    }
    if(i == n*2-1)
    {
      rep(j,n)
      {
        kans2[j] = d[j];
      }
    }
  }
  vector<bool> reachto(n,false);
  vector<bool> reachfrom(n,false);
  reachto[n-1] = true;
  reachfrom[0] = true;
  rep(i,n)
  {
    rep(j,m)
    {
      if(reachto[b[j]]) reachto[a[j]] = true;
      if(reachfrom[a[j]]) reachfrom[b[j]] = true;
    }
  }
  bool ok = true;
  rep(i,n)
  {
    if(kans2[i] < kans1[i] && reachto[i] && reachfrom[i])
    {
      ok = false;
    }
  }
  if(!ok) cout << -1 << endl;
  else cout << max(-kans1[n-1],0) << endl;
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var total int = 0
	var i int
	for i = 1; i < n+1; i++ {
		if i%3 != 0 && i%5 != 0 {
			total += i
		}
	}
	fmt.Println(total)
}


Measured memory_bytes: 1752
#include<iostream>
using namespace std;
int k[9999][999];
main(){int n,s;cin>>n;for(int i=0;i<n;i++){cin>>k[0][i];}
for(int i=0;i<n-1;i++){for(int j=n-2;j>=i;j--){if(k[s][j]>k[s][j+1]){s++;
for(int l=0;l<n;l++){k[s][l]=k[s-1][l];}
k[s][j]=k[s-1][j+1];k[s][j+1]=k[s-1][j];}}}
for(int i=0;i<n;i++){cout<<k[s][i];
if(i<n-1){cout<<' ';}else{cout<<endl;}}cout<<s<<endl;}

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

#define MOD 1000000007


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
     bitset <100001> b1;
     vector <long int >vec;
     long int i,q,l,r;
     for(i=2;i<100001;i++)
       b1[i]=1;
     
     long long int j;
     for(i=2;i<100001;i++)
       {
       	if(b1[i]==1)
       	  {
       	  	for(j=i*1ll*i;j<100001;j+=i)
       	  	  b1[j]=0;
       	  }
       }
  for(i=2;i<100001;i++)
     {
     	if(b1[i]==1 && b1[(i+1)/2]==1)
     	  vec.push_back(i);
     }
    cin>>q;
   
    while(q--)
      {  int low,hi;
         cin>>l>>r;
         low=lower_bound(vec.begin(),vec.end(),l)-vec.begin();
         hi=upper_bound(vec.begin(),vec.end(),r)-vec.begin();
         cout<<hi-low<<'\n';
      }
   return 0;
}

Measured memory_bytes: 640
def convert(x,p):
    if p==12:
	return
    convert(x/2,p+1)
    if p==3:
        ans.append(".")
    ans.append(str(x%2))

while True:
    n=input()
    if n<0:break
    ans=[]
    shift=int(n*16)
    if n==shift/16.0 and shift<4096:
        convert(shift,0)
	print "".join(ans)
    else:
        print "NA"

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size()-1; i++){
        if(s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    for(int i = 0; i < s.size()-2; i++){
        if(s[i] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    ll a; cin >> a;
    string b; cin >> b;
    int x = stoi(b.substr(0,1));
    int y = stoi(b.substr(2,1));
    int z = stoi(b.substr(3,1));
    ll ans = 0LL;
    rep(i,100*x) ans += a;
    rep(i,10*y) ans += a;
    rep(i,z) ans += a;
    cout << ll(ans/100LL) << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    cout << (N % 2 == 0 ? N / 2 : 1 + N / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
D = []
for i in range(N):
    a = list(map(int,input().split()))
    if(a[0] == a[1]):
        D.append(1)
    else:
        D.append(0)
tf = 0
for i in range(N-2):
    if D[i] == D[i+1] == D[i+2] == 1:
        tf = 1
if tf == 1:
    print("Yes")
else:
    print("No")

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

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

int main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	ll res1 = 0;
	ll res2 = 0;
	ll sum = 0;
	REP(i, N){
		sum += A[i];
		if(i%2==0){
			if(sum<=0){
				res1 += (1-sum);
				sum = 1;
			}
		}else{
			if(sum>=0){
				res1 += (1+sum);
				sum = -1;
			}
		}
	}
	sum = 0;
	REP(i, N){
		sum += A[i];
		if(i%2==1){
			if(sum<=0){
				res2 += (1-sum);
				sum = 1;
			}
		}else{
			if(sum>=0){
				res2 += (1+sum);
				sum = -1;
			}
		}
	}
	cout << min(res1, res2) << endl;
    return 0;
}

Measured memory_bytes: 1024
#import <Foundation/Foundation.h>
#include <stdio.h>

NSString* input(void){
    NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
    return [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
}
void output(NSString *s,NSString *sep){
    NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
    [fileHandle writeData:[s dataUsingEncoding:NSUTF8StringEncoding]];
    [fileHandle writeData:[sep dataUsingEncoding:NSUTF8StringEncoding]];
    [fileHandle closeFile];
}

NSMutableArray* to_numarray(NSString *s){
    NSMutableArray *l = [NSMutableArray arrayWithArray:[s componentsSeparatedByString:@" "]];
    NSInteger buf = 0;
    for(int i=0;i<[l count];i++){
        buf = [[l objectAtIndex:i] integerValue];
        [l replaceObjectAtIndex:i withObject:[NSNumber numberWithInteger:buf]];
    }
    return l;
}

int main(int argc, const char * argv[]) {
    NSString *buf = input();
    NSMutableArray *l = to_numarray(buf);
    NSInteger A = [[l objectAtIndex:0] integerValue];
    NSInteger B = [[l objectAtIndex:1] integerValue];
    NSInteger C = [[l objectAtIndex:2] integerValue];
    NSString *s;
    s = (A+B>=C)?@"Yes":@"No";
    output(s, @"\n");
    return 0;
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

const int SIZE = 200000 + 10;
int v[SIZE];
int lt[SIZE];
int blt[SIZE];
int main2() {

  int N;
  scanf("%d", &N);
  REP(i, N) scanf("%d", &v[i]);
  fill_n(lt, N, N);
  fill_n(blt, N, -1);
  vector<int> l;
  REP(i, N) {
    while(!l.empty() && v[l.back()] > v[i]) {
      lt[l.back()] = i;
      l.pop_back();
    }
    if( !l.empty() ) blt[i] = l.back();
    l.push_back(i);
  }

  // REP(i, N) cout << v[i] << " "; cout << endl;
  // REP(i, N) cout << lt[i] << " "; cout << endl;
  // REP(i, N) cout << blt[i] << " "; cout << endl;
  ll ans = 0;
  REP(i, N) {
    int x = blt[i];
    int y = lt[i];
    ans += (ll)v[i] * (x - i) * (i - y);
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

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

int main(){
  int n, c;
  cin >> n >> c;
  vector<vector<int>> vec(c+1, vector<int>(1e5+1, 0));
  rep(i,n){
    int s, t, ch;
    cin >> s >> t >> ch;
    vec[ch][s]++;
    vec[ch][t]--;
  }
  rep(i, 1e5){
    for(int j = 1; j <= c; j++) {
      vec[j][i+1] += vec[j][i];
      if(!vec[j][i] && vec[j][i+1]) vec[j][i]++;
    }
  }
  vector<int> num(1e5+1, 0);
  int ans = 0;
  rep(i, 1e5+1){
    rep(j, c+1){
      num[i] += vec[j][i];
    }
    ans = max(ans, num[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, m, c; scanf("%d%d%d", &n, &m, &c);
	std::vector<int> b(m);
	for(int i = 0; i < m; i++) scanf("%d", &b[i]);
	std::vector<std::vector<int>> a(n, std::vector<int>(m));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++) {
		int tmp = c;
		for(int j = 0; j < m; j++) tmp += b[j] * a[i][j];
		if(tmp > 0) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program {

    static int Main(string[] args) {
        List<int> list = new List<int>();

        while (true) {
            string v = Console.ReadLine();
            if (v == null) { break; }
            if (v.Length == 0) { break; }

            list.Add(int.Parse(v));
        }

        Stack<int> s = new Stack<int>();
        for (int i = 0; i < list.Count; i++) {
            if (list[i] == 0) {
                Console.WriteLine(s.Pop());
                continue;
            }
            s.Push(list[i]);
        }

        return 0;
    }
}



Measured memory_bytes: 10064
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    ll ans = 0;
    // A,B,CはN以上にはならない
    FOR(A, 1, N) {
        FOR(B, 1, N) {
            if (A * B >= N) { break; }
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(int argc, const char * argv[]){
    int a, b, c, dst;
    scanf("%d %d %d", &a, &b, &c);
    for (a; a <= b; a++) {
        if(c%a == 0) dst++;
    }
    printf("%d\n", dst);
}


Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

int main(){
    string in;
    cin >> in;
    if(in[2]==in[3] && in[4]==in[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    string s,t;
    cin >> s >> t;

    bool check=false;
    for(int i=0;i<s.length();i++){
        if(s==t){
            check=true;
            break;
        }
        s=s[s.length()-1]+s;
        s.erase(s.length()-1);
    }
    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,m;
	
	scanf("%d %d",&n,&m);
	
	int k[n];
	
	int a[30][30];
	int i,j;
	
	for(i = 0; i < n; i++){
		scanf("%d ",&k[i]);
		for(j = 0; j < k[i]; j++){
			scanf("%d ",&a[i][j]);
		}
	}
	
	int sum = 0;
	
	int check[31];
	
	for(i = 0; i < n; i++){
		for(j = 0; j < k[i]; j++){
			check[a[i][j]]++;
		}
	}
	
	for(i = 0; i < 32; i++){
		if(check[i] == n){
			sum++;
		}
	}
	
	printf("%d\n",sum);
	
	return 0;
}
	
	
	
	
	
	
	

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>

// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  int N;
  cin>>N;
  vector<int> deli(N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>deli[i];
  }

  i64 sum;

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if(i>j)
      sum+=deli[i]*deli[j];
    }
    
  }
  
  cout<<sum;
  
  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef pair<pair<int, int>, pair<int,int>> P;

P s[100010];
pair<int,int> ans[100010];
int main() {
	int n, m, p, y;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> p >> y;
		s[i].first.first = p;
		s[i].first.second = y;
		s[i].second.first = 0;
		s[i].second.second = i;
	}
	sort(s, s + m);
	int rank = 1;
	s[0].second.first = 1;
	for (int i = 1; i < m; i++) {
		if (s[i - 1].first.first == s[i].first.first) {
			rank++;
		}
		else {
			rank = 1;
		}
		s[i].second.first = rank;
	}
	for (int i = 0; i < m; i++) {
		ans[s[i].second.second].first = s[i].first.first;
		ans[s[i].second.second].second = s[i].second.first;
	}
	string country, city;
	for (int i = 0; i < m; i++) {
		country = to_string(ans[i].first);
		city = to_string(ans[i].second);
		for (int j = 0; j < 6 - country.length();j++) {
			cout << 0;
		}
		cout << country;
		for (int j = 0; j < 6 - city.length(); j++) {
			cout << 0;
		}
		cout << city;
		cout << endl;
	}
	return 0;
}

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

int main() {
  int N, K, x, sum;

  cin >> N >> K;
  
  
  //ロボットAの移動距離は2a
  //ロボットBの移動距離は2*(K-b)
  sum = 0;
  
  for(int i=0; i < N; i++) {
    cin >> x;
    
    if(2*x > 2*(K-x)) 
      sum += 2*(K-x);
    else
      sum += 2*x;
  }
  
  cout << sum << endl;
}


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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    fast;
    int a;
    cin >> a;
    cout << a + a*a + a*a*a;
}


Measured memory_bytes: 3652