akhauriyash/Code-Regression huggingface dataset:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    
    H,W = LMIIS()
    A = []
    for _ in range(H):
        A.append(input())
    from copy import deepcopy
    blacks = deque()
    visited = [[False]*W for _ in range(H)]
    for w in range(W):
        for h in range(H):
            if A[h][w] == '#':
                blacks.append((h,w))
                visited[h][w] = True

    count = -1
    
    while len(blacks) > 0:
        count += 1
        next_blacks = deque()
        while len(blacks) > 0:
            i,j = blacks.pop()
            if 0 <= i-1 and not visited[i-1][j]:
                next_blacks.append((i-1,j))
                visited[i-1][j] = True
            if 0 <= j-1 and not visited[i][j-1]:
                next_blacks.append((i,j-1))
                visited[i][j-1] = True
            if i+1 < H and not visited[i+1][j]:
                next_blacks.append((i+1,j))
                visited[i+1][j] = True
            if j+1 < W and not visited[i][j+1]:
                next_blacks.append((i,j+1))
                visited[i][j+1] = True
        blacks = next_blacks
    print(count)



if __name__ == '__main__':
    main()

Measured memory_bytes: 121964
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())

x=y=0
for i,j in zip(a,b):
    if i>j:x+=i-j
    else:y+=(j-i)//2
if y>=x:
    print("Yes")
else:
    print("No")

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

int main() {
  char b;
  cin >> b;
  if (b == 'A') cout << 'T' << endl;
  if (b == 'T') cout << 'A' << endl;
  if (b == 'C') cout << 'G' << endl;
  if (b == 'G') cout << 'C' << endl;
}


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

vector<int> from_s[100008];
vector<int> to_s[100008];
int rem[100008];
void add(int a,int b) {
	to_s[a].push_back(b);
	from_s[b].push_back(a);
	rem[b]++;
}
int queue[100008];
int qst=0;
int qls=0;
void qadd(int vl) {
	queue[qls++]=vl;
}
int qpop() {
	return queue[qst++];
}
int parents[100008];


int main(){
	int N,M;
	scanf("%d%d",&N,&M);
	for(int i=0;i<N+M-1;i++){
		int va,vb;
		scanf("%d%d",&va,&vb);
		add(va,vb);
	}
	for(int i=1;i<=N;i++) {
		if(rem[i]==0) qadd(i);
	}
	while(qst<qls) {
		int node = qpop();
		for(int i=0;i<to_s[node].size();i++) {
			int next=to_s[node][i];
			rem[next]--;
			if(rem[next]==0) {
				parents[next] = node;
				qadd(next);
			}
		}
	}
	for(int i=1;i<=N;i++) printf("%d\n",parents[i]);
	return 0;
}


Measured memory_bytes: 12928
from fractions import gcd
A, B, K = [int(i) for i in input().split()]


def divisor_list(n):
    """n の正の約数のリスト"""
    ret = []
    for k in range(1, int(n**0.5) + 1):
        if n % k == 0:
            ret.append(k)
            if k != n // k:
                ret.append(n // k)
    return list(sorted(ret, reverse=True))


print(divisor_list(gcd(A, B))[K - 1])

Measured memory_bytes: 5432
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100000;
const double eps = 1e-6;
const double PI = acos(-1.0);

int H, W, D;
int cnt, Q;
struct Point {
	int x, y, id;
	Point () {}
	Point (int _x, int _y, int _id) {
		x = _x; y = _y; id = _id;
	}
	friend bool operator < (const Point A, const Point B) {
		return A.id < B.id;
	}
}PP[MaxN + 5];

int prefix[MaxN + 5];

int dis(Point A, Point B) {
	return abs(A.x - B.x) + abs(A.y - B.y);
}

int main()
{
	while(scanf("%d %d %d", &H, &W, &D) != EOF)
	{
		cnt = 0;
		for(int i = 1; i <= H; i++) {
			for(int j = 1; j <= W; j++) {
				int t;
				scanf("%d", &t);
				PP[++cnt] = Point(i, j, t);
			}
		}
		sort(PP + 1, PP + cnt + 1);
		scanf("%d", &Q);
		prefix[0] = 0;
		for(int i = 1; i < cnt; i++)
			prefix[i] = prefix[i - 1] + dis(PP[i], PP[i + 1]);
		for(int cas = 1; cas <= Q; cas++) {
			int L, R;
			scanf("%d %d", &L, &R);
			if(D == 1) {
				printf("%d\n", max(0, prefix[R - 1] - prefix[L - 1]));
			}
			else {
				int cost = 0;
				int S = L, T = R;
				while(S != T) {
					cost += dis(PP[S + D], PP[S]);
					S += D;
				}
				printf("%d\n", cost);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
int dp[510][510];
bool used[510][510];
int main(){
    int n;
    cin >> n;
    int m = n*n;
    vector<int> a(m);
    rep(i,m){
        cin >> a[i];
        a[i]--;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dp[i][j] = min({i,n+1-i,j,n+1-j});
            used[i][j] = 1;
        }
    }
    ll sm = 0;
    rep(i,m){
        int s = a[i]%n;
        int t = a[i]/n;
        s++;
        t++;
        sm += dp[s][t]-1;
        chmin(dp[s][t],dp[s-1][t]);
        chmin(dp[s][t],dp[s+1][t]);
        chmin(dp[s][t],dp[s][t-1]);
        chmin(dp[s][t],dp[s][t+1]);
        used[s][t] = 0;
        queue<pair<int,int> > q;
        q.push(MP(s,t));
        while(!q.empty()){
            auto x = q.front();
            q.pop();
            int b = x.first;
            int c = x.second;
            
            for(int d=-1;d<=1;d++){
                int k = 0;
                if(used[b+d][c])k = 1;
                if(dp[b+d][c] > dp[b][c]+k){
                    dp[b+d][c] = dp[b][c]+k;
                    q.push(MP(b+d,c));
                }
            }
            
            for(int d=-1;d<=1;d++){
                int k = 0;
                if(used[b][c+d])k = 1;
                if(dp[b][c+d] > dp[b][c]+k){
                    dp[b][c+d] = dp[b][c]+k;
                    q.push(MP(b,c+d));
                }
            }
        }
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 4876
use std::io;
use std::str::FromStr;

static MOD: u64 = 1000000007;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn binary_power(x: u64, n: u64) -> u64 {
    if n == 0 {
      return 1;
    }
    if n % 2 == 0 {
      return (binary_power(x, n / 2) % MOD).pow(2) % MOD;
    } else {
      return binary_power(x, n - 1) % MOD * x % MOD;
    }
}
  
fn inverse_mod(n: u64) -> u64 {
    binary_power(n, MOD-2)
}  

fn combination(n: u64, mut m: u64) -> u64 {
    if n < m {
        return 0;
    }
    
    if m > n - m {
        m = n - m
    }

    let mut ret = 1u64;
    for i in 0..m {
        ret %= MOD;
        ret *= n - i;        
    }
    ret %= MOD;

    let mut div = 1u64;
    for i in 1..(m+1) {
        div %= MOD;
        div *= i;
    }
    div %= MOD;

    // println!("{}, {}", ret, div);
    ret * inverse_mod(div) % MOD
}

fn main() {
    let (x, y) = input_tuple();
    if x < y / 2  || y < x / 2 {
        println!("0");
        return;
    }
    if (x + y) % 3 != 0 {
        println!("0");
        return;
    }

    // println!("{}", convination((x+y)/3, (x-y).abs()/3));

    let count = (x + y) / 3;
    println!("{}", combination(count, (count + x - y) / 2));

}


Measured memory_bytes: 4352
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math
# mod = 10**9 + 7

# n = int(input())
# a = list(map(int, input().split()))
n = int(input())
s = input()
ans = []
for i in s:
    ans.append(chr((ord(i)-ord('A')+n)%26 + ord('A')))

print(''.join(ans))

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

static const int MAX = 1000;
static const int VMAX = 10000;

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

int solve(){
	int ans = 0;
	
	bool V[MAX];
	for(int i=0;i<n;i++){
		B[i]=A[i];
		V[i]=false;
	}
	
	sort(B,B+n);
	for(int i=0;i<n;i++)  T[B[i]]=i;
	for(int i=0;i<n;i++){
		if(V[i]) continue;
		int cur = i;
		int S=0;
		int m=VMAX;
		int an=0;
		while(1){
			V[cur]=true;
			an++;
			int v=A[cur];
			m=min(m,v);
			S+=v;
			cur=T[v];
			if(V[cur]) break;
		}
		ans+=min(S+(an-2)*m,m+S+(an+1)*s);
	}
	return ans;
}

int main() {
	
	cin>>n;
	s=VMAX;
	for(int i=0;i<n;i++){
		cin>>A[i];
		s=min(s,A[i]);
	}
	
	int ans=solve();
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3176
n = int(input())
A = [int(a) for a in input().split()]

A.sort()
if n == 2:
    print(A[1],A[0])
else:
    ans_a = A[n-1]

    left = 0
    right = n-1
    while True:
        if left == right:
            ans_b = A[left]
            break
        elif left + 1 == right:
            if abs(A[left]-ans_a/2) < abs(A[right]-ans_a/2):
                ans_b = A[left]
            else:
                ans_b = A[right]
            break
        elif ans_a//2 < A[(left+right)//2]:
            right = (left+right)//2
        else:
            left = (left+right)//2

    print(ans_a,ans_b)


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

int cnt;

void insertionSort(int A[], int n, int g){
  int j, v;

  for ( int i = g; i < n; i++ ){
    v = A[i];
    j = i - g;
    while ( j >= 0 && A[j] > v ){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n){
  cnt = 0;
  int m = 0, G[100], j=0;
  G[0] = 1;
  while (1){
    m++;
    G[m] = 3*G[m-1]+1;
    if ( G[m] > n ) break;
  }
  for ( int i = m-1; i >= 0; i-- ) insertionSort(A, n, G[i]);
  cout << m << '\n';
  for ( int i = m-1; i >= 0; i-- ){
    cout << G[i];
    if ( i > 0 ) cout << " ";
  }
  cout << endl;
}

int main(){
  int n, A[1000000];

  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> A[i];

  shellSort(A, n);

  cout << cnt << endl;
  for ( int i = 0; i < n; i++ ) cout << A[i] << endl;

  return 0;
}


Measured memory_bytes: 6996
n = int(input())
a = list(map(int, input().split()))
x = "APPROVED"
for i in range(n):
    if a[i] == (2 * int(a[i] / 2)):
        if a[i] != (3 * int(a[i] / 3)):
            if a[i] != (5 * int(a[i] / 5)):
                x = "DENIED"
print(str(x))

Measured memory_bytes: 9096
N = int(input())
S = input()
r,g,b = 0,0,0
for i in S:
    if i == 'R':
        r+=1
    if i == 'G':
        g+=1       
    if i == 'B':
        b+=1 

count = 0
for i in range(1,N):
    for j in range(N):
        if j+i*2 >= N:
            break
        if S[j] != S[j+i] and S[j] != S[j+2*i] and S[j+i] != S[j+2*i]:
                count+=1
print(r*g*b-count)

Measured memory_bytes: 9060
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

const int MAX_V = 256, MAX_E = 768 + 1;

int head[MAX_V],nxt[MAX_E],to[MAX_E],cost[MAX_E];
int m;

void init_edge(){
	m=0;
	for(int i=0;i<MAX_V;i++) head[i]=-1;
}

void add_edge(int u,int v,int c){
	nxt[m]=head[u];to[m]=v;cost[m]=c;head[u]=m;m++;
}

int mask;

int V,E;
int N;

void add_edge2(int u,int v,int lo,int hi){
	add_edge(v,u,-lo);
	add_edge(u,v,hi);
}

void getGraph(string str){
	init_edge();
	for(int i=0;i<N;i++){
		int lo,hi;
		if(i<str.size()){
			lo=str[i]-'0';
			hi=lo;
		}else{
			lo=0;
			hi=1;
		}
		add_edge2(i*2,i*2+1,lo,hi);
	}
	for(int v=0;v<N;v++){
		for(int bit=0;bit<=1;bit++){
			int u=((v<<1)&mask)|bit;
			int cost=-bit;
			add_edge2(v*2+1,u*2,cost,cost);
		}
	}
	add_edge2(1,0,0,0);
}

int dis[MAX_V];
bool negCycle(){
	bool flg=false;
	for(int v=0;v<V;v++){
		dis[v]=0;
	}
	for(int stage=0;stage<=E+1;stage++){
		bool update=false;
		for(int v=0;v<V;v++){
			for(int e=head[v];e!=-1;e=nxt[e]){
				int u=to[e];
				int c=cost[e];
				int ndis=dis[v]+c;
				if(dis[u]>ndis){
					update=true;
					dis[u]=ndis;
				}
			}
		}
		if(stage==E+1) flg=update;
		if(update==false) break;
	}
	return flg;
}

bool check(string str){
	getGraph(str);
	bool flg=negCycle();
	return !flg;
}

string solve(string lo_str){
	if(lo_str[0]=='1') return "no";
	if(check(lo_str)) return lo_str;
	int match=lo_str.size()-1;
	string str=lo_str;
	string ans="";
	for(;match>=1;match--){
		if(lo_str[match]=='1') continue;
		string cur=lo_str.substr(0,match);
		cur+='1';
		bool flg=check(cur);
		if(flg){
			ans=cur;
			break;
		}
	}
	if(ans=="") return "no";
//	printf("%s\n",ans.c_str());
//	ans+='1';
	for(int i=match+1;i<lo_str.size();i++){
		string cur=ans+'0';
		if(check(cur)) ans=cur;
		else ans+='1';
	}
	return ans;
}

char ch[130];

int main(){
	int w;
	scanf("%d%s",&w,ch);
	string lo_str=ch;
	N=lo_str.size();
	V=N*2;
	E=N*6+1;
	mask=N-1;
	string ans=solve(lo_str);
	printf("%s\n",ans.c_str());
	return 0;
}

Measured memory_bytes: 1072
// C - Attention
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; string S; cin>>N>>S;
	vi E(N+1), W(N+1);//累積和
	rpz(i, N){
		E[i+1] = E[i] + (S[i]=='E');
		W[i+1] = W[i] + (S[i]=='W');
	}
	int mini = INT_MAX;
	rp(leader, 1, N+1)
		mini = min(mini, E[N]-E[leader] + W[leader-1]);
	cout<< mini <<endl;
}

Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items1 = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = items1[0];
            var M = items1[1];
            var H = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var roads = new Dictionary<int, HashSet<int>>();
            foreach (var i in Enumerable.Range(0, N))
            {
                roads[i] = new HashSet<int>();
            }

            foreach (var i in Enumerable.Range(0, M))
            {
                var items2 = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
                var A = items2[0] - 1;
                var B = items2[1] - 1;
                roads[A].Add(B);
                roads[B].Add(A);
            }

            var count = 0;
            foreach(var i in Enumerable.Range(0, N))
            {
                if (roads[i].Any(elem => H[elem] >= H[i]))
                {
                    continue;
                }

                count++;
            }

            Console.WriteLine(count.ToString());
        }
    }
}


Measured memory_bytes: 81556
import java.util.*; 
public class Main {

  public static void main(String[] args) {
  
  Scanner sc=new Scanner(System.in);
  int a[]=new int[3];
  a[0]=sc.nextInt();
  a[1]=sc.nextInt();



  System.out.println(!(a[1]*a[0]%2==0)?"Yes":"No");
  }
  
}

Measured memory_bytes: 22612
#include <iostream>

using namespace std;

int main(){
  int h,w;

  while(cin >>h>>w,(h||w)){

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
	
	//最初と最後は全部#
	if( (i==0)||(i==(h-1))){
	  cout<<"#";
	}
	else{
	  //最初の１個は#
	  if((j==0)||(j==(w-1))){
	    cout<<"#";
	  }
	  //他は.
	  else{
	      cout<<".";
	  }
	}
      }
      cout<<endl;
    }

    cout<<endl;



  }


  return 0;
}



Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,s=0;
  cin>>n;
  int temp=n;
  while(temp){
    s+=temp%10;
    temp/=10;
  }
  if(n%s==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}


Measured memory_bytes: 256
import queue

N, U, V = map(int, input().rstrip().split())
U -= 1
V -= 1

v2e = [set() for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().rstrip().split())
    v2e[a].add(b)
    v2e[b].add(a)
    
q = queue.Queue()
q.put(U)
p = [-1] * N
p[U] = U
while True:
    a = q.get()
    
    if a == V:
        break
    
    for b in v2e[a]:
        if p[b] == -1:
            p[b] = a
            q.put(b)
            
a = V
min_p = []
while True:
    min_p.append(a)
    if a == U:
        break
    a = p[a]

p = [-1] * N
p[min_p[(len(min_p)-1)//2-len(min_p)%2]] = min_p[(len(min_p)-1)//2-len(min_p)%2]
for a in v2e[min_p[(len(min_p)-1)//2-len(min_p)%2]]:
    p[a] = a
p[min_p[-len(min_p)//2+len(min_p)%2]] = min_p[-len(min_p)//2+len(min_p)%2]

q = queue.Queue()
q.put((min_p[-len(min_p)//2+len(min_p)%2], 0))
while q.qsize() > 0:
    a, d = q.get()
    
    for b in v2e[a]:
        if p[b] == -1:
            p[b] = a
            q.put((b, d + 1))
            
print(d + (len(min_p) - 2) // 2 + len(min_p) % 2)

Measured memory_bytes: 91548
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    lli ans=0;
    repA(i,1,n)
    repA(j,1,n)
    {
        const lli g=__gcd(i,j);
        repA(k,1,n)
            ans+=__gcd(g,k);
    }
    cout<<ans<<endl;
}   aryanc403();
    return 0;
}


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

int main() {

    string S;
    cin >> S;

    rep(i, S.length()) {
        if (S[i] == '?') {
            S[i] = 'D';
        }
    }

    cout << S << endl;

    // int ans = 0;
    // rep(i, S.length()) {
    //     if (S[i] == 'D') ans++;
    //     if (i < S.length()-1 && S.substr(i, 2) == "PD") ans++;
    // }

    // cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];
int n,k;

int ans = 0;
int sz[N];
int dp[N],ed[N];
void dfs(int x, int p)
{
    sz[x] = 1;
    for(int nx:G[x])if(nx!=p)
    {
        dfs(nx,x);
        sz[x] += sz[nx];
    }
    if(sz[x]==1) dp[x] = -1;

    int ct = 0;
    for(int nx:G[x])if(nx!=p)
    {
        ed[x] = max(ed[x],ed[nx]);
        dp[x] = max(dp[x],dp[nx]);
        ct += (sz[nx]>=k);
    }
    ed[x] = max(ed[x],ct);

    vector<int> gain;
    for(int nx:G[x])if(nx!=p)
    {
        int tmp = ct - (sz[nx]>=k);
        dp[x] = max(dp[x],ed[nx]+tmp);
        ed[x] = max(ed[x],ed[nx]+tmp);

        gain.pb(ed[nx]-(sz[nx]>=k));
    }

    sort(all(gain),greater<int>());
    if(gain.size()>=2) dp[x] = max(dp[x],ct+gain[0]+gain[1]);

    ans = max(ans,dp[x]+(n-sz[x]>=k));
    // printf(" %d: dp %d ed %d\n", x,dp[x],ed[x]);
}

int main()
{
    cin >>n >>k;
    rep(i,n-1)
    {
        int u,v;
        cin >>u >>v;
        --u; --v;
        G[u].pb(v);
        G[v].pb(u);
    }

    dfs(0,-1);
    cout << ans << endl;
    return 0;
}

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

int n, m, A[3000];

bool dfs(int s, int i) {
    if (i == n) return s == m;
    return dfs(s + A[i], i + 1) || dfs(s, i + 1);
}

int main(void) {
    int q, i;
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &m);
        if (dfs(0, 0)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}

Measured memory_bytes: 1012
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

bool is_prime(int x){
	for (int i = 2; i * i <= x; i++){
		if (x % i == 0){
			return false;
		}
	}
	return true;
}

int32_t main(){
	vector <int> p;
	for (int i = 1; i <= 200000; i++){
		if (is_prime(i)){
			p.push_back(i);
		}
	}
	int n;
	cin >> n;
	for (int i = 0; i < p.size(); i++){
		if (p[i] >= n){
			return cout << p[i], 0;
		}
	}
}


Measured memory_bytes: 3696
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    vpint a(n); vpin(a);
    reverse(all(a));
    int ans = 0;
    rfor(p, a) {
        int x = p.first + ans;
        int y = p.second;
        int num = y - x % y;
        if(x % y == 0) num = 0;
        ans += num;
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
#define fastio ios::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define fi first
#define se second
#define maxn 2001
 
const int mod = 1e9+7 ;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
 
bool dp[maxn][100001];
int pre[maxn];
 
signed main()
{
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	fastio;
	int n;	cin >> n;
	int a[n+1], sum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		pre[i] = pre[i-1] + a[i];
	}
	dp[0][0] = true;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= 100000; j++)
		{
			if (!dp[i][j])
			{
				if (j >= a[i])
				{
					if (j + a[i] <= 100000)
					dp[i][j] = max(dp[i-1][j-a[i]], dp[i-1][j+a[i]]);
					else dp[i][j] = dp[i-1][j-a[i]];
				}
				else
				{
					if (j + a[i] <= 100000)
					dp[i][j] = max(dp[i-1][a[i]-j], dp[i-1][a[i]+j]);
					else dp[i][j] = dp[i-1][j-a[i]];
				}
			}
			if (j + a[i] <= 100000 && !dp[i][j+a[i]])	dp[i][j+a[i]] = dp[i-1][j];
		}
	}
	for (int j = 0; j <= 100000; j++)
	{
		if (dp[n][j])
		{
			cout << (pre[n] + j) / 2;
			return 0;
		}
	}
}

Measured memory_bytes: 198936
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        a1 = [a[k][j:j+m] for k in range(i,i+m)]
        if a1 == b:
            print('Yes')
            exit()

print('No')


Measured memory_bytes: 3060
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
char ch[22]; 
int main()
{
	scanf("%s",ch+1); printf("%c%c%c\n",ch[1],ch[2],ch[3]);
	return 0;
}


Measured memory_bytes: 1704
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String inputString = scanner.next();
        int inputInt = scanner.nextInt();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(inputString);

        int reverseCounter = 0;
        StringBuilder prefix = new StringBuilder();

        boolean startIsStart = true;
        for (int i = 0; i < inputInt; i++) {
            int T = scanner.nextInt();
            if (T == 1) {
                reverseCounter++;
                startIsStart = !startIsStart;
            } else {
                int F = scanner.nextInt();
                String C = scanner.next();
                if (startIsStart) {
                    if (F == 1) {
                        prefix.append(C);
                    } else {
                        stringBuilder.append(C);
                    }
                } else {
                    if (F == 2) {
                        prefix.append(C);
                    } else {
                        stringBuilder.append(C);
                    }
                }
            }
        }

        stringBuilder.insert(0, prefix.reverse());
        int a = reverseCounter % 2;
        if (a == 1) {
            stringBuilder.reverse();
        }
        System.out.println(stringBuilder.toString());
    }
}


Measured memory_bytes: 120488
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using ld = long double;
using vld = vector<ld>;
using vvld = vector<vld>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#define fst first
#define snd second

const int INF = 1e9;
struct edge
{
    int c;
    P p;
    edge(int c, P p) : c(c), p(p) {}
    bool operator>(const edge &r) const { return c > r.c; }
};
int main()
{

    int h, w, k, x1, y1, x2, y2;
    cin >> h >> w >> k;
    cin >> y1 >> x1 >> y2 >> x2;
    x1--;
    y1--;
    x2--;
    y2--;
    vvchar g(h, vchar(w));
    rep(y, h) rep(x, w) cin >> g[y][x];
    vvint v(h, vint(w, INF));

    queue<edge> q;
    P start = P(y1, x1), goal = P(y2, x2);
    q.push(edge(0, start));
    v[y1][x1] = 0;

    vint dy = {0, 1, 0, -1}, dx = {1, 0, -1, 0};
    while (q.size())
    {
        edge e = q.front();
        q.pop();
        P p = e.p;

        if (p == goal)
        {
            break;
        }

        int now = e.c;
        rep(dir, 4) for (int i = 1; i <= k; i++)
        {
            int ny = p.fst + dy[dir] * i;
            int nx = p.snd + dx[dir] * i;
            if (ny < 0 || nx < 0 || ny > h - 1 || nx > w - 1 || g[ny][nx] == '@' || v[ny][nx] <= now)
            {
                break;
            }

            if (v[ny][nx] > now + 1)
            {
                v[ny][nx] = now + 1;
                q.push(edge(now + 1, P(ny, nx)));
            }
        }
    }

    ld ans = ceil(v[y2][x2]);
    if (ans == INF)
    {
        ans = -1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11944
#include<iostream>
using namespace std;
int n, m, k;
int book[15][15], C[15];
int OK(int x) {
    //printf("x = %d\n",x);
    for(int j = 1; j <= m; ++j) {
        int ans = 0;
        for(int i = 0; i < n; ++i) {
            if(x & (1<<i)) ans += book[i+1][j];
        }
        if(ans < k) return -1;
    }
    
    int tot = 0;
    for(int i = 0; i < n; ++i) {
        if(x & (1<<i)) tot += C[i+1]; 
    }
    //printf("tot = %d\n",tot);
    return tot;
}

int main() {
    cin >> n >> m >> k;
    for(int i = 1; i <= n; ++i) {
        cin >> C[i];
        for(int j = 1; j <= m; ++j)
            cin >> book[i][j];
    }

    int Min = 0x7fffffff;
    for(int i = 0; i < (1<<(n)); ++i) {
        int ans = OK(i);
        if(ans != -1 && ans < Min) Min = ans;
    }
    if(Min != 0x7fffffff)
        cout << Min << '\n';
    else cout << "-1\n";
return 0;
}

Measured memory_bytes: 3564
import itertools

n = int(input())
a = ''.join(input().split())
b = ''.join(input().split())

List = [''.join(map(str, i)) for i in itertools.permutations(range(1, n+1), n)]
List.sort()

a_ind = List.index(a)
b_ind = List.index(b)

print(abs(a_ind-b_ind))

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

int main(){
    string S,T;
    cin>>S;
    cin>>T;
    int s=S.length(), t=T.length();
    int A[s+1][t+1];
    for(int i=0; i<=s; ++i){
        for(int j=0; j<=t; ++j){
            if(i==0 || j==0) A[i][j]=0;
            else if(S[i-1]==T[j-1]) A[i][j]=A[i-1][j-1]+1;
            else A[i][j]=max(A[i-1][j], A[i][j-1]);
        }
    }
    //cout<<A[s][t]<<"\n";
    int index=A[s][t];
    int i=s,j=t;
    string res(index,' ');
    while(i>0 && j>0){
        if(S[i-1]==T[j-1]){
            res[index-1]=S[i-1];
            --index;
            --j;
            --i;
        }
        else if(A[i-1][j]>A[i][j-1]) --i;
        else --j;
    }
    cout<<res<<"\n";
}

Measured memory_bytes: 35456
# Aizu Problem 0000: QQ
#
import sys, math, os

# read input:
#PYDEV = os.environ.get('PYDEV')
#if PYDEV=="True":
#    sys.stdin = open("sample-input2.txt", "rt")

for i in range(1, 10):
    for j in range(1, 10):
        print("%dx%d=%d" % (i, j, i*j))

Measured memory_bytes: 7576
N, X = map(int, input().split())
L = [int(i) for i in input().split()]

ans = 1
ct = 0
D = 0
while True:
    D += L[ct]
    if D <= X:
        ct += 1
        ans += 1
    else:
        break
    if ct > N - 1:
        break

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){

    int a = 0;
    int b = 0;

    scanf("%d %d", &a, &b);

    if (a < b){

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

            printf("%d", a);
        }

    } else if (b <= a){

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

            printf("%d", b);
        }

    }

    return 0;
}

Measured memory_bytes: 128
/*************************************************************************
    > File Name: B.cpp
    > Author: Akira
    > Mail: qaq.febr2.qaq@gmail.com
    > Created Time: 2017年03月18日 星期六 20时30分11秒
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
#include<vector>
#include<set>
#include<list>
#include<ctime>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))

using namespace std;

#define MaxN 5005
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1e9+7;
const int eps = 1e-8;
#define bug cout << 88888888 << endl;
int N;
LL K;
LL node[MaxN];
int main()
{
    while(~scanf("%d%lld", &N, &K))
    {
        LL sum = 0;
        for(int i=1;i<=N;i++)
        {
            scanf("%lld", node+i);
        }
        sort(node+1, node+1+N);
        for(int i=1;i<=N;i++)
        {
            if(sum<K)
            {
                sum += node[i];
            }
            else break;
        }
        if(sum<K) 
        {
            printf("%d\n", N);
            continue;
        }
        LL* it = (upper_bound(node+1,node+1+N, K));
        it -=1;
        int ans = 0;

        for(int i=1;i<=N;i++)
        {
            if(sum>=K)
            {
                sum -= node[i];
            }
            
            if(sum<K)
            {
                ans = i-1;
                break;
            }
        }
        LL* low = it;
        LL* high = it;
        int lim = ans;
        while( low!= node+lim )
        {
            int cnt = 0;
            for(LL* i = low;i<=high;i++)
            {
                cnt += *i;
            }
            while(cnt>=K)
            {
                cnt -= *high;
                high--;
            }
            //cout << cnt << endl;
            for(int i=ans;i>0;i--)
            {
                if(cnt+node[i]>=K) ans --;
            }
            if(ans==0) break;
            low--;
        }
        printf("%d\n", ans);

    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define F(i,L,R) for (ll i = L; i < R; i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(x) scanf("%lld",&x)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll k;
  cin>>k;
  F(i,0,k) cout<<"ACL";
  return 0;
}

Measured memory_bytes: 3604
while True:
  n = int(input())
  if n == 0:
     break
  else:
    cnt = 0
    for i in range(1, n // 2 + 1):
      sum = i
      for j in range(i + 1, n):
        sum += j
        if sum == n:
          cnt += 1
          break
        elif sum > n:
          break
    print(cnt)


Measured memory_bytes: 5584
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

int H, W, N;

char gfield[30][32];
char field[30][32];
char next_field[30][32];

void copy_field(char f[30][32], char g[30][32]) {
    for (int j = 0; j < 30; ++j) {
        for (int k = 0; k < 32; ++k) {
            g[j][k] = f[j][k];
        }
    }
}

bool check () {
    bool updated = true;
    
    while (updated) {
        updated = false;

        // drop
        for(int n = 0; n < H; ++n) {
            for(int j = H - 1; j > 0; --j) {
                for(int k = 0; k < W; ++k) {
                    if (field[j][k] == '.') {
                        swap(field[j][k], field[j-1][k]);
                    }
                }
            }
        }

        copy_field(field, next_field);

        // row
        for (int j = 0; j < H; ++j) {
            for (int k = 0; k < W; ++k) {
                if (field[j][k] == '.') continue;

                int l = 1;
                for (;k + l < W; ++l) {
                    if (field[j][k] != field[j][k + l]) {
                        break;
                    }
                }
                if (l >= N) {
                    updated = true;
                    for (int x = k; x < k + l; ++x) {
                        next_field[j][x] = '.';
                    }
                }
            }
        }

        // column
        for (int j = 0; j < H; ++j) {
            for (int k = 0; k < W; ++k) {
                if (field[j][k] == '.') continue;

                int l = 1;
                for (;j + l < H; ++l) {
                    if (field[j][k] != field[j + l][k]) {
                        break;
                    }
                }
                if (l >= N) {
                    updated = true;
                    for (int x = j; x < j + l; ++x) {
                        next_field[x][k] = '.';
                    }
                }
            }
        }

        copy_field(next_field, field);

    }

    for (int j = 0; j < H; ++j) {
        for(int k = 0; k < W; ++k) {
            if(field[j][k] != '.') {
                return false;
            }
        }
    }
    return true;
}

string solve() {
    for (int j = 0; j < H; ++j) {
        for(int k = 0; k < W-1; ++k) {
            copy_field(gfield, field);

            swap(field[j][k], field[j][k + 1]);

            if(check()) {
                return "YES";
            }
        }
    }
    return "NO";
}

int main() {
    cin >> H >> W >> N;
    for (int j = 0; j < H; ++j) {
        cin >> gfield[j];
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

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

bool dp[300001];//dp[i]残り石がi個のとき先手が勝つか
int a[100];
int main()
{
	int n,k;
	int ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	fill(dp,dp+300001,false);
	for(int i=0;i<a[0];i++)
		dp[i]=false;
	for(int i=a[0];i<k+1;i++)
	{
		bool f=false;
		for(int j=0;j<n;j++)
		{
			if(i-a[j]<0)
				break;
			if(!dp[i-a[j]])
			{
				f=true;
				break;
			}
		}
		dp[i]=f;
	}
	if(dp[k])
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
	//cout<<dp[k]<<endl;
	return 0;
}

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

int main(){
	ll q,h,s,d,n;
	cin>>q>>h>>s>>d>>n;
	ll cost=min(min(4*q,2*h),s);
	ll cost2 = min(2*cost,d);
	if(n%2==1){
		puts(n/2*cost2+cost);
		return 0;
	}
	puts(n/2*cost2);
}

Measured memory_bytes: 256
/**
 *    Creator :  bizarre
 *    Date : 3/2020
 *    Problem Number : 390
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre     ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
/*
const int inf = 2e9, mod = 1e9 + 7,N=1e6+5;
long long fact[N], inv[N];

void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}
int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
                c++;
            }

        }
    }

}
*/

int main()
{

    int n;
    cin>>n;
    cout << (n/2)+(n%2);
    return 0;
}


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

int main() {
   string S;
  cin >>S;
  bool answer=true;
    for(int i=0;i<3;i++){
      if(S.at(i)==S.at(i+1)){
        answer=false;
      }
    }
  if(answer){
    cout<<"Good"<<endl;
  }
  else{
    cout<<"Bad"<<endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a1 = input[0];
            int a2 = input[1];
            int a3 = input[2];

            int wa = a1 + a2 + a3;

            if (22 <= wa)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }
        }
    }
}


Measured memory_bytes: 13268
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    s = input()
    s = s[::-1]
    hoge = ["maerd","remaerd","esare","resare"]
    i, bit = 0, 0
    while True:
        if i == len(s):
            break
        if s[i:i+5] == hoge[0]:
            i += 5
        elif s[i:i+7] == hoge[1]:
            i += 7
        elif s[i:i+5] == hoge[2]:
            i += 5
        elif s[i:i+6] == hoge[3]:
            i += 6
        else:
            print("NO")
            bit = 1
            break
    if bit == 0:
        print("YES")
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 13416
N, K = map(int, input().split())

MOD = 10 ** 9 + 7

cache = {}
def f(k, n):
    if k == 1:
        return 1
    if k in cache:
        return cache[k]
    result = pow(k, n, MOD)
    for i in range(2, k + 1):
        result -= f(k // i, n)
        result %= MOD
    cache[k] = result
    return result


print(sum(f(K // i, N) * i for i in range(1, K + 1)) % MOD)


Measured memory_bytes: 9184
A, B = map(int, input().split())
S = input()
# print(S[:A])
# print(S[A])
# print(S[A:])
if S[:A].isdecimal() is True and S[A] == '-' and S[A+1:].isdecimal() is True:
    print('Yes')
else:
    print('No')


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}
ll n,m,sum;
vector<vector<ll>> scene(100,vector<ll>(100,0));
vector<vector<vector<ll>>> pic(4,vector<vector<ll>>(50,vector<ll>(50,0)));

bool check(int x,int y){
  rep(i,4){
    ll cnt = 0;
    rep(j,m){
      rep(k,m){
        if(value(x+k,y+j,n,n)){
          if(pic[i][k][j] != -1 && pic[i][k][j] != scene[x+k][y+j]) break;
          else if(pic[i][k][j] == scene[x+k][y+j]) ++cnt;
        }
      }
    }
    if(cnt == sum){
      rep(j,m){
        rep(k,m){
          if(pic[i][k][j] != -1){
            cout << x+k+1 << ' ' << y+j+1 << endl;
            return true;
          }
        }
      }
    }
  }
  return false;
}

void solve(){
  rep(i,n){
    rep(j,n){
      if(check(j,i)){
        return ;
      }
    }
  }
  cout << "NA"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin >> n >> m && n+m){
    rep(i,n){
      rep(j,n){
        cin >> scene[j][i];
      }
    }
    sum =0;
    rep(i,m){
      rep(j,m){
        cin >> pic[0][j][i];
        if(pic[0][j][i] != -1) ++sum;
      }
    }
    rep(i,m){
      rep(j,m){
        pic[1][m-i-1][j] = pic[0][j][i];
      }
    }
    rep(i,m){
      rep(j,m){
        pic[2][m-j-1][m-i-1] = pic[0][j][i];
      }
    }
    rep(i,m){
      rep(j,m){
        pic[3][i][m-j-1] = pic[0][j][i];
      }
    }
    solve();
  }
  return 0;
}

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

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

	vector<long long> a(n);
	
	long long cnt = 0;
	
	for (int i = 0; i < n; i++) { cin >> a[i];

		while (true) {

			if (a[i] % 2 != 0) {
				break;
			}
          
			cnt++;
			a[i] /= 2;

		}
	
	}
		
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
int Solve(int a, int b)
{
	int Array[10000];
	int sum = 0;
	int ans;
	for (int i = 0; i < b; i++)
	{
		cin >> Array[i];
		sum += Array[i];
	}
	ans = a - sum;
	if (ans < 0)
	{
		return -1;
	}
	else return ans;
}
int main()
{
	int x, y;
	cin >> x >> y;
	cout << Solve(x, y);
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
const int N = 5555;
int n, k, a[N];
bool check[N] = {0};
long long sum = 0;

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum < (long long)k) {
        cout << n << endl;
        return 0;
    }
    a[0] = 0;
    sort(a + 1, a + n + 1);

    check[0] = true;
    int pos = n;
    for (int i = n; i >= 1; i--) {
        if (a[i] >= k) {
            pos = i;
            continue;
        }
        for (int j = k - 1; j >= 0; j--) {
            if (check[j] && j + a[i] >= k) {
                pos = i;
                continue;
            } else {
                if (check[j]) check[j + a[i]] = true;
            }
        }
    }
    cout << pos - 1 << endl;
}


Measured memory_bytes: 256