akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node find(Node u,int x)
{
  while(u!=NIL && x!= u->key)
  {
    if(x < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k)
{
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL)
  {
    y=x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if(y == NIL)
  {
    root = z;
  }
  else
  {
    if(z->key < y->key)y->left = z;
    else y->right = z;
  }
}

void inorder(Node u)
{
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u)
{
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ )
  {
    scanf("%s", com);

    if ( com[0] == 'i' )
    {
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' )
    {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(com[0] == 'f')
    {
      scanf("%d",&x);
      Node t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}



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

std::string solve()
{
    int N;
    long long int M;
    long long int V, P;

    cin >> N >> M >> V >> P;

    long long int A[N];

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

    sort(A, A + N);

    long long int ans = 0;
    long long int key = N - P; // index of the P-th largest.

    ans += N - key;

    long long int cuml[N + 1];

    cuml[0] = 0;
    for (int i = 0; i < N; i++)
    {
        cuml[i + 1] = cuml[i] + A[i];
    }

    for (long long int i = 0; i < key; i++)
    {
        long long int score_i = A[i] + M; // i問目の点数の最大限

        if (score_i < A[key])
            continue; // どれだけ頑張っても、A[key] に到達できないので、大きいものに入らない

        if (V < P)
        {
            ans++;
            continue;
        }

        long long int needToVote = M * V;

        long long int canVoteSum = 0;

        canVoteSum += (P - 1) * M; //高い方から
        canVoteSum += (i + 1) * M; //低い方から

        canVoteSum += (key - i) * score_i - (cuml[key + 1] - cuml[i + 1]);
        if (needToVote <= canVoteSum)
            ans++; // all votes are consumed.
    }
    return to_string(ans);
}

int main()
{
    cout << solve() << endl;

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

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

	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	LL cnt=0,ans=0;

	cin >> S;

	if(S[0]=='0'){
		cnt = 0;
	}else{
		cnt = 1;
	}
	FOR(i,1,S.length()){
		if(cnt==0){
			if(S[i]=='0'){
				ans++;
			}
		}else if(cnt==1){
		   if(S[i]=='1'){
				ans++;
			}
		}
		cnt = (cnt + 1) % 2;
	}

	cout << ans <<endl;

	return 0;

}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
long long int x[100007];
int main(){
	long long int n,a,b;
	long long int s=0;
	int i,j,k;
	cin>>n>>a>>b;
	for(i=0;i<n;i++){
		cin>>x[i];
		if(i==0)continue;
		if(a*(x[i]-x[i-1])<b)s+=a*(x[i]-x[i-1]);
		else s+=b;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int n,k;	scanf("%d %d",&n,&k);
	char s[n];	scanf("%s",s);
	if(s[k-1]=='A'){
		s[k-1]='a';
	}
	else if(s[k-1]=='B'){
		s[k-1]='b';
	}
	else if(s[k-1]=='C'){
		s[k-1]='c';
	}
	printf("%s",s);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int a,b,x;
	for(int j=1;j<=9;j++){
		a=j;
		for(int i=1;i<=9;i++){
			b=i;
			cout<<a<<"x"<<b<<"="<<a*b<<endl;
		}
	}
}

Measured memory_bytes: 1116
def findNumberOfTriangles(arr, n):
    count = 0
    ans = []
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                if (arr[i] + arr[j] > arr[k] and
                    arr[i] + arr[k] > arr[j] and
                    arr[k] + arr[j] > arr[i]):
                    if len(set([arr[i], arr[j], arr[k]]))==3:
                        count += 1


    return count

n = int(input())
arr = [int(x) for x in input().split()]
print(findNumberOfTriangles(arr, n))

Measured memory_bytes: 9200
a = int(input())
b = int(input())
c = int(input())
x1 = int(input())
x2 = 0
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
                x2 = 500*i + 100*j + 50*k
                if (x2==x1):
                    ans+=1

print(ans)


Measured memory_bytes: 9104
#https://atcoder.jp/contests/abc142/submissions/7777847

import sys
input = sys.stdin.readline

N,M = map(int,input().split())
lis = []
for _ in range(M):
    a,b = map(int,input().split())
    C = list(map(int,input().split()))
    s = 0
    for c in C:
        s |= 1 << (c-1) #その鍵が開けられる宝箱に応じてビットシフト
    # |は論理和（ ビット演算での+ ）
    lis.append((s,a))

dp = [float("inf")]*(2**N)  #2**N == 1<<N
dp[0] = 0
#下から積み上げていくdp、bitDPではset()の代わりに|が使える
for bit in range(2**N):
    for i in range(M):
        s,a = lis[i]
        t = bit | s
        dp[t] = min(dp[t],dp[bit]+a)

if dp[-1] == float("inf"):
    print(-1)
else:
    print(dp[-1])



Measured memory_bytes: 42588
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

inline void InitRand()
{
    srand((unsigned int)time(NULL));
}

int main() {
    InitRand();
    int D; cin >> D;
    veci C(26);
    vecveci S(D,veci(26));
    veci T(D);
    REP(i,26) cin >> C[i];
    REP(i,D) REP(j,26) cin >> S[i][j];
    veci last(26),pre(26);
    REP(i,D) {
        int cost = 0;
        int d = 1;
        int max_p;
        REP(j,26) {
            pre = last;
            int total = 0;
            total += S[i][j];
            pre[j] = d;
            REP(k,26) {
                total -= C[k]*(d-pre[k]);
            }
            pre[j] = last[j];
            if(total > cost) {
                cost = total;
                max_p = j;
            }
        }
        last[max_p] = d;
        T[i] = max_p;
    }

    veci last_d(26);
    ll old_ans = 0;
    REP(i,D) {
        int d = i+1;
        last_d[T[i]] = d;
        old_ans += S[i][T[i]];
        REP(j,26) {
            old_ans -= C[j]*(d-last_d[j]);
        }
    }

    clock_t s = clock();

    while(1) {
        int B = rand()%D;
        int Q = rand()%26;
        int old_p = T[B];
        T[B] = Q;
        ll score = 0;
        veci last(26);
        REP(j,D) {
            int d = j+1;
            last[T[j]] = d;
            score += S[j][T[j]];
            REP(k,26) {
                score -= C[k]*(d-last[k]);
            }
        }
        if(old_ans < score) {
            old_ans = score;
        }
        else {
            T[B] = old_p;
        }
        clock_t e = clock();
        const double time = static_cast<double>(e - s) / CLOCKS_PER_SEC * 1000.0;
        if(time >= 1980) break;
    }
    REP(i,D) cout << T[i]+1 << endl;
}

Measured memory_bytes: 3720
import java.util.Scanner;

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

		if(n.substring(0,1).equals("7") || n.substring(1,2).equals("7") || n.substring(2,3).equals("7")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35712
import bisect

while(1):
    [N,M]=[int(x) for x in raw_input().split()]
    if N==0:
        break
    a=[0 for x in range(N+1)]
    for i in range(N):
        a[i+1]=int(raw_input())
    #b=sorted([x+y for x in a for y in a])
    #c=[]
    #for i in range(1,len(b)):
    #    if b[i]>M:
    #        break
    #    elif b[i-1]!=b[i]:
    #        c.append(b[i-1])
    b=[a[x]+a[y] for x in range(N+1) for y in range(x,N+1)]
    #c=f7(b)
    c=sorted(b)
    #print c
    largest=0
    id=0
    st=len(c)-bisect.bisect(c,M)+1
    #print st
    for i in range(st,len(c)+1):
        if id==len(c):
            break
        while(id<len(c) and c[-i]+c[id]<=M):
            #print c[-i],c[id],c[-i]+c[id]
            largest=max(largest,c[-i]+c[id])
            id+=1
    print largest

Measured memory_bytes: 43988
#import
import math

#input
a,b,h,m = map(int,open(0).read().split())

ht=30*h+0.5*m
mt=6*m

x=a**2+b**2-2*a*b*math.cos(abs((ht-mt)*math.pi/180))
print(math.sqrt(x))

Measured memory_bytes: 9484
import bisect
from collections import deque
n=int(input())
A=deque([int(input())])

for i in range(n-1):
  a=int(input())
  b=bisect.bisect_left(A,a,lo=0,hi=len(A))
  if b==0:
    A.appendleft(a)
  else:
    A[b-1]=a
print(len(A))


Measured memory_bytes: 7356
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

class UFTree {
    vector<int> parent;
    vector<int> height;

public:
    UFTree(int size)
    {
        for (int i = 0; i < size; i++) {
            parent.push_back(i);
            height.push_back(0);
        }
    }
    int root(int node)
    {
        if (parent[node] == node) {
            return node;
        }
        return parent[node] = root(parent[node]);
    }
    void merge(int n0, int n1)
    {
        int r0 = root(n0), r1 = root(n1);
        if (r0 == r1) {
            return;
        }
        if (height[r0] < height[r1])
            swap(r0, r1);
        if (height[r0] == height[r1])
            height[r0]++;
        parent[r1] = r0;
    }
};

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

    const int XMAX = 100'000;
    vector<vector<int>> p(XMAX);
    vector<int> q(XMAX, -1);
    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        p[x].push_back(y);
        q[y] = x;
    }

    UFTree uft(XMAX);
    rep(i, XMAX)
    {
        for (int y : p[i]) {
            if (q[y] != -1) {
                uft.merge(q[y], i);
            }
        }
    }

    vector<vector<int>> r(XMAX);
    vector<int> s(XMAX, 0);
    rep(i, XMAX)
    {
        for (int y : p[i]) {
            r[uft.root(i)].push_back(y);
        }
        s[uft.root(i)]++;
    }

    int64_t result = -n;
    rep(i, XMAX)
    {
        sort(r[i].begin(), r[i].end());
        r[i].erase(unique(r[i].begin(), r[i].end()), r[i].end());
        result += (int64_t)r[i].size() * s[i];
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 8868
#include <stdio.h>

void solve(int n);
int findSumOfDigits(int n);

int main()
{
  int n;

  scanf("%d", &n);
  
  solve(n);

  return 0;
}

void solve(int n)
{
  if (0 == n % findSumOfDigits(n))
    {
      printf("Yes\n");
    }
  else
    {
      printf("No\n");
    }
}

int findSumOfDigits(int n)
{
  int sum = 0;
  while (n > 0)
    {
      sum += n % 10;
      n /= 10;
    }
  
  return sum;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int R, G;
  cin >> R >> G;
  cout<<2*G-R<<"\n";
  return 0;
}


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

int main(){long N;
cin >> N;
vector<long> a(N + 1);
erep(i, N) cin >> a.at(i);

vector<long> cnt(1e5 + 10);
erep(i, N){
    if(a.at(i) == 0){
        cnt.at(0)++;
        cnt.at(1)++;
    }
    else{
        cnt.at(a.at(i) - 1)++;
        cnt.at(a.at(i))++;
        cnt.at(a.at(i) + 1)++;
    }
}
sort(cnt.begin(), cnt.end());
reverse(cnt.begin(), cnt.end());
long ans = cnt.at(0);



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

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll ans = 0;
  if(a>=k)ans = k;
  else if(a+b>=k)ans = a;
  else ans = -1*(k-b-a)+a;
  cout<<(ans)<<endl;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(10);
           ll x;
           cin>>x;
           for(ll i=0;i<110000;i++){
            if(i*(i+1)/2>=x){
             cout<<i<<endl;
              return 0;
            }
           }
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 100010
char a[N];
int ne[N];
int main()
{
    int i,j,k,s;
    scanf("%s",a);
    k=strlen(a);
    i=0;
    j=k-1;
    s=0;
    while(i<j)
    {
        if(a[i]==a[j])
        {
            i++;
            j--;
        }
        else
        {
            if(a[i]=='x')
            {
                s++;
                i++;
            }
            else
            if(a[j]=='x')
            {
                s++;
                j--;
            }
            else
            {
                printf("-1\n");
                return 0;
            }
        }
    }
    printf("%d\n",s);
    return 0;
}


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

using namespace std;


int countDivisors(int n) 
{ 
    int cnt = 0; 
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
}
#define N 100005

int dp[10*N];

void solve(){
	for(int i=1;i<=10*N;i++){
		for(int j=1;j*i<=10*N;j++){
			dp[j*i]++;
		}
	}
}


int main()
{
    int n;
    cin>>n;
    int cnt =0 ;
    // vector<int> v;
    // int i=1;
    // int j=n;

    // while(i<=j)
    // {
    //     if(i+j == n)
    //     {
    //         if(i==j)
    //         {
    //             v.push_back(i);
    //         }
    //         else
    //         {
    //             v.push_back(i);
    //             v.push_back(j);
    //         }
            
    //         i++;
    //         j--;
    //     }
    //     else if(i+j>n)
    //     {
    //         j--;
    //     }
    //     else
    //     {
    //         i++;
    //     }
            
    // }
    solve();

    for(int i=1 ;i<n;i++)
    {
        cnt =dp[i]+cnt;
    }


    cout<<cnt;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int n; cin >> n;
    int w[n]; rep(i, n) cin >> w[i];

    int sum = 0;
    int ans = 0;
    rep(i, n - 1) ans += w[i];
    rep(i, n){
        sum += w[i];
        int tmp = 0;
        REP(j, i + 1, n){
            tmp += w[j];
        }
        ans = min(ans, abs(sum - tmp));
    }
    OP(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    string s;
    cin>>s;
    map<char,int> mp;
    rep(i,4){
        mp[s[i]]++;
    }
    rep(i,4){
        if(mp[s[i]]!=2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3576
//#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

typedef long long i64;

i64 lim;

bool verif (i64 x, i64 dr, i64 l, i64 r) {
    if (dr <= l)
        return dr * l < lim;
    if (x >= r)
        return x * r < lim;

    double q = (double)(x + r) / 2;
    i64 mij = q;

    if ((double)mij == q) {
        return mij * mij < lim;
    }
    return mij * (mij + 1) < lim;
}

int _x, _y;
bool check (int a, int b, int l, int r) {
    if (b < a || r < l)
        return 1;

    if (a <= _x && _x <= b) {
        int len = _x - a;
        return check(a, a + len - 1, r - len + 1, r) && check(a + len + 1, b + 1, l, r - len);
    }

    if (l <= _y && _y <= r) {
        int len = _y - l;
        return check(b - len + 1, b, l, l + len - 1) && check(a, b - len, l + len + 1, r + 1);
    }

    return verif(a, b, l, r);
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(); cout.tie();
    int q;
    cin >> q;

    while (q --) {
        int x, y;
        cin >> x >> y;
        lim = 1LL * x * y;

        _x = x, _y = y;

        int ans = 0;
        for (int step = 1 << 30; step > 0; step >>= 1) {
            if (ans + step <= (1 << 30) - 1 + (1 << 30) && check(1, ans + step, 1, ans + step)) {
                ans += step;
            }
        }

        cout << ans << "\n";
    }

    return 0;
}


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

const int size = 2e5;
vector<int> graph[size+1];
int nodeValue[size+1];
bool vis[size+1];

void dfs(int node){
	if(vis[node]) return ;
  	else{
  		vis[node] = true;
      	for(int i=0;i<graph[node].size();i++){
      	 //   cout << "node " << node << " " << graph[node][i] << " " << '\n';
      	    if(!vis[graph[node][i]]){
      		    nodeValue[graph[node][i]]+=nodeValue[node];
    		    dfs(graph[node][i]);
      	    }
    	}
    }
}


int main(){
	
  	int n,q; cin >> n >> q;
  
  	for(int i=1;i<=n-1;i++){
    	int a,b; cin >> a >> b;
      	graph[a].push_back(b);
      	graph[b].push_back(a);
    }
  	
  	for(int i=1;i<=q;i++){
      int node,value; cin >> node >> value;
      nodeValue[node]+=value;
    //   cout << "node " << node << " value " << value << '\n';
    }
  
  	dfs(1);
  	
  	for(int i=1;i<=n;i++) cout << nodeValue[i] << " ";


	return 0;
}

Measured memory_bytes: 23680
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

void hora(int tc) {
	ll n;
	cin>>n;
	if(n & 1) cout<<0<<endl;
	else {
		n /= 2;
		ll tot = 0;
		while(n) {
			tot += n / 5;
			n /= 5;
		}
		cout<<tot<<endl;
	}
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int K,A,B,a,b;
	cin >> K >> A >> B;
	if(A%K==0 || B%K ==0)
		cout << "OK" << endl;
	else if((K*(A/K+1)<=B) || (K*(B/K-1)>=A)){
		cout << "OK" << endl;
	}else{
		cout << "NG"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>

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


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

  rep(i,1010) {
    if (i / 10 == B  && i * 8 / 100 == A) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import collections

N = int(input())
A_s = list(map(int, input().split()))

CNT_A = collections.Counter(A_s).most_common()

ans_list = []

if (len(CNT_A) >= 3):
    CNT_A.sort()

    for i in range(len(CNT_A) - 2):
        val = CNT_A[i][0]
        next_val = CNT_A[i + 1][0]
        nnnn_val = CNT_A[i + 2][0]
        
        
        if (abs(val - next_val) <= 2):
            cnt = CNT_A[i][1] + CNT_A[i + 1][1]
            if (abs(val - nnnn_val) <= 2):
                cnt += CNT_A[i + 2][1]
                
        else:
            cnt = CNT_A[i][1]
        
        ans_list.append(cnt)
    
    ans = max(ans_list)

elif (len(CNT_A) == 2):
    val = CNT_A[0][0]
    n_val = CNT_A[1][0]
    
    if (abs(val - n_val) <= 2):
        ans = CNT_A[0][1] + CNT_A[1][1]
    else:
        ans = CNT_A[0][1]
    
else:
    ans=CNT_A[0][1]

print(ans)

Measured memory_bytes: 16096
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<numeric>
#include<math.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a1, a2, a3, b1, b2, b3;
    vector<int> town(5);
    cin >> a1 >> b1;
    ++town[a1], ++town[b1];
    cin >> a2 >> b2;
    ++town[a2], ++town[b2];
    cin >> a3 >> b3;
    ++town[a3], ++town[b3];
    bool ok = true;
    rep(i, 5) {
        if ( town[i] >= 3 ) {
            ok = false;
            break;
        }
    }
    if ( ok ) cout << "YES" << endl;
    else      cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, A, B;
  cin>>N>>A>>B;
  ll ans = N/(A+B)*A;
  N %= A+B;
  if(N>=A) ans += A;
  else ans += N;
  cout<<ans<<endl;
}



Measured memory_bytes: 3580
#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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (ll)4e18;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	ll res = a + b;
	ll num = n / res;
	ll sol = n % res;
	ll ans = num * a;
	ans += min(sol, a);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
INF = 10 ** 9

dp = [0] + [INF for _ in range(N - 1)]
dp[1] = dp[0] + abs(h[1] - h[0])
for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[N - 1])

Measured memory_bytes: 13976
n=int(input())
ans=[0]*n
i=0
for k in range(1,30001):
    if k%2==0 or k%3==0:
        ans[i]=k
        i+=1
    if i==n-1:
        break
x=sum(ans)
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
for k in range(30000,0,-1):
    if (x+k)%6==0 and gcd(x,k)>1:
        ans[-1]=k
        break
print(*ans)

Measured memory_bytes: 4556
a=list(map(int,input().split()))
n=1
while True:
    if a[1]*n >= a[0]:
        x=a[2]*n
        break
    n += 1
m=1
while True:
    if a[3]*m >= a[0]:
        y=a[4]*m
        break
    m += 1
z=[x,y]
w=sorted(z)
print(w[0])


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

using namespace std;

int a[1005];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	
	int tot = 0;
	
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		tot += a[i];
	}
	
	int cnt = 0;
	
	for (int i = 0; i < n; i++) {
		if (a[i] * 4 * m < tot) continue;
		cnt++;
	}
	
	if (cnt < m) printf("No\n");
	else printf("Yes\n");
}


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

int main(){
    int H,N; cin>>H>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
        H-=A.at(i);
    }
    if(H<=0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(N: int, V: "List[int]", C: "List[int]"):
    ans = [V[i]-C[i] for i in range(len(V))]
    ans2 = [i for i in ans if i >= 0]

    print(sum(ans2))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    V = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    C = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, V, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class BBishop {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll H, W;
	    in >> H >> W;
	    ll ans = (H / 2) * W + (H % 2) * (W + 1) / 2;
	    if (W == 1 || H == 1) ans = 1;
	    out << ans << '\n';
	}
};


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

	BBishop solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import math


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


N = int(input())
As = list(map(int, input().split(" ")))
As = [0] + As
kosu = [0] *(N+1)

anss = []
bs  = [0] *(N+1)
for i in range(N,N//2,-1):
    if As[i] == 0:
        bs[i] =0
    else:
        bs[i] = 1

for i in range(N// 2, 0, -1):
    temp = 0
    for k in range(1,N + 1):
        if i * k > N:
            break
        if bs[i * k] == 1:
            temp += 1
    if As[i] % 2  != temp %2:
        bs[i] = 1
print(bs.count(1))
for i,num in enumerate(bs):
    if num == 1:
        print(i)
# print(M)
# for i in ans:
#     print(i)

Measured memory_bytes: 8756
from operator import mul
from functools import reduce

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(mul, range(n, n - r, -1))
    denom = reduce(mul, range(1, r + 1))
    return numer // denom


n = int(input())
a = list(map(int, input().split()))
ai = max(a)
diff = float("inf")
for aj in set(a):
    if abs(ai / 2 - aj) < diff:
        ans = [ai, aj]
        diff = abs(ai / 2 - aj)
print(' '.join(map(str, ans)))


Measured memory_bytes: 16208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n, m; cin >> n >> m;
    int tmp;
    rep(i, m){
        cin >> tmp;
        n -= tmp;
    }
    cout << max(n, -1) << endl;
    return 0;
}

Measured memory_bytes: 3580
k,n = map(int,input().split())
mp = [int(x) for x in input().split()]
a = []
for i in range(n):
    if(i==(n-1)):
        last = k - mp[i] + mp[0]
        a.append(last)
        break
    a.append(mp[i+1] - mp[i])

ml = max(a)
print(sum(a)-ml)

Measured memory_bytes: 26436
n=int(input())
l=list(map(int,input().split()))
flag=True
li=[]
for i in range(len(l)):
  if l[i]%2==0:
    li.append(l[i])
for i in range(len(li)):
  if li[i]%3!=0 and li[i]%5!=0:
    flag=False
#print(li)
if flag==True:
  print("APPROVED")
else:
  print("DENIED") 

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N - K; i++) {
    if (A.at(i) < A.at(i + K)) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

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

    vector<ll> A(N+1);

    rep(i,N) {
        int tmp = i+1;
        int cnt = 1;
        while(tmp<=N) {
            A[tmp]++;
            cnt++;
            tmp = cnt*(i+1);
            
        }
    }
    ll ans = 0;

    rep(i,N) {
        ans += (i+1)*A[i+1];
    }

    cout << ans << endl;
}

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

int main(void) {
	int a, b;
	cin >> a >> b;
	double n = (double)(pow(10, (floor)(log10(b) + 1))*a + b);
	n = sqrt(n);
	if (ceil(n) != floor(n)) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<ll> A(MAXN, 0);

signed main(){
    cin >> N;
    for(ll i=1;i<=3500;i++) {
        for(ll j=1;j<=3500;j++) {
            //cout << "OK" << endl;
            if((4*i*j-N*i-N*j)>0) {
                if((N*i*j)%(4*i*j-N*i-N*j)==0) {
                    cout << i << " " << j << " " << (N*i*j)/(4*i*j-N*i-N*j) << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#define MAXN (int)(1e5+105)
using namespace std;
int a[MAXN];
int main() {
	int n, cnt = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for(int i = 1; i <= n; i++) {
		if(a[i] == i) {
			swap(a[i], a[i+1]);
			cnt ++;
		}
	}
	printf("%d\n", cnt);
	return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
//#define MOD 1000000007
const int INF = 1LL<<30;

char fi[1010][1010];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int dist[1010][1010];

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

    rep(i,h) rep(j,w) dist[i][j]=-1;
    queue<pair<int,int>> que;
    rep(i,h){
        rep(j,w){
            cin>>fi[i][j];
            if(fi[i][j]=='#'){
                que.push({i,j});
                dist[i][j]=0;
            } 
        }
    }

    


    while (!que.empty()) {
        auto v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        int x=v.first;
        int y=v.second;

        rep(i,4){
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(dist[nx][ny]!=-1) continue;
            if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
            dist[nx][ny]=dist[x][y]+1;
            que.push({nx,ny});


        }
    }

    int ans=0;
    rep(i,h){
        rep(j,w){
            ans=max(ans,dist[i][j]);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 13456
/*
    Created by Rahul Goel.
*/
#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;
template < typename T >
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*******************************************************************************/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
ll mod_sum() { return 0LL; }
template < typename T, typename... Args >
T mod_sum(T a, Args... args) { return ((a + MOD_sum(args...))%MOD + MOD)%MOD; }
/*******************************************************************************/
ll mod_prod() { return 1LL; }
template< typename T, typename... Args >
T mod_prod(T a, Args... args) { return (a*MOD_prod(args...))%MOD; }
/*******************************************************************************/
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
/*******************************************************************************/
//.-.. . -. -.- .- .. ... .-.. --- ...- .
/*
    Code begins after this.
*/

ll solve() {
    ll n;
    cin >> n;
    ll val = 0;
    for (ll i = 0; i < n + 100; i++) {
        val = (val * 10 + 7) % n;
        if (val == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

signed main() {
    fastio;

    ll t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
const int inf=0x3f3f3f3f;
const int maxn=4e3+10;
int cnt=0,head[maxn];
int dst[maxn],vis[maxn]={0};
int n;
struct Edge{
    int val,to,next;
}edge[maxn];
struct node{
    int dst,to;
    bool operator < (const node &b) const{
        return dst>b.dst;
    }
}p[maxn];
void add_edge(int from,int to,int val)
{
    cnt++;
    edge[cnt].to=to;
    edge[cnt].val=val;
    edge[cnt].next=head[from];
    head[from]=cnt;
}
void dijkstra(int s)
{
//	memset(dst,inf,sizeof dst);
//	memset(vis,0,sizeof vis);
	for(int i=0;i<=n;i++){
		vis[i]=0;
		dst[i]=inf;
	}
    priority_queue<node>q;
    q.push((node){0,s});
    while(!q.empty()){
        node on=q.top();q.pop();
        if(vis[on.to]) continue;
        dst[on.to]=on.dst;
        vis[on.to]=1;
        for(int i=head[on.to];i;i=edge[i].next){
            if(dst[edge[i].to]>dst[on.to]+edge[i].val){
		       	dst[edge[i].to]=dst[on.to]+edge[i].val;
		       	if(vis[edge[i].to]==0)
		  		q.push((node){dst[edge[i].to],edge[i].to});
			}	
        }
    }
}
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int m,s,x,y;
    memset(head,-1,sizeof head);
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        add_edge(i,i+1,1);
        add_edge(i+1,i,1);
    }
    add_edge(x,y,1);
    add_edge(y,x,1);
   int len[2020][2020];
    for(int i=1;i<=n;i++){
    	dijkstra(i);
    	for(int j=1;j<=n;j++){
   // 		cout<<dst[j]<<' ';
    		if(len[i][j]==0) len[i][j]=dst[j];
    		else len[i][j]=min(len[i][j],dst[j]);
		}
	}
    int ans[maxn];
    for(int i=1;i<n;i++){
    	for(int j=i+1;j<=n;j++){
    		ans[len[i][j]]++;
		}
	}
    for(int i=1;i<n;i++) cout<<ans[i]<<' ';
}

Measured memory_bytes: 16128
import java.util.*;
 class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
      int arr[] = new int[n] ;
      
      for(int i = 0; i< n ; i++ ){
          arr[i] = scan.nextInt();
      }
      int count = 0 ;
      while(evenCheck(arr)){
          for(int i = 0 ; i <n ;i++){
              arr[i] = arr[i]/2 ;
          }
          count++;
      }
      System.out.println(count) ;
      
  
     
      
    }
     static boolean evenCheck(int arr[]){
          int count = 0 ;
          for(int i = 0 ; i<arr.length ; i++){
              if(arr[i]%2 != 0 ){
                  return false ;
              }
          }
          return true ;
      }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;

int a, b, c, d, p, x, y;
signed main()
{
  cin >> a >> b >> c >> d >> p;
  
  x = a * p;

  y = b;

  if(p - c > 0){
    y += d * (p - c);
  }

  cout << min(x, y) << endl;
  
  return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
      #define ll  long long int
      #define N 100000
      #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
      #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
      #define po pop_back
      #define pb push_back
      #define pp pair<ll,ll>
      #define lb lower_bound
      #define fi first
      #define se second
      #define debug(x) cout << #x << " = " << x << endl
      #define ub upper_bound
      #define ibs ios_base::sync_with_stdio(false)
      #define cti cin.tie(0)
      #define all(x) x.begin(),x.end()
      #define PI 3.14159265
      #define cot cout.tie(0)
      using namespace std;
       /**
        * @author :: Sawlani
        *
        */
        int main()
        {
              ll n;
              cin  >>  n;
              ll a[n+1];

              f(i,1,n)
              {
                  cin >> a[i];

              }

              ll ans=0;
              f(i,1,n)
              {

                  f(j,i+1,n)
                  {
                      ans+=a[i]*a[j];

                  }
              }
              cout <<  ans << endl;
        }



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,k,i,j,l,mod=1e9+7,ans,dp[2][1<<20],ned1[25],ned2[25],put[1<<20],x,y,z;
int bi[1<<20][22],cnt;
int main()
{
	cin>>n>>m>>k;
	for (i=1;i<=k;i++)
	{
		cin>>x>>y>>z;
		y--;
		ned1[x]|=(1<<y);
		ned2[x]|=(1<<y)*z;
	}
	n--;
	for (i=0;i<(1<<n);i++)
	{
		for (j=0;j<n;j++) bi[i][j]=(1<<n);
		cnt=0;
		for (j=1;j<n;j++)
		{
			if (((1<<j)&i)) cnt++;
			if (((1<<j)&i)&&(!((1<<(j-1))&i)))
			{
				bi[i][cnt]=(i^(1<<j)^(1<<(j-1)));
			}
		}
	}
	/*for (i=0;i<(1<<n);i++)
	{
		cerr<<i<<':';
		for (j=0;j<n;j++)
		{
			cerr<<bi[i][j]<<' ';
		}
		cerr<<endl;
	}*/
	for (i=0;i<(1<<n);i++)
	{
		//put[i]=(~((~i)^((~i)&(-(~i)))));
		put[i]=(1<<n);
		for (j=n-1;j>=0;j--)
		{
			if (!(i&(1<<j)))
			{
				put[i]=i^(1<<j);
				break;
			}
		}
	}
	/*for (i=0;i<(1<<n);i++) cerr<<put[i]<<' ';
	cerr<<endl;*/
	dp[0][0]=1;
	for (i=1;i<=m;i++)
	{
		memcpy(dp[i&1],dp[(i-1)&1],sizeof(dp[i&1]));
		for (j=0;j<(1<<n);j++)
		{
			dp[i&1][put[j]]+=dp[i&1][j];
			dp[i&1][put[j]]%=mod;
		}
		/*for (j=0;j<(1<<n);j++)
		{
			//if ((ned1[i]&j)!=ned2[i]) dp[i&1][j]=0;
			cerr<<dp[i&1][j]<<' ';
		}*/
		//cerr<<endl;
		for (l=0;l<n;l++)
		{
			for (j=(1<<n)-1;j>=0;j--)
			{
				dp[i&1][bi[j][l]]+=dp[i&1][j];
				dp[i&1][bi[j][l]]%=mod;
			}
		}
		for (j=0;j<(1<<n);j++)
		{
			if ((ned1[i]&j)!=ned2[i]) dp[i&1][j]=0;
			//cerr<<dp[i&1][j]<<' ';
		}
		//cerr<<endl;
	}
	for (i=0;i<(1<<n);i++)
	{
		ans+=dp[m&1][i];
		ans%=mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 59648
#include<iostream>
using namespace std; // 575

const int MAX = 20;
int main() {
	int N, V[MAX], C[MAX];
	cin >> N;
	int ans = 0;
	for (int i = 0;i < N;++ i) cin >> V[i];
	for (int i = 0;i < N;++ i) cin >> C[i];
	for (int i = 0;i < N;++ i) ans += max(0, V[i] - C[i]);
	cout << ans;
	
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

V>Cなら足す、以上
*/

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = II()
    print("ABC"+str(n))
    return

#B
def B():
    ni = [2 ** i for i in range(1, 10)]
    n = II()
    ans = 1
    for i in range(1, n + 1):
        if i in ni:
            ans = i
    print(ans)        
    return

#C
def C():
    n, m = LI()
    edg = [[] for i in range(n)]
    for _ in range(m):
        a, b = LI_()
        edg[a].append(b)
        edg[b].append(a)
    next = []
    for i in edg[0]:
        next.append(i)
    for ne in next:
        for i in edg[ne]:
            if i == n - 1:
                print("POSSIBLE")
                return
    print("IMPOSSIBLE")
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 83404
n,m,c = map(int, input().split())
count = 0
res = 0
b = list(map(int, input().split()))
         
for i in range(n):
  a = list(map(int, input().split()))
  
  for j in range(m):
    res += a[j]*b[j]
  
  if res+c > 0:
    count += 1
    res = 0
  else:
    res = 0

print(count)

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

using pii = pair<int, int>;

int i, n, m, k, l, x, y, a[15][2];

bool good(pii const& x) {
  int y = x.second;
  for(i = 0; i < n; i++) {
    if((y >> i) & 1 && (a[i][0] & y || a[i][1] & l - y))
      return false;
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  for(cin >> n; i < n; i++) {
    for(cin >> m; m--;) {
      cin >> x >> y;
      a[i][y] |= 1 << x - 1;
    }
  }
  l = (1 << n) - 1;
  vector<pii> b;
  for(int i = 1; i <= l; i++) {
    b.emplace_back(__builtin_popcount(i), i);
  }
  sort(begin(b), end(b), [](pii const& x, pii const& y) {return x.first > y.first;});
  auto it = find_if(begin(b), end(b), good);
  cout << find_if(begin(b), end(b), good)->first << '\n';
  
  return 0;
}


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

using namespace std;
typedef long long ll;

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

    int n;
    cin>>n;

    vector<double> p(n);

    for(int i=0;i<n;i++)
        cin>>p[i];

    vector<vector<double>> dp(n+1,vector<double>(n+1));
    dp[0][0]=1.0;
    //float g=dp[0][0];
    //cout<<g;
    for(int i=1;i<=n;i++){
        dp[i][0]=dp[i-1][0]*p[i-1];
    }
    for(int i=1;i<=n;i++){
        dp[0][i]=dp[0][i-1]*(1.0-p[i-1]);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n-i;j++){
            dp[i][j]=(dp[i-1][j]*(p[i+j-1]))+(dp[i][j-1]*(1.0-p[i+j-1]));
        }
    }
    double ans=0.0;
    for(int i=0;i<=n;i++){
        if(i>n-i){
            ans=ans+dp[i][n-i];
        }
    }
    cout<<setprecision(10)<<ans;
    return 0;
}


Measured memory_bytes: 73732