akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n;string s;cin>>n>>s;
    ll l=0,r=n-1,ans=0;
    while(l<r){
        if(s[l]=='R')l++;
        if(s[r]=='W')r--;
        if(s[l]=='W'&&s[r]=='R'&&l<n&&r>=0){
            l++;r--;ans++;
        }
    }
    out(ans);
}

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

int main()
{
  string s;
  cin>>s;
  long long int x = s.length()-1;
    if(s[x]=='2'||s[x]=='4'||s[x]=='5'||s[x]=='7'||s[x]=='9')
    {
      cout<<"hon"<<'\n';
    }
    else if(s[x]=='0'||s[x]=='1'||s[x]=='6'||s[x]=='8')
    {
      cout<<"pon"<<'\n';
    }
    else
    {
      cout<<"bon"<<'\n';
    }
  return 0;
}
   


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

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

    ll ans = 0;
    if(w < h){
        ll o = w;
        w = h;
        h = o;
    }
    ll k = w / 2;
    ll q = h / 2;
    

    if(w % 2 != 0){
        k++;
    }
    if(h % 2 != 0){
        q++;
    }
    if(h == 1){
        ans = 1;
    }else{
        ans = k * q;
        if(w % 2 == 0){
            ans += k * (h - q);
        }else{
            ans += (k - 1) * (h - q);
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

ll POWER (ll x, ll y, ll mod){
    ll ans = 1, c = x;
    while (y){
        if ((y & 1) == 1)
            ans = ans * c % mod;
        c = c * c % mod;
        y /= 2;
    }
    return ans;
}

const ll N = 1e4 + 6, MOD = 1e9 + 7;
const double C = 1;

string S;
int n;
int D;
ll dp[N][105][2];

int main()
{
    ios::sync_with_stdio(false);
    cin>>S>>D;
    n = (int)S.size();
    S = "#" + S;
    dp[0][0][1] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < D; j++){
            for (int c = 0; c < 10; c++){
                int x = (j - c + D * 11) % D;
                dp[i][j][0] += dp[i - 1][x][0];
                if (c < S[i] - '0')
                    dp[i][j][0] += dp[i - 1][x][1];
                if (c == S[i] - '0')
                    dp[i][j][1] += dp[i - 1][x][1];
            }
            for (int l = 0; l < 2; l++)
                dp[i][j][l] %= MOD;
        }
    cout<<(dp[n][0][0] + dp[n][0][1] - 1 + MOD) % MOD<<endl;
    return 0;
}


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

int main(){
  int a;
  cin >> a;
  cout << a + pow(a,2) + pow(a,3) << endl;
}

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

using namespace std;
using ll = long long;

vector<ll> a, b, c;

int K;

vector<ll> calc(vector<ll>& x, vector<ll>& y)
{
  vector<ll> res;
  for (ll X : x) {
    for (ll Y : y) {
      res.push_back(X + Y);
    }
  }
  sort(res.begin(), res.end(), greater<ll>());
  if (res.size() > K) {
    res.erase(res.begin() + K, res.end());
  }
  return res;
}

int main()
{
  int x, y, z;
  cin >> x >> y >> z >> K;
  a.resize(x);
  b.resize(y);
  c.resize(z);
  for (int i = 0; i < x; i++) cin >> a[i];
  for (int i = 0; i < y; i++) cin >> b[i];
  for (int i = 0; i < z; i++) cin >> c[i];
  auto v = calc(a, b);
  v = calc(v, c);
  for (ll r : v) cout << r << endl;
}


Measured memory_bytes: 43112
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int main()
{
    rkc;
    ll n,x,c=1,s=0;
    cin>>n>>x;
    ll a[n];
    fl(i,0,n){cin>>a[i];s+=a[i];if(s<=x)c++;}
    cout<<c;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String n = sc.nextLine();
        
        String []in = n.split(" ");
        
        long x = Long.parseLong(in[0]);
        long a = Long.parseLong(in[1]);
        long b = Long.parseLong(in[2]);
        
        if(-a + b <= 0){
            System.out.println("delicious");
        } else if(-a + b <= x){
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
                
    }
    
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
      //#define ll long long
      using namespace std;
      #define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
      #define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
      #define ll long long
      #define pb push_back
      #define pll pair<ll,ll>
      #define ff first
      #define ss second
     
      #define N 2000001
      #define M 998244353
      #define INF 1000000000000000
int main()
{
 // SPEED;
 ll n;

 cin>>n;
  ll  a[n];
  ll i,j,k;
  unordered_map<ll,ll> m;ll sum=0;
  for(i=0;i<n;i++)
  {
    cin>>a[i];m[a[i]]++;sum=sum+a[i];
  }
  //cout<<sum<<endl;
  ll t;
  cin>>t;
  while(t-->0)
  {
    ll x,y;
    cin>>x>>y;

    sum=sum-m[x]*x+(m[x])*y;
    
    cout<<sum<<endl;
    m[y]=m[x]+m[y];
    m[x]=0;
    
  }



}

Measured memory_bytes: 7676
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))

ans = "No"

n = int(input())

for i in range(n):
    p = int(input())
    if a1.count(p)>0:
        a1[a1.index(p)]=-1
    if a2.count(p)>0:
        a2[a2.index(p)]=-1
    if a3.count(p)>0:
        a3[a3.index(p)]=-1

if max(a1)==-1 or max(a2)==-1 or max(a3)==-1:
    ans="Yes"

if (a1[0]==-1 and a2[0]==-1 and a3[0]==-1) or (a1[1]==-1 and a2[1]==-1 and a3[1]==-1) or ((a1[2]==-1 and a2[2]==-1 and a3[2]==-1)):
    ans="Yes"

if (a1[0]==-1 and a2[1]==-1 and a3[2]==-1) or (a1[2]==-1 and a2[1]==-1 and a3[0]==-1) :
    ans="Yes"

print(ans)



Measured memory_bytes: 62248
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9

int main(){
    ll i,j,k,Hs,Ws,ans;

    ll H,W;
    cin >> H >> W;

    ans=(H*W+1)/2; // 繰り上げの時, int型を用いて(A+B-1)/Bで計算すればAをBで割った時の答えが出てくる
    
    if(H==1 || W==1) ans = 1;

    cout << ans << endl;


}

Measured memory_bytes: 256
import itertools
 
n = int(input())
l =[]
 
for _ in range(n):
  a = int(input())
  m = []
  for _ in range(a):
    xn, yn = map(int, input().split())
    m.append([xn-1, yn])
  l.append(m)
 
for i in itertools.product([1, 0], repeat=n):
  i = list(i)
  flg = 0
  for j in range(n):
    for k in l[j]:
      if i[j] == 1:
        if i[k[0]] != k[1]:
          flg += 1
          break
  if flg == 0:
    break
    
print(sum(i))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	ll n; cin >> n;
	int ans=log10(n)+1;
	for(int i=1;i<=sqrt(n);i++){
		if(n%i==0){
			ans=min(ans,(int)max(log10(i)+1,log10(n/i)+1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3892
#include <stdio.h>
#include <algorithm>
#include <map>
#include <ctime>

using namespace std;

long long n;
long long a[510][510];
long long p[120000] , prime[120000] , tot;
map < long long , long long > m;
long long cnt;
long long lcm ( long long a , long long b , long long c , long long d ) {
	long long t = a / __gcd ( a , b ) * b;
	t = t / __gcd ( t , c ) * c;
	t = t / __gcd ( t , d ) * d;
	return t;
}
void work () {
	long long i , j , t , l;
	scanf ( "%lld" , &n );
	for ( i = 2 ; i <= 100000 ; i++ ) {
		if ( !p[i] ) {
			prime[++tot] = i;
		}
		for ( j = 1 ; j <= tot ; j++ ) {
			if ( i * prime[j] > 100000 ) break;
			p[i*prime[j]] = 1;
			if ( i % prime[j] == 0 ) break;
		}
	}
	for ( i = 0 ; i <= n + 1 ; i++ ) {
		for ( j = 0 ; j <= n + 1 ; j++ ) {
			a[i][j] = 1;
		}
	}
	t = l = 0;
	for ( i = 1 ; i <= n ; i++ ) {
		for ( j = 1 ; j <= n ; j++ ) {
			if ( (i+j) % 2 == 0 ) {
				a[i][j] = a[i][j] * prime[(i+j)/2];
				a[i][j] = a[i][j] * prime[n*2-i+j];
			}
		}
	}
	for ( i = 1 ; i <= n ; i++ ) {
		for ( j = 1 ; j <= n ; j++ ) {
			if ( (i+j) % 2 == 1 ) {
				l = lcm ( a[i-1][j] , a[i+1][j] , a[i][j-1] , a[i][j+1] );
				t = l + 1;
				while ( m[t] == 1 ) {
					t += l;
				}
				a[i][j] = t;
				m[t] = 1;
			}
		}
	}
	for ( i = 1 ; i <= n ; i++ , printf ( "\n" ) )
		for ( j = 1 ; j <= n ; j++ ) printf ( "%lld " , a[i][j] );
	//for ( i = 1 ; i <= n ; i++ )
	//	for ( j = 1 ; j <= n ; j++ ) if ( a[i][j]<0)printf ( "%lld " , a[i][j] );
	
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 13824
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  ll A,B,C,K; cin >> A >> B >> C >> K;
  if ( K % 2 == 0 ) {
    cout << A-B << endl;
  } else {
    cout << (A-B)*(-1) << endl;
  }
  return 0;
}


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

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

    double ret = 0;
    double p;
    for (int i = 1; i <= n; i++) {
        double tmp = i;
        p = (double)1/n;
        while (k > tmp) {
            tmp = tmp * 2;
            p = p*0.5;
        }
        ret = ret + p;
    }

    cout << setprecision(12) << ret << endl;
}


Measured memory_bytes: 256
from math import sqrt

N, D = map(int,input().split())
X = [[0]*D for _ in range(N)]
for i in range(N):
  X[i] = list(map(int,input().split()))
    
cnt = 0
for i in range(N-1):
  for j in range(i+1,N):
    sum = 0
    for d in range(D):
      sum += pow((X[i][d] - X[j][d]), 2)
    sum = sqrt(sum)
    if sum.is_integer():
      cnt += 1
print(cnt)

Measured memory_bytes: 3064
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let mut n: i64 = sc.next();
    while n > 0 {
        if n % 4 == 0 {
            println!("Yes");
            return;
        }
        n -= 7;
    }
    if n == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
require 'pp'

x = gets.to_i
memo = {}
memo2 = Array.new(2000)

index = 0
(-1000).upto(1000) do |b|
    memo[b ** 5 + x] = b
    memo2[index] = b ** 5
    index+=1
end

memo2.each_with_index do |x, i|
    if memo[x]
        puts "#{i - 1000} #{memo[x]}"
        exit 0
    end
end


Measured memory_bytes: 14464
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
T = input()
ans = len(T)
for i in range(len(S) - len(T) + 1):
    tmp = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            tmp += 1
    if tmp < ans:
        ans = tmp
print(ans)


Measured memory_bytes: 27256
// Last Change: 03/21/2019 20:29:55.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll N, D, X, ipt, ans;
  cin >> N >> D >> X;

  ans = 0;
  for (ll i = 0; i < N; ++i) {
    cin >> ipt;
    ans += D / ipt + ((D % ipt) > 0 ? 1 : 0);
  }
  ans += X;

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


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

int main() {
    int a,p, sum, ans;
    cin >> a >> p;
    sum = 3*a + p;
    ans = sum/2;
    cout << ans << endl;
}

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

public class Main {
	
	public  void solve() throws IOException{
		int n;
		while( (n = nextInt()) != 0 ){
			int[] ans = new int[n/2+1];
			Set<Integer> set = new HashSet<Integer>();
			for(int i = 1; i < n; i++){
				int x = i*i%n;
				set.add(x);
			}
			for(Integer p : set){
				for(Integer q : set){
					if( p == q ){
						continue;
					}
					int key = ((p-q)+n)%n;
					key = Math.min(n-key, key);
					ans[key]++;
				}
			}
			for(int i = 1; i < ans.length; i++){
				writer.println(ans[i]);
			}
		}
		writer.flush();
	}
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run() throws IOException{
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}		
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

Measured memory_bytes: 10000
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;

int main(){
	int x1,y1,x2,y2,n,xf=1,yf=1,x,y;
	scanf("%d%d%d%d%d",&x1,&y1,&x2,&y2,&n);
	if(x1>x2)swap(x1,x2),xf=-1;
	if(y1>y2)swap(y1,y2),yf=-1;
	vector<pair<int,int>>v;
	for(int i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		if(x1<=x&&x<=x2 && y1<=y&&y<=y2)v.emplace_back(x*xf,y*yf);
	}
	sort(v.begin(),v.end());
	vector<int>d(v.size(),1<<30);
	for(auto &e:v)n=e.second,*lower_bound(d.begin(),d.end(),n)=n;
	n=lower_bound(d.begin(),d.end(),1<<30)-d.begin();
	printf("%.9f\n",100.0*(x2-x1+y2-y1)-20*n+5*(n+(n>=min(x2-x1,y2-y1)+1))*3.14159265359);
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll solve(int N,int M,vector<ll>& x,vector<ll>& y,vector<ll>& z) {
    ll best = 0;
    for(int pm1=-1;pm1<=1;pm1+=2)
    for(int pm2=-1;pm2<=1;pm2+=2)
    for(int pm3=-1;pm3<=1;pm3+=2){
        vector<ll> s(N);
        rep(i,N){
            s[i] = x[i]*pm1 + y[i]*pm2 + z[i]*pm3;
        }
        sort(ALL(s)); reverse(ALL(s));
        // cerr<<s<<endl;
        ll score = 0;
        rep(i,M) score += s[i];
        // ll score = accumulate(s.begin(), s.begin()+M, 0);
        best = max(best, score);
    }
    return best;
}

int main() {
    int N,M; cin>>N>>M;
    vector<ll> x(N), y(N), z(N);
    rep(i,N){
        cin>>x[i] >>y[i]>>z[i];
    }
    cout << solve(N,M,x,y,z) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int main(int, char *[])
{
    int N;
    cin >> N;
    
    cout << ((N&1) ? 2*N : N) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

ll n, p, s, a[maxn], b[maxn], c[maxn];

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

	cin >> n >> p;
	fori (i, 0, n)
	{
		cin >> a[i] >> b[i];
		s += b[i];
	}
	fori (i, 0, n)
		c[i] = (100 - p) * a[i] + p * b[i];
	sort(c, c + n);
	ll ans = 0, sum = 0;
	forb (i, n - 1, 0)
	{
		if (sum >= s * p)
			break;
		ans++;
		sum += c[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
object Main extends App {
  import scala.io.StdIn._
  val n = readLong()
  var ans = 1000000000000L
  for(i <- 1L to(Math.floor(Math.sqrt(n)).toLong)){
    if(n % i == 0){
      ans = Math.min(ans,i+n/i-2)
    }
  }
  println(ans)
}

Measured memory_bytes: 57004
inf = float("inf")

n = int(input())
s = list(map(int, input()))

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            t = 0
            for l in s:
                if t == 0:
                    if l == i:
                        t += 1
                elif t == 1:
                    if l == j:
                        t += 1
                elif t == 2:
                    if l == k:
                        t += 1
            if t == 3:
                ans += 1

print(ans)


Measured memory_bytes: 44380
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    string ans;
    ll n,a,b,c,m,k,q,l;
    cin >> a >> b >> c;
    if(a==b&&b==c)ans="Yes";
    else ans="No";
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    int N; cin >> N;
    vector<double> h(N);
    for (int i = 0; i < N; i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    for (int i = 1; i < N; i++){
        h[i] = (h[i-1]+h[i])/2.0;
    }
    cout << fixed << setprecision(10) << h[N-1] << endl;
}

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

using namespace std;
int main(){
    int i,n,q,k;
    int num=0;
    vector<int> S;
    vector<int> T;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>k;
        S.push_back(k);
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>k;
        if(*lower_bound(S.begin(),S.end(),k)==k)
            num++;
    }
    cout<<num<<endl;
    return 0;
}



Measured memory_bytes: 3444
import itertools

N, K = map(int, input().split())
A = tuple(map(int, input().split()))

MOD = 10 ** 9 + 7

dp = [[0] * (K + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(1, N + 1):
    S = [0] + list(itertools.accumulate(dp[i - 1]))
    for j in range(K + 1):
        dp[i][j] = (S[j + 1] - S[max(0, j - A[i - 1])]) % MOD
print(dp[N][K])


Measured memory_bytes: 174728
n,k=map(int,input().split())
s=input()
s=list(s)
if s[k-1]=='A':
    s[k-1]='a'
elif s[k-1]=='B':
    s[k-1]='b'
elif s[k-1]=='C':
    s[k-1]='c'
s= "".join(s)
print(s)

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	vector<vpii> v[3];
	rep(k, 3) {
		int n;
		if(k == 0)
			n = 1;
		else
			scanf("%d", &n);
		v[k].assign(n, vpii());
		rep(i, n) {
			int K;
			scanf("%d", &K);
			rep(j, K) {
				int ah, am, bh, bm;
				scanf("%d:%d-%d:%d", &ah, &am, &bh, &bm);
				int a = ah * 60 + am, b = bh * 60 + bm;
				v[k][i].push_back(mp(a, b));
			}
		}
	}
	int ans = 0;
	each(i, v[0][0]) {
		int a = i->first, b = i->second;
		int cnt[2] = {};
		rep(k, 2) {
			rep(l, v[1+k].size()) {
				bool ok = false;
				each(j, v[1+k][l])
					ok |= j->first <= a && b <= j->second;
				cnt[k] += ok;
			}
		}
		ans += min(cnt[0], cnt[1]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication2 {
    class Program {
        static void Main(string[] args) {

            TextReader input = Console.In;

            string str = "";

            // データセット取得
            int dataSet = 0;
            str = input.ReadLine();
            if (string.IsNullOrEmpty(str)) {
                return;
            }
            if (!int.TryParse(str, out dataSet)) {
                return;
            }
            if (dataSet == 0) {
                return;
            }

            for (int ii = 0; ii < dataSet; ii++) {
                str = input.ReadLine();
                if (string.IsNullOrEmpty(str)) {
                    break;
                }
                // スペースで区切る
                string[] triLens = str.Split(' ');
                // 3 個でない場合
                if (triLens.Length != 3) {
                    continue;
                }
                List<int> lens = new List<int>();
                int work = 0;
                if (!int.TryParse(triLens[0], out work)) {
                    continue;
                }
                lens.Add(work);
                if (!int.TryParse(triLens[1], out work)) {
                    continue;
                }
                lens.Add(work);
                if (!int.TryParse(triLens[2], out work)) {
                    continue;
                }
                lens.Add(work);
                lens.Sort(delegate(int w1, int w2){return w2.CompareTo(w1);});
                if (lens[0] * lens[0] == lens[1] * lens[1] + lens[2] * lens[2]) {
                    Console.WriteLine("YES");
                } else {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

Measured memory_bytes: 5460
import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_A
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String w = null;
            long num = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                if (lineNumReader.getLineNumber() == 1) {
                    w = inputStr.toLowerCase();
                }
                
                // ???????????¶.
                if ("END_OF_TEXT".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // 2????????\???????????±????????????
                if (lineNumReader.getLineNumber() > 1) {
                    // ??§???????°????????????\??????????????§????°????????????±???.
                    inputStr = inputStr.toLowerCase();
                    
                    // ???????????????
                    String[] words = inputStr.split(" ");
                    for (String word : words) {
                        if (word.equalsIgnoreCase(w)) {
                            num++;
                        }
                    }
                }
            }
            
            // ??¢???????????????
            System.out.println(num);
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
}

Measured memory_bytes: 24180
#include<stdio.h>

int main(void){
  int n,a,b,ans=0,sum,i,j;
  scanf("%d%d%d",&n,&a,&b);
  for(i=1;i<=n;i++){
    sum=0;
    j = i;
    for(;j;j/=10) sum+=j%10;
    if(a<=sum && sum<=b) ans+=i;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 100
int N, K;
int A[MAXN];

#define MAXK 100004
int memo[MAXK];
int go(int k) {
   if (k == 0)
      return 0;
   int& res = memo[k];
   if (res < 0) {
      res = 0;
      REP(i, N) {
         if (A[i] > k) break;
         if (!go(k - A[i])) {
            res = 1;
            break;
         }
      }
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> N >> K;
   REP(i, N)
      cin >> A[i];

   memset(memo, -1, sizeof(memo));
   int res = go(K);
   cout << (res ? "First" : "Second") << '\n';

   return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
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()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int n,k;
  cin >> n >> k;
  vi p(n);
  REP(i,n)cin >> p[i];
  sort(ALL(p));
  int ans=0;
  REP(i,k)ans+=p[i];
  PRINT(ans);
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define vii vector<vector<int>>
#define mii map<int,int>
#define pb push_back
#define mod 1e9 + 7;
const int INF = 1e9 + 5;
#define PQ priority_queue<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define endl "\n"

using namespace std;

int main(){

	int n;
	cin>>n;
	vi h(n), dp(n, INT_MAX);
	dp[0]=0;
	for(int i=0; i<n; i++)cin>>h[i];

	for(int i=0; i<n; i++){
		
		for(int j=i+1; j<=i+2; j++){
			if(j<n){
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}

	cout<<dp[n-1]<<endl;

}

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


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

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
int main(){
ll n;
  cin>>n;
  ll count=0;
  for(ll i=1;i<=n;i+=2){
    ll memo=0;
  for(ll j=1;j<=i;j++){
  if(i%j==0)
    memo++;
  }
if(memo==8)
  count++;
  }
  cout<<count;
return 0;
}


Measured memory_bytes: 256
N=int(input())
AS = list(map(int,input().split()))
if 0 in AS:
  print(0)
  exit()
sum = 1
l=len(AS)
for i in range(l):
  A=AS[i]
  sum = sum * A
  if sum > 10**18:
    sum = -1
    break
if sum > 10**18:
  print(-1)
else:
  print(sum)

Measured memory_bytes: 21604
l,r = map(int, input().split())
if l//2019 != r//2019:
  print(0)
  exit(0)
l = l%2019
r = r%2019
a = 2019
for i in range(l,r+1):
  for j in range(l,i):
    a = min(a,(i*j)%2019)
print(a)


Measured memory_bytes: 9180
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int a, b; cin >>a >>b;
  double v = 3.305785;
  printf("%.8lf\n", a * b / v);
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  int N,cnt=0;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++) cin>>a[i];
  sort(a,a+N);
  for(int i=0;i<N;i++){
    if(a[i]==a[i+1]) continue;
    else cnt++;
  }  
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
//default
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;int ans=0;
#define answer cout << ans << endl;
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;

using Graph = vector<vector<int>>;
vector<int> color;
int b=0,w=0;
bool dfs(const Graph &G, int v, int cur = 0) {
    color[v] = cur;
    if(cur==0) b++;
    else if(cur==1) w++;
    for (auto next_v : G[v]) {
        // 隣接頂点がすでに色確定していた場合
        if (color[next_v] != -1) {
            if (color[next_v] == cur) return false; // 同じ色が隣接したらダメ
            continue;
        }

        // 隣接頂点の色を変えて、再帰的に探索 (一回でも false が返ってきたら false)
        if (!dfs(G, next_v , 1 - cur)) return false;
    }
    return true;
}

signed main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;
    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 探索
    color.assign(N, -1);
    bool is_bipartite = true;
    for (int v = 0; v < N; ++v) {
        if (color[v] != -1) continue; // v が探索済みだったらスルー
        if (!dfs(G, v)) is_bipartite = false;
    }

    if (is_bipartite){
      cout << b*w-M << endl;
    }
    else{
      cout << N*(N-1)/2-M << endl;
    }
}


Measured memory_bytes: 19328
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;
int main(){
	int N,A,B=-12938;
	priority_queue<int> que;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A;
		que.push(A);
	}
	while(que.size()!=0){

	if(que.top()==B){
		N--;
	}
		B=que.top();
		que.pop();
	}
	cout<<N<<endl;
}


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

int main(){
	int n;
	cin >> n;
	for(int i=0;i<=n/4;i++){
		for(int j=0;j<=n/7;j++){
			if(4*i+7*j == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<map<int,int>>mps(n);
    
    for(int i=0;i<n;i++){
        cin>>mps.at(i)[1]>>mps.at(i)[0];   
    }
    sort(mps.begin(),mps.end());
    int time=0;
    bool ok=true;
    for(int i=0;i<n;i++){
        mps.at(i)[0];
        time+=mps.at(i)[1];
        if(time<=mps.at(i)[0]) ok=true;
        else{
            ok=false;
            break;
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

    
      

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

template<typename T>
T modpower(T a, T n, T mod) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;
    ll res = 0;
    vector<ll> d(k + 1);
    for (int i = k; i > 0; --i) {
        ll num = k / i;
        ll tmp = modpower(num, n, MOD);
        for (ll x = i * 2; x <= k; x += i) tmp -= d[x];
        d[i] = tmp;
    }
    FOR (i, 1, k + 1) {
        res += (i * d[i]) % MOD;
        res %= MOD;
    }
    cout << res << endl;
    
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0; i<N; i++) cin >> L.at(i);
  sort(L.begin(), L.end());
  int term=0;
  for(int i=0; i<N-1; i++) term+=L.at(i);
  if(term>L.at(N-1)) cout << "Yes" << endl;
  else cout << "No" << endl; 
}

Measured memory_bytes: 256
S = input()
T = input()

if len(T) > len(S):
    print("UNRESTORABLE")
    exit()

ans = []

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j]!=T[j] and S[i+j]!='?':
            break
    else:
        ans.append((S[:i] + T + S[i+len(T):]).replace('?', 'a'))

if len(ans) == 0:
    print("UNRESTORABLE")
else:
    ans.sort()
    print(ans[0])


Measured memory_bytes: 3064
W, H, N = map(int, input().split())
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())

max_W = W
max_H = H
S = W * H
sx, sy = 0, 0

for i in range(N):
    if a[i] == 1:
        if (x[i] - sx) * (max_H - sy) >= 0:
            S -= (x[i] - sx) * (max_H - sy)
            sx = x[i]
    elif a[i] == 2:
        if (max_W - x[i]) * (max_H - sy) >= 0:
            S -= (max_W - x[i]) * (max_H - sy)
            max_W = x[i]
    elif a[i] == 3:
        if (max_W - sx) * (y[i] - sy) >= 0:
            S -= (max_W - sx) * (y[i] - sy)
            sy = y[i]
    else:
        if (max_W - sx) * (max_H - y[i]) >= 0:
            S -= (max_W - sx) * (max_H - y[i])
            max_H = y[i]

if S < 0:
    S = 0

print(S)

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

string s;
mii m;

int main() {
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> s;
	for (auto& c : s) {
		++m[int(c - 'A')];
	}
	vi v;
	for (auto& elem : m) {
		v.pb(elem.sc);
	}
	cout << (sz(v) == 2 && v[0] == 2 ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	int n,i;
	cin>>n>>i;
	cout<<n-i+1<<endl;

	
	return 0;
}





Measured memory_bytes: 256
import numpy as np
import bisect
n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))

aa.sort()
cc.sort()

cnt = 0
for b in bb:
    na = bisect.bisect_left(aa,b)
    nc = n - bisect.bisect_right(cc,b)
    cnt += na*nc
print(cnt)

Measured memory_bytes: 31476
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {
	int num, s1, s2, g1, g2, i;
	string s;
	cin >> num >> s1 >> s2 >> g1 >> g2 >> s;
	s1--; s2--;
	g1--; g2--;
	for(i = s1; i < max(g1, g2); i++){
		if (s[i] == '#' && s[i + 1] == '#') {
			printf("No\n");
			return 0;
		}
	}
	if (g1 > g2) {
		for (i = s2 - 1; i < g2; i++) {
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
				break;
		}
		if (i == g2) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
LIMIT = 10 ** 5
n = gets.to_i
a = gets.split.map(&:to_i)
hist = Array.new(LIMIT, 0)
a.each do |v|
  hist[v] += 1
end
ans = 0
for i in 1..(LIMIT - 2) do
  sum = hist[i - 1] + hist[i] + hist[i + 1]
  ans = sum if ans < sum
end
puts ans


Measured memory_bytes: 21008
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
dp=[0]*N
data={'r':P,'s':R,'p':S}
ans=0
for i in range(N):
  if 0<=i-K:
    if T[i-K]==T[i]:
      if dp[i-K]==0:
        ans+=data[T[i]]
        dp[i]=1
    else:
      ans+=data[T[i]]
      dp[i]=1
  else:
    dp[i]=1
    ans+=data[T[i]]
print(ans)

Measured memory_bytes: 10004
open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in

  let rec digits base n res =
    if n = 0 then res 
    else digits base (n/base) ((n mod base)::res)
  in

  let digits_l = digits 10 n [] in
  let sum = List.fold_left (+) 0 digits_l in

  Printf.printf "%s\n" @@
  if n mod sum = 0 then "Yes" else "No"


Measured memory_bytes: 1024