akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

N = int(input())
graph = [[] for _ in range(N)]
Ed = {}
for i in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    Ed[(a-1)*N+b-1] = i
    Ed[(b-1)*N+a-1] = i

q = [0]
checked = [False]*N
checked[0] = True

V_color = [None]*N
V_color[0] = 0

ans = [None]*(N-1)
while q:
    qq = []
    for p in q:
        c = V_color[p]
        t = 1
        for np in graph[p]:
            if not checked[np]:
                checked[np] = True
                qq.append(np)
                ind = Ed[p*N+np]
                if t == c:
                    t += 1
                ans[ind] = t
                V_color[np] = t
                t += 1
    q = qq

print(max(ans))
for a in ans:
    print(a)

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

int main(){
  int N , K ; 
  cin >> N >> K ; 
  vector<int> h(N) ; 
  vector<int> dp(N) ; 
  
  for(int i = 0 ; i < N ; i++) cin >> h.at(i) ; 
  
  for(int i = 1 ; i < N ; i++){
    dp.at(i) = dp.at(i-1) + abs(h.at(i) - h.at(i-1)) ;
    //cout << dp.at(i) << endl ; 
    for(int j = i-1 ; j >= 0  && (i - j) <= K ; j--){
        dp.at(i) = min(dp.at(i) , dp.at(j)+abs( h.at(j) - h.at(i) )) ; 
        //cout << dp.at(i) << endl ; 
      
    }

  }
      cout << dp.at(N-1) << endl ; 
}

Measured memory_bytes: 4048
#include <iostream>
#include <vector>
using namespace std;
int main()
{
     vector<int> nums = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 
     int k;
     cin >> k;
     for(int i = 0; i < nums.size(); i++) {
     	if(k == i + 1) {
     		cout << nums[i] << "\n";
     		return 0;
     	}
     }
     
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

void solve(){
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if(w >= v){
		cout << "NO" << endl;
		return;
	}
	
	ll d = ceil(1.0 * abs(b - a) / (v - w));
	if(d <= t)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

int main(){
	solve();
	return 0;
}


Measured memory_bytes: 3740
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			double xa1=in.nextDouble(),ya1=in.nextDouble(),xa2=in.nextDouble(),ya2=in.nextDouble();
			double xb1=in.nextDouble(),yb1=in.nextDouble(),xb2=in.nextDouble(),yb2=in.nextDouble();

			if(xa1<=xb2&&xb1<=xa2&&ya1<=yb2&&yb1<=ya2)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}

	static public void debug(Object... o)
	{
		System.err.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 20776
# coding: utf-8

button_count = int(input().rstrip())

buttons = [int(input().rstrip()) - 1 for i in range(button_count)]

current = 0
flag = [False for i in range(button_count)]
ans = 0
for i in range(button_count):
    if flag[current]:
        ans = -1
        break
    if current == 1:
        break
    flag[current] = True
    current = buttons[current]
    ans += 1

print(ans)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	string s;
	cin >> s;
	vector<int> cr(N+1, 0), cw(N+1, 0);
	REP(i, N) {
	  if (s[i] == 'R') cr[i+1]++;
	  else cw[i+1]++;
	  cr[i+1] += cr[i];
	  cw[i+1] += cw[i];
	}
	int64 res = INF_LL;
	REP(i, N+1) {
	  int64 rc = cr[N] - cr[i], wc = cw[i];
	  int64 now = rc + wc - min(rc, wc);
	  chmin(res, now);
	}
	cout << res << endl;
}


Measured memory_bytes: 5188
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a, b, t;
    cin >> a >> b >> t;
    cout << b * (t / a) << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    string ans;
    rep(i, N) {
        ans += S[i];
        ans += T[i];
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >>k;
  int res;
  
  while(a>=b && k>0){
    b*=2;
    k--;
  }
  while(b>=c && k>0){
    c*=2;
    k--;
  }
  if(a < b && b < c){cout << "Yes";}
  else{cout << "No";}
}

Measured memory_bytes: 3628
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""


def main():
    N, M = map(int, input().split())
    xy = []
    for _ in range(M):
        xy.append(list(map(int, input().split())))
    prob = [False] * N
    prob[0] = True
    ball = [1] * N
    for x, y in xy:
        ball[x-1] = ball[x-1] - 1
        ball[y-1] = ball[y-1] + 1
        if ball[x-1] < 1 and prob[x-1]:
            prob[x-1] = False
            prob[y-1] = True
        elif ball[x-1] >= 1 and prob[x-1]:
            prob[y-1] = True
    print(prob.count(True))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63064
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

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

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
char s[200005];
int main(){
  scanf("%s",s);
  int n=strlen(s);
  int T=0,S=0;
  REP(i,n){
    if(s[i]=='T'){
      if(S>0) --S;
      else ++T;
    }else ++S;
  }
  cout<<S+T<<endl;
  return 0;
}




Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        int c[] = new int[n-1];
        Arrays.setAll(a, i -> stdIn.nextInt());
        Arrays.setAll(b, i -> stdIn.nextInt());
        Arrays.setAll(c, i -> stdIn.nextInt());
        int ans = b[a[0]-1];
        for(int i = 1 ; i < n; i++ )
            ans += b[a[i]-1] +(a[i] - a[i-1] == 1 ? c[a[i-1]-1] : 0);
        System.out.println(ans);
    }
}

Measured memory_bytes: 27092
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define INT long long 
#define MOD 1000000007
using namespace std;

INT n, a[300030], ans;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < 3*n ; i++ ) cin>>a[i];
    sort(a, a+3*n);
    for(INT i = n ; i < 3*n ; i+=2 ) ans += a[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
//Special Trains

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    vector<double>c(n),s(n),f(n);
    rep(i,0,n-1)cin>>c[i]>>s[i]>>f[i];
    rep(i,0,n){
        double t=0;
        rep(j,i,n-1){
            if(t<s[j])t=s[j]+c[j];
            else t=f[j]*ceil(t/f[j])+c[j];
        }
        cout<<(int)t<<nnn;
    }
    return 0;
}

Measured memory_bytes: 3760
int main(){
    int ss, gs, fwt, fb, wt, t = 0;
    
    scanf("%d%d%d%d%d", &ss, &gs, &fwt, &fb, &wt);
    
    for(ss; ss < 0; ss++)
    t = t + fwt;
    
    if(t != 0)
    t = t + fb;
    
    for(ss; ss < gs; ss++)
    t = t + wt;
    
    printf("%d\n", t);
    
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans;
  if (a==b && b==c) ans = 1;
  else if (a==b || b==c || c==a) ans = 2;
  else ans = 3;
  cout << ans << endl;
}

Measured memory_bytes: 256
import heapq
N,M=map(int,input().split())
a=[0 for i in range(M)]
c=[0 for i in range(M)]
for i in range(M):
    a[i],b=map(int,input().split())
    tmp=[int(i)-1 for i in input().split()]
    for j in tmp:
        c[i]+=2**j
edge=sorted([(a[i],c[i]) for i in range(M)])
q=[]
heapq.heappush(q,(0,0))
dist=[10**15 for i in range(2**N)]
dist[0]=0
while(len(q)!=0):
    prc,src=heapq.heappop(q)
    if dist[src]<prc:
        continue
    for e in edge:
        cost,nxt=e
        dest=nxt|src
        if dest==src:
            continue
        if dist[dest]>dist[src]+cost:
            dist[dest]=dist[src]+cost
            heapq.heappush(q,(dist[dest],dest))
ans=dist[-1]
if ans==10**15:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 4164
sToHms s = show(s `div` 3600) ++ ":" ++ show(s `mod` 3600 `div` 60) ++ ":" ++ show(s `mod` 3600 `mod` 60)

main = do
	second <- getLine
	let second_int = read second :: Int
	putStrLn $ sToHms second_int

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

using namespace std;

int main(){

  


  int n, at;
  vector<int> a;

  cin >> n;
  for(int i =0; i< n;i++)
  {
    cin >> at;
    a.push_back(at);
  }

  sort(a.begin(),a.end(), greater<int>());

  int al=0, bo=0;
  for (int j=0;j<n;j++)
  {
    if((j % 2 )==0)
    {
      al+=a[j];
    }else{
      bo+=a[j];
    }
  }
  cout << al-bo<<endl;
       
      
  // cout << x <<endl;
  // cout << a <<endl;
  // cout << b <<endl;
  


  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[3010],t[3010];
int n,m,f[3010][3010];
void print(int i,int j)
{
	if (!i || !j)
	{
		return;
	}
	else if (f[i-1][j]==f[i][j])
	{
		print(i-1,j);
	}
	else if (f[i][j-1]==f[i][j])
	{
		print(i,j-1);
	}
	else
	{
		print(i-1,j-1);
		putchar(s[i]);
	}
}
int main()
{
	scanf("%s",s+1);
	scanf("%s",t+1);
	n=strlen(s+1);
	m=strlen(t+1);
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			f[i][j]=max(f[i-1][j],f[i][j-1]);
			if (s[i]==t[j])
			{
				f[i][j]=max(f[i][j],f[i-1][j-1]+1);
			}
		}
	}
	/*
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			cerr<<f[i][j]<<" ";
		}
		cerr<<endl;
	}
	*/
	if (!f[n][m])
	{
		puts("");
		return 0;
	}
	print(n,m);
	return 0;
}


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

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

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N, M; cin >> N >> M;
    vector<ll> H;
    vector<ll> v(N,0);
    REP(i, N) {
        ll tmp; cin >> tmp;
        H.push_back(tmp);
    }
    ll res = 0;
    REP(i, M) {
        ll l, r; cin >> l >> r;
        v[l-1] = max(v[l-1],H[r-1]);
        v[r-1] = max(v[r-1],H[l-1]);
    }
    REP(i, N) {
        if (v[i] < H[i]) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5068
#include<bits/stdc++.h>
using namespace std;
int x,y,z,h,g;
int main()
{
    cin>>x>>y>>z;
    h=x-z;
    while(h-z>0)
    {
        if(h-y-z<0)break;
        else h=h-y-z;
        g++;
    }
    cout<<g<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

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

using namespace std;

typedef long long ll;

int main()
{
  int n;
  int res = 0;
  int have_even = 0;
  cin >> n;
  vector<ll> a = vector<ll>(n);
  REP(i, n)
  {
    cin >> a[i];
    if (a[i] % 2 == 0)
    {
      have_even++;
    }
  }

  if (have_even != 0)
  {
    REP(i, n)
    {
      while (true)
      {
        if (a[i] % 2 == 0 && a[i] != 0)
        {
          a[i] = a[i] / 2;
          res++;
        }
        else
        {
          break;
        }
      }
    }
    cout << res << endl;
  }
  else
  {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 384
import sys

def solve(n, k, as1):
    if (n-1)%(k-1)==0:
        return (n-1)//(k-1)
    else:
        return (n-1)//(k-1)+1

def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_n, str_k] = line.split(' ')
    line = sys.stdin.readline().rstrip()
    as1 = line.split(' ')
    return (int(str_n), int(str_k), [int(a) for a in as1])

def main():
    n, k, as1 = readQuestion()
    answer = solve(n, k, as1)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 14900
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long gcd(long long a, long long b){if(b==0)return a;return gcd(b,a%b);}

vector<vector<char>> HW;
vector<vector<int>> HWW;
int H, W; 

int recv(int h, int w, int count, bool b) {
    if (HW[h-1][w-1] == '#' && !b) ++count;
    if (h == H && w == W) return count;

    if (HWW[h-1][w-1] <= count) return 1000000;
    HWW[h-1][w-1] = count;
    int res = 1000000;
    if (h < H) res = min(res, recv(h+1, w, count, HW[h-1][w-1] == '#'));
    if (w < W) res = min(res, recv(h, w+1, count, HW[h-1][w-1] == '#'));

    return res;
}

int main() {
    cin >> H >> W;
    repp(i,0,H) {
        vector<char> v(W);
        repp(j,0,W) cin >> v[j];
        HW.push_back(v);
    }
    repp(i,0,H) {
        vector<int> v(W);
        repp(j,0,W) v[j] = 1000000;
        HWW.push_back(v);
    }
    bool b = HW[0][0] == '#';
    int initial_count = 0;
    if (b) ++initial_count;
    int count = min(recv(1+1,1,initial_count,b), recv(1,1+1,initial_count,b));
    cout << count << endl;
}



Measured memory_bytes: 256
n=gets.to_i
dp=Array.new(n+1){[]}
dp[0]=[0,0,0]
n.times do |i|
  h=gets.split.map &:to_i
  dp[i+1][0]=h[0]+[dp[i][1],dp[i][2]].max
  dp[i+1][1]=h[1]+[dp[i][0],dp[i][2]].max
  dp[i+1][2]=h[2]+[dp[i][0],dp[i][1]].max
end
p dp[n].max

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

int stoi(const char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return -1;
  }
}

int main() {
  ll m,d,ans=0;
  cin >> m >> d;
  for (int i = 1; i < d+1; i++)
  {
    if (i / 10 >= 2 && i % 10 >= 2 && (i / 10) * (i % 10) <= m) ans++;
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int N, A, res;
unordered_map<int, int>mp;


int main() {
	int N;
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> A;
		++mp[A];
	}
	for (int i = 1 << 30; i; i /= 2) {
		for (auto it = mp.begin(); it != mp.end(); ++it) {
			if (it->first * 2 == i) {
				res += it->second / 2;
				it->second %= 2;
			}
			else if (mp.find(i - it->first) != mp.end()) {
				int t = min(it->second, mp[i - it->first]);
				res += t;
				it->second -= t;
				mp[i - it->first] -= t;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 8520
import sys
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

readline = sys.stdin.readline

N, M = map(int, readline().split())

a = []
b = []
for i in range(M + 1, M + N + 1):
    K, *L = map(int, readline().split())
    l = len(L)
    a.extend([i] * l)
    b.extend(L)

m = csr_matrix(([1] * len(a), (a, b)), shape=(N + M + 1, N + M + 1))
n, label = connected_components(m, directed=False)
if all(label[1 + M:] == label[1 + M]):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 27144
N,M=parse.(split(readline()))
C=zeros(Int,10^5)
for a=map(x->parse(Int,x),split(readline()))
	C[a]+=1
end
C=conv(C,C)
k=2*10^5
ans=0
for c=reverse(C)
	t=min(M,c)
	ans+=t*k
	k-=1
	M-=t
end
println(ans)


Measured memory_bytes: 185376
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,f;
  cin>>a;
  b=a/1000;
  c=(a/100)%10;  
  d=(a/10)%10;   
  e=a%10;       
  f=7-b;
  if(c+d+e==f) cout<<b<<"+"<<c<<"+"<<d<<"+"<<e<<"=7"<<endl;
  else if(c-d+e==f) cout<<b<<"+"<<c<<"-"<<d<<"+"<<e<<"=7"<<endl;
  else if(c+d-e==f) cout<<b<<"+"<<c<<"+"<<d<<"-"<<e<<"=7"<<endl;
  else if(c-d-e==f) cout<<b<<"+"<<c<<"-"<<d<<"-"<<e<<"=7"<<endl;
  else if(-c+d+e==f) cout<<b<<"-"<<c<<"+"<<d<<"+"<<e<<"=7"<<endl;
  else if(-c-d+e==f) cout<<b<<"-"<<c<<"-"<<d<<"+"<<e<<"=7"<<endl;
  else if(-c+d-e==f) cout<<b<<"-"<<c<<"+"<<d<<"-"<<e<<"=7"<<endl;
  else  cout<<b<<"-"<<c<<"-"<<d<<"-"<<e<<"=7"<<endl;
  

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
    int a, b, i, ttl;
    int tmp, remaind, reverse;
    ttl = 0;
    scanf("%d %d", &a, &b);

    for(i = a; i <= b;i++){
        tmp = i;
        reverse = 0;
        while(tmp != 0) {
          remaind = tmp % 10;
          reverse = reverse * 10 + remaind;
          tmp /= 10;
        }
        if(reverse == i) ttl++;
    }
    printf("%d\n", ttl);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    ll n;
    cin>>n;
    vector<ll> v(3*n);
    for(ll i=0;i<3*n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    ll ans=0;
    for(ll i=n;i<3*n;i+=2) ans+=v[i];
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		long n = fs.nextLong();

		long x[] = new long[3], y[] = new long[3];
		
		x[1] = (long)1e9; x[2] = 1;
		y[2] = (n + (long)1e9 -1)/(long)1e9; y[1] = y[2]*(long)1e9 - n;
  		
		for(int i=0;i<3;i++) {
			System.out.print(x[i] + " " + y[i] + " ");
		}
		
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21204
using System;
using System.Collections.Generic;
//using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		// 入力フェーズ
        string[] input = Console.ReadLine().Split(' ');
				int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);

string ret = "NO";
        if(N%2 == 0)
        {
          // even N/2 <= K -> ok
          if( N/2 >= K) ret = "YES";
        }else{
          // odd N/2 + 1 <= K -> ok
          if(N/2 + 1 >= K) ret = "YES";
        }
    // 出力
        Console.WriteLine(ret);
    }
		class myClass{ //自作クラス
			public int ID {set; get;}
			public long Point {set; get;}
		}

		static private long myMethod(int args)
		{
			// 自作メソッド
			long ret = 0;

			return ret;
		}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;

int main() 
{
	int x,n;
	cin>>x>>n;
	vector<int> p(n);
	int ans=x;
	if(n!=0)
	{
		for(int i=0;i<n;i++)
		{
			cin>>p[i];
		}
		//直前の最小値
		int pre=300;
		for(int i=101;i>=-1;i--)
		{
			bool ch=true;
			for(int j=n-1;j>=0;j--)
			{
				if(i==p[j])
				{
					ch=false;
				}
			}
			if(ch&&pre>=abs(i-x))
			{
				ans=i;
				pre=abs(i-x);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3628
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:usize,
    }
    println!("{}",(b-1)*(a-1))
}

Measured memory_bytes: 2136
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct data {
	int a;
	int b;
} data;

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int fnc() {

	char s1[128], s2[128];
	getstr(s1);

	s2[0] = s1[2];
	s2[1] = s1[3];
	s2[2] = 0;
	s1[2] = 0;

	int i1, i2;
	sscanf(s1, "%d", &i1);
	sscanf(s2, "%d", &i2);
	if (1 <= i1 && i1 <= 12) {
		if (1 <= i2 && i2 <= 12) {
			out("AMBIGUOUS\n");
		}
		else {
			out("MMYY\n");
		}
	}
	else {
		if (1 <= i2 && i2 <= 12) {
			out("YYMM\n");
		}
		else {
			out("NA\n");
		}
	}

	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		// 年齢
		int A = sc.nextInt();

		// 通常の値段
		int B = sc.nextInt();

		// 年齢が0～5歳の場合0円
		if (0 <= A && A <= 5) {
			System.out.print(0);
			// 6～12歳の場合半額
		} else if (6 <= A && A <= 12) {
			System.out.print(B / 2);
			// 13歳以上は通常
		} else if (13 <= A) {
			System.out.print(B);
		}
	}
}

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

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define F first
#define S second 
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

// --------------------------template ends here------------------------------

void solve() {
    float l;
    cin >> l;
    float x = l/3;
    double ans = x*x*x;
    std::cout << std::fixed;
    std::cout << std::setprecision(6);
    std::cout << ans;
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

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

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    ll lcm=c/__gcd(c,d)*d;
    ll ans=b-b/c-b/d+b/lcm-a+a/c+a/d-a/lcm;
    cout<<ans<<endl;
    return 0;
}


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

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll g = min(min(min(a, b), c), min(d, e));
    cout << 4 + (n + g - 1) / g << endl;
}


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


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

    rep(i,1100) {
        int pa = floor(i*0.08);
        int pb = floor(i*0.10);

        if(pa==a && pb==b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 1000010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>a(n);
	vector<VE>x(n), y(n);
	rep(i, n) {
		cin >> a[i];
		x[i].resize(a[i]);
		y[i].resize(a[i]);
		rep(j, a[i]) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	int ans = 0;
	rep(bit, 1 << n) {
		vector<int>istrue(n);
		int cnt = 0;
		bool ok = true;
		rep(i, n) {
			if (bit&(1 << i)) {
				istrue[i] = true;
				cnt++;
			}
		}
		rep(i, n) {
			rep(j, a[i]) {
				if (istrue[i]) {
					if (istrue[x[i][j]] != y[i][j]) {
						ok = false;
					}
				}
				else {
					
				}
			}
		}
		if (ok)chmax(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n;
  int a[200000];
  
  cin >> n;
  
  int max = 0;
  int max2 = 0;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > max) {
      max = a[i];
    } else if (a[i] > max2) {
      max2 = a[i];
    }
  }

  for (int i = 0; i < n; i++){
    if (a[i] != max){
      cout << max << endl;
    } else {
      cout << max2 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2432
from collections import deque
from copy import deepcopy

n,*a = map(int,open(0).read().split())
acopy = deepcopy(a)
a.sort()
acopy.sort(reverse = True)

L = deque([])
a = deque(a)
acopy = deque(acopy)
Lcopy = deepcopy(L)

max_ = a.pop()
L.append(max_)
min_ = acopy.pop()
Lcopy.append(min_)

while a:
    if a:
        b = a.popleft()
        L.append(b)
    if a:
        c = a.popleft()
        L.appendleft(c)
    if a:
        d = a.pop()
        L.append(d)
    if a:
        e = a.pop()
        L.appendleft(e)

while acopy:
    if acopy:
        b = acopy.popleft()
        Lcopy.append(b)
    if acopy:
        c = acopy.popleft()
        Lcopy.appendleft(c)
    if acopy:
        d = acopy.pop()
        Lcopy.append(d)
    if acopy:
        e = acopy.pop()
        Lcopy.appendleft(e)
ans1,ans2 = 0,0
#print(L,Lcopy)
for i in range(len(L)-1):
    ans1 +=abs(L[i+1] - L[i])
for i in range(len(Lcopy)-1):
    ans2 +=abs(Lcopy[i+1] - Lcopy[i])
print(max(ans1,ans2))

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

int N, A, ans = 0;
vector<int> v;
vector<int> c;

int main(){
    cin >> N;
    v.resize(N);
    c.resize(N);
    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++){
	if(v[i] > c[i]){
	    ans += v[i] -c[i];
	}	    
    }
    
    cout << ans << "\n";
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 0;i<n;i++){
			list.add(Math.abs(sc.nextInt() - x));
		}
		if(list.size() == 1){
			System.out.println(list.get(0));
			System.exit(0);
		}
		int g = sub(list.get(0),list.get(1));
		for(int i = 1;i<n-1;i++){
			g = sub(g,list.get(i+1));
		}
		System.out.println(g);
	}
	static int sub(int a, int b){
		 if (a < b) {
		        int tmp = a;
		        a = b;
		        b = tmp;
		    }

		    //ユークリッドの互除法
		    int r = -1;
		    while (r != 0) {
		        r = a % b;
		        a = b;
		        b = r;
		    }

		    return a; 
	}
}


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

//define ll long long;
//define ar array;

long long arr[150000];

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

    for (int i = 1; i <= 10000; i++){
        for (int j = 1; j <= 10000; j++){
            if (i*j > 10000){
                break;
            }
            for (int k = 1; k <= 10000; k++){
                long long val = (i*i) + (j*j) + (k*k) + (i*j) + (j*k) + (k*i);
                if (val > 10000){
                    break;
                }
                else {
                    arr[val]++;

                }
            }
        }
    }

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++){
        cout << arr[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;

ll N, C;
ll d[31][31] = {};
ll c[501][501] = {};
ll e[30][3] = {};
int main()
{
	cin >> N >> C;
	repe(i, 1, C)repe(j, 1, C)cin >> d[i][j];
	repe(i, 1, N)repe(j, 1, N)cin >> c[i][j];

	repe(k, 1, C) {
		repe(i, 1, N)repe(j, 1, N) {
			e[k][(i + j) % 3] += d[c[i][j]][k];
		}
	}

	ll ans = 1 << 30;
	repe(i, 1, C) {
		repe(j, 1, C) {
			if (i != j) {
				repe(k, 1, C) {
					if (i != k && j != k) {
						ans = min(ans, e[i][0] + e[j][1] + e[k][2]);
					}
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll X;
    cin >> X;
    if(X == 3 || X == 5 || X == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

kyori = abs(A-B)
if A == B:
    print("YES")
    exit()
if V > W:
    if kyori/(V-W) > T:
        print("NO")
    else:
        print("YES")
else:
    print("NO")

Measured memory_bytes: 61664
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        xy: [(f64, f64); 3],
    }
    let a = ((xy[0].0 - xy[1].0).powf(2f64) + (xy[0].1 - xy[1].1).powf(2f64)).sqrt();
    let b = ((xy[1].0 - xy[2].0).powf(2f64) + (xy[1].1 - xy[2].1).powf(2f64)).sqrt();
    let c = ((xy[2].0 - xy[0].0).powf(2f64) + (xy[2].1 - xy[0].1).powf(2f64)).sqrt();

    let M = if a > b && a > c {
        a
    } else if b > a && b > c {
        b
    } else {
        c
    };

    let s = (a + b + c) / 2.;
    let S = (s * (s - a) * (s - b) * (s - c)).sqrt();

    let r = (2. * S) / (a + b + c);

    println!("{:.*}", 12, r * M / (2. * r + M));
}


Measured memory_bytes: 4352
S = input()

t = 'YAKI'
tmp = 0
for i in range(len(S)):
    if S[i] == t[i]:
        flag = True
        tmp += 1
    else:
        flag = False
        break
        
    if tmp == 4:
        break
  
if tmp == 4 and flag == True:
    print('Yes')
    
else:
    print('No')

Measured memory_bytes: 3060
while 1:
    m,n = map(int, raw_input().split())
    if m==n==0: break
    if m<n: m,n = n,m
    r = 1; c = 0;
    while 1:
        c += 1; r = m%n;
        if r==0: break
        n,m = r,n;
    print n, c

Measured memory_bytes: 4204
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,k,a[100010],b[100010];
ll ret,tmp;
vi tgt;

int main(){
    I(n); I(k);
    tgt.pb(k);
    REP(i,30){
        int kouho = (k >> i) << i;
        kouho += ((1 >> i) - 1);
        if (kouho > 0 && kouho <= k) tgt.pb(kouho);
    }
    REP(i,n) { I(a[i]); I(b[i]); }
    for (auto mask : tgt){
        tmp = 0;
        REP(i,n) if ((mask | a[i]) == mask) tmp += b[i];
        ret = max(ret,tmp);
    }
    cout << ret << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 998244353
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 300003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
long long fak[mx],inv[mx];
long long C(int n,int k){
	if(k>n)return 0;
	long long ret=(fak[n]*inv[k])%MOD;
	ret=(ret*inv[n-k])%MOD;
	return ret;
}

long long n,a,b,k,jaw;
long long pow_(long long a,int b){
	if(b==0)return 1;
	long long sem=pow_(a,b/2);
	sem=(sem*sem)%MOD;
	if(b&1)sem=(sem*a)%MOD;
	return sem;
}

int main(){
	fak[0]=inv[0]=1;
	for(int i=1;i<=3e5;i++){
		fak[i]=(fak[i-1]*i)%MOD;
		inv[i]=pow_(fak[i],MOD-2);
	}
	cin>>n>>a>>b>>k;
	for(long long x=0;x<=n;x++){
		long long y;
		long long sem=k-a*x;
		if(sem%b)
			continue;
		y=sem/b;
		if(y>n || y<0)
			continue;
		long long tmp=(C(n,x)*C(n,y))%MOD;
		jaw=(jaw+tmp)%MOD;
	}
	cout<<jaw;
}




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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int a, b;
    cin >> a >> b;
    int tren = 1, cnt = 0;
    while(tren < b){
        tren += a-1;
        cnt++;
    }
    cout << cnt;
    return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  
  int s = 0;
  for (int i = 0; i < S.length(); ++i) {
    if (S[i] == T[i]) s+=1;
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++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 irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
 
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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

// 場所i以降で文字Cが最初に現れる位置

signed main()
{
  string s,t; cin>>s>>t;
  vector<vector<int>> is(26);
  
  int n = s.size(); int m = t.size();
  rep(i,n) is[s[i]-'a'].push_back(i);
  rep(i,n) is[s[i]-'a'].push_back(i+n);
  ll ans=0;
  int p=0;
  rep(i,m){
    int c=t[i]-'a';
    if(is[c].size()==0) {
      cout<<-1<<endl;
      return 0;
    }
    p= *lower_bound(is[c].begin(),is[c].end(),p)+1;
    if(p >= n){
      p -= n;
      ans+=n;
    }
  }
  ans+=p;
  cout<<ans<<endl;
}


Measured memory_bytes: 1724