akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
 long long int a,flag;
 flag=0;
 vector<int> v;
 cin>>a;
 for(int i=0;i<a;i++){
 	int tmp;
 	cin>>tmp;
 	v.push_back(tmp);
 }
for(int i=0;i<a;i++){
	if(v[i]%2==0){
		if(v[i]%3!=0&&v[i]%5!=0){
			flag=1;
		}
	}
}
if(flag==0){
	cout<<"APPROVED"<<endl;
}else if(flag==1){
	cout<<"DENIED"<<endl;
}

}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 998244353;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  string s; cin >> s;

  vi v;
  for(ll i=1;i*i<=n;++i) {
    if(n % i == 0) {
      if(n/i % 2) v.push_back(i);
      if(i*i != n && i%2) v.push_back(n/i);
    }
  }
  int sz = SZ(v);
  sort(ALL(v));
  map<int, int> hojo;
  ll ans = 0;

  REP(i, sz) {
    int d = v[i];
    //cout << d << endl;
    vvll dp(n+1, vll(2));
    dp[0][1] = 1;
    REP(j, d) {
      if(s[j] == '1') {
        dp[j+1][1] = dp[j][1];
        dp[j+1][0] = dp[j][1] + 2 * dp[j][0];
        dp[j+1][0] %= MOD;
      } else {
        dp[j+1][1] = dp[j][1];
        dp[j+1][0] = 2 * dp[j][0];
        dp[j+1][0] %= MOD;
      }
      //cout << dp[j] << endl;
    }

    FOR(j, d, n) {
      int nowval = s[j%d]-'0';
      if(j/d%2) nowval = !nowval;
      char c = nowval+'0';
      if(s[j] == '0') {
        if(c == '0') {
          dp[j+1][1] = dp[j][1];
        } else {
        }
      } else {
        if(c == '0') {
          dp[j+1][0] = dp[j][1];
        } else {
          dp[j+1][1] = dp[j][1];
        }
      }

      dp[j+1][0] += dp[j][0];
      dp[j+1][0] %= MOD;
      //cout << dp[j] << endl;
    }
    //cout << dp[n] << endl;

    ll add = dp[n][0] + dp[n][1];
    add %= MOD;

    for(auto &e: hojo) {
      if(d % e.first == 0) {
        add += MOD - e.second;
        add %= MOD;
      }
    }
    hojo[d] = add;

    add *= 2 * d;
    add %= MOD;
    ans += add;
    ans %= MOD;
  }
  cout << ans << endl;
}
























Measured memory_bytes: 11460
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string str;
  string ans;
  cin>>str;
  if(str.at(2)==str.at(3)&&str.at(4)==str.at(5)){
    ans="Yes";
  }
  else{
    ans="No";
  }
  cout<<ans;
}

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

using namespace std;

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

    vector<long long> h(n);
    for (int i=0; i<n; i++) {
        cin >> h.at(i);
    }
    
    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());

    long long ret = 0;

    for (int i=k; i<n; i++) {
        ret += h.at(i);
    }
    
    cout << ret << endl;

}



Measured memory_bytes: 1792
#! /usr/bin/python3
# ABC044_B
# B - 美しい文字列 / Beautiful Strings
"""
collectionsを使わないタイプ

制約
    1≤|w|≤100
    w は英小文字 (a-z) のみからなる文字列である。
"""

import collections
test_mode = False
use_Counter = True    # collections.Counter を使うかどうか


def judge_0(l):
    """
    collections.Counter を使うタイプ
    奇数会出現する要素があると False を返し、
    全ての要素が偶数回出現すると True を返す。
    """
    broken = False
    count_l = collections.Counter(l)    # l の各要素の出現回数をカウント

    if test_mode:
        print(count_l)

    for i in count_l:
        if count_l[i] % 2 == 1:
            if test_mode:
                print('break')
            broken = True
            break

    return not broken


def judge_1(l):
    """
    collections.Counter を使わないタイプ
    奇数会出現する要素があると False を返し、
    全ての要素が偶数回出現すると True を返す。
    """
    broken = False  # break したら True になるフラグ

    for i in l:
        if test_mode:
            print('{}:'.format(i), l.count(i))
            if l.count(i) % 2 == 1:
                print('break')
        if l.count(i) % 2 == 1:
            broken = True
            break

    return not broken



def main():
    """
    main関数
    """
    w = list(str(input()))  # 文字列をリストに変換
    if use_Counter:
        beautiful = judge_0(w)
    else:
        beautiful = judge_1(w)

    if beautiful:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getbit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void MAIN() {
  int n, m;
  cin >> n >> m;
  vector<ii> a(n);
  for (auto &i : a) {
    cin >> i.sc >> i.fi;
    i.sc = -i.sc;
  }
  sort(all(a), greater<ii>());
  set<int> s;
  for (int i = 0; i < m; i++) {
    s.insert(-i);
  }
  int ans = 0;
  for (auto &i : a) {
    auto it = s.lower_bound(- m - i.sc);
    if (it != s.end()) {
      s.erase(it);
      ans += i.fi;
    }
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main() {
  string s;
  while (true) {
    string s;
    getline(cin, s);
    if (s.at(0) - '0' == 0) break;
    int count = 0;
    for (size_t i = 0; i < s.size(); i++) {
      int a = s.at(i) - '0';
      count += a;
    }
    cout << count << endl;
  }
}


Measured memory_bytes: 3148
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      String S = sc.next();
      char[] data = new char[n];

      int count =0;

      if(n%2!=0){
        System.out.println("No");
        System.exit(0);
      }

      for(int i = 0;i<n;i++){
         data[i] = S.charAt(i);
      }
      for(int i =0;i<n/2;i++){
         if(data[i]==data[(n/2)+i]){
           count++;
         }
       }
         if(count==n/2){
           System.out.println("Yes");
         }else{
           System.out.println("No");
         }



}
}


Measured memory_bytes: 22868
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	/* 入力 */
	int r = scan.nextInt();
	int g = scan.nextInt();
	int b = scan.nextInt();
	int n = scan.nextInt();	      

	/* 組み合わせを考える */
	int count = 0;
	for(int i = 0; i < n/r+1; i++){
	    for(int j = 0; j < n/g+1; j++){
		if(n-(i*r+j*g) < 0){
		    break;
		}else if((n-(i*r+j*g)) % b == 0){
		    count++;
		}
	    }
	}


	System.out.println(count);
    }
}


Measured memory_bytes: 23380
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N, M;
	int[] s, c;
	int[] buf;
	boolean enable = true;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		M = Integer.parseInt(tokens[1]);
		s = new int[M];
		c = new int[M];
		for (int i = 0; i < M; ++i) {
			tokens = in.readLine().split(" ");
			s[i] = Integer.parseInt(tokens[0]) - 1;
			c[i] = Integer.parseInt(tokens[1]);
		}
		this.buf = new int[N];
		Arrays.fill(buf, -1);
	}

	void calc() {
		for (int i = 0; i < M; ++i) {
			if (buf[s[i]] < 0 || buf[s[i]] == c[i]) {
				// 未初期化，埋められる
				buf[s[i]] = c[i];
			} else {
				// 既存と違う: NG
				enable = false;
				break;
			}
		}
		if (!enable) {
			return;
		}
		// 残りを埋める
		if (N == 1) {
			if (buf[0] < 0) {
				buf[0] = 0;
			}
			return;
		}
		if (buf[0] == 0) {
			if (N != 1) {
				enable = false;
			}
			return;
		}
		buf[0] = buf[0] < 0 ? 1 : buf[0];
		for (int i = 1; i < N; ++i) {
			if (buf[i] < 0) {
				buf[i] = 0;
			}
		}
	}

	void showBuf() {
		for (int i = 0; i < buf.length; ++i) {
			System.out.print(buf[i] + " ");
		}
		System.out.println();
	}

	void showResult() {
		// showBuf();
		if (enable) {
			StringBuilder strBuilder = new StringBuilder();
			for (int i = 0; i < N; ++i) {
				strBuilder.append(Integer.toString(buf[i]));
			}
			System.out.println(strBuilder.toString());
		} else {
			System.out.println(-1);
		}
	}

}


Measured memory_bytes: 21204
N,K = map(int,input().split())
max_total = 0
res = 0
p = list(map(int,input().split()))
for _ in range(len(p)):
  p[_] = (p[_]+1)/2
  
total = sum(p[0:K])
max_total = total
for i in range(K,N):
  if p[i] > p[i-K]:
    total = total + p[i] - p[i-K]
    max_total = max(max_total,total)
  else:
    total = total + p[i] - p[i-K]

print(max_total)

Measured memory_bytes: 24548
// last.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include<iostream>
#include<math.h>
#include <algorithm>
using namespace::std;
int main(){
 
int N;
int M;
int X;
int Y;

int left;
int right;

cin>>N;
cin>>M;
cin>>X;
cin>>Y;
 
 
int *xi = new int[N];
int *yi = new int[M];
for(int i=0;i<N;i++){
	cin>>xi[i];
}
for(int i=0;i<M;i++){
	cin>>yi[i];
}
 
int max = xi[0];
int min = yi[0];
 
for(int i=0;i<N;i++){
	if(max<xi[i]){
		max=xi[i];
	}
}
for(int i=0;i<M;i++){
	if(min>yi[i]){
		min=yi[i];
	}
}

if(X>max){
	left=X;
}else{
	left=max;
}

if(Y<min){
	right=Y;
}else{
	right=min;
}
 
 
if(right-left>0){
	cout<<"No War";
}else{
	cout<<"War";
}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        for(int n; (n = scn.nextInt()) > 0;) {
            ArrayList<Line> lines = new ArrayList<>();
            int m = scn.nextInt(), a = scn.nextInt();
            for(int i = 0; i < m; i++) {
                lines.add(new Line(scn.nextInt(), scn.nextInt(), scn.nextInt()));
            }
            Collections.sort(lines);
            for(Line line : lines) {
                a = line.move(a);
            }
            System.out.println(a);
        }
    }
}

class Line implements Comparable<Line> {
    private int height, left, right;
    
    public Line(int h, int p, int q) {
        height = h;
        left = p;
        right = q;
    }
    
    public int move(int a) {
        if(a == left) {
            a = right;
        } else if(a == right) {
            a = left;
        }
        return a;
    }
    
    public int compareTo(Line obj) {
        return obj.height - height;
    }
}

Measured memory_bytes: 68604
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int a,b,c,d,time=0;
	cin>>a>>b>>c>>d;
	if(a<=c){
		if(c<b){
			if(b<=d)time=b-c;
			else time=d-c;
		}
	}else{
		if(a<d){
			if(b<=d)time=b-a;
			else time=d-a;
		}
	}
	cout<<time<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back

using namespace std;

int main()
{
   FAST/**/
    
   string s;
   cin>>s;
   ll n = s.length();
   
   vector<ll> l,r;
   for(ll i=0;i<n;i++)
   {
       if(s[i] == 'L')
            l.pb(i);
       else r.pb(i);        
   }
   
   unordered_map<ll,ll> ma;
   for(ll i=0;i<n;i++)
   {
       if(s[i] == 'R')
       {
           ll temp = *lower_bound(l.begin(), l.end(), i);
           ll dis = temp-i;
           if(dis%2 == 0)
                ma[temp]++;
           else ma[temp-1]++;        
       }
       
       else
       {
           ll temp = *(--lower_bound(r.begin(), r.end(), i));
           ll dis = -temp+i;
           if(dis%2 == 0)
                ma[temp]++;
           else ma[temp+1]++;    
       }
   }
   
   for(ll i=0;i<n;i++)
        cout<<ma[i]<<" ";
   
   return 0;
}

Measured memory_bytes: 5508
#include <iostream>
#include <vector>


using namespace std;


int K;

vector<vector<long long>> rnrn;


int main()
{

	cin >> K;
	int r = 10;

	rnrn = vector<vector<long long>>(r, vector<long long>(11));


	for (int i = 0; i < 10; i++) {
		rnrn[0][i] = 1;
	}

	for (int i = 1; i < r; i++) {
		for (int j = 0; j < 10; j++) {
			rnrn[i][j] = rnrn[i - 1][j] + rnrn[i - 1][j + 1];

			if (j > 0) {
				rnrn[i][j] += rnrn[i - 1][j - 1];
			}
		}
	}

	long long ans = 0;
	int k = K;
	int a = 0;
	int i = 0;
	for (; i < r && ans == 0; i++) {
		for (int j = 1; j < 10; j++) {
			if (k <= rnrn[i][j]) {

				ans += j;
				a = j;
				break;
			}

			k -= rnrn[i][j];

		}
	}

	for (i-=2; i >= 0; i--) {
		ans *= 10;
		for (int j = 0; j < 10; j++) {

			if (abs(j - a) > 1) {
				continue;
			}

			if (k <= rnrn[i][j]) {

				ans += j;
				a = j;
				break;
			}

			k -= rnrn[i][j];

		}


	}


	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; ++i) {
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  for (auto& s : S) cout << s;
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    if N==M==1:
        ans=1
    elif N==1 or M==1:
        ans=N*M-2
    else:
        ans=(N-2)*(M-2)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rev2(i, s, n) for (int i = (int)(n) - 1; i >= (int)(s); i--)
#define bitrep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define all(v) v.begin(), v.end()
#define println(x) cout << x << endl
#define fi first
#define se second
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
using pii = pair<int, int>;

int main()
{
    int n; cin >> n;
    vector<int> p(n), q(n), r(n);
    rep(i, n)
    {
        cin >> p[i];
        r[i] = i + 1;
    }
    rep(i, n)
    {
        cin >> q[i];
    }
    int a, b, c = 0;
    do
    {
        c++;
        if (p == r) a = c;
        if (q == r) b = c;
    } while (next_permutation(all(r)));
    cout << abs(a - b) << endl;
}

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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int A, B;
    string S, T, U;
    cin >> S >> T >> A >> B >> U;

    if (S == U) A--;
    else if (T == U) B--; 

    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#define INF 1100000000
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int mp[220000][26];
int dp[220000];
int main()
{
  string S; cin >> S;
  S.insert(S.begin(), 'X'); S.push_back('X');

  vector<int> nextalf(26, S.size() - 1);
  REP(i, 26) mp[S.size() - 1][i] = S.size();
  for (int i = S.size() - 2; i >= 0; i--) {
    REP(j, 26) mp[i][j] = nextalf[j];
    nextalf[S[i] - 'a'] = i;
  }

  REP(i, 220000) dp[i] = INF;
  dp[0] = 0;
  REP(i, S.size()) {
    REP(j, 26) {
      dp[mp[i][j]] = min(dp[mp[i][j]], dp[i] + 1);
    }
  }

  vector<bool> in_shortest_path(S.size(), false);
  in_shortest_path.back() = true;
  for (int i = S.size() - 1; i >= 0; i--) {
    REP(j, 26) {
      if (dp[mp[i][j]] == dp[i] + 1 && in_shortest_path[mp[i][j]])
        in_shortest_path[i] = true;
    }
  }

  int now = 0;
  string ans = "";
  while (now < S.size() - 1) {
    REP(i, 26) {
      if (dp[mp[now][i]] == dp[now] + 1 && in_shortest_path[mp[now][i]]) {
        ans += i + 'a';
        now = mp[now][i];
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(),v.end(),greater<int>());
  
  cout <<  v[0] - v[2] << endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <set>
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int d[8][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
int w, h;
void dfs(int y, int x, vector<vector<int>> &v) {
  v[y][x] = 0;
  for(int i = 0; i<8; i++) {
    int ny = y + d[i][0];
    int nx = x + d[i][1];
    if(0<=ny and ny<h and 0<=nx and nx<w and v[ny][nx] == 1) {
      dfs(ny, nx, v);
    }
  }
}

int main(void) {
  while(1) {
    cin>>w>>h;
    if(w == 0 and h == 0)
      break;
    vector<vector<int>> v;
    for(int i = 0; i<h; i++) {
      vector<int> vv;
      for(int j=0; j<w; j++) {
	int x;
	cin>>x;
	vv.push_back(x);
      }
      v.push_back(vv);
    }
    int cnt = 0;
    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
	if (v[i][j] == 1) {
	  cnt++;
	  dfs(i, j, v);
	}

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





Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  string s;
  cin >> n >> s;

  string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA";

  string ans = s;
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];
    int idx = alp.find(c);
    ans[i] = alp[idx + n];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#coding:utf-8
import sys,os
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

    N = II()
    from math import ceil
    print(ceil(N/2))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
n = int(input())
edgeList = []
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(i):
        if a[j] != -1:
            edgeList.append([a[j], i, j])
rootList = [-1 for i in range(n)]
sumLength = 0

def getRoot(x):
    r = rootList[x]
    if r < 0:
        rootList[x] = x
    elif r != x:
        rootList[x] = getRoot(r)
    return rootList[x]
        

edgeList.sort(key=lambda x: x[0])
for e in edgeList:
    x = getRoot(e[1])
    y = getRoot(e[2])
    if x != y:
        sumLength += e[0]
        rootList[x] = rootList[y] = min(x, y)
print(sumLength)

Measured memory_bytes: 6116
#include <iostream>

using namespace std;

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        ans = gcd(ans, a);
    }

    cout << ans << endl;
    return 0;
}


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

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

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int n,k,x,y; cin>>n>>k>>x>>y;
  if(n>k) print(k*x+(n-k)*y);
  else print(n*x);

  return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    s = S()

    return s[0] + str(len(s)-2) + s[-1]



print(main())



Measured memory_bytes: 6732
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll a[3];
    ll i;
    for(i=0; i<3; i++) cin >> a[i];
    sort(a, a+3);
    
    pt(a[0]*a[1]/2);
    
    
}






Measured memory_bytes: 256
from collections import Counter
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    A = [input() for _ in range(N)]
    common = Counter(A).most_common()
    ans = 0
    for i in common:
        if i[1] % 2 == 1:
            ans += 1
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 24436
def sieve(n):
    '''
    :param n:
    :return: n以下の素数のリストを返す
    エラトステネスの篩→O(n log log n)
    '''
    prime = []
    is_prime = [True] * (n + 1) #is_prime[i] = Trueならiは素数
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2 * i, n + 1, i):
                is_prime[j] = False
    return prime

N = int(input())
P = sieve(N)
ans = 1
for p in P:
    a = 0
    b = N // p
    while b > 0:
        a += b
        b //= p
    ans = ans * (a + 1) % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int set;            	/* 使用できる最大値格納用変数 */
	int tag;            	/* 目標値格納用変数 */
	int mid;            	/* 計算用変数 */
	int agg[100];       	/* 計算結果格納用配列 */
	int i, j;           	/* ループ変数 */
	int input_count = 0;	/* 入力数カウンタ */
	int num_count = 0;  	/* 目標を満足する値のカウンタ */
	
	/* 配列の初期化 */
	for(i = 0;i < 100;i++){
		agg[i] = 0;
	}
	
	/* 数値の入力、演算を無限ループ */
	while(1){
		/* 使用できる最大値、目標値の入力 */
		scanf("%d %d", &set, &tag);
		
		/* 終了処理 */
		if(set == 0 && tag == 0){
			break;
		}
		/* カウンタをリセット */
		num_count = 0;
		
		/* 目標を満足する値をカウント */
		for(i = 1;i < set;i++){
			for(j = i;j <= set;j++){
				/* i + j と目標値の差をmidに代入 */
				mid = tag - (i + j);
				/* midがiとjの間にある場合カウント*/
				if(mid > i && mid < j){
					num_count++;
				}
			}
		}
		
		/* カウントした結果を格納 */
		agg[input_count] = num_count;
		/* 入力数をカウント */
		input_count++;
	}
	
	/* 結果の出力 */
	for(i = 0;i < input_count;i++){
		printf("%d\n", agg[i]);
	}
	
	return 0;
}



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

vector<Int> factors(Int n) {
    vector<Int> v;
    for (Int i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            if (i != 1) v.push_back(i);
            if (i*i != n) v.push_back(n/i);
        }
    }
    return v;
}

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

    
    vector<Int> d1, d2;
    d1 = factors(N);
    d2 = factors(N-1);

    Int cnt1 = 0;

    for (int i = 0; i < d1.size(); ++i) {

        Int M = N;
        Int now = d1[i];
        while (M % now == 0) {
            M /= now;
        }
        if (M % now == 1) cnt1++;
    }

    Int cnt2 = d2.size();


    cout << cnt1 + cnt2 << endl;
}




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

int main() {
  string s;
  cin >> s;
  
  for (int bit = 0; bit < (1<<3); bit++) {
    int t = s.at(0) - '0';
    for (int i = 0; i < 3; i++) {
      if (bit & (1<<i)) {
        t += s.at(i + 1) - '0';
      }
      else {
        t -= s.at(i + 1) - '0';
      }
    }
    if (t == 7) {
      for (int j = 0; j < 3; j++) {
        if (bit & (1<<j)) {
          cout << s.at(j) << '+';
        }
        else {
          cout << s.at(j) << '-';
        }
      }
      cout << s.at(3) << "=7" << endl;
      break;
    }
  }
}



      

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
#define INF 100000000000

ll llAbs(ll num){
	if(num < 0) num = num * -1;
	return num;
}

int main()
{
	int n;
	cin>>n;
	ll *x = new ll[n];
	ll *y = new ll[n];
	int *a = new int[n];
	rep(i,n){
		cin>>a[i];
	}
	x[0] = a[0];
	for(int i = 1 ; i < n; i++){
		x[i] = x[i-1] + a[i];
	}
	y[n-1] = a[n-1];
	for(int i = n-2; i >= 0; i--){
		y[i] = y[i+1] + a[i];
	}
	ll ans = INF;
	for(int i = 0; i < n-1; i++){
		ans = min(ans, llAbs(x[i] - y[i+1]));
		//cout<<llAbs(x[i] - y[i+1])<<endl;
		//cout<<x[i]<<" "<<y[i+1]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4096
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> &P){
os << P.first;
os << " ";
os << P.second;
os << "\n";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N){
        cin >> A[i];
    }
    int ans=-INF;
    int cur_min = A[0];
    FOR(i,1,N){
        chmax(ans,A[i]-cur_min);
        chmin(cur_min, A[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 4396
#include <stdio.h>
#include <math.h>

int main(){
  int k, a, b;
  scanf("%d\n %d %d", &k, &a, &b);
  if(abs(a-b)>=k)printf("OK\n");
  else{
    for(int i=0; i<(1000+k)/k; i++){
      if(i*k>=a&&i*k<=b){
        printf("OK\n");
        return 0;
      }
      if(i*k>b)break;
    }
    printf("NG\n");
  }
}

Measured memory_bytes: 1588
from collections import defaultdict
from itertools import accumulate
import sys

input = sys.stdin.buffer.readline

n, k = map(int, input().split())
jisho = defaultdict(int)
A = [int(input()) for _ in range(n)]
A = [0] + A
SA = list(accumulate(A))
T = [0] * (n + 1)
for i in range(n + 1):
    T[i] = (SA[i] - k * i, i)
T.sort()


class SegmentTree:
    ele = 0

    def func(self, a, b):
        return a + b

    # SEG木は1-index
    # Aに関しては0-index

    def __init__(self, n):  # Aは0-idx
        self.n = n
        self.num = 2 ** ((self.n - 1).bit_length())
        self.SEG = [self.ele] * (2 * self.num)

    def search(self, idx):
        return self.SEG[idx + self.num]

    def initialize(self, A):
        for i in range(self.n):
            self.SEG[i + self.num] = A[i]
        for i in range(self.num - 1, 0, -1):
            self.SEG[i] = self.func(self.SEG[2 * i], self.SEG[2 * i + 1])

    def update(self, idx, val):
        idx += self.num
        self.SEG[idx] = val
        idx //= 2
        while idx:
            self.SEG[idx] = self.func(self.SEG[2 * idx], self.SEG[2 * idx + 1])
            idx //= 2

    # def delay(self,):

    def query(self, left, right):
        # maspy式。開区間のママ処理する
        # left, rightで値を分けているのは交換法則不成立のときのため
        # 開区間→Rが奇数→右端が偶数→1ずらしてから計算
        # 　下から上への遷移は2で割る
        # juppy氏は閉区間に直していた
        resleft = self.ele
        resright = self.ele
        left += self.num
        right += self.num
        while right - left > 0:
            if left % 2 == 1:
                resleft = self.func(resleft, self.SEG[left])
                left += 1
            if right % 2 == 1:
                right -= 1
                resright = self.func(resright, self.SEG[right])
            left //= 2
            right //= 2
        return self.func(resleft, resright)


ST = SegmentTree(n + 1)
ans = 0
for val, i in T:
    ans += ST.query(0, i + 1)
    ST.update(i, 1)
print(ans)


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

using namespace std;
using ll = long long;

int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	string s;
	cin >> s;
	s = "x" + s + "x";

	bool okA = true, okB = true, ok = false;
	for (int i = A; i <= C; ++i) {
		if (s[i] == '#' && s[i-1] == '#') { okA = false; }
	}
	for (int i = B; i <= D; ++i) {
		if (s[i] == '#' && s[i-1] == '#') { okB = false; }
		if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') { ok = true; }
	}

	if ((D < C && okA && okB && ok) || (C < D && okA && okB)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 772
N = int(input())
A = list(map(int, input().split()))

minus = 0
x = abs(A[0])
cnt = 0
for a in A:
    minus += (a < 0)
    a = abs(a)
    x = min(x, a)
    cnt += a

if x == 0:
    ans = cnt
elif minus % 2 == 0:
    ans = cnt
else:
    ans = cnt - 2 * x
print(ans)


Measured memory_bytes: 20108
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}
int A[N],lev[N];
ll ans[N];
ll tot =0;
vector<int> adj[N],v[N];
void dfs(int i,int p){
    for(auto ve:adj[i])if(p-ve){
        lev[ve]=lev[i]+1;
        dfs(ve,i);
    }
    v[lev[i]].pb(i);
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m,i,j,k,x,q;
    int t=1;
    cin>>n;
    int u,vi;
    rep(i,1,n-1){
        cin>>u>>vi;
        adj[u].pb(vi);
        adj[vi].pb(u);
    }
    rep(i,1,n){cin>>A[i];tot+=A[i];}
    sort(A+1,A+n+1);
    reverse(A+1,A+n+1);
    cout<<tot-A[1]<<"\n";
    dfs(1,-1);
    int l =1;
    rep(i,0,n){
        for(auto ve:v[i])ans[ve]=A[l++];
    }
    rep(i,1,n)cout<<ans[i]<<" ";
    cout<<"\n";







    
    return 0;
}


Measured memory_bytes: 7552
N[7],X[7][1024],Y[7][1024],M[7][1024];C(p,q,i,j,t,d){for(j=0;j<N[q];M[q][j++]=d)for(d=1e9,i=-1;++i<N[p];t<d?d=t:0)t=M[p][i]+abs(X[p][i]-X[q][j])+abs(Y[p][i]-Y[q][j]);}x,y,c,b,d,a,e;main(i){char l[1001];for(;scanf("%*d%d",&y)*y;printf(d-1e9?"%d %d\n":"NA\n",b,d)){bzero(N,28);for(b=0;y--;)for(x=-scanf("%s",l);c=l[++x];)c>48?i=c<54?c-48:c>82?0:6,X[i][N[i]]=x,Y[i][N[i]]=y,b+=!N[i]++:0;for(i=6;--i;d=1e9)!N[i]?a=i,e=i+1:0;for(b>6?a=1,e=6:b<6?a=e:0;a<e;C(x,6),*M[6]<d?d=*M[6],b=a:0,a++)for(C(i=**M=0,x=1+a%5);++i<4;x=y)C(x,y=1+(a+i)%5);}}

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

int main()
{
    int a,b,c,x,sum=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            int k=(x-i*500-j*100)/50;
            if(i*500+j*100+k*50==x&&k>=0&&k<=c)
                sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}


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

public class Main {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long x = sc.nextLong();
    long[] strLen = new long[n+1];
    long cntP = 0;

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        strLen[0] = 1;
        for (int i=1; i<=n; i++) {
            strLen[i] = strLen[i-1] * 2 + 3;
        }
//        System.out.println(Arrays.toString(strLen));

        while (true) {
            if (x == 1) {
                System.out.println(cntP);
                return;
            }
            if (x == strLen[n] / 2) {
                System.out.println(cntP + (strLen[n]/2 - 1) / 2 + 1 );
                return;
            }
            if (x == strLen[n] / 2 + 1) {
                System.out.println(cntP + (strLen[n]/2 - 1) / 2 + 2 );
                return;
            }
            if (x == strLen[n] - 1) {
                System.out.println(cntP + strLen[n]/2 + 1);
                return;
            }
            if (x == strLen[n]) {
                System.out.println(cntP + strLen[n]/2 + 1);
                return;
            }
            if (1 < x && x < strLen[n] / 2) {
                x--;
                n--;
                continue;
            }
            if (strLen[n] / 2 + 1 < x && x < strLen[n] - 1) {
                cntP += strLen[n] / 4L;
                cntP++;
                x--;
                x -= (strLen[n] / 2 - 1);
                x--;
                n--;
                continue;
            }
        }

    }


}


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

int main() {
  ll N; cin >> N;
  vector<ll> bits;
  ll rem = N;
  ll p = 0;
  if (N == 0) {cout << 0 << endl; return 0;}
  while (rem!=0) {
    p++;
    ll n = abs(rem);
    if (p%2 == 1) {
      bits.push_back((n%(1LL << p)) >> (p-1) & 1);
      rem -= n%(1LL << p); //cout << rem << endl;
    }
    if (p%2 == 0) {
      bits.push_back((n%(1LL << p)) >> (p-1) & 1);
      rem += n%(1LL << p); //cout << rem << endl;
    }
  }
  for (ll i = bits.size()-1; i >= 0; i--) {
    cout << bits[i];
  }
  cout << endl;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



mint f(int n) {
    if (n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) {
        x *= 2;
    }
    return x;
}

mint choose (int n, int a) {
    mint x = 1, y = 1;
    rep(i, a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}


int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    mint ans = f(n);
    ans -= 1;
    ans -= choose(n, a);
    ans -= choose(n, b);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,m,k;
  cin>>n>>m>>k;
  vector<Int> as(n),bs(m);
  for(Int i=0;i<n;i++) cin>>as[i];
  for(Int i=0;i<m;i++) cin>>bs[i];

  vector<Int> sa(n+1,0),sb(m+1,0);
  for(Int i=0;i<n;i++) sa[i+1]=sa[i]+as[i];
  for(Int i=0;i<m;i++) sb[i+1]=sb[i]+bs[i];

  Int ans=0;
  for(Int i=0;i<=n;i++){
    Int val=sa[i];
    if(val>k) break;
    Int j=--upper_bound(sb.begin(),sb.end(),k-val)-sb.begin();
    assert(sa[i]+sb[j]<=k);
    chmax(ans,i+j);
  }
  cout<<ans<<newl;
  return 0;
}


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

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

    //I don't care about anybody, and fuck ratings! I'll go to google!
    string s; cin>>s;
    if(s=="Sunny") cout<<"Cloudy\n";
    else if(s=="Cloudy") cout<<"Rainy\n";
    else cout<<"Sunny\n";
    return 0; 
}


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

int main() {
string S,T;
cin >> S >> T;

if(T==S+"a"|| T==S+"b"|| T==S+"c"|| T==S+"d"|| T==S+"e"|| T==S+"f"|| T==S+"g"|| T==S+"h"|| T==S+"i"|| T==S+"j"|| T==S+"k"|| T==S+"l"|| T==S+"m"|| T==S+"n"|| T==S+"o"|| T==S+"p"|| T==S+"q"|| T==S+"r"|| T==S+"s"|| T==S+"t"|| T==S+"u"|| T==S+"v"|| T==S+"w"|| T==S+"x"|| T==S+"y"|| T==S+"z")  cout  <<  "Yes"  <<  endl;
else cout << "No" <<endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
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;};



signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int ans = 1;
    REP(i, 2, n+1) {
        for(int j = i * i; j <= n; j *= i) {
            chmax(ans, j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def prime?(n)
  return n >= 2 if n <= 3
  return true if n == 5
  return false unless 30.gcd(n) == 1
  (7..n**(0.5)).step(30) do |p|
    return false if
      n % (p) == 0 || n % (p + 4) == 0 || n % (p + 6) == 0 || n % (p + 10) == 0 ||
      n % (p + 12) == 0 || n % (p + 16) == 0 || n % (p + 22) == 0 || n % (p + 24) == 0
  end
  true
end

Q = gets.to_i
max = 10**5+10

a = Array.new(max, 0)
max.times do |i|
  if prime?(i) && prime?((i+1)/2)
    a[i] = 1
  end
end

s = Array.new(max+1, 0)
max.times do |i|
  s[i+1] = s[i] + a[i]
end

ans = []
Q.times do
  l, r = gets.split.map(&:to_i)
  ans << s[r+1] - s[l]
end
puts ans

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

int main(void)
{
    int x,t;
    cin >> x >> t;
    if(x - t <= 0){cout << 0 << endl;}
    else{cout << x-t << endl;}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		int dp[][]=new int[s.length()+1][t.length()+1];
		for(int i=1;i<=s.length();i++){
		    for(int j=1;j<=t.length();j++){
		        if(s.charAt(i-1)==t.charAt(j-1)){
		            dp[i][j]=dp[i-1][j-1]+1;
		        }else{
		            dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
		        }
		    }
		}
		String ans=reconstruct(dp,s.length(),t.length(),s,t);
		System.out.println(ans);
	}
	public static String reconstruct(int dp[][],int r,int c,String s,String t){
	    if(r==0||c==0)
	    return "";
	    if(s.charAt(r-1)==t.charAt(c-1))
	    return reconstruct(dp,r-1,c-1,s,t)+Character.toString(s.charAt(r-1));
	    else if(dp[r][c]==dp[r-1][c]){
	        return reconstruct(dp,r-1,c,s,t);
	    }else{
	        return reconstruct(dp,r,c-1,s,t);
	    }
	}
    
}


Measured memory_bytes: 98632
// abc140_b
// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
	}
	vector<int> B(N);
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	vector<int> C(N-1);
	for (int i = 0; i < N-1; i++) {
		cin >> C[i];
	}

	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += B[A[i]];
		if (i > 0 && A[i] == A[i-1] + 1) {
			sum += C[A[i-1]];
		}
		//sum += B[A[i]-1];
		////cout << "sum=" << B[A[i] - 1] << endl;

		//if (i != 0 && i != N - 1 && (A[i]) != 1) {
		//	sum += C[A[i] - 2];
		//	//cout << "sum=" << C[A[i] - 2] << endl;
		//}
	}
	cout << sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n,k;
    cin >> n >> k;
    int p[n];
    rep(i,n)cin >> p[i];
    int sum=0;
    int mx=0;
    rep(i,k){
        sum+=p[i];
    }
    mx=sum;
    for(int i=k;i<n;i++){
        sum+=p[i]-p[i-k];
        chmax(mx,sum);
    }
  	cout << fixed;
    cout << setprecision(10) << ((double)mx+(double)k)/2;


    
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int n,a,f[100001],ans;
int main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a;
    f[a-1]++,f[a+1]++,f[a]++;
  }
  for(int i=1;i<=100000;i++)if(f[i]>ans)ans=f[i];
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int main(void){
  int n,k;
  long long int sum = 0;
  cin>>n>>k;
  vector<int> p(n);
  
  for(int i = 0; i < n; i++)
  {
    cin>>p[i];
  }
  
  sort(p.begin(),p.end());
  for(int i = 0; i < k; i++)
  {
    sum += p[i];
    //cout<<p[i]<<endl;
  }
  cout<<sum<<endl;
  return 0;
}




Measured memory_bytes: 3548
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            int x =int.Parse(str);
            x = x * x * x;
            Console.Write(x);
            Console.Write("\n");

        }
    }
}

Measured memory_bytes: 5600