akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#define N 70
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
ll n;
ll dp[N][2][2][2];
vector<int> ds;
void getds(ll x) {
	for (int i = 0; i <= 63; ++i) {
		ds.push_back(x%2);
		x /= 2;
	}
	reverse(ds.begin(), ds.end());
}
ll dfs(int cur, int f1, int f2, int add) {
	if (cur > 63) {
		if (!add) return 1;
		return 0;
	}
	if (dp[cur][f1][f2][add] >= 0) return dp[cur][f1][f2][add];
	dp[cur][f1][f2][add] = 0;
	for (int d1 = 0; d1 < 2; ++d1) {
		for (int d2 = 0; d2 < 2; ++d2) {
			if (cur == 0 && d1 == 0 && d2 == 1) continue;
			if (!f1 && d1 > ds[cur]) continue;
			if (!f2 && d2 > d1) continue;
			if (add && d1&&d2) continue;
			if (!add && !d1 && d2) continue;
			ll res= dfs(cur+1, f1 | (d1 < ds[cur]), f2 | (d2 < d1), (d1!=d2));
			dp[cur][f1][f2][add] = (dp[cur][f1][f2][add] + res) % mod;
		}
	}
	return dp[cur][f1][f2][add];
}
int main() {
	cin>>n;
	ds.clear();
	getds(n);
	memset(dp, -1, sizeof(dp));
	dfs(0, 0, 0, 0);
	cout<<dp[0][0][0][0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void insert();
void inorder();
void preorder();
struct node{
  int key;
  struct node *right,*left,*parent;
};
typedef struct node * Node;
Node root;
#define NIL NULL


void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key<y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(!strcmp(com,"insert")){
      scanf("%d",&x);
      insert(x);
    }
    else if(!strcmp(com,"print")){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
while True:
    n = list(map(int,input().split()))
    if n[0] == -1 or n[1] == -1:
        if sum(n) == -3:
            break
        print("F")
    elif n[0]+n[1] >= 80:
        print("A")
    elif n[0]+n[1] >= 65:
        print("B")
    elif n[0]+n[1] >= 50:
        print("C")
    elif n[0]+n[1] >= 30:
        if n[2] >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")
    


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll n = 100;
    ll cnt = 0;
    while(n < x){
        n += n*0.01;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  lli N;
  cin >> N;
  vector<lli>a(N+1);
  vector<lli>b(N);
  REP(i,N+1){
	  cin>>a[i];
  }

  REP(i,N){
	  cin>>b[i];
  }
  lli sum=0;
  REP(i,N){
	  lli minab=min(a[i],b[i]);
	  a[i]-=minab;
	  b[i]-=minab;
	  sum+=minab;
	  if (b[i]!=0){
	   minab=min(a[i+1],b[i]);
		a[i+1]-=minab;
	  	b[i]-=minab;
	  	  sum+=minab;
	  }
  }
	cout <<sum<<endl;
}

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

    long sum, n;
    int x, y, h, w;
    int len;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextLong();
	    sum = 0;
	    if(n!=0) solve();
	}
    }

    void solve(){
	for(int i=0; i<n; i++){
	    x = sc.nextInt();
	    y = sc.nextInt();
	    h = sc.nextInt();
	    w = sc.nextInt();
	    len = x+y+h;
	    sum += fee();
	}
	System.out.println(sum);
    }

    int fee(){
	if(len<=60 && w<=2)
	    return 600;
	else if(len<=80 && w<=5)
	    return 800;
	else if(len<=100 && w<=10)
	    return 1000;
	else if(len<=120 && w<=15)
	    return 1200;
	else if(len<=140 && w<=20)
	    return 1400;
	else if(len<=160 && w<=25)
	    return 1600;
	return 0;
    }
}
	

Measured memory_bytes: 56436
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============ford_fulkerson============================
ll MAX_V = 202;
struct edge {ll to, cap, rev;};
vector<vector<edge>> G(MAX_V);
vector<bool> used(MAX_V, false);

void add_edge(ll from, ll to, ll cap) {
  G.at(from).push_back((edge){to, cap, (ll)G.at(to).size()});
  G.at(to).push_back((edge){from, 0ll, (ll)G.at(from).size() - 1});
}

ll dfs(ll v, ll t, ll f) {
  if (v == t) {
    return f;
  }
  used.at(v) = true;
  for (ll i = 0; i < G.at(v).size(); ++i) {
    edge &e = G.at(v).at(i);
    if (!used.at(e.to) && e.cap > 0) {
      ll d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G.at(e.to).at(e.rev).cap += d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(ll s, ll t) {
  ll flow = 0;
  while (true) {
    used = vector<bool>(MAX_V, false);
    ll f = dfs(s, t, INF);
    if (f == 0) {
      return flow;
    }
    flow += f;
  }
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<pll> red(N), blue(N);
  for (ll i = 0; i < N; ++i) {
    cin >> red.at(i).first >> red.at(i).second;
    add_edge(200, i, 1);
  }
  for (ll i = 0; i < N; ++i) {
    cin >> blue.at(i).first >> blue.at(i).second;
    add_edge(100 + i, 201, 1);
  }
  for (ll i = 0; i < N; ++i) {
    pll now = red.at(i);
    for (ll j = 0; j < N; ++j) {
      if ((now.first < blue.at(j).first) && (now.second < blue.at(j).second)) {
        add_edge(i, 100 + j, 1);
      }
    }
  }
  cout << max_flow(200, 201) << "\n";
}


Measured memory_bytes: 3824
import math

g = 1000000007
N, A, B, C = map(int, input().split())


fr = [1] * (2 * N)
for i in range(2, 2*N):
    fr[i] = i * fr[i-1] % g

def dot(A, B):
    return A * B % g

def po(A, B):

    return pow(A, B, g)

def add(A, B):
    return (A + B) % g

def combi(a, b):
    return fr[a] * div(1, fr[b]) * div(1, fr[a-b]) % g

def div(a, b):
    return a * pow(b, g-2, g) % g



AB = A+B
A = div(A, AB)
B = div(B, AB)
C = div(C, 100)


s = 0
for M in range(N, 2 * N):
    w = dot(add(dot(po(A, N), po(B, M - N)), dot(po(A, M-N), po(B, N))), combi(M-1, N-1) * M * div(1, add(1, -C)))
    s = add(s, w)

print(s)


Measured memory_bytes: 45160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
vector<ll> V;
char buff[4005];
int sum[4005][3];
int main() {
    int n;cin>>n;scanf("%s",buff+1);
    for(int i=n;i>=1;i--){
        sum[i][0]=sum[i+1][0];
        sum[i][1]=sum[i+1][1];
        sum[i][2]=sum[i+1][2];
        if(buff[i]=='R') sum[i][0]++;
        if(buff[i]=='G') sum[i][1]++;
        if(buff[i]=='B') sum[i][2]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(buff[i]!='R'&&buff[j]!='R'&&buff[i]!=buff[j]){
                ans+=sum[j][0];
                if(2*j-i<=n&&buff[2*j-i]=='R') ans--;
            }
            if(buff[i]!='G'&&buff[j]!='G'&&buff[i]!=buff[j]){
                ans+=sum[j][1];
                if(2*j-i<=n&&buff[2*j-i]=='G') ans--;
            }
            if(buff[i]!='B'&&buff[j]!='B'&&buff[i]!=buff[j]){
                ans+=sum[j][2];
                if(2*j-i<=n&&buff[2*j-i]=='B') ans--;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3780
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
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 II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = LI_()
        edges[a].append(b)
        edges[b].append(a)
    C = LI()
    C.sort(reverse=True)
    visited = [0] * N
    D = [0] * N
    def solve(v, i):
        visited[v] = 1
        D[v] = C[i]
        for to in edges[v]:
            if not visited[to]:
                i += 1
                i = solve(to, i)
        return i
    solve(0, 0)
    M = sum(C[1:])
    print(M)
    print(*D)

    return

main()

Measured memory_bytes: 16244
// Problem : D - Swap and Flip
// Contest : AtCoder - Keyence Programming Contest 2020
// URL : https://atcoder.jp/contests/keyence2020/tasks/keyence2020_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 20
#define MX 52

int n;
int dp[1LL<<N][MX], a[N], b[N];
int val[N][N];

//Solution

void solve(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int j=0;j<n;j++) cin>>b[j];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            val[i][j] = (i%2 == j%2 ? a[j] : b[j]);
        }
    }
    for(int i=0;i<=(1<<n);i++){
        for(int j=0;j<MX;j++) dp[i][j] = inf;
    }
    dp[0][0] = 0;
    for(int mask=0;mask<(1<<n);mask++){
        int i = __builtin_popcount(mask);
        for(int num=0;num<MX;num++){
            int cost = 0;
            for(int j=0;j<n;j++){
                if((mask>>j)&1) continue;
                if(val[i][j] >= num)
                    dp[mask|(1<<j)][val[i][j]] = min(dp[mask|(1<<j)][val[i][j]], dp[mask][num]+cost);
                cost++;
            }
        }
    }
    int ans = inf;
    for(int i=0;i<MX;i++) ans = min(ans,dp[(1<<n)-1][i]);
    cout<<(ans == inf ? -1 : ans)<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 110160
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int dp[300][300];
//main
signed main(){
  int N;cin>>N;
  std::vector<char> v(N);
  std::vector<int> w(300);
  w[0]=1;for(int i=1;i<300;i++)w[i]=w[i-1]*i%MOD;
  for(int i=0;i<N;i++)cin>>v[i];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  int now=0;
  for(int i=0;i<N;i++){
    if(v[i]=='-')continue;
    else{
      for(int j=0;j<N;j++){
        if(v[i]=='U'){
          dp[now+1][j+1]+=dp[now][j];
          dp[now+1][j]+=dp[now][j]*j;
        }
        else {
          dp[now+1][j]+=dp[now][j]*j;
          if(j)dp[now+1][j-1]+=dp[now][j]*j*j;
        }
      }
      for(int j=0;j<N;j++)dp[now+1][j]%=MOD;
      now++;
    }
  }
  cout<<dp[now][0]<<endl;
}



Measured memory_bytes: 3800
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

int main(){
	int n, x, t;
	std::cin>>n>>x>>t;

	int ans= n/x + ((n%x==0)? 0: 1);
	ans= ans*t;

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
  	//"math"
)

func main() {
  	var k float64
  	var n int
  	fmt.Scan(&k,&n)
    houses := make([]float64, n)
  
    for i,_ := range houses {
      fmt.Scan(&houses[i])
    }

    min,dist := 1000000,1000000
    for i := 0; i < n; i++ {
      j := i - 1
      if i == 0 {
      	j = i + 1
        dist = int(houses[n-1] - houses[i])
      } else {
        dist = int(houses[j]+k - houses[i])
      }
      
      if min > dist {
      	min = dist
      }
    }
	fmt.Println(min)
}

Measured memory_bytes: 6400
#include<bits/stdc++.h> 
using namespace std;
#define ll  long long
int main(){
	int N;
	cin >> N;
	for (long long int i = -2000; i <= 2000; i++) {
		for (long long int j = -2000; j <= 2000; j++) {
			if (i*i*i*i*i - j * j*j*j*j == N) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,q;
  string s;
  cin>>n;
  cin>>s;
  cin>>q;
  int k[q+1]={};
  ll sum[n+1]={};
  for(int i=0;i<q;i++){
    cin>>k[i];
  }
  for(int i=0;i<n;i++){
    if(s[i]=='M') sum[i]++;
    if(i>0) sum[i]+=sum[i-1];
  }

  for(int i=0;i<q;i++){
    ll ans=0;
    ll c=0,d=0,m=0;
    ll dm=0;
    for(int j=0;j<n;j++){
      if(s[j]=='D') d++;
      else if(s[j]=='M'){
        m++;
        dm+=d;
      }else if(s[j]=='C'){
        ans+=dm;
      }
      if(j-k[i]+1>=0){
        if(s[j-k[i]+1]=='D'){
          d--;
          dm-=m;
        }else if(s[j-k[i]+1]=='M'){
          m--;
        }
      }
    }
    cout<<ans<<endl;
  }


  return 0;
}


Measured memory_bytes: 9220
#include <iostream>
using namespace std;
int a[100], n, res;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int flag = 1;
    while (flag) {
        flag = 0;
        for (int i = 1; i < n; i++) {
            if (a[i - 1] > a[i]) {
                swap(a[i - 1], a[i]);
                flag = 1;
                res++;
            }
        }
    }
    for (int i = 0; i < n - 1; i++) cout << a[i] << ' ';
    cout << a[n - 1] << endl << res << endl;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    bool A[4][14];
    for(int i=0;i<4;i++)
        for(int j=1;j<14;j++)A[i][j]=false;
    while(N--){
        char c;
        int n;
        cin>>c>>n;
        if(c=='S')A[0][n]=true;
        else if(c=='H')A[1][n]=true;
        else if(c=='C')A[2][n]=true;
        else A[3][n]=true;
    }
    string S="SHCD";
    for(int i=0;i<4;i++)
        for(int j=1;j<=13;j++)
            if(!A[i][j])cout<<S[i]<<' '<<j<<'\n';
}


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

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for (;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

char s[1000];

int main() {
	int d;
	scanf("%s",s);
	scanf("%d",&d);
	int len = strlen(s);
	for (int i=0; i<len; ++i) {
		if (i % d == 0) cout << s[i];
	}
	
/*	int n,m;
	cin >> n >> m;
	if (n * m == 15) cout << "*";
	else if (n + m == 15) cout << "+";
	else cout << "x"; */
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;


int main(void)
{
    int R[MAX], n;

    cin >> n;
    for (int i; i < n; i++) cin >> R[i];

    int max_profit = -2000000000;
    int min_rate = R[0];

    for (int i = 1; i < n; i++) {
        max_profit = max(max_profit, R[i] - min_rate);
        min_rate = min(min_rate, R[i]);
    }

    cout << max_profit << endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  int ans;
  if (S=="SUN") ans = 7;
  else if (S=="MON") ans = 6;
  else if (S=="TUE") ans = 5;
  else if (S=="WED") ans = 4;
  else if (S=="THU") ans = 3;
  else if (S=="FRI") ans = 2;
  else if (S=="SAT") ans = 1;
  
  cout << ans << endl;
  
}

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

int main(int argc, char** argv) {
	int N;
	vector<int> H;
	int i, max = 0, count;

	cin >> N;
	H.resize(N);
	for (int c = 0; c < N; c++) {
		cin >> H.at(c);
	}

	for (i = 0; i < (H.size() - 1 - max); i++) {
		count = 0;
		while ((i + count + 1) <= (H.size() - 1)) {
			if (H.at(i + count) < H.at(i + count + 1)) {
				break;
			}
			count++;
		}
		if (max < count) {
			max = count;
		}
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 768
import math

def main():
    N = int(input())
    lowercase = 'abcdefghijklmnopqrstuvwxyz'
    ans = ''
    for i in range(len(str(N))):
        j = N % 26
        if N == 0:
            break
        if j == 0:
            N = N // 26 - 1
        else:
            N = N // 26
        ans = lowercase[j-1] + ans
        # print(N, j-1, ans)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 62020
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[110];
multiset<int> st;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		st.insert(a[i]);
	}
	sort(a, a + n);
	if (a[n - 1] != a[n - 2]) {
		puts("Impossible");
		return 0;
	}
	st.erase(st.find(a[n - 1]));
	st.erase(st.find(a[n - 1]));
	for (int i = a[n - 1] - 1; i * 2 >= a[n - 1]; i--) {
		if (i * 2 > a[n - 1]){
			if (st.count(i) < 2) {
				puts("Impossible");
				return 0;
			}
			st.erase(st.find(i));
			st.erase(st.find(i));
		}
		if (i * 2 == a[n - 1]){
			if (!st.count(i)) {
				puts("Impossible");
				return 0;
			}
			st.erase(st.find(i));
		}
	}
	if (st.empty())puts("Possible");
	else if ((*st.begin() - 1) >= (a[n - 1] + 1) / 2)puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
eval"N,*A,M=#{`tr -! ,`}2**64-1"
C=[0,N].map{|z|y,*a=A[z,N]*3
a.map{y^y=_1}}
e,f=C.map{|z|z[b=0,N].map{b=b*9+_1&M}
b}
q=1-9**N&M
N.times{|i|e==f&&p(i,A[i]^A[N])
e=e*9+C[0][i]*q&M}

Measured memory_bytes: 64724
# coding: utf-8
# Here your code !

a = list(map((int), input().split(' ')))
N, M = a[0], a[1]

first = []
second = []

for i in range(M):
    
    b = list(map((int),input().split(' ')))
    start, end = b[0], b[1]
    
    if start == 1:
        first.append(end)
    if end == N:
        second.append(start)
        
first_set = set(first)
second_set = set(second)

matched_l = list(first_set & second_set)

if matched_l is None or len(matched_l) == 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')


Measured memory_bytes: 21856
N, M = map(int, input().split())
dp = [0]*(M+1)
for _ in range(N):
    l = list(map(int, input().split()))
    for e in l[1:]:
        dp[e] += 1
ans = 0
for e in dp:
    if e == N:
        ans += 1
print(ans)


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

int main() {
  int N;
  cin >> N;
  int ans = 1, count, maxcount = 0, tmp;
  for (int i = 1; i <= N; i++) {
    tmp = i;
    count = 0;
    while (tmp % 2 == 0) {
      count++;
      tmp /= 2;
    }
    if (maxcount < count) {
      maxcount = count;
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
B = [int(x) for x in input().split()]

A = [0]*N

A[0] = B[0]
A[N - 1] = B[N - 2]

for i in range(1, N - 1):
    A[i] = min(B[i - 1], B[i])

ans = sum(A)

print(ans)

Measured memory_bytes: 9188
#include <iostream>
using namespace std;
#define ll long long
ll a,b,c,n;
ll bamboos[1001]={0};

ll Synthetic(ll x,ll y,ll z,int i){
	if(i == n){
		if(x<=0||y<=0||z<=0) return 1e12;
		return abs(x-a)+abs(y-b)+abs(z-c);
	}

	ll op1 = Synthetic(x,y,z,i+1);
	ll op2 = Synthetic(x+bamboos[i],y,z,i+1) + ((x>0)?10:0);
	ll op3 = Synthetic(x,y+bamboos[i],z,i+1) + ((y>0)?10:0);
	ll op4 = Synthetic(x,y,z+bamboos[i],i+1) + ((z>0)?10:0);
	return min(op1,min(op2,min(op3,op4)));
}

int main(){
	
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++) cin>>bamboos[i];
	cout<<Synthetic(0,0,0,0);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define LOG
#define PRINT
#define LCERR
#include <iostream>
auto optimize_cpp_stdio = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::setvbuf(stdout, nullptr, _IOFBF, BUFSIZ);
    return 0;
}();
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

namespace {

using namespace std;

class Solution {
public:
    bool build_stairs(vector<int>& H) {
        for (int i = 0; i < H.size(); ++i) {
            if (i == 0 || H[i] - 1 >= H[i - 1]) {
                H[i] -= 1;
            }
            if (i > 0 && H[i - 1] > H[i]) {
                return false;
            }
        }
        return true;
    }

private:

};

int solve() {
    Solution solution;
    // handle IO here
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    cout << (solution.build_stairs(H) ? "Yes\n" : "No\n");
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
 vector <int> bingo(9);
  for (int i = 0; i < 9; i++) {
    cin >> bingo.at(i);
  }
  int a;
  int b = 0;
  cin >> a;
  vector<int> vec(a);
  for (int i = 0; i < a; i++) {
    cin >> vec.at(i);
    for (int j = 0; j < 9; j++) {
	if (bingo.at(j) == vec.at(i)) {
      bingo.at(j) = -1;
    }
    }
  }
  if ((bingo.at(0) == bingo.at(4)) && (bingo.at(4) == bingo.at(8))) {
    b++;
  }else if ((bingo.at(2) == bingo.at(4)) && (bingo.at(4) == bingo.at(6))) {
    b++;
  }else if ((bingo.at(0) == bingo.at(1)) && (bingo.at(1) == bingo.at(2))) {
    b++;
  }else if ((bingo.at(3) == bingo.at(4)) && (bingo.at(4) == bingo.at(5))) {
    b++;
  }else if ((bingo.at(6) == bingo.at(7)) && (bingo.at(7) == bingo.at(8))) {
    b++;
  }else if ((bingo.at(0) == bingo.at(3)) && (bingo.at(3) == bingo.at(6))) {
    b++;
  }else if ((bingo.at(1) == bingo.at(4)) && (bingo.at(4) == bingo.at(7))) {
    b++;
  }else if ((bingo.at(2) == bingo.at(5)) && (bingo.at(5) == bingo.at(8))) {
    b++;
  }
  if (b != 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

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

int main(){
  map<int,int> mp;
  int n; cin >> n;
  for(int i=0;i<n;++i){
    int num; cin >> num;
    mp[num]++;
  }
  
  for(auto c:mp){
    if(c.second >= c.first) ans += c.second - c.first;
    else ans += c.second;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){
  int H,W,count;
  cin >> H >> W;
  vector<vector<char>> input(H+2, vector<char>(W+2));
  for(int i = 0; i < H ; i++){
    for(int j = 0; j < W ; j++){
      cin >> input[i + 1][j + 1];
    }
  }
  for(int i = 0 ; i < H; i++){
    for(int j = 0; j < W; j++){
        count = 0;
  		if(input[i + 1][j + 1] == '.'){
        	for(int k = i; k < i + 3; k++){
              for(int l = j; l < j + 3; l++){
                if(input[k][l] == '#'){
                  count++;}
              }
            }
        input[i + 1][j + 1] = (char)(count + 48);
        }
     }
  }
  for(int i = 0; i < H ; i++){
    for(int j = 0; j < W ; j++){
      cout << input[i + 1][j + 1];
    }
    cout << endl;
  }
}

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

bool a[100010];

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

  int x;
  for (int i=1; i<=n; i++) {
    scanf("%d",&x);
    if (x==i)
      a[i]=true;
  }
  int cnt=0;
  for (int i=1; i<=n; i++) {
    if (a[i]==true) {
      cnt++;
      if (a[i]==true)
	a[i+1]=false;
    }
  }

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

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, K;
int V[110];

signed main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++)cin >> V[i];
    int ans = 0, lim = min(N, K);
    for (int L = 0; L <= lim; L++) {
        for (int R = 0; R <= lim - L; R++) {
            vint vec;
            for (int i = 0; i < L; i++)vec.push_back(V[i]);
            for (int i = N - 1; i > N - R - 1; i--)vec.push_back(V[i]);
            sort(vec.begin(), vec.end());
            for (int i = 0; i < min((int) vec.size(), K - L - R); i++)if (vec[i] < 0)vec[i] = 0;
            int sum = 0;
            for (int i = 0; i < vec.size(); i++)sum += vec[i];
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs_visit(int);
void dfs(void);

int n,M[N][N],color[N],d[N],f[N],t=0;

int main()
{
  int u,k,v;
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j] = 0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}

void dfs()
{
  int x;

  for(x=0;x<n;x++) color[x] = WHITE;

  for(x=0;x<n;x++){
    if(color[x] == WHITE) dfs_visit(x);
  }

  for(x=0;x<n;x++) printf("%d %d %d\n",x+1,d[x],f[x]);
}

void dfs_visit(int x)
{
  int c;
  color[x] = GRAY;
  t++;
  d[x] += t;
  for(c=0;c<n;c++){
    if(M[x][c] == 0) continue;
    if(color[c] == WHITE) dfs_visit(c);
  }
  color[x] = BLACK;
  t++;
  f[x] += t;
}



Measured memory_bytes: 2052
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var rgb = Sarray();
            if ((rgb[0] * 100 + rgb[1] * 10 + rgb[2]) % 4 == 0)
                WriteLine("YES");
            else
                WriteLine("NO");
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, x;
  cin >> a >> b >> x;
  ll ue, sita;
  if(a % x == 0) {
    ue = a / x - 1;
  } else {
    ue = a / x;
  }
  sita = b / x;
  cout << sita - ue << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
main(){
  ios_base::sync_with_stdio(false);
  int v,e,s,t,lose[10001];
  vector<int> vec[10001];
  queue<int> que;
  cin >> v >> e;
  for(int i=1;i<=e;i++){
    cin >> s >> t;
    lose[t]++;
    vec[s].push_back(t);
  }
  for(int i=1;i<=v;i++){
    if(lose[i] == 0) que.push(i);
  }
  bool flag,flag2=false;
  while(!que.empty()){
    int point = que.front();
    que.pop();
    flag = false;
    cout << point << endl;
    for(int i=0;i<vec[point].size();i++){
      lose[vec[point][i]]--;
      if(!lose[vec[point][i]]){
	que.push(vec[point][i]);
	if(flag) flag2 = true;
	flag = true;
      }
    }
  }
  cout << flag2 << endl;
  return(0);
}



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



int main() {
    ll a, b;
    cin >> a >> b;
    
    ll g = gcd(a,b);
    //cout << g << endl;
    
    ll ans = 0;
    for(ll i = 2; i*i <= g; i++) {
        if(g % i == 0) {
            ans++;
            while(g % i == 0) {
                g /= i;
            }
        }
    }
    
    if(g != 1)
        ans++;
    
    cout << ans+1 << endl;
    
    
    return 0;
}




Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	M = N-1
	ans = (1+M)*M//2
	print(ans)

if __name__ == '__main__':
	main()

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

int N;

int gcd(int a, int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}

int vgcd(vector<int> a){
    int ans = a[0];
    for(int i=0;i<a.size();++i){
        ans = gcd(a[i],ans);
    }
    return ans;
}

int main(){
    cin >> N;
    vector<int> A;
    int l;
    for(int i=0;i<N;++i){
        cin >> l;
        A.push_back(l);
    }
    int ans = vgcd(A);
    cout << ans << endl;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
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 (int i = 0; i < n; i++) cout << s[i];
    cout << endl;
}

Measured memory_bytes: 256
import heapq
n,m = map(int, input().split())
a =list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

used = 0
for _ in range(m):
  tmp = heapq.heappop(a)
  heapq.heappush(a, -1*(-tmp//2))
print(-sum(a))

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int N,K; cin >> N >> K;
	vector<int> h(N);
	int ans = 0;
	for(int i = 0; i < N; ++i) {
		cin >> h[i];
		if(h[i]>=K) ans++;
	}
	cout << ans << endl;



	return 0;
}


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

const int inf = 1e9+7;
int a[100007];
int n;
long long ans;

int main(){
	
	cin >> n;
	for(int i = 2;i<=n;i++){
		int x = i;
		for(int j = 2;j<=x;j++){
			while(x%j==0){
				a[j]++;
				x/=j;
			}
		}
	}
	ans = 1;
	for(int i = 2;i<=n;i++){
		if(a[i]){
			ans*=(a[i]+1)%inf;
			ans%=inf;
		}
	}
	cout << ans;
} 

Measured memory_bytes: 256
//09
#include<iostream>
#include<queue>

using namespace std;

struct S{
  int t,p;
};

int main(){
  int n;
  cin>>n;
  int p[100000];
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  queue<S> que;
  S is={0,0};
  que.push(is);
  bool ps[100000]={true};
  for(;;){
    S c=que.front();
    for(int i=1;i<=6;i++){
      int x=c.p+i;
      for(;;){
	if(x>=n-1)goto end;
	if(ps[x]++)break;
	if(p[x]==0){
	  S n={c.t+1,x};
	  que.push(n);
	  break;
	}
	x+=p[x];
      }
    }
    que.pop();
  }
  end:
  cout<<que.front().t+1<<endl;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  int l, r;
  l = r = 0;
  rep(i, m){
    int a;
    cin >> a;
    if(a < x) l++;
    else r++;
  }
  cout << min(l, r) << endl;
  return 0;
}

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

int main() {
  int64_t A, B, C, X, Y;
  std::cin >> A >> B >> C >> X >> Y;
  if ((A + B) <= 2 * C) {
    std::cout << A * X + B * Y << std::endl;
  } else if (X > Y) {
    std::cout << std::min(A, 2 * C) * (X - Y) + 2 * C * Y << std::endl;
  } else {
    std::cout << 2 * C * X + std::min(B, 2 * C) * (Y - X) << std::endl;
  }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
struct kek{
    int a,b,c,d;
};


void solve() {
    /*int n,m,q;
    cin>>n>>m>>q;
    vector<kek> arr(q);
    for(int i=0;i<q;i++){
        cin>>arr[i].a>>arr[i].b>>arr[i].c>>arr[i].d;
    }
    gogo(arr, m, n);*/
    int a,b,k;
    cin>>k>>a>>b;
    if(b/k-(a-1)/k==0){
        cout<<"NG";
    }
    else{
        cout<<"OK";
    }
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}

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

int main(){
    int k;
    string s;
    cin >> k >> s;

    if(k >= s.size()){
        cout << s << endl;
    }else{
        string ans;
        ans = s.substr(0, k);
        ans = ans + "...";
        cout << ans << endl;
    }
      
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,m;

    cin>>n>>m;

    ll val = __gcd(n,m);

    ll val1 = (n*m)/val;

    cout<<val1;
   
    return 0;
}

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

const int INF = 1e9;

int n;
int li[105];

int main(){
	scanf("%d",&n);
	int tot = 0;
	for(int i=1;i<=n;i++){
		scanf("%d",&li[i]);
		tot+=li[i];
	}
//	sort(li+1,li+n+1);
	int ans = INF;
	int tm = 0;
	for(int i=1;i<n;i++){
		tm+=li[i];
		int sisa = tot-tm;
		ans = min(ans,abs(sisa-tm));
	}
	printf("%d\n",ans);
	return 0;
}

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

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

ll A[200000];

map <ll, ll> mp;

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

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

	if (mp.size() <= K)
	{
		cout << 0 << endl;
	}
	else {
		ll number = mp.size() - K;

		vector<ll> v;
		for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++)
		{
			v.push_back(it->second);
		}
		sort(v.begin(), v.end());

		ll count = 0;
		ll changeNum = 0;
		for (vector<ll>::iterator it = v.begin(); it != v.end(); it++)
		{
			changeNum += *it;
			count++;
			if (count == number)
			{
				break;
			}
		}
		cout << changeNum << endl;
	}
	return 0;
}

Measured memory_bytes: 14964
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#pragma region DEBUG
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#pragma endregion DEBUG
#define MOD 1000000007
#define MAX 500005
#define endl "\n"
vector <lli> below(MAX);
vector <lli> ans(MAX);
lli n;
long long binpow(long long a, long long b) {
    lli m = MOD;
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout)
    lli t;
    //cin>>t;
    t = 1;
    while(t--){
       // lli n;
        lli n;
        cin>>n;
        lli a = binpow(10,n);
        lli b = 2*binpow(9,n);
        lli c = binpow(8,n);
        lli ans = a-b+c;
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
        cout<<ans<<endl;
    

        
    }
}

Measured memory_bytes: 10964
import java.util.ArrayList;
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner insert = new Scanner(System.in);
		ArrayList<String> result = new ArrayList<String>();
		while(true) {
			int n = insert.nextInt();
			if(n==0) {
				break;
			}
			int[] k = new int[n];
			for(int i=0; i<n; i++){
				k[i] = insert.nextInt();
			}	
			String moji = insert.next();
			char eki[] = new char[moji.length()];
			int eki2[] = new int[moji.length()];
			for(int i = 0; i < moji.length(); i++) {
				eki[i] = moji.charAt(i);
				eki2[i] = (int)(eki[i]);		
			}
			for(int i=0; i<eki.length; i++){
				int val = 'a'<=eki[i]&&eki[i]<='z'?eki[i]-'a' : eki[i]-'A'+26;
				val = (val + 52 - k[i%n])%52;
				eki[i] = (char) ((val < 26)? 'a'+val: 'A'+val-26);
			}
			result.add(String.valueOf(eki));
		}
		for(String a:result) {
			System.out.println(a);
		}
	}
	
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    map<string, int> m;
    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;
    rep(i, N)
    {
        string s;
        cin >> s;
        m[s]++;
    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3600
t[9999];main(T,W,N,w,c,i,j,m){
for(;scanf("%d%d",&W,&N)>1;printf("Case %d:\n%d\n%d\n",T++,m-1,i)){
	for(memset(t,0,sizeof(t)),t[0]=1,i=0;i<N;i++)
		for(scanf("%d,%d",&c,&w),j=W;j>=0;j--)if(t[j])if(t[j+w]<t[j]+c)t[j+w]=t[j]+c;
	for(m=j=0;j<=W;j++)if(m<t[j])m=t[j],i=j;
}exit(0);}

Measured memory_bytes: 644
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let s: Vec<usize> = get!(String)
        .chars()
        .map(|c| c as usize - '0' as usize)
        .collect();
    let mut ans: usize = 0;
    for i in 0..1 << s.len() - 1 {
        let mut n = 0;
        for j in 0..s.len() {
            if (i >> j) & 1 == 1 {
                ans += n * 10 + s[j];
                n = 0;
            } else {
                n = n * 10 + s[j];
            }
        }
        ans += n;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
fn main() {
    let n: usize = read();
    let mut vec: Vec<u32> = read_vec();

    // 関係あるのは自分より西にある建物だけ。
    // 一番東の建物から順に考えていく。
    let mut counter = 0;

    for i in (0..n).rev() {
        if vec.iter().max() == Some( &vec[i] ) {
            counter += 1;
        }

        vec[i] = 0;
    }

    println!("{}", counter);

}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352