akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
import numpy as np
n, k = map(int, stdin.buffer.readline().split())
a = np.array(stdin.buffer.read().split(), dtype=np.int64)

ng = 0
ok = 10 ** 9 + 1
while ok - ng > 1:
    mid = (ok + ng) >> 1
    if np.sum(np.ceil(a / mid) - 1) <= k:
        ok = mid
    else:
        ng = mid
print(ok)


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


N=int(input())
A=list(map(int,input().split()))
A.sort()
ANS=[]

from collections import deque
X=deque(A)

while X[0]>=0 and len(X)>=3:
    x=X.popleft()
    z=X.pop()
    ANS.append([x,z])
    X.appendleft(x-z)

if len(X)==2:
    x=X[0]
    z=X[-1]

    ANS.append([z,x])
    print(z-x)
    for ans in ANS:
        print(*ans)
    sys.exit()
    




if X[0]<0:
    
    
    z=X.popleft()

    Y=[]
    while len(X)>=2:
        x=X.popleft()
        if x<0:
            Y.append(x)
        else:
            ANS.append([z,x])
            z=z-x

    x=X.pop()
    for y in Y:
        ANS.append([x,y])
        x-=y

    ANS.append([x,z])
    x-=z

    print(x)
    for ans in ANS:
        print(*ans)


    
            


Measured memory_bytes: 71584
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
		tree_order_statistics_node_update> indexed_multiset;

int n , k;
vector<int>vi;
set<int>s;
map<int,int>mp;
int main(){
	cin>>n>>k;
	for(int i = 0; i <n ; i++){
		int  x ; cin>>x;
		mp[x]++;
		s.insert(x);
	}
	for(auto it: s){
		vi.push_back(mp[it]);
	}
	sort(vi.rbegin() , vi.rend());
	int cnt = 0;
	for(int i = 0; i< min(k,(int)vi.size()) ; i++ ){
		cnt+=vi[i];
	}cout<<n-cnt;
   	return 0;	
}


Measured memory_bytes: 20092
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a) for(int i=(a);;++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    int num_sec[N]={};
    FOR(i, 0, N){
        cin >> num_sec[i];
    }
    sort(num_sec, num_sec+N);
    long long sum=0;
    FOR(i, 0, N){
        sum += num_sec[i];
    }
    cout << num_sec[0] << " " << num_sec[N-1] << " " << sum << endl;
    
}





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

int main() {
    int K, S;
    cin >> K >> S;

    int ans = 0;
    for (int x = 0; x <= K; x++){
        for (int y = 0; y <= K; y++){
            if (S - (x + y) >= 0 && S - (x + y) <= K){
                ans++;
            }
        }
    }

    cout << ans <<endl;
}

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

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(intmax_t, x);

    reps(i, 1, 1e6) {
        if (i * 100 <= x && x <= i * 105) {
            return output(1), 0;
        }
    }

    output(0);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct gNode{
  int key, priority;
  struct gNode *left;
  struct gNode *right;
}gNode;
gNode * del(gNode **,int);
gNode * _delete(gNode **,int);
int find(gNode *p,int x){
  while(p != NULL){
    if(p->key == x) return 1;
    else if(p->key > x) p = p->left;
    else p = p->right;
  }
  return 0;
}
void Inorder(gNode *p){
  if(p->left != NULL) Inorder(p->left);
  printf(" %d", p->key);
  if(p->right != NULL) Inorder(p->right);
  return;
}
void Preorder(gNode *p){
  printf(" %d", p->key);
  if(p->left != NULL) Preorder(p->left);
  if(p->right != NULL) Preorder(p->right);
  return;
}
void print(gNode *p){
  Inorder(p);
  printf("\n");
  Preorder(p);
  printf("\n");
  return;
}
gNode * Make_node(int x,int y){
  gNode *new = malloc(sizeof(gNode));
  new->key = x;
  new->priority = y;
  new->left = NULL;
  new->right = NULL;
  return new;
}
gNode *R_R(gNode *p){
  gNode *q = p->left;
  p->left = q->right;
  q->right = p;
  return q;
}
gNode *L_R(gNode *p){
  gNode *q = p->right;
  p->right = q->left;
  q->left = p;
  return q;
}
gNode* Ins(gNode **t, int key, int priority){
  gNode *new;
  if((*t) == NULL)
    return new = Make_node(key,priority);
  if ((*t)->key == key)
    return *t;
  if(key < (*t)->key){
    (*t)->left = Ins(&(*t)->left, key, priority);
    if((*t)->priority < (*t)->left->priority)
      (*t) = R_R((*t));
  }
  else {
    (*t)->right = Ins(&(*t)->right, key, priority);
    if((*t)->priority < (*t)->right->priority)
      (*t) = L_R((*t));
  }
  return *t;
}
gNode * del(gNode **t, int key){
  if((*t) == NULL)
    return NULL;
  if(key < (*t)->key)
    (*t)->left = del(&((*t)->left),key);
  else if(key > (*t)->key)
    (*t)->right = del(&((*t)->right),key);
  else return _delete(t,key);
  return *t;
}
gNode * _delete(gNode **t,int key){
  if((*t)->left == NULL && (*t)->right == NULL)
    return NULL;
  else if((*t)->left == NULL)
    (*t) = L_R(*t);
  else if((*t)->right == NULL)
    (*t) = R_R(*t);
  else {
    if((*t)->left->priority > (*t)->right->priority)
      (*t) = R_R(*t);
    else
      (*t) = L_R(*t);
  }
  return del(t,key);
}
int main(){
  int i;
	int n, x, y;
  char com[8];
  gNode *r = NULL;
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++){
    scanf("%s", com);
    switch(com[0]){
    case 'i':scanf("%d %d", &x, &y);
      r = Ins(&r, x, y);
      break;
    case 'd':scanf("%d", &x);
      r = del(&r, x);
      break;
    case 'f':scanf("%d", &x);
      if(find(r,x)) printf("yes\n");
      else printf("no\n");
      break;
    case 'p':print(r);
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 8108
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int cnt = 0;
    
    cin >> N;
    
    for(int i=1; i<=N; i++){
        if(i < 10)  cnt++;
        else if(i >= 100 && i < 1000)   cnt++;
        else if(i >= 10000 && i < 100000)   cnt++;
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  string s,t;
  cin>>s;
  cin>>t;

  vector< vector< ll > > dp(3002,vector<ll>(3002,0));

  string lcs;

  rep(i,s.size()+1){
    rep(j,t.size()+1){

      if(s[i] == t[j]){
        dp[i+1][j+1] = max({dp[i][j]+1,dp[i][j+1],dp[i+1][j]});

      }
      else{
        dp[i+1][j+1] = max({dp[i][j+1],dp[i+1][j]});
      }

    }
  }

  rep(i,s.size()+1){
    rep(j,t.size()+1){
      //cout << dp[i][j] << " ";
    }
    //cout << endl;
  }

  ll i=s.size(),j=t.size();
  ll cnt=dp[i][j];
  if(cnt==0){
    cout << "" << endl;
    return 0;
  }
  while(i>0 && j>0){

    while(cnt==dp[i][j-1] && j>1) j--;
    while(cnt==dp[i-1][j] && i>1) i--;

    lcs+=s[i-1];
    //cout << i << "," << j << endl;
    //cout << s[i-1] << "," << t[j-1] << endl;
    i--;
    j--;
    cnt--;
    if(cnt==0) break;

  }

  reverse(all(lcs));

  cout << lcs << endl;

  return 0;

}


Measured memory_bytes: 70784
n, a, b = map(int, input().split())
l = input()
num_d = num_i = 0
for i in range(n):
    if l[i] == 'c':
        print('No')
    elif l[i] == 'a':
        if num_d+num_i < a+b:
            print('Yes')
            num_d += 1
        else:
            print('No')
    else:
        if num_d+num_i < a+b:
            if num_i < b:
                print('Yes')
                num_i += 1
            else:
                print('No')
        else:
            print('No')

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

using namespace std;

int n, ans;

vector<int> vec, a(205);

int main() {
    cin >> n;
    vec.resize(n * 2);
    n *= 2;
    for (auto &it : vec) {
        cin >> it;
    }
    sort(vec.begin(), vec.end());
    for (int i = 0; i < n; i += 2) {
        ans += vec[i];
    }
    cout << ans;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
tran=[INT() for i in range(5)]
print(5-1+ceil(N, min(tran)))


Measured memory_bytes: 3064
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

// const ll DIV = (ll)8e3+7;
const ll MAXN = (ll)8e3+7;

vector<pair<int,int>> A;
double dis(int i,int j){
   double ret = 0;
   ret += pow(A[i].first - A[j].first,2);
   ret += pow(A[i].second - A[j].second,2);
   return sqrt(ret);
}

int main(void) {
   ll N;
   cin>>N;
   rep(i,0,N) {
      int x,y;
      cin>>x>>y;
      A.push_back(make_pair(x,y));
   }
   double ans = 0;
   rep(i,0,N) rep(j,i+1,N) {
      // cout<<dis(i,j)<<endl;
      ans += dis(i,j);
   }
   ans *= 2;
   ans /= N;
   // cout<<ans<<endl;
   printf("%.10f\n",ans);



   return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
//const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
//ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a%mod; a = a * a%mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
// head

int t;
int k,q;
int d[5005];
ll sumd = 0;
int posd = 0;
int solve(ll n,ll x,int mod)
{
    posd=0;
    sumd=0;
    for(int i=0;i<k;++i){
        if(d[i]%mod) posd++;
        sumd += d[i]%mod;
    }
    ll a = (n-1)/k;
    ll am = (n-1)%k;
    ll cnt = sumd/mod;
    ll mm = sumd%mod;
    ll cntmod = cnt*a+(mm*a)/mod;
    ll ans = a*posd - cntmod;
    ll b = mm*a%mod;

    x%=mod;
    if(x+b >= mod) ans--;
    x = (x+b)%mod;
    for(int i=0;i<am;++i) {
        ll y = (x+d[i])%mod;
        if(x<y) ans++;
        x=y;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
#ifdef RG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin>>k>>q;
    sumd=0;
    posd=0;
    for(int i=0;i<k;++i) {
        cin>>d[i];
    }
    int n,x,mod;
    for(int i=0;i<q;++i) {
        cin>>n>>x>>mod;
        cout<<solve(n,x,mod)<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

void trace(int A[], int N){
    int i;
    for( i = 0; i < N; i++){
        if(i > 0)printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N){
    int j, i, v;
    for( i=1; i < N; i++){
        v = A[i];
        j = i - 1;
        while( j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace( A, N);
    }
}

int main(){
    int N, i, j;
    int A[100];

    scanf("%d", &N);
    for( i=0; i < N; i++)scanf("%d", &A[i]);

    trace(A, N);
    insertionSort(A, N);

    return 0;
}


Measured memory_bytes: 2064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char[] a = scan.next().toCharArray();
		int[] alpha = new int[1000];
		for (int i = 0; i < a.length; i++) {
			alpha[a[i]]++;
			if (alpha[a[i]] > 1) {
				System.out.println("no");
				return;
			}
		}
		System.out.println("yes");
	}
}


Measured memory_bytes: 21844
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def main():
    k = II()
    sumv = 0
    # (a,a,a)
    for i in range(1, k+1):
        sumv += i
    # (a,a,b)
    for a in range(1, k):
        for b in range(a+1, k+1):
            sumv += 6*gcd(a, b)
    # (a,b,c)
    for a in range(1, k-1):
        for b in range(a+1, k):
            for c in range(b+1, k+1):
                sumv += 6*gcd(gcd(a, b), c)
    print(sumv)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73728
#include <iostream>
#pragma warning(disable : 4996)
using namespace std;
pair<int, long long> par[100000];
pair<int, long long> root(int x) {
	if (par[x].first == x) return par[x];
	pair<int, long long> ret = root(par[x].first);
	return par[x] = make_pair(ret.first, ret.second + par[x].second);
}
bool same(int x, int y) {
	return root(x).first == root(y).first;
}
void unite(int x, int y, int w) { 
	pair<int, long long> tx = root(x);
	pair<int, long long> ty = root(y);
	if (tx.first != ty.first) {
		par[tx.first] = make_pair(ty.first, ty.second - tx.second + w);
	}
}
long long query(int a, int b) {
	return root(a).second - root(b).second;
}
int N, Q, a, b, w; char c;
int main() {
	while (true) {
		scanf("%d%d", &N, &Q);
		if (N == 0 && Q == 0) break;
		for (int i = 0; i < N; i++) par[i] = make_pair(i, 0);
		for (int i = 0; i < Q; i++) {
			cin >> c;
			if (c == '!') {
				scanf("%d%d%d", &a, &b, &w);
				unite(a - 1, b - 1, w);
			}
			else {
				scanf("%d%d", &a, &b);
				if (!same(a - 1, b - 1)) {
					printf("UNKNOWN\n");
				}
				else {
					printf("%lld\n", query(a - 1, b - 1));
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 6728
using System;
using System.Collections.Generic;

namespace abc173_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var H = CIn.ReadInt();
      var W = CIn.ReadInt();
      var K = CIn.ReadInt();
      var c = CIn.ReadCharMatrix(H, W);

      var hp = Math.Pow(2, H);
      var wp = Math.Pow(2, W);

      var ans = 0;

      for (int i = 0; i < hp; i++)
      {
        for (int j = 0; j < wp; j++)
        {
          var n = 0;

          for (int k = 0; k < H; k++)
          {
            for (int l = 0; l < W; l++)
            {
              if (c[k, l] == '#' && ((i >> k) & 1) == 0 && ((j >> l) & 1) == 0)
              {
                n++;
              }
            }
          }

          if (n == K) ans++;
        }
      }

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 28240
#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.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int alice = 0, bob = 0;
  for(int i = 0; i < N; i++)
  {
    if(i % 2 == 0)
      alice += a.at(i);
    else
      bob += a.at(i);
  }
  
  cout << abs(alice - bob) << endl;
}

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

int mem[100005]={-1};
vector<int> frog;

int dp(int n)
{
	if(n<0){
		return 0;
	}
	if(n==0){
		return 0;
	}
	if(n==1){
		return abs(frog[1]-frog[0]);
	}
	if(mem[n]!=-1){
		return mem[n];
	}
	int x = dp(n-1);
	int y = dp(n-2);
	int cost = min(x+abs(frog[n]-frog[n-1]),y+abs(frog[n]-frog[n-2]));
	mem[n]=cost;
	return cost;
}

int main()
{
	int n;
	cin>>n;
	memset(mem,-1,sizeof(mem));
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		frog.push_back(x);
	}
	cout<<dp(n-1);
	return 0;
}

Measured memory_bytes: 8856
#include<algorithm>
#include<iostream>
#include<set>
#include<vector>
using namespace std;
int n,s;
vector<vector<vector<int>>> dp;
int DP(int nn,int ss,int k){
  //cout<<nn<<" "<<ss<<" "<<k<<endl;
  if(nn==0)return ss==0;
  if(ss<0 || s<ss || n>10 )return 0;
  if(dp[nn][ss][k]!=-1)return dp[nn][ss][k];
  dp[nn][ss][k]++;
  for(int i=0;i<10;i++){
    if(!(k&(1<<i)))dp[nn][ss][k]+=DP(nn-1,ss-nn*i,k+(1<<i));
  }
  return dp[nn][ss][k];
}
 
int solve(){
  return DP(n,s,0);
}
 
int main(){
  dp.resize(11);
  for(int i=0;i<dp.size();i++){
    dp[i].resize(1*1+2*2+3*3+4*4+5*5+6*6+7*7+8*8+9*9+100);
    for(int j=0;j<dp[i].size();j++){
      dp[i][j].resize(1<<10);
      for(int k=0;k<dp[i][j].size();k++){
        dp[i][j][k]=-1;
      }
    }
  }
  while(cin>>n>>s){
    if(s<dp[0].size()){
      cout<<solve()<<endl;
    }else{
      cout<<0<<endl;
    }
  }
}

Measured memory_bytes: 18160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string S;
  cin >> S;
  int ssize = (int)S.size();
  vector<bool> dp(ssize+10,false);
  dp[0] = true;
  rep(i,ssize){
    if(dp[i]){
      if(S.substr(i,5) == "dream" || S.substr(i,5) == "erase"){
        dp[i+5] = true;
      }
      if(S.substr(i,7) == "dreamer"){
        dp[i+7] = true;
      }
      if(S.substr(i,6) == "eraser"){
        dp[i+6] = true;
      }
    }
  }
  if(dp[ssize]) cout  << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++)cin >> vec[i];
	cin >> n;

	int counter = 0;
	for (int i = 0; i < n; i++) {
		int t;cin >> t;
		if (find(vec.begin(), vec.end(), t) != vec.end()) {
			counter++;
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 3120
using System;
using System.Collections.Generic;

namespace cswork {
    class Program {
        static void Main (string[] args) {
            // Contest166.Q3 ();

            List<int> line = GetListInt (Read (), " ");
            int n = line[0];
            int m = line[1];

            List<int> h = GetListInt (Read (), " ");

            List<int>[] list = new List<int>[n];
            for (int i = 0; i < n; i++) {
                list[i] = new List<int> ();
                list[i].Add (i);
            }

            for (int i = 0; i < m; i++) {
                line = GetListInt (Read (), " ");
                int ai = line[0];
                int bi = line[1];

                list[ai - 1].Add (bi - 1);
                list[bi - 1].Add (ai - 1);
            }

            int count = 0;
            for (int i = 0; i < n; i++) {
                bool isTop = true;
                for (int j = 1; j < list[i].Count; j++) {
                    if (h[list[i][0]] <= h[list[i][j]]) {
                        isTop = false;
                        break;
                    }
                }

                if (isTop) {
                    count++;
                }
            }

            Write (count);

            Exit ();
        }

        public static void Q2 () {
            List<int> line = GetListInt (Read (), " ");
            int n = line[0];
            int k = line[1];

            bool[] array = new bool[n];
            for (int i = 0; i < k; i++) {
                int d = ReadInt ();
                List<int> list = GetListInt (Read (), " ");
                for (int j = 0; j < list.Count; j++) {
                    array[list[j] - 1] = true;
                }
            }

            int count = 0;
            for (int i = 0; i < n; i++) {
                if (!array[i]) {
                    count++;
                }
            }

            Write (count);
            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string Read () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> GetList (string str, string delim) {
            return new List<string> (str.Split (delim));
        }

        public static List<int> GetListInt (string str, string delim) {
            List<string> list = new List<string> (str.Split (delim));
            return list.ConvertAll (x => int.Parse (x));
        }
    }
}

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

typedef vector<int> 	vi;
typedef vector<vi>		vvi;
typedef long long int	ll;

void dfs(vvi &adj_list, int s, vi &color){
	color[s] = 1;
	for(int nbour : adj_list[s]){
		if(!color[nbour])
			dfs(adj_list, nbour, color);
	}
}

int main(){

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

	int n, m;
	cin >> n >> m;

	vvi adj_list(n, vi());
	int x, y, z;
	for(int i = 0; i < m; i++){
		cin >> x >> y >> z;
		adj_list[x - 1].push_back(y - 1);
		adj_list[y - 1].push_back(x - 1);
	}

	vi color(n, 0);
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(!color[i]){
			dfs(adj_list, i, color);
			ans++;
		}
	}
	cout << ans;

	return 0;
}

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

int main() {
   int n;
   cin >> n;
   set<string>st;
   string ans="Yes";
   char l,r;
   rep(i,n){
      string s; cin >> s;
      r=s[0];  st.insert(s);
      if(i){
         if(l!=r)
         ans="No";
      }
      l=s[s.size()-1];
   }
   if(st.size()!=n)
   ans="No";

   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i,N) cin>>A[i];
    SORT(A);
    ll ans=0;
    if(N%2==0){
        rep(i,N/2-1){
            ans-=A[i]*2;
        }
        ans-=A[N/2-1];
        ans+=A[N/2];
        reps(i,N/2+1,N){
            ans+=A[i]*2;
        }
    }
    else{
        rep(i,N/2-1){
            ans-=A[i]*2;
        }
        reps(i,N/2+2,N){
            ans+=A[i]*2;
        }
        ll ans2=0,ans3=0;
        ans2=-A[N/2-1]-A[N/2]+A[N/2+1]*2;
        ans3=-A[N/2-1]*2+A[N/2]+A[N/2+1];
        ans+=max(ans2,ans3);
    }
    cout<< ans <<"\n";

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  
  int ans=1;
  int dai;
  cin>>dai;
  
  vector<int> p(n);
  repo(i,n){
  cin>>p[i];
    if(dai>p[i])ans++;
  dai=min(dai,p[i]);
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n, m; cin >> n;
  map<string, ll> score;
  REP(i, n){
    string s;
    cin >> s;
    score[s]++;
  }
  cin >> m;
  REP(i, m){
    string t;
    cin >> t;
    score[t]--;
  }

  ll ans = 0;
  FOREACH(x,score){
    ll tmp = x.second;
    ans = max(ans, tmp);
  }
  cout << ans << endl;

}

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

long long n,a,b;
const int MAXN = 212345;

long long m = 1e9 + 7;

long long inv[MAXN];
long long inverse_factorial[MAXN];

long long binomial_coefficient(int n, int k){
    long long prod = 1;
    for(int i=n;i>=n-k+1;i--) prod = (i*prod)%m;
    return (prod * inverse_factorial[k] % m)%m;
}

long long Pow(long long base,long long i){
    base %= m;
    if(i<=0) return 1;
    else if(i==1) return base;
    else{
        long long aux = Pow(base,i/2);
        if(i%2==0) return (aux*aux)%m;
        else return (base*((aux*aux)%m))%m;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    //freopen("input.txt","r",stdin);

    cin>>n>>a>>b;

    inv[1] = 1;
    for(int i = 2; i < MAXN; ++i)
        inv[i] = (m - (m/i) * inv[m%i] % m) % m;

    inverse_factorial[0] = inv[1];

    for(int i=1;i<MAXN;i++) inverse_factorial[i] = (inverse_factorial[i-1] * inv[i])%m;

    long long d = Pow(2,n);

    cout << (2*m + d - 1 - binomial_coefficient(n,a) - binomial_coefficient(n,b))%m;

}


Measured memory_bytes: 3584
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [list(map(int, input().split())) for i in range(M)]
# P[i][0] = P_(i + 1), P[i][1] = X_(i + 1) となる
# 例：　P[0][1] = P_1, P[2][1] = X_3

for i in range(M):
    updated_T = T[:]
    updated_T[P[i][0] - 1] = P[i][1]

    print(sum(updated_T))


Measured memory_bytes: 63556
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	string N;
	int N_int = 0;
	cin >> N;
	int S = 0;
	int i, j;
	N_int = atoi(N.c_str());
	for (i = 0; i < N.size(); ++i) {

		S += N[i]-48;
		//cout << N_int << endl;
	}
	if (N_int%S == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include<stdio.h>

int main() {
	char s[500][500];
	int n, m, num[500][500] = {};
	scanf("%d%d",&n,&m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf(" %c", &s[i][j]);
          	if(s[i][j]=='#'){
			num[i - 1][j]++;
			num[i - 1][j - 1]++;
			num[i - 1][j + 1]++;
			num[i][j + 1]++;
			num[i][j - 1]++;
			num[i + 1][j - 1]++;
			num[i + 1][j]++;
			num[i + 1][j + 1]++;
            }
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i][j] == '#') {
				printf("#");
			}
			else {
				printf("%d", num[i][j]);
			}
		}
		printf("\n");
	}
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  V<lint> w(n), d(n); for (int i = 0; i < n; ++i) cin >> w[i] >> d[i];
  auto chk = [&](lint mid) -> bool {
    lint s = 0;
    for (int i = 0; i < n; ++i) if (w[i] <= mid) {
      s += (mid - w[i]) / d[i] + 1;
      if (s >= k) return true;
    }
    return s >= k;
  };
  lint ng = 0, ok = 3e18;
  while (ok - ng > 1) {
    lint mid = (ng + ok) / 2;
    (chk(mid) ? ok : ng) = mid;
  }
  cout << ok << '\n';
}

Measured memory_bytes: 1792
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
sub = 999
ans = 0
l = []
for i in range(n):
    l.append(abs(t - h[i] * 0.006 - a))
    if sub >= l[i]:
        sub = l[i]
        ans = i + 1
print(ans)

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

using namespace std;

int main(){
  string S, T, U;
  int A, B, i;
  
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if(S == U){
    A--;
  }
  else{
    B--;
  }
  
  cout << A << ' ' << B << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,L;cin>>N>>L;
    L*=2;
    vector<ll> T(N);
    for(int i=0;i<N;i++){
        cin>>T[i];
        T[i]*=2;
    }
    
    double x=0.0,y=0.0;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) continue;
            ll a;
            if(i<j) a=N-(j-i+1);
            else a=i-j-1;
            
            if(i>j) T[j]+=L;
            
            x+=cos(M_PI*double(T[i]+T[j])/double(L))/(double(N*(N-1)*(N-2)/6))*double(a);
            y+=sin(M_PI*double(T[i]+T[j])/double(L))/(double(N*(N-1)*(N-2)/6))*double(a);
            
            if(i>j) T[j]-=L;
        }
    }
    
    cout<<setprecision(25)<<x<<" "<<y<<endl;
}



Measured memory_bytes: 4168
N, M = gets.split.map(&:to_i)
R = Hash.new {|h, i| h[i] = []}
M.times do
a, b, c = gets.split.map(&:to_i)
  R[a] << [b, c]
end

T = Array.new(N + 1, -Float::INFINITY)

def calc(node, step = 0, cost = 0, n_pass = 0)
  return true if cost <= T[node]
  return false if node == N && (n_pass == 1 || step >= N)
  return true if step >= 2 * N
  T[node] = cost
  np = node == N ? n_pass + 1 : n_pass
  R[node].all? {|b, c| calc(b, step + 1, cost + c, np)}
end

puts calc(1) ? T[N] : 'inf'

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll inv(ll x) {return power(x, MOD - 2);}
const int MAXN = 1e5 + 5;
//const bool is_in = container.find(element) != container.end();
int main()
{
	zapp;
	ll s,w;
	cin>>s>>w;
	if(w>=s)
		cout<<"unsafe";
	else
		cout<<"safe";

	return 0;
}

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

int main() {
	int n; cin>>n;
	long long sum = 0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			int x = __gcd(i,j);
			for(int k=1; k<=n; k++){
				sum += __gcd(x,k);
			}
		}
	}
	cout<<sum<<endl;
}

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

int main(void) {
    
    string s,t;
    cin>>s>>t;
    int n = t.length();
    string s1=t.substr(0,n-1);
    if(s1==s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	// your code goes here
	return 0;
}



Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a<b)
        if(b<c)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    else
        cout << "No" << endl;
        
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define Swap(a,b) {int temp=a;a=b;b=temp;}
typedef long long ll;
typedef unsigned long long ull;
#pragma GCC optimize(3,"Ofast","inline")
unordered_map<int,int> primes;

void get_primes(int x){
    for(int i=2;i<=x/i;i++){
        int res=0;
        while(x%i==0){
            x/=i;
            res++;
        }
        if(res) primes[i]+=res;
    }
    if(x>1) primes[x]++;
}

int main(){
    ll n,cnt=0;
    scanf("%lld",&n);
    for(ll i=1;i<n;i++){
        ll mul=n-i;
        primes.clear();
        get_primes(mul);

        ll ans=1;
        for(auto prime:primes){
            int a=prime.se;
            ans=(ans*(a+1));
        }
        cnt+=ans;
    }
    printf("%lld",cnt);
}


Measured memory_bytes: 3788
#include <stdio.h>

int area(int j,int d);
int main(void) {
	int x, s, d, i, j;
	while(scanf("%d", &d) !=EOF){
		x = 600 / d;
		s = 0;
		for (j = 1; j < x; j++) {
			s += area(j,d);
		}
		printf("%d\n", s);
	}
	return 0;
}
int area(int j,int d) {
	return d*(j*d)*(j*d);
}


Measured memory_bytes: 2120
//
// Created by Wangzhe on 2019/10/19.
//

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 1e5 + 10, INF = 1e18;


int main() {
    ll a, b; cin >> a >> b;
    ll c = a - 2 * b;
    if (c < 0) cout << 0 << endl;
    else cout << c << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  set<int> st;
  repp(i,1,10) repp(j,1,10) st.insert(i*j);
  YesNo(st.count(N));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
    int n, l = 0;
    cin >> n;
    vector<long long> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    long long m = 1;
    for (int i = 0; i < n; i++) {
        if (9223372036854775807 / m < s[i]) {
            m = -1;
            l = i;
            break;
        }
        m = m * s[i];
        if (m > 1000000000000000000) {
            m = -1;
            l = i;
            break;
        }
    }
    for (int i = l; i < n; i++) {
        if (l == 0) {
            break;
        } else if (s[i] == 0) {
            m = 0;
            break;
        }
    }

    cout << m << endl;
    return 0;
}

Measured memory_bytes: 3996
// Dmitry _kun_ Sayutin (2019)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

bool dfs(int v, vector<vector<int>>& mat, vector<char>& used, vector<int>& rpair) {
    used[v] = 1;
    
    for (int u = 0; u != SZ(mat); ++u)
        if (mat[v][u] != -1 and rpair[u] == -1) {
            rpair[u] = v;
            return true;
        }

    for (int u = 0; u != SZ(mat); ++u)
        if (mat[v][u] != -1 and not used[rpair[u]] and dfs(rpair[u], mat, used, rpair)) {
            rpair[u] = v;
            return true;
        }

    return false;
}

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

    // code here
    int n, m;
    cin >> n >> m;

    vector<vector<int>> field(n, vector<int>(m));

    for (int i = 0; i != n; ++i)
        for (int j = 0; j != m; ++j)
            cin >> field[i][j];

    for (int iter = 0; iter != m; ++iter) {
        vector<vector<int>> mat(n, vector<int>(n, -1));
        
        for (int i = 0; i != n; ++i)
            for (int j = iter; j != m; ++j) {
                int tp = (field[i][j] - 1) / m;

                mat[i][tp] = j;
            }

        vector<int> rpair(n, -1);

        for (int i = 0; i != n; ++i) {
            vector<char> used(n);
            assert(dfs(i, mat, used, rpair));
        }

        for (int j = 0; j != n; ++j) {
            int i = rpair[j];

            swap(field[i][iter], field[i][mat[i][j]]);
        }
    }

    for (int i = 0; i != n; ++i)
        for (int j = 0; j != m; ++j)
            cout << field[i][j] << " \n"[j + 1 == m];

    for (int j = 0; j != m; ++j) {
        vector<int> arr;
        for (int i = 0; i != n; ++i)
            arr.push_back(field[i][j]);
        sort(ALL(arr));
        
        for (int i = 0; i != n; ++i)
            field[i][j] = arr[i];
    }

    for (int i = 0; i != n; ++i)
        for (int j = 0; j != m; ++j)
            cout << field[i][j] << " \n"[j + 1 == m];

    
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int[] a = new int[w+1];
		for(int i=1;i<=w;i++)a[i]=i;
		int m = sc.nextInt();
		while(m--!=0){
			String[] s = sc.next().split(",");
			int l = Integer.parseInt(s[0]);
			int r = Integer.parseInt(s[1]);
			int t = a[l];
			a[l] = a[r];
			a[r] = t;
		}
		for(int i=1;i<=w;i++)System.out.println(a[i]);
	}
}

Measured memory_bytes: 26000
#include<iostream>

int main()
{
    int n;

    std::cin >> n;
    int a[n];

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


    for (int i = 0; i < n; i++) {

        std::cout << a[n-i-1];

        if (i != n -1) {
            std::cout << " ";
        } else {
            std::cout << std::endl;
        }
    }
    return 0;

}

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

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    a: usize,
    b: usize
    }
    let fa = if (a - 1) % 2 == 0 { a - 1 } else { (a - 1) ^ (a - 2) } ^ if a - 1 > 0 && (a - 1) / 2 % 2 == 1 { 1 } else { 0 };
    let fb = if b % 2 == 0 { b } else { b ^ (b - 1) } ^ if b > 0 && b / 2 % 2 == 1 { 1 } else { 0 };
    let ans = fa ^ fb;
    println!("{}", ans);
}


Measured memory_bytes: 2200
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define black_tree tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define pair_black_tree tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update>
#define gp __gnu_pbds
#define INF 1000000000
#define MOD 1000000007
#define MAX 1000001
#define endl '\n'
#define ll long long
#define ld long double
#define lli long long int
#define ull unsigned long long
#define ulli unsigned long long int
#define pb push_back
#define pf push_front
#define ook order_of_key
#define fbo find_by_order
#define np next_permutation
#define mp make_pair
#define eb emplace_back
#define mae max_element
#define mie min_element
#define lb lower_bound 
#define ub upper_bound
#define bs binary_search
#define ff first
#define ss second
using namespace std;
using namespace gp;
string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    char c=s[s.length()-1];
    if(c=='s'){
    	cout<<s<<"es";
	}
	else{
		cout<<s<<"s";
	}
}

Measured memory_bytes: 3660