akhauriyash/Code-Regression huggingface dataset:
# Tree Walk


class Node():
    def __init__(self, idx=-1, parent=-1, left=-1, right=-1):
        self.idx = idx
        self.parent = parent
        self.left = left
        self.right = right


class BinaryTree():
    def __init__(self, n):
        self.T = [Node(i) for i in range(n)]
        self.preorder_idx = []
        self.inorder_idx = []
        self.postorder_idx = []

    def set_children(self, idx, l, r):
        node = self.T[idx]
        node.left = l
        node.right = r
        if l != -1:
            self.T[l].parent = idx
        if r != -1:
            self.T[r].parent = idx

    def get_root(self):
        for idx, node in enumerate(self.T):
            if node.parent == -1:
                return idx

    def preorder(self, idx):
        if idx == -1:
            return
        node = self.T[idx]
        self.preorder_idx.append(idx)
        self.preorder(node.left)
        self.preorder(node.right)

    def inorder(self, idx):
        if idx == -1:
            return
        node = self.T[idx]
        self.inorder(node.left)
        self.inorder_idx.append(idx)
        self.inorder(node.right)

    def postorder(self, idx):
        if idx == -1:
            return
        node = self.T[idx]
        self.postorder(node.left)
        self.postorder(node.right)
        self.postorder_idx.append(idx)


N = int(input())
tree = BinaryTree(N)

for _ in range(N):
    idx, l, r = map(int, input().split())
    tree.set_children(idx, l, r)

root = tree.get_root()
tree.preorder(root)
tree.inorder(root)
tree.postorder(root)

print('Preorder')
print('', *(tree.preorder_idx))
print('Inorder')
print('', *(tree.inorder_idx))
print('Postorder')
print('', *(tree.postorder_idx))



Measured memory_bytes: 5620
a, b = map(int, input().split())
import fractions
gcd = fractions.gcd(a, b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    #arr.append([1, 1])
    return arr
if a == 1 or b == 1:
    print(len(factorization(gcd)))
    quit()
print(len(factorization(gcd)) + 1)

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

int main(){
  int n;
  cin>>n;
  int Alice = 0;
  int Bob = 0;
  int k = 0;
  vector<int> a(n);
  for(int i = 0;i < n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int i = 1;i <= n;i++){
    int j = 0;
    j = i % 2;
    if(j == 1){
      Alice += a.at(k);
    }
    if(j == 0){
      Bob += a.at(k);
    }
    k++;
  }
  cout<<Alice - Bob<<endl;
  }

Measured memory_bytes: 3152
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n=3,ans=0;
    // scanf("%lld",&n);
    ll a[n];
    rep(i,0,n){
        scanf("%lld",&a[i]);
    }
    sortup(a,3);
    ans+=a[2]-a[1];
    a[0]+=a[2]-a[1];
    if( (a[2]-a[0])%2 ){
        ans+=(a[2]-a[0])/2+1+1;
    }else{
        ans+=(a[2]-a[0])/2;
    }
    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    lint a;
    ldouble b;
    cin >> a >> b;
    println(lint(a * b));
    return 0;
}

Measured memory_bytes: 3728
#include <cstdio>
#include <algorithm>
using namespace std;
int ans[2010];
int main(){
	int N,X,Y,i,j,a,b,d;
	scanf("%d%d%d",&N,&X,&Y);
	for(i=1;i<=N;i++)
		for(j=i+1;j<=N;j++){
			a=j-i;//一种按不加X,Y的路径走
			b=(X>i?X-i:i-X)+(Y>j?Y-j:j-Y)+1;//另一种按通过X,Y的路径走,1是指X到Y路径的长度
			d=min(a,b);//两种路径取最小值
			ans[d]++;
		}
	for(i=1;i<N;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

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

  std::vector<long long int> b;
  scanf("%lld", &N);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    b.push_back(tmp);
  }

  for(long long int i = 0; i < 3; i++){
    for(long long int j = 0; j < 3; j++){
      for(long long int k = 0; k < N; k++){
        if(A[i][j] == b[k]){
          A[i][j] = -1;
        }
      }
    }
  }

  // check bing
  long long int bingo = 0;
  for(long long int i = 0; i < 3; i++){
    if(A[i][0] == A[i][1] && A[i][1] == A[i][2] && A[i][2] == -1){
      bingo = 1;
      break;
    }
    if(A[0][i] == A[1][i] && A[1][i] == A[2][i] && A[2][i] == -1){
      bingo = 1;
      break;
    }
  }

  if(A[0][0] == A[1][1] && A[1][1] == A[2][2] && A[2][2] == -1){
    bingo = 1;
  }
  if(A[2][0] == A[1][1] && A[1][1] == A[2][0] && A[2][0] == -1){
    bingo = 1;
  }

  std::cerr << "Answer:" << std::endl;

  if(bingo){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  vector<ll> v(n),a(n);
  for(int i=0 ; i<n ; i++){
    cin >> a[i];
    v[i] = a[i] - (i+1);
  }
  sort(v.begin(), v.end());
  ll x = (v[n/2]);
  ll sum = 0;
  for(int i=0 ; i<n ; i++){
    sum += abs(v[i] - x);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"
int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	string s,t="abcdefghijklmnopqrstuvwxyz";
	cin>>s;
	for(ll i=0;i<26;i++){
		if(count(s.begin(),s.end(),t[i])==0)return cout<<t[i],0;
	}
	cout<<"None";
	
}

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

int main() {
    string S;
    cin >> S;
    long long ans = 0;
    rep(i, pow(2, S.size() - 1)) {
        string tmp;
        tmp += S[0];
        rep(j, S.size() - 1) {
            if (i & (1 << j)) {
                ans += stoll(tmp);
                tmp = "";
            }
            tmp += S[j + 1];
        }
        if (tmp != "") {
            ans += stoll(tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import itertools
n,c = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(c)]
C = [list(map(int,input().split())) for _ in range(n)]
mod0 = []
mod1 = []
mod2 = []
for i in range(n):
    for j in range(n):
        # indexのずれを考慮 ((i+1)+(j+1))%3が本来のmod値
        if (i+j)%3 == 1:
            mod0.append(C[i][j]-1)
        elif (i+j)%3 == 2:
            mod1.append(C[i][j]-1)
        else:
            mod2.append(C[i][j]-1)

conv_0, conv_1, conv_2 = [],[],[]
for i in range(c):
    tmp0, tmp1, tmp2 = 0,0,0
    for j in range(len(mod0)):
        tmp0 += D[mod0[j]][i]
    for j in range(len(mod1)):
        tmp1 += D[mod1[j]][i]
    for j in range(len(mod2)):
        tmp2 += D[mod2[j]][i]
    conv_0.append(tmp0)
    conv_1.append(tmp1)
    conv_2.append(tmp2)
res = float('inf')
for x,y,z in itertools.permutations(list(range(c)), 3):
    cnt = conv_0[x] + conv_1[y] + conv_2[z]
    res = min(cnt, res)
print(res)

Measured memory_bytes: 9428
<?php
$input = file_get_contents('php://stdin');
$inarr = explode("\n", $input);

$nmlist = explode(" ", $inarr[0]);
$aList = array_map("intval", explode(" ", $inarr[1]));

$n = (int)$nmlist[0];
$m = (int)$nmlist[1];

$sum = array_sum($aList);
$div = $sum/(4 * $m);

for($i=0;$i<$m;$i++){
    $select = max($aList);
    if($select<$div){
        echo "No"."\n";
        exit();
    }
    $aList = array_diff($aList, [$select]);
}
echo "Yes"."\n";

?>

Measured memory_bytes: 4728
/*
       ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄
      ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░▌
      ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌
      ▐░▌          ▐░▌       ▐░▌▐░▌       ▐░▌
      ▐░▌ ▄▄▄▄▄▄▄▄ ▐░▌       ▐░▌▐░▌       ▐░▌
      ▐░▌▐░░░░░░░░▌▐░▌       ▐░▌▐░▌       ▐░▌
      ▐░▌ ▀▀▀▀▀▀█░▌▐░▌       ▐░▌▐░▌       ▐░▌
      ▐░▌       ▐░▌▐░▌       ▐░▌▐░▌       ▐░▌
      ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌
      ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░▌
       ▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀  
 
 #can_change_the_world_with_the_help_of_0_1
                                    -darshan786    */
 
  
 
 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0); 
#define F first 
#define MAXN   1010
#define int long long
#define S second
#define all(v) v.begin(),v.end() 
#define PI pair<int,int>
#define PIS pair<int,string>





int values[41];
   
void value()
{
   values[0]=1;
    for(int i=1;i<=40;i++)
    {
        values[i]=2*values[i-1];
    }
}
const int maxn = 3e5 + 5;
 
int a[maxn];
 
int tree[6*maxn];
 
int query(int v ,int l ,int r ,int lq ,int rq) {
  if(lq <= l && r <= rq) {
    return tree[v];
  }
  
  if(l > rq or lq > r) {
    return 0;
  }
  
  int mid = (l+r)/2;
  
  int t1 = query(2*v + 1 , l , mid , lq , rq);
  int t2 = query(2*v + 2 , mid + 1 , r , lq , rq);
  
  return max(t1 , t2);
}
 
void update(int v , int pos , int l , int r , int val)
{
  if(l == r) {
    tree[v] = val;
    return;
  }
  
  int mid = (l+r)/2;
  
  if(pos <= mid) {
    update(2*v + 1, pos , l , mid , val);
  }
  else {
    update(2*v + 2, pos , mid+1 , r , val);
  }
  
  tree[v] = max(tree[2*v + 1] , tree[2*v + 2]);
}


int32_t main() {
    boost
     #ifndef ONLINE_JUDGE
     freopen("input.c","r",stdin);
     freopen("output.c","w",stdout);
    #endif



   int n , k;
  
  cin >> n >> k;
  


  for(int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  
  auto solve=[&]()
  {
  int mx = 1;
  
  for(int i = 1; i <= n; ++i) {
    int t1 = query(1 , 1 , 3e5 , max(1LL , a[i] - k) , min(300000ll , a[i] + k));
    int t2 = query(1 , 1 , 3e5 , a[i] , a[i]);
    
    
    if(t2 < t1+1) {
      update(1 , a[i] , 1 , 3e5 , t1 + 1);
      mx = max(mx , t1 + 1);
    }
  }
  
 return mx;

};

cout<<solve();
}



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

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    int ans = a[0];
    for(int i = 1; i < N; i++) ans = __gcd(ans, a[i]);
    cout << ans << endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	vector<int> a(5);
	int k;

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

	cin >> k;

	for (int i = 0; i < 5; i++)
	{
		for (int j = i + 1; j < 5; j++)
		{
			if (a[j] - a[i] > k)
			{
				println(":(");
				return 0;
			}
		}
	}

	println("Yay!");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;
	int cmin, c;
	c = 0;
	for (int j = 0;j < T.size();j++) {
		if (S.at(j) != T.at(j)) {
			c++;
		}
	}
	cmin = c;
	for (int i = 1;i < S.size() - T.size() + 1;i++) {
		c = 0;
		for (int j = 0;j < T.size();j++) {
			if (S.at(i + j) != T.at(j)) {
				c++;
			}
		}
		if (c < cmin) {
			cmin = c;
		}
	}
	cout << cmin << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(void)
{
	int n,num,i;
	char ch;
	int s[14]={0,},h[14]={0,},c[14]={0,},d[14]={0,};
	scanf("%d",&n);
	for(i=0;i<2*n;i++){
		scanf("%c",&ch);
		scanf("%d",&num);
		if(ch=='S') s[num]=1;
		if(ch=='H') h[num]=1;
		if(ch=='C') c[num]=1;
		if(ch=='D') d[num]=1;
	}
	for(i=1;i<14;i++){
		if(s[i]==0) printf("S %d\n",i);
	}
	for(i=1;i<14;i++){
		if(h[i]==0) printf("H %d\n",i);
	}
	for(i=1;i<14;i++){
		if(c[i]==0) printf("C %d\n",i);
	}
	for(i=1;i<14;i++){
		if(d[i]==0) printf("D %d\n",i);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;
typedef  pair<LL,LL> P;


const LL INF=1<<30;
const LL MOD=1000000007;




int main(){
    int m;cin>>m;
    cout<<48-m<<endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			int a = scanner.nextInt();
			String op = scanner.next();
			int b = scanner.nextInt();
			if(op.equals("?")){break;}
			switch (op) {
			case "+":System.out.println(a + b);break;
			case "-":System.out.println(a - b);break;
			case "*":System.out.println(a * b);break;
			case "/":System.out.println(a / b);break;			
			}
		}
		scanner.close();
	}

}

Measured memory_bytes: 26160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define ff first
#define ss second

void setIO(string name = "") { // name is nonempty for USACO file I/O
    ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
    freopen((name+".in").c_str(), "r", stdin); // see Input & Output
    freopen((name+".out").c_str(), "w", stdout);
}
// the code that we provide requires everything above this line to compile



int main() {
	int n;cin>>n;
	int arr[n];
	for(int i = 0; i < n; ++i) cin>>arr[i];
	ll ans = 1e3;
	for(int i = 0; i < n - 1; ++i){
		ll st = 0;
		if(arr[i] < arr[i+1]) st = ans / arr[i];
		ans += (arr[i+1] - arr[i])*st;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair

string s;
vi v;

int main(){
cin >> s;
rep(i, 0, s.size()-1){
if(s[i]=='0')v.pb(0);
if(s[i]=='1')v.pb(1);
else if(v.size()>0&&s[i]=='B')v.pop_back();
}
rep(i, 0, v.size()-1)cout << v[i];



return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	int max = -1;
	int mi = -1;
	for (int i = 0; i < N; i++)
	{
		if (max < A[i])
		{
			mi = i;
			max = A[i];
		}
	}
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		if (i != mi)
		{
			sum += A[i];
		}
	}
	if (sum > max)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

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

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

	return 0;

}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;
#define cni cin

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,m,k,ans;
string s;

main(){
	cin>>n;
	cout<<(n==7||n==5||n==3?"YES":"NO")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[505];
bool solve(int i){
    vector<int> v;
    int sum = 0;
    for(int j=1;j<=n;j++){
        v.push_back(a[j]-a[j]/i*i);
        sum += a[j]-a[j]/i*i;
        sum %= i;
    }

    if(sum != 0) return 0;
    sort(v.begin(), v.end());
    int l = 0, r = v.size()-1;

    long long res = 0;
    while(l < r){
        int mn = min(v[l], i-v[r]);
        v[l] -= mn;
        v[r] += mn;
        v[r] %= i;

        res += mn;
        if(v[l] == 0) l++;
        if(v[r] == 0) r--;
    }
    if(res <= k) return 1;
    return 0;
}

int main(){
    int sum = 0;
    scanf("%d%d", &n, &k);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]), sum += a[i];
    int ans = 0;
    for(int i=1;i*i<=sum;i++){
        if(solve(i)) ans = max(ans, i);
        if(solve(sum/i)) ans = max(ans, sum/i);
    }
    printf("%d\n", ans);
}

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

using namespace std;

enum Label { LABEL1, LABEL2, LABEL3, LABEL4, LABEL5, LABEL6, INVALID };

enum Direction {
  E,
  N,
  S,
  W,
};

class Dice {
public:
  Dice(int label[6])
      : top_(LABEL1), bottom_(LABEL6), front_(LABEL2), back_(LABEL5),
        right_(LABEL3), left_(LABEL4) {
    for (int i = 0; i < 6; ++i) {
      label_[i] = label[i];
    }
  }

  void north() {
    Label tmp = top_;
    top_ = front_;
    front_ = bottom_;
    bottom_ = back_;
    back_ = tmp;
  }

  void south() {
    Label tmp = top_;
    top_ = back_;
    back_ = bottom_;
    bottom_ = front_;
    front_ = tmp;
  }

  void east() {
    Label tmp = top_;
    top_ = left_;
    left_ = bottom_;
    bottom_ = right_;
    right_ = tmp;
  }

  void west() {
    Label tmp = top_;
    top_ = right_;
    right_ = bottom_;
    bottom_ = left_;
    left_ = tmp;
  }

  void roll(char ch) {
    Direction direction;
    switch (ch) {
    case 'E':
      east();
      break;
    case 'N':
      north();
      break;
    case 'S':
      south();
      break;
    case 'W':
      west();
      break;
    default:
      break;
    }
  }

  int getTop() { return label_[top_]; }

  int getRight(int topNumber, int frontNumber) {
    Label top = toLabel(topNumber);
    Label front = toLabel(frontNumber);
    Label anser[6][6] = {
        // front
        // 1      2       3       4       5       6
        {INVALID, LABEL3, LABEL5, LABEL2, LABEL4, INVALID}, // 1 top
        {LABEL4, INVALID, LABEL1, LABEL6, INVALID, LABEL3}, // 2
        {LABEL2, LABEL6, INVALID, INVALID, LABEL1, LABEL5}, // 3
        {LABEL5, LABEL1, INVALID, INVALID, LABEL6, LABEL2}, // 4
        {LABEL3, INVALID, LABEL6, LABEL1, INVALID, LABEL4}, // 5
        {INVALID, LABEL4, LABEL2, LABEL5, LABEL3, INVALID}, // 6
    };
    Label anserLabel = anser[top][front];
    return label_[anserLabel];
  }

private:
  Label toLabel(int number) {
    for (int i = 0; i < 6; ++i) {
      if (number == label_[i]) {
        return static_cast<Label>(i);
      }
    }
    return INVALID;
  }
  int label_[6];
  Label top_;
  Label bottom_;
  Label front_;
  Label back_;
  Label right_;
  Label left_;
};

int main() {
  int label[6];
  for (int i = 0; i < 6; ++i) {
    cin >> label[i];
  }
  Dice dice(label);

  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int top, front;
    cin >> top >> front;
    cout << dice.getRight(top, front) << endl;
  }

  return 0;
}



Measured memory_bytes: 3084
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
using namespace std;
int zf[26]={0};
int pp[6]={0};
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	char space;
	scanf("%c",&space);
	for(int i=0;i<n;i++)
	{
		for(int k=0;k<m;k++)
		{
			scanf("%c",&space);
			zf[space-'a']++;
			if(zf[space-'a']>=4)
			{
				zf[space-'a']-=4;
				pp[4]++;
			}
		}
		scanf("%c",&space);
	}
	for(int i=0;i<26;i++)
	{
		if(zf[i]%2==1)
		{
			zf[i]--;
			pp[1]++;
		}
		if(zf[i]==2)
			pp[2]++;
	}
	int flag=0;
	if(n%2==1)
		flag++;
	if(m%2==1)
		flag++;
	if(flag==0)
	{
		if(pp[4]>=n/2*m/2)
			printf("Yes");
		else
			printf("No");
	}
	if(flag==1)
	{
		if(pp[4]>=(n/2)*(m/2)&&pp[1]==0)
			printf("Yes"); 
		else
			printf("No");
	}
	if(flag==2)
	{
		if(pp[1]==1 && pp[4]>=(n/2)*(m/2))
			printf("Yes");
		else
			printf("No");
	}
	printf("\n");
	return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;


int main(void){
    int n;
    cin >> n;
    VI vec(n);
    REP(i, n){
        cin >> vec.at(i);
    }
    int ans = 0;
    
    FOR(i,0,n-2){
        if( ( vec.at(i) < vec.at(i+1) && vec.at(i+1) < vec.at(i+2) )|| ( vec.at(i+2) < vec.at (i+1)  && vec.at(i+1)< vec.at(i) )) {
            ans++;
        }
    }
    
    cout << ans;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<unordered_map>
#define Arena                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
using namespace std;
// int i = 0, j = 0;

int main()
{
    Arena

        int n;
    cin >> n;
    unordered_map<string, int> m;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << m.size() << endl;

    return 0;
}


Measured memory_bytes: 16920
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <sstream>
#include <cctype>
#include <climits>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <vector>
#include <iterator>
#include <algorithm>
#include <stack>
#define _clr(x,y) memset(x,y,sizeof(x))
#define _inf(x) memset(x,0x3f,sizeof(x))
#define pb push_back
#define mp make_pair
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
typedef long long LL;
int main()
{
	//ios_base::sync_with_stdio(false);cin.tie(0);
	#ifndef ONLINE_JUDGE
		//freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
	
	int n,ans=0,cnt=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I') cnt++;
		else cnt--;
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;

int n;
int c[1002], w[1002];
bool f[1002][1002];
int dp[1002];
int wsum[1002];

void init()
{
	c[0] = c[n + 1] = -INF;
	w[0] = w[n + 1] = INF;
	fill((int *)dp, (int *)dp + sizeof(dp) / sizeof(int), INF);
	dp[0] = 0;
	for (int i = 1; i <= n; i++) f[i][i] = true;
}

int main()
{
	scanf("%d", &n);
	init();
	
	for (int i = 1; i <= n; i++){
		scanf("%d %d", &c[i], &w[i]);
		wsum[i] += wsum[i - 1] + w[i];
	}
	
	for (int t = 0; t <= n; t++){
		for (int i = 1; i + t <= n; i++){
			int a = i, b = i + t;
			int sum = wsum[b] - wsum[a - 1];
			if (!f[a][b]) continue;
			if (sum <= c[a - 1]) f[a - 1][b] = true;
			if (sum <= c[b + 1]) f[a][b + 1] = true;
		}
	}
	
	for (int i = 1; i <= n; i++){
		for (int t = 0; i + t <= n; t++){
			int a = i, b = i + t;
			if (f[a][b]) dp[b] = min(dp[b], dp[a - 1] + 1);
		}
	}
	
	printf("%d\n", dp[n]);
}

Measured memory_bytes: 2184
#include <stdio.h>
#include <string.h>
int main(void)
{
	char a[101],b[101];
	int A,B,c;
	scanf("%s%s",a,b);
	
	A=strlen(a);
	B=strlen(b);
	
	if(A>B){
		c=1;
	}else if(A<B){
		c=2;
	}else{
		if(strcmp(a,b)>0){
			c=1;
		}else if(strcmp(a,b)<0){
			c=2;
		}else if(strcmp(a,b)==0){
			c=3;
		}
	}
	if(c==1){
		printf("GREATER\n");
	}else if(c==2){
		printf("LESS\n");
	}else if(c==3){
		printf("EQUAL\n");
	}
	return 0;
}

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

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> X(M);
  if(M != 1) {
    if(N < M) {
      vector<ll> d(M - 1);
      for(ll i = 0; i < M; i++) cin >> X.at(i);
      sort(X.begin(), X.end());
      ll ans = X.at(M - 1) - X.at(0);
      for(ll i = 0; i < M - 1; i++) d.at(i) = X.at(i + 1) - X.at(i);
      sort(d.begin(), d.end());
      for(ll i = 0; i < N - 1; i++) ans -= d.at(M - 2 - i);
      cout << ans << endl;
    }
    else cout << 0 << endl;
  }
  else cout << 0 << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <limits>
using namespace std;

#define SZ(a) (int)(a).size()
using ll = long long;

vector<ll> f(vector<ll> a) {
    int n = SZ(a);
    vector<ll> b(n + 1);
    b[n] = 0;
    if (n > 1) b[n - 1] = 0;
    ll s = 0;
    stack<pair<int, int>> stk;
    for (int i = n - 2; i >= 0; i--) {
        // printf("%d\n", i);
        auto x = a[i];
        auto y = a[i + 1];
        int cnt = 0;
        while (y < x) {
            y *= 4;
            cnt++;
        }
        while (cnt > 0) {
            if (stk.empty()) {
                s += (ll)(n - i - 1) * cnt * 2;
                cnt = 0;
            } else {
                auto &p = stk.top();
                auto j = p.first;
                auto &c = p.second;
                int c1 = min(cnt, c);
                s += (ll)(j - i - 1) * c1 * 2;
                cnt -= c1;
                c -= c1;
                if (c == 0) {
                    stk.pop();
                }
            }
        }
        b[i] = s;
        x = a[i];
        y = a[i + 1];
        int cnt1 = 0;
        while (y >= 4 * x) {
            x *= 4;
            cnt1++;
        }
        if (cnt1 > 0) {
            stk.emplace(i + 1, cnt1);
        }
    }
    return b;
}

int main() {
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    auto b = f(a);
    reverse(begin(a), end(a));
    auto c = f(a);
    ll ans = numeric_limits<ll>::max();
    // for (int i = 0; i <= n; i++) {
    //     cerr << b[i] << " ";
    // }
    // cerr << "\n";
    // for (int i = 0; i <= n; i++) {
    //     cerr << c[i] << " ";
    // }
    // cerr << "\n";
    for (int i = 0; i <= n; i++) {
        ans = min(ans, b[i] + c[n - i] + i);
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main(){

    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;

    if(A >= B && A >= C) for(int i = 0; i < K; i++) A *= 2;
    else if(B >= C && B >= A) for(int i = 0; i < K; i++) B *= 2;
    else if(C >= A && C >= B) for(int i = 0; i < K; i++) C *= 2;

    cout << A + B + C << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;
char a[999][999];
int main()
{     int m,n,i,j;
      cin>>n>>m;
      for(i=0;i<=n+1;i++)
         for(j=0;j<=m+1;j++)a[i][j]='#';
      for(i=1;i<=n;i++)
         for(j=1;j<=m;j++)cin>>a[i][j];
      for(i=0;i<=n+1;i++)
         {for(j=0;j<=m+1;j++)cout<<a[i][j];
          cout<<endl;}
	  return 0;
}


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

static const int MAX_NUM = 251;

int main(void)
{
    int i;
    int tmp;
    int num;
    int elem[MAX_NUM];

    scanf("%d", &num);
    for (i = 1; i <= num; i++) {
        scanf("%d", &elem[i]);
    }

    for (i = 1; i <= num; i++) {
        printf("node %d: key = %d, ", i, elem[i]);
        if (i > 1) {
            printf("parent key = %d, ", elem[i / 2]);
        }
        tmp = i * 2;
        if (tmp <= num) {
            printf("left key = %d, ", elem[tmp]);
        }
        ++tmp;
        if (tmp <= num) {
            printf("right key = %d, ", elem[tmp]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 1196
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 0
    if all(s.count(c) > 0 for c in "753"):
        ret += 1
    for c in "753":
        ret += dfs(s + c)
    return ret

print(dfs("0"))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<pair<int, int> > edges;
  if(s[n-1] == '1' || s[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  REP(i, 1, n) {
    if(s[i-1] != s[n-1-i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<int> j(n, n-1);
  int tmp = n-1;
  for(int i=n-1; i>=0; i--) {
    j[i] = tmp;
    if(s[i] == '1') tmp = i;
  }
  rep(i, n-1)
    edges.push_back(make_pair(i+1, j[i]+1));
  for(auto e: edges)
    cout << e.first << ' ' << e.second << endl;
  return 0;
}



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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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 = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

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

void solve() {
    ll n, m, l;
    cin >> n >> m >> l;
    vector<vector<ll>> g(n, vector<ll>(n, (ll)INF * INF));
    vector<vector<ll>> h(n, vector<ll>(n, (ll)INF * INF));
    REP(i, n) {
        g[i][i] = 0;
        h[i][i] = 0;
    }
    int a, b;
    ll c;
    REP(i, m) {
        cin >> a >> b >> c;
        a--; b--;
        if (c > l) continue;
        g[a][b] = c;
        g[b][a] = c;
    }

    REP(k, n) {
        REP(i, n) {
            REP(j, n) {
                g[i][j] = min(g[i][j] ,g[i][k] + g[k][j]);
            }
        }
    }

    REP(i, n) REP(j, n) {
        if (i == j) continue;
        if (g[i][j] <= l) {
            h[i][j] = 1;
        }
    }
    
    REP(k, n) {
        REP(i, n) {
            REP(j, n) {
                h[i][j] = min(h[i][j] ,h[i][k] + h[k][j]);
            }
        }
    }

    int q;
    cin >> q;
    int s, t;
    REP(i, q) {
        cin >> s >> t;
        s--; t--;
        if (g[s][t] == (ll)INF * INF) {
            cout << -1 << EOL;
            continue;
        }
        cout << h[s][t] - 1 << EOL;
    }
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int a, b, c, x, i, j, k, cnt=0;
    scanf("%d%d%d%d", &a, &b, &c, &x);
    for (i=0; i <= a && 500*i<=x; i++)
    {
        for (j=0; j <= b && 100*j+500*i<=x; j++)
        {
            for (k=0; k <= c && 50*k+100*j+500*i<=x; k++)
            {
                if (500*i+100*j+50*k==x)
                {
                    cnt++;
                }
            }
        }
    }

    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define N_MAX 100000

bool BinarySearch(int* pArray, int size, int key)
{
	bool bIsFind = false;

	int left = 0, right = size - 1;
	int middle = 0;
	
	while (left <= right)
	{
		middle = (left + right) >> 1;
		if (pArray[middle] == key) 
		{
			bIsFind = true; break;
		}
		else if (pArray[middle] > key) right = --middle;
		else left = ++middle;
	}

	return bIsFind;
}

int main()
{
	int count = 0;
	int n, S[N_MAX];
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> S[i];
	int q, key;
	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		cin >> key;
		if (BinarySearch(S, n, key)) ++count;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1001001001;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    ll m = INF;
    int index = -1;
    rep(i, n) {
        if (abs(a[i])<m) {
            m = abs(a[i]);
            index = i;
        }
    }
    rep(i, n) ans += abs(a[i]);
    for (int i=0; i<index; i++) {
        if (a[i]<0) {
            a[i] *= -1;
            a[i+1] *= -1;
        }
    }
    for (int i=n-1; i>index; i--) {
        if (a[i]<0) {
            a[i-1] *= -1;
            a[i] *= -1;
        }
    }
    if (a[index]<0) ans -= m*2;
    
    cout << ans << endl;
    return 0;
}


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


int main() {
    ll N, A, B;

    cin >> N >> A >> B;

    ll sum = A + B;
    ll rem = N%sum;

    if(rem > A) rem = A;

    ll ans = 0;
    ans = N/sum * A + rem;

    cout << ans << endl;
    
    
    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(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    vector<int> n(3);
    rep (i, 3) cin >> n.at(i);

    sort(n.begin(), n.end());

    cout << n.at(0) << " " << n.at(1) << " " << n.at(2) << endl;
}


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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int mod = 0;
  if(N%X == 0) {
    mod = N/X;
  } else {
    mod = N/X + 1;
  }
  cout << mod * T << endl;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> dp(n + 10, INF);
  dp[0] = 0;
  rep(i, n) {
    cmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
    cmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1792
n=int(input())
L=[[list(map(int,input().split())) for _ in range(int(input()))] for _ in range(n)]
a=0
for i in range(1, 2**n):
  f=True
  for j in range(n):
    if (i>>j)&1==0:
      continue
    for x,y in L[j]:
      if (i>>(x-1))&1!=y:
        f=False
        break
    if not f:
      break
  if f:
    a=max(a, bin(i)[2:].count('1'))
print(a)        


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, s, ans=0, min=101;
    cin >> n;
    vector<int> dp(n);
    for (int i=0; i<n; i++)
    {
        cin >> s;
        ans+=s;
        if (s%10!=0 && min>s) min=s;
    }
    if (ans%10!=0)cout << ans << endl;
    else if (min==101) cout << 0 << endl;
    else cout << ans-min << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,D; cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for(int i = 0; i < N; i++)
	{
        for(int j = 0; j < D; j++)
		{
            cin >> X[i][j];
        }
    }
    int ans = 0;
    int sum;
    int sa;
    for(int i = 0; i < N; i++)
	{
        for(int j = i+1; j < N; j++)
		{
            sum = 0;
            for(int k = 0; k<D; k++)
			{
                sa =X[i][k]-X[j][k];
                sum+=sa*sa;
            }
            int r =sqrt(sum);
            if(r*r==sum) ans++;
        }
    }
    cout << ans << endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    for(ll n = 1 ; n <= 3500 ; n++) for(ll h = 1 ; h <= 3500 ; h++){        
        if((4*h*n-N*n-N*h) > 0 && (N*h*n)%(4*h*n-N*n-N*h)==0){
            ll w = (N*h*n)/(4*h*n-N*n-N*h);
            cout << n << " " << h << " " << w << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long calc_next(long x, long r, long D){
    return r*x-D;
}

int main(void){
    int N, M, R, L, max_L=-1, min_R=1000000;
    std::cin >> N >> M;
    
    for(int i=0; i<M; ++i){
        std::cin >> L >> R;
        if(max_L < L)
            max_L = L;
        if(min_R > R)
            min_R = R;
    }
    
    if(max_L > min_R)
        std::cout << "0" << std::endl;
    else
        std::cout << min_R-max_L+1 << std::endl;
    return 0;
}


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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int N, M;
vi A, B, C, D;

void calcL1Norm(int x, int y){
    int tmp = INF;
    int res, dist;

    rep(i, M){
        dist = abs(x - C[i]) + abs(y - D[i]);
        if(dist < tmp){
            tmp = dist;
            res = i;
        }
    }
    cout << res+1 << endl;
}

void solve(){
        rep(i, N) calcL1Norm(A[i], B[i]);
}

int main(){
    cin >> N >> M;
    
    A.resize(N, 0);
    B.resize(N, 0);
    rep(i, N) cin >> A[i] >> B[i];

    C.resize(M, 0);
    D.resize(M, 0);
    rep(i, M) cin >> C[i] >> D[i];

    solve();
}


Measured memory_bytes: 760
import sys
input = sys.stdin.readline

A ,B, K = map(int,input().split())

# for i in range(K):
#     if A > 0:
#         A -= 1
#     elif B > 0:
#         B -= 1

if A + B <= K:
    A = 0
    B = 0

elif A <= K:
    B = B - K + A
    A = 0
    

elif A > K:
    A = A - K 

print(A,B)

Measured memory_bytes: 3188
n = int(input())
inList = [input() for i in range(n)]
cntList = [0, 0, 0, 0]
for i in inList:
    if i == 'AC':
        cntList[0] += 1
    elif i == 'WA':
        cntList[1] += 1
    elif i == 'TLE':
        cntList[2] += 1
    elif i == 'RE':
        cntList[3] += 1
print('AC x '+str(cntList[0]))
print('WA x '+str(cntList[1]))
print('TLE x '+str(cntList[2]))
print('RE x '+str(cntList[3]))

Measured memory_bytes: 16304
#include<bits/stdc++.h>
using namespace std;
int k,s,sum=0;
int main(){
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(s-x-y>=0&&s-x-y<=k) sum++;}}
    cout<<sum<<endl;
    return 0;
}

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

int main() {
	string a;
	cin >> a;
	if (a == "a" || a == "i" || a == "u" || a == "e" || a == "o") {
		cout << "vowel" << endl;
	}
	else
		cout << "consonant" << endl;
	
}

Measured memory_bytes: 3608