akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N;
ll target = 1;
unordered_map<ll, ll> mp;

// 素数列挙
void prime_factor(ll n) {
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
}

int calc_larger(int n) {
    int ret = 0;
    each(m, mp) {
        if (m.second + 1 >= n) ret++;
    }
    return ret;
}

void solve() {
    ll ans = calc_larger(75) + calc_larger(25) * (calc_larger(3) - 1) +
             calc_larger(15) * (calc_larger(5) - 1) +
             calc_larger(5) * (calc_larger(5) - 1) * (calc_larger(3) - 2) / 2;
    cout << ans << endl;
}

int main() {
    cin >> N;
    repone(i, N) prime_factor(i);

    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int b =0;
    	for (int i=1;i <= N;i++){
    	  b += i;
    	}
    
    	System.out.println(b);
    }
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    vector<vector<bool>> connected(N+1, vector<bool>(N+1,false));
    rep(i,0,M) {
        connected[a[i]][b[i]] = true;
        connected[b[i]][a[i]] = true;
    }
    vector<int> paths(N);
    rep(i,0,N) paths[i] = i+1;
    int answer = 0;
    do {
        bool valid = true;
        rep(i,0,paths.size()-1) {
            if (!connected[paths[i]][paths[i+1]]) {
                valid = false;
                break;
            }
        }
        if (valid) answer++;
    } while(next_permutation(all(paths)) && paths.front() == 1);
    cout << answer << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<memory.h>
#include<ctime>
#include<cstdio>
#include<map>
#include<stack>

using namespace std;

string ss;
int w,n,e,s;
bool check()
{
    if(w==1&&e==1&&n==1&&s==1)return 1;
    if(w==1&&e==1&&n==0&&s==0)return 1;
    if(w==0&&e==0&&n==1&&s==1)return 1;
    if(w==0&&e==0&&n==0&&s==0)return 1; 
    return 0;
}
int main()
{
    cin>>ss; 
    for(int i=0;i<ss.length();i++)
    {
	    if(ss[i]=='W')
		{
			w=1;
		}
	    else 
		{
			if(ss[i]=='N')
			{
				n=1;
			}
			else 
			{
				if(ss[i]=='E')
				{
					e=1;
				} 
				else 
				{
					if(ss[i]=='S')
					{
						s=1;
					}
				}			
			}	     		
		}	
	}

    if(check())
    {
    	cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
    return 0;
}


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

template<typename T> using V = vector< T >;
using Vi = V<int>;

int main(){
    int n;
    cin>>n;
    Vi a(n),b(n),c(n);
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];
    for(int i=0; i<n-1; i++) cin>>c[i];

    int total = 0;
    for(int i=0; i<n; i++){
        total+=b[a[i]-1];
        if(i>0){
            if(a[i]-a[i-1]==1){
                total+=c[a[i-1]-1];
            }
        }
    }

    cout<<total<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EvenRelation solver = new EvenRelation();
        solver.solve(1, in, out);
        out.close();
    }

    static class EvenRelation {
        int[] result;
        List<List<Node>> list;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            list = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                list.add(new ArrayList<>());
            }

            for (int i = 1; i < n; i++) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                int w = in.nextInt();
                list.get(u).add(new Node(v, w));
                list.get(v).add(new Node(u, w));
            }
            result = new int[n];
            for (int i = 0; i < n; i++) {
                if (result[i] == 0) {
                    dfs(i, 1);
                }
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < n; i++) {
                if (result[i] == 1) {
                    sb.append("1\n");
                } else {
                    sb.append("0\n");
                }
            }
            out.println(sb.toString());
        }

        public void dfs(int v, int c) {
            result[v] = c;
            for (Node n : list.get(v)) {
                if (result[n.dist] == 0) {
                    if (n.weight % 2 == 1) {
                        dfs(n.dist, -c);
                    } else {
                        dfs(n.dist, c);
                    }
                }
            }
        }

        class Node {
            public final Integer dist;
            public final Integer weight;

            Node(Integer dist, Integer weight) {
                this.dist = dist;
                this.weight = weight;
            }

        }

    }
}



Measured memory_bytes: 84488
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<long long> V;
typedef vector<V> VV;
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 long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
    int n;
    int ans=0;

    cin >>n;
    cout<<((n+1)/2)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using T = tuple<int, int, int>;
const int MX = 100005;
int n, m, p[MX], d[MX], a, b, c;
long long w[MX];
T tp[MX];
int find(int x){return (p[x] < 0 ? x : p[x] = find(p[x]));}
void uni(int x, int y, int z){
	x = find(x); y = find(y);
	if(x != y){
		if(p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		w[x] += w[y];
		d[x] += d[y];
		p[y] = x;
	}
	if(z <= w[x]) d[x] = 0;
	else d[x]++;
}
int main(){
	scanf("%d%d", &n, &m);
	rep(i,n){
		scanf("%lld", w+i);
		p[i] = -1;
	}
	rep(i,m){
		scanf("%d%d%d", &a, &b, &c);
		tp[i] = T(c,a-1,b-1);
	}
	sort(tp, tp+m);
	rep(i,m){
		tie(c,a,b) = tp[i];
		uni(a,b,c);
	}
	printf("%d\n", d[find(a)]);
}

Measured memory_bytes: 2944
XY= list(map(int,input().split()))
X=XY[0]
Y=XY[1]

if X==1:
    syokinx=300000
elif X==2:
    syokinx=200000
elif X==3:
    syokinx=100000
else:
    syokinx=0

if Y==1:
    syokiny=300000
elif Y==2:
    syokiny=200000
elif Y==3:
    syokiny=100000
else:
    syokiny=0

if X==1 and Y==1:
    syokinz=400000
else:
    syokinz=0

print(syokinx+syokiny+syokinz)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b;
  cin >> a >> b;

  int k = (a+b)/2;

  if((a+b)%2 == 0) cout << k << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;

}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
 
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()
#define cae cout<<ans<<endl
 
int main()
{
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	
	c*=2;
	int ans=INT_MAX;
	int tmp;
	rep(i,max(x,y)+1){
		tmp=c*i+a*max(0,x-i)+b*max(0,y-i);
		ans=min(ans,tmp);
	}
	cae;
	
	return 0;
}

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

public class Main {
	static int N = 0;
	static String S = "";
	static int K = 0;
	public static void main(String[] args) {
		//入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			N = Integer.parseInt(br.readLine());
			S = br.readLine();
			K = Integer.parseInt(br.readLine());

		} catch(IOException e) {
			e.printStackTrace();
		}

		char c = S.charAt(K-1);
		System.out.println(S.replaceAll("[^" + c + "]", "*"));

	}
}

Measured memory_bytes: 22740
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<cassert>
#include<queue>
#include<stack>

#define REP(i,b,n) for(long long int  i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it,o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)


const long long int  MAX  = 1000001;
bool p[MAX];
using namespace std;

vector<long long int > primeFactor( long long int  n ){
  vector<long long int > v;
  rep(i, sqrt(n)+1){
    if(!p[i])continue; 
    if( n % i != 0 )continue;
    long long int  cnt = 1;
    n /= i;
    while( n % i == 0){
      n /= i;
      cnt++;
    }
    v.push_back(cnt);
  }  
  if( n != 1 ) v.push_back(1);
  return v;
}

long long int  solve(vector<long long int > &pf, long long int  now, vector<long long int > &comb){
  if(now == pf.size()){
    long long int  tmp = 1;
    rep(i, pf.size()){
      if(pf[i] == comb[i]){
	tmp *= pf[i] + 1;
      }
    }
    return tmp;
  }
  long long int  sum = 0;
  rep(i, pf[now] + 1){
    comb.push_back(i);
    sum += solve(pf, now+1, comb);
    comb.pop_back();
  }
  return sum;
}

main(){
  rep(i, MAX)p[i] = true;
  p[0] = p[1] = false;
  rep(i, sqrt(MAX)){
    if(!p[i])continue;
    for(long long int  j = 2; j * i < MAX; j++){
      p[i*j] = false;
    }
  }
 
  long long int  l;
  while( cin >> l ){
    if( l == 0)break;
    vector<long long int > pf = primeFactor(l), comb;
    cout << ( solve(pf, 0, comb) + 1) / 2 << endl;
  }
}

Measured memory_bytes: 1884
# C - Base -2 Number

N = int(input())

ans = ''
if N == 0:
    ans = '0'
while N != 0:
    if N % 2 == 1:
        ans = '1' + ans
        N -= 1
    else:
        ans = '0' + ans
    N //= -2
print(ans)


Measured memory_bytes: 9160
N,M,X = gets.strip.split.map(&:to_i)
book = []
N.times do |k|
  book[k] = gets.strip.split.map(&:to_i)
end
ary = []
#N=12なら全探索でOK？
#bit全探索を起用
#each_with_index(*args)...「値、番号」のセットで返してくれる
[0, 1].repeated_permutation(N) do |x|
  score = Array.new(M,0)
  sum = 0
  x.each_with_index do |bit, i|
    if bit == 1
      sum += book[i][0]
      (0..M-1).each do |l|
        score[l] += book[i][l+1]
      end
    end
  end
  if score.all? {|y| y >= X} then
    ary.unshift(sum)
  end
end
if ary.size == 0 then
  puts "-1"
else
  puts ary.min
end

Measured memory_bytes: 14464
/**
 *    Author: "Robin Singh" !!
 *    rob_in_1
**/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
  bool first = true; 
  string res = "{";
  for (const auto &x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}"; 
  return res;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  dbg_out(T...);
}
#ifdef LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", dbg_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

const long double eps = 1e-9;
const int mod = 1e9+7;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

//===================================================================================================!!

const int nn = 1e5+3;
int n, ans;
string s;
int dp[nn][15];

int expo(int a, int n){
    int r = 1;
    while(n){
        if(n % 2) r = r * a % 13;
        a = a * a % 13;
        n /= 2;
    }
    return r;
}

int fun(int ind, int cur){
    if(ind < 0){
        if(cur % 13 == 5) return 1;
        else return 0;
    }
    if(dp[ind][cur] != -1) return dp[ind][cur];

    if(s[ind] != '?'){
        int x = (s[ind] - '0') * expo(10, ind-n+1) % 13;
        return dp[ind][cur] = fun(ind-1, (cur + x)%13);
    }
    else{
        int here = 0;
        for(int i = 0; i <= 9; i++){
            int x = i * expo(10, ind-n+1) % 13;
            here = (here + fun(ind-1, (cur+x)%13)) % mod;
        }
        return dp[ind][cur] = here;
    }
}

void solve(){
    cin >> s;
    n = sz(s);
    memset(dp, -1, sizeof dp);
    cout << fun(n-1, 0) % mod;
}

int32_t main(){
  #ifdef LOCAL 
    // freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
  #endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 20560
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)

int tot = 100500;
int n,arr[10000][2],w;
int dp[101][100000];

//map<pair<int,int>,int>mp;

int ans(int ind,int weight)
{
    //if(ind==n)
    
    if(weight>w)return -MOD*MOD;
    if(ind>=n+1)return 0; 

   // if(mp.find({ind,weight})!=mp.end())return mp[{ind,weight}];
    if(dp[ind][weight]!=-1)return dp[ind][weight];
    //mp[{ind,weight}]=-MOD*MOD-10000;
     dp[ind][weight]=0;
    
     dp[ind][weight]=max(arr[ind][1]+ans(ind+1,weight+arr[ind][0]),ans(ind+1,weight));

    //return mp[{ind,weight}];
    return dp[ind][weight];


}




signed main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    st(dp,-1);
    cin>>n>>w;

    forn(i,1,n)cin>>arr[i][0]>>arr[i][1];

    cout<<(ans(0,0));

     return 0;

}

//       g++ -g c2.cpp ; ./a.exe

Measured memory_bytes: 79232
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
    vector<bool> vec(1000001,true);
    int n; cin >> n;
    set<int> st;
    for(int i = 0;i < n; i++){
        int a; cin >> a;
        if(st.count(a) == 1) vec[a] = false;
        else st.insert(a);
    }
    
    for(int x:st){
        for(int i =2; x*i < 1000001; i++){
            vec[x*i] = false;
        }
    }
    int ans = 0;
    for(int x:st){
        if(vec[x]) ans++;
    }
    cout << ans << endl;
    return 0;
}
//Saw catupper-san's video

Measured memory_bytes: 12984
N     = int(input())
lst_A = list(map(int, input().split()))

def main(lst_A):
    
    lst_even  = [A for A in lst_A if A % 2 == 0]
    lst_match = [
        even_A for even_A in lst_even
        if even_A % 3 == 0 or even_A % 5 == 0
    ]

    if len(lst_match) == len(lst_even):
        return "APPROVED"
    else:
        return "DENIED"

if __name__ == "__main__":

    answer = main(lst_A)
    print(answer)
    

Measured memory_bytes: 3060
word_number, questions_number = map(int, input().split())
# words = list(input())
words = input()
questions = []
for question in range(questions_number):
    a,b = map(int, input().split())
    questions.append([a-1, b-1])

# 複数回の問題を2秒以内はきついので前処理する必要あり
# for i in range(len(questions)):
#     counter = 0
#     for j in range(questions[i][0], questions[i][1]):
#         # if words[j] == "A" and words[j+1] == "C":
#         if words[j: j+2] == "AC":
#             counter += 1
#     print(counter)

hasAC = [0] * word_number
for i in range(word_number-1):
    if words[i: i+2] == "AC":
        hasAC[i+1] = hasAC[i] + 1
    else:
        hasAC[i+1] = hasAC[i]

for i in range(questions_number):
    print(hasAC[questions[i][1]] - hasAC[questions[i][0]])


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	vector<int> A(n);
	for (int i=0; i<n; i++) cin >> A[i];
	int s = 0;
	for (int i=0; i*2<n; i++) {
		s = s ^ (A[2*i] ^ A[2*i + 1]);
	}
	for (int i=0; i<n; i++) {
		int a = s ^ A[i];
		cout << a << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3988
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1000000000100000000;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n, m; cin >> n >> m;
    vector<ll> A(n), B(m), C(m);
    ll sum = 0;
    rep(i, n){
        cin >> A[i];
        sum += A[i];
    }
    sort(all(A));
    priority_queue<pll> que;
    rep(i, m){
        ll b, c; cin >>  b >> c;
        que.push({c, b});
    }
    int index = 0;
    rep(i, n){
        if(index >= n || que.empty())break;
        auto p = que.top(); que.pop();
        ll c = p.first, b = p.second;
        rep(j, b){
            if(index >= n)break;
            if(A[index] > c){index = INF; break;}
            sum += c - A[index];
            index++;
        }
    }
    cout << sum << ln;
}

Measured memory_bytes: 7640
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]

ans = 0
current = 0
for i in 1..N-1 do
  if lines[1][i-1] >= lines[1][i] then
    current += 1
  else
    current = 0
  end
  if ans < current then
    ans = current
  end
end
print ans

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

int main() {

	int n, m, x, y; cin >> n >> m >> x >> y;
	
	vector<int> X(n), Y(m);
	for (int i = 0; i < n; i++)	cin >> X[i];
	for (int i = 0; i < m; i++)	cin >> Y[i];

	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());

	bool isNoWar = false;
	for (int i = x + 1; i <= y; i++) {
		if (X[n - 1] < i && i <= Y[0]) {
			isNoWar = true;
			break;
		}
	}	

	if (!isNoWar) cout << "War" << endl;
	else cout << "No War" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	if (a >= 13) {
		cout << b << endl;
	}
	else if (6 <= a && a <= 12) {
		cout << b / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}

}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
i = 0
while True:
    if i%2 == 0:
        c -= b
        if c <= 0:
            print('Yes')
            break
    
    else:
        a -= d
        if a <= 0:
            print('No')
            break
    
    i += 1

Measured memory_bytes: 9116
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

int dp[105][100005];

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

    int N, W;
    cin >> N >> W;

    vector<int> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    REP(i, N) {
        FOR(j, 0, W) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + w[i] <= W) {
                dp[i + 1][j + w[i]] = max(dp[i][j + w[i]], dp[i][j] + v[i]);
            }
        }
    }

    int ans = 0;
    FOR(j, 0, W) {
        ans = max(ans, dp[N][j]);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int h, w, k, o = 0;
  cin >> h >> w >> k;
  vector<string> c(h);
  for(int i = 0; i < h; i++) cin >> c[i];
  for(int i = 0; i < (1 << h); i++) {
    for(int j = 0; j < (1 << w); j++) {
      int t = 0;
      for(int m = 0; m < h; m++)
        for(int n = 0; n < w; n++)
          if(c[m][n] == '#' && i & (1 << m) && j & (1 << n)) t++;
      o += t == k;
    }
  }
  printf("%d\n", o);
}

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

int main(){
  long long n,result = 0;
  std::cin>>n;
  for(int i=1; i<=n; ++i){
    if(!((i%15 == 0)||(i%3 == 0)||(i%5 == 0)))
      result += i;
  }
  std::cout<<result<<std::endl;
}


Measured memory_bytes: 3644
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 1
    for i in range(N):
        if ans == -1 and A[i] != 0:
            continue
        ans *= A[i]
        if ans > 10**18:
            ans = -1
    print(ans)

if __name__ == "__main__":
    solve()

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

int main() {
  int N,count,ans;
  cin>>N;
  ans=0;
  vector<int> prime={3,5,7,11,13,17,19,23,29,31};
  for(int i=0;i<N;i++){
    count=0;
    for(int j=0;j<10;j++){
      if((i+1)%(prime.at(j))==0){
        count++;
      }         
    }
    if(count==3)
      ans++;
    if(i==134 || i==188)
      ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
  int i,j,N,M,Q;
  
  scanf("%d %d %d",&N,&M,&Q);
  
  int x[501][501] = {{0}};
  
  for(i=0; i<M;i++) {
    int l,r;
    scanf("%d %d",&l,&r);
    x[l][r]++;
  }

  for(i=1; i<=N; i++) {
    for(j=1; j<=N; j++) {
      x[i][j] = x[i][j] + x[i-1][j] + x[i][j-1] - x[i-1][j-1];
    }
  }
	
  for(i=0; i<Q; i++) {
    int p,q;
    scanf("%d %d",&p,&q);
    printf("%d\n",x[q][q] - x[p-1][q] - x[q][p-1] + x[p-1][p-1]);
  }
    
  return(0);
}
  
  


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAX_N = 1000;
const int MAX_W = 1000;
int W, N;
int v[MAX_N];
int w[MAX_N];
int dp[MAX_W + 1];

void solve() {
	fill(dp, dp + W + 1, 0);
	for (int i = 0; i < N; i++) {
		for (int j = W; j >= 0; j--) {
			if (j - w[i] >= 0) {
				dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
			}
		}
	}
	printf("%d\n", dp[W]);
	for (int i = W; i >= 0; i--) {
		if (dp[W] != dp[i]) {
			printf("%d\n", i + 1);
			break;
		}
	}
}

int main () {
	int i = 0;
	while (scanf("%d", &W), W) {
		i++; printf("Case %d:\n", i);
		scanf("%d", &N);
		for (int i = 0; i < N; i++) {
			scanf("%d,%d", &v[i], &w[i]);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 1040
#include <stdio.h>

long long n;
long long a;
long long eo[110], ez[110];
long long maxx;
long long sum;
long long to = 1;

void ee(long long x)
{
	int ff = 1;
	
	while(x > 0)
	{
		eo[ff] += x % 2;
		eo[ff] %= 1000000007;
		x /= 2;
		ff++;
		ff % 1000000007;
	}
	
	if(ff > maxx)
		maxx = ff;
}

int main(void)
{
	scanf("%lld", &n);
	
	for(int i = 0 ; i < n ; i++)
	{
		scanf("%lld", &a);
		
		ee(a);
	}
	
	maxx--;
	
	for(int i = 1 ; i <= 100 ; i++)
	{
		ez[i] = (n % 1000000007 - eo[i] % 1000000007) % 1000000007;
		ez[i] %= 1000000007;
	}
	
	for(int i = 1 ; i <= 100 ; i++)
	{
		sum += ((ez[i] % 1000000007 * eo[i] % 1000000007) % 1000000007 * to % 1000000007) % 1000000007;
		sum %= 1000000007;
		to *= 2;
		to %= 1000000007;
	}
	
	printf("%lld", sum % 1000000007);
	return 0;
}

Measured memory_bytes: 128
def show (nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else :
            print(nums[i])

def bubble(A):
    flag = True
    i = 0
    n = len(A)
    while(flag):
        flag = False
        for j in range(i+1,n)[::-1]:
            if A[j][1] < A[j-1][1]:
                A[j],A[j-1] = A[j-1],A[j]
                flag = True
        i += 1

def selection(A):
    n = len(A)
    for i in range(0,n):
        minj = i
        for j in range(i,n):
            if A[j][1] < A[minj][1]:
                minj = j
        if i != minj:
            A[i],A[minj] = A[minj],A[i]

n = int(input())
A = list(input().split())
B = A.copy()

bubble(A)
selection(B)

show(A)
print("Stable")
show(B)
if A == B:
    print("Stable")
else:
    print("Not stable")




Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define N 100
#define INF 1e9 + 5
#define LINF 1e18 + 5

using namespace std;
using ll = long long;
string a, b;
ll memo[3003][3003], gp[3003][3003];
ll solve(int y, int x)
{
    if (memo[y][x] != -1)
        return memo[y][x];
    if (x == 0 || y == 0)
        return memo[y][x] = 0;
    ll best = -1;
    ll res = solve(y - 1, x);
    gp[y][x] = 1;
    ll g = solve(y, x - 1);
    if (res < g)
    {
        res = g;
        gp[y][x] = 2;
    }
    if (a[y] == b[x])
    {
        g = solve(y - 1, x - 1) + 1;
        if(res<g){
            res=g;
            gp[y][x]=3;
        }
    }

    return memo[y][x] = res;
}
/*
 abyxb
a10000 
x11122
y11222
b12223

*/
int main()
{
    cin >> a >> b;
    a = "$" + a;
    b = "$" + b;
    memset(memo, -1, sizeof(memo));
    memo[0][0] = 0;
    ll maxlenth = solve(a.length() - 1, b.length() - 1);
    for (int y = 0; y < a.length(); y++)
    {
        for (int x = 0; x < b.length(); x++)
        {
            //cout << memo[y][x];
        }
        //cout << endl;
    }

    int x = b.length() - 1, y = a.length() - 1;
    string t = "";
    while (x > 0 && y > 0)
    {
       if(memo[y][x]!=memo[y-1][x]&&memo[y][x]!=memo[y][x-1]){
           t = a[y]+t;
           x--;y--;
       }else{
           if(memo[y][x]==memo[y-1][x]){
               y--;
           }else{
               x--;
           }
       }
    }
    // cout<<maxlenth<<endl;
    cout << t;
    return 0;
}

Measured memory_bytes: 141568
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;
    vector<int> A(N), B(N,0);
    REP (i, N) {
        cin >> A[i];
        while (A[i] % 2 == 0) {
            B[i]++;
            A[i] /= 2;
        }
    }
    cout << *min_element(B.begin(),B.end()) << endl;

    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc081/abc081_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc081/abc081_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc081/abc081_b && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3608
n = int(input())
p_list = list(map(int, input().split()))

count = 0
for index in range(1, n-1):
    tmp = p_list[index - 1:index + 2]

    max_index = tmp.index(max(tmp))
    min_index = tmp.index(min(tmp))

    if max_index != 1 and min_index != 1:
        count += 1

print(count)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

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

typedef long long lint;
typedef pair<int,int> P;

const long long int mod=1e9+7;



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

	int num = 0;

	if(N<10){
		cout << N << endl;
	}else if(N<100){
		cout << 9 << endl;
	}else if(N<1000){
		cout << 9+N-99 << endl;
	}else if(N<10000){
		cout << 9+900 << endl;
	}else if(N<100000){
		cout << 9+900+N-9999 << endl;
	}else{
		cout << 9+900+90000 << endl;
	}

}


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

#ifdef GCC
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#define all(x) begin(x), end(x)
#define log(x) cout << (x) << "\n"
#define loop(i, begin, end)for(__typeof(end) i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define rep(i, n) loop(i, 0, n)

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;
using vpi = vector<pi>;

int main() {
    int m, n;
    cin >> n >> m;
    vi A(n);
    vpi B_C(m);

    rep (i, n) cin >> A[i];
    rep (i, m) {
        cin >> B_C[i].second >> B_C[i].first;
        B_C[i].first *= -1;
    }

    sort(all(A));
    sort(all(B_C));

    int bci = 0, v = -B_C[bci].first, c = B_C[bci].second;
    for (int i = 0; i < n; ++i) {
        if (!c) {
            if (bci == m-1) break;
            v = -B_C[++bci].first, c = B_C[bci].second;
        }
        if (A[i] >= v) break;
        A[i] = v, c -= 1;
    }

    ll sm = 0;
    rep (i, n) sm += A[i];
    log(sm);
}


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

int
main(void)
{
  int arr[200];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];

  bool is_odd= false;
  int result = 0;

  while(true) {
    for (int i = 0; i < n; i++) {
      if (arr[i] % 2 != 0) is_odd = true;
    }

    if (is_odd) break;

    for (int i = 1; i < n; i++) arr[i] /= 2;
    result++;

  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;
    while(t--)
    {
        int n,m,i,x,y,z;
        cin>>n;
        string s;
        cin>>s;
        if(s.length()<=n)
            cout<<s<<endl;
        else
        {
            cout<<s.substr(0,n)<<"..."<<endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {

	static int n;
	static double[] x1, y1, x2, y2;
	static double sx, sy, gx, gy;
	static ArrayList<Integer>[] g;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		while (q-- > 0) {
			long x0, y0, x1, y1, x2, y2, x3, y3;
			x0 = sc.nextLong();
			y0 = sc.nextLong();
			x1 = sc.nextLong();
			y1 = sc.nextLong();
			x2 = sc.nextLong();
			y2 = sc.nextLong();
			x3 = sc.nextLong();
			y3 = sc.nextLong();
			Point p0 = new Point(x0, y0);
			Point p1 = new Point(x1, y1);
			Point p2 = new Point(x2, y2);
			Point p3 = new Point(x3, y3);
			if (linesIntersect(p0, p1, p2, p3)) {
				System.out.println(1);
			} else {
				System.out.println(0);
			}
		}

	}

	static class Point {
		long x, y;
		int id;

		public Point(long x, long y) {
			this.x = x;
			this.y = y;
		}
	}

	static boolean linesIntersect(Point s1, Point d1, Point s2, Point d2) {
		long prd1 = crossProduct(s1, d1, s1, d2) * crossProduct(s1, d1, s1, s2);
		long prd2 = crossProduct(s2, d2, s2, s1) * crossProduct(s2, d2, s2, d1);
		if (prd1 == 0 && prd2 == 0) {
			if (((s2.x - s1.x) * (s2.x - d1.x) <= 0 && (s2.y - s1.y) * (s2.y - d1.y) <= 0)
					|| ((d2.x - s1.x) * (d2.x - d1.x) <= 0 && (d2.y - s1.y) * (d2.y - d1.y) <= 0)
					|| ((s1.x - s2.x) * (s1.x - d2.x) <= 0 && (s1.y - s2.y) * (s1.y - d2.y) <= 0)
					|| ((d1.x - s2.x) * (d1.x - d2.x) <= 0 && (d1.y - s2.y) * (d1.y - d2.y) <= 0)) {
				return true;
			} else
				return false;
		} else
			return prd1 <= 0 && prd2 <= 0;
	}

	static long crossProduct(Point s1, Point d1, Point s2, Point d2) {
		return (d1.x - s1.x) * (d2.y - s2.y) - (d1.y - s1.y) * (d2.x - s2.x);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 40076
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type* arr = new type[n];
#define forn(i, n) for (int i = 1; i <= n; i++)
#define me0(x) memset(x, 0, sizeof(x))
#define me1(x) memset(x, -1, sizeof(x))
#define all(v) (v.begin(), v.end())
#define tests(x) \
    int x;       \
    cin >> x;    \
    while (x--)
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int INF = 1e18;
const int N = 1e6 + 2;
void run() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("intput.txt", "r", stdin);
    freopen("o2.txt", "w", stdout);
#endif
}

int solve() {
    int n;
    cin >> n;
    int a[n+2], ans = 0;
    forn(i, n) cin >> a[i];
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            for (int k = j + 1; k <= n; k++) {
                if (a[i] + a[j] > a[k]) {
                	if(a[i] != a[j] && a[j]!= a[k])
                	ans++;
                }
            }
        }
    }
    return ans;
}
int32_t main() {
    run();
    // tests(t) {
    cout << solve() << "\n";
    //}
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#define repeat(i,n)     for(int i=0; i<(n); ++i)
#define repeat1(i,n)    for(int i=1; i<=(n); ++i)
#define range(i,l,r)    for(int i=(l); i<(r); ++i)

using namespace std;
typedef long long llint;

int main() {
    char    str[] = "CODEFESTIVAL2016";
    char    in[50];
    int ans = 0;

    scanf("%s", in);
    repeat(i, strlen(str)) {
        if(in[i] != str[i]) ++ans;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn dru(n: u64, m: u64) -> u64 {
    if n % m == 0 {
        return n / m;
    } 
    n / m + 1
}

fn main() {
    let n: u64 = input();
    let mut min_vol = std::u64::MAX;
    for _ in 0..5 {
        let vol: u64 = input();
        min_vol = min(min_vol, vol);
    }
    println!("{}", dru(n, min_vol)+ 4);
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<math.h>
#include<queue>
#include<stack>
#include<ctime>
#include<set>
using namespace std ;

#define MAXN 200007

int n , q ;
vector < int > v[ MAXN ] ;

int aux[ MAXN ] ;
int ans[ MAXN ] ;

int tot = 0 ;

void dfs ( int vertex , int prv ) {
    tot += aux[ vertex ] ;
    ans[ vertex ] = tot ;
    int sz = v[ vertex ].size ( ) ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        if ( v[ vertex ][ i ] == prv ) { continue ; }
        dfs ( v[ vertex ][ i ] , vertex ) ;
    }
    tot -= aux[ vertex ] ;
}

void input ( ) {
    scanf ( "%d%d" , &n , &q ) ;
    for ( int i = 1 ; i < n ; ++ i ) {
        int x , y ;
        scanf ( "%d%d" , &x , &y ) ;
        v[ x ].push_back ( y ) , v[ y ].push_back ( x ) ;
    }
    for ( int i = 1 ; i <= q ; ++ i ) {
        int x , y ;
        scanf ( "%d%d" , &x , &y ) ;
        aux[ x ] += y ;
    }
}


void solve ( ) {
    dfs ( 1 , -1 ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        printf ( "%d " , ans[ i ] ) ;
    }
    printf ( "\n" ) ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 27136
quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = parse.(Int, split(readline()))

function main()
  N = in_1()
  A = in_a()
  @assert length(A) == N-1
  buka = zeros(Int, N)
  for joshi in A
    buka[joshi] += 1
  end
  for b in buka
    println(b)
  end
end

main()


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

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

  int miss = 0;
  for ( int i = 1; i <= n; i++ ) {
    int p;
    cin >> p;
    if ( p != i ) { miss++; }
  }

  string ans = ( miss <= 2 ) ? "YES" : "NO";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
while True:
	n,m = map(int, input().split())
	if n == 0 and m == 0:
		break
	cnt = 0
	
	for i in range(1, n+1):
		for j in range(i+1, n+1):
			for k in range(j+1, n+1):
				if i + j + k == m:
					cnt += 1
	print(cnt)

Measured memory_bytes: 7640
#include<stdio.h>
int main(void){
int N ; 
long long int sum=0, count=0;
scanf("%d",&N);
for(int i=1;i<=N;i++){
    if((i%3==0) || (i%5==0) || (i%15==0)) count+=i;
    sum+=i;
}
printf("%lld\n",sum-count);
return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <deque>
#include <vector>

int main() {
    int N, M;
    std::cin >> N >> M;
    std::vector<bool> vps(N, false);
    std::vector<bool> vls(M, false);
    std::vector<std::vector<int> > alp(N);
    std::vector<std::vector<int> > all(M);
    for (int i = 0; i < N; ++i) {
        int K;
        std::cin >> K;
        for (int x = 0; x < K; ++x) {
            int L;
            std::cin >> L;
            alp[i].push_back(L-1);
            all[L-1].push_back(i);
        }
    }

    std::deque<int> people;
    std::deque<int> langs;
    people.push_back(0);
    while (!people.empty() || !langs.empty()) {
        while (!people.empty()) {
            int p = people.front();
            people.pop_front();
            if (vps[p])
                continue;
            vps[p] = true;
            for (int i = 0; i < alp[p].size(); ++i)
                langs.push_back(alp[p][i]);
        }
        while (!langs.empty()) {
            int lan = langs.front();
            langs.pop_front();
            if (vls[lan])
                continue;
            vls[lan] = true;
            for (int i = 0; i < all[lan].size(); ++i)
                people.push_back(all[lan][i]);
        }
    }

    int ret = 1;
    for (int i = 0; i < N; ++i)
        ret = ret && vps[i];

    std::cout << (ret ? "YES\n" : "NO\n");

    return 0;
}


Measured memory_bytes: 8952
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

//BIT
struct BIT{
	int N;
	int data[300010];
	void init(int n){
		N = n;
	}
void add(int a,int w){
	for(int x = a;x <= N;x += x & -x) data[x] +=w;
}
//bit[1] + ... + bit[a]
int sum(int a){
	int ret = 0;
	for(int x = a; x > 0; x -= x & -x) ret+= data[x];
	return ret;
}
};

/*BIT 0~n-1ver
void add(int a,int w){
	for(int x = a;x < N; x |= x + 1) bit[x] += w;
	}
}

int sum(int a){
	int ret = 0;
	for(int x = a-1;x >= 0; x = (x & (x+1)) - 1)ret += bit[x];
	return ret;
	}*/

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	vector<vector<int> > souvenir(m+1,vector<int>());
	REP(i,n){
		int l,r;
		cin >> l >> r;
		souvenir[r-l+1].push_back(l);
	}
	BIT bittree;bittree.init(m+1);
	int absolutepass = n;
	for(int d = 1;d <=m;d++){
		for(auto a : souvenir[d-1]){
			bittree.add(a,1);bittree.add(a+d-1,-1);
			absolutepass--;
		}
		int ans = absolutepass;
		for(int dd = d;dd <= m;dd+=d){
			ans += bittree.sum(dd);
		}
		cout << ans << endl;
	}
  return 0;
}


Measured memory_bytes: 6784
n = int(input())
maxn = 55555
is_prime = [True if i%2 == 1 else False for i in range(0, maxn+1) ]
is_prime[0] = False
is_prime[1] = False
is_prime[2] = True # 2は素数
for i in range(3, int(maxn**0.5) + 1, 2):
    if not is_prime[i]:
        continue
    for j in range(i*2, maxn+1, i):
        is_prime[j] = False

ps = [i for i in range(maxn+1) if is_prime[i]]

a = [] 
i = 2
while True:
    if ps[i] % 5 == 1:
        a.append(ps[i])
    if len(a) == n:
        break
    i += 1

print(' '.join(map(str, a)))


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
int n, m, q, t1, t2, mxr, mxc = 0, ans = 0;
vector<int> rv[300005], cv[300005];
bool goated[300005];

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

	cin >> n >> m >> q;
	while(q--){
		cin >> t1 >> t2;
		rv[t1].pb(t2);
		cv[t2].pb(t1);
	}

	mxr = 0;
	FOR(i, n)
		mxr = max(mxr, (int)rv[i].size());
	
	FOR(i, n){
		if((int)rv[i].size() == mxr) {
			goated[i] = 1;
			mxc++;
		}
	}

	FOR(i, m){
		int curc = 0;
		for(auto u : cv[i]){
			if(goated[u])
				curc++;
		}

		if(curc == mxc)
			ans = max(ans, (int)cv[i].size() + mxr - 1);
		else
			ans = max(ans, (int)cv[i].size() + mxr);
	}

	cout << ans << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 36656
#include <stdio.h>

int main(void)
{
  int x, y, z;
  int n;
  int s;
  scanf("%d %d %d", &x, &y, &z);
  n = 0;
  s = z * 2 + y;
  while ( x >= s ) { n++; s += (y+z); }
  printf("%d\n", n);
  return 0;
}

Measured memory_bytes: 128
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int p[101];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(p, 0, sizeof(p));
    p[0] = 1;
    for (int i = 1; i < 101; i++) {
        if (i >= 4 && p[i-4])
            p[i] = 1;
        if (i >= 7 && p[i-7])
            p[i] = 1;
    }

    printf(p[gi()] ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
s=[list(map(int,list(input().split()))) for i in range(m)]
p = list(map(int,input().split()))

ans = 0
for i in range(2 ** n):
    #1の時は点灯
    switch = [0] * n
    for j in range(n):
        if((i >> j) & 1):
            switch[j] = 1
    for k in range(m):
        cnt = 0
        for l in range(1,s[k][0] + 1):
            if(switch[s[k][l] - 1] == 1):
                cnt += 1
        if(cnt % 2 != p[k]):
            break
        if(k == m - 1):
            ans += 1    

print(ans)

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


int main() {
  int n ;
  cin >> n ;
  
  int a=n/3600;
  int b=(n%3600)/60;
  int c=(n%3600)%60;
  
  cout << a << ":" << b << ":" << c << endl;
  
}


Measured memory_bytes: 3120