akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
    int n;
    scanf("%d",&n);
    int i,j,k;
    char list[n][3][100];
    char tmp[100];

    char base[100] = {'\0'};
    for(i=0;i<n;i++) {
        scanf("%s%s", list[i][0], list[i][1]);
        snprintf(list[i][2], 100,"%d", i+1);
    }

    for(i=1;i<n;i++){
        for(j=1;j<n;j++){
            if(strcmp(list[j-1][0], list[j][0])>0){
                for(k=0;k<3;k++) {
                    strcpy(tmp, list[j-1][k]);
                    strcpy(list[j-1][k], list[j][k]);
                    strcpy(list[j][k], tmp);
                }
            } else if(strcmp(list[j-1][0], list[j][0])==0){
                if(atoi(list[j-1][1])<atoi(list[j][1])){
                    for(k=0;k<3;k++) {
                        strcpy(tmp, list[j-1][k]);
                        strcpy(list[j-1][k], list[j][k]);
                        strcpy(list[j][k], tmp);
                    }
                }
            }
        }
    }
    /*    int l = 1;
          int m = 0;
          while(1) {
          m = 1;
          while(1){
          if(strcmp(list[l-1][0], list[l][0])!=0){
          break;
          }
          l++;
          m++;
          }
          printf("flag\n");
          for(i=l-m+1;i<l;i++){
          for(j=l-m+1;j<l;j++){
          if(strcmp(list[j-1][1], list[j][1])<0){
          for(k=0;k<3;k++) {
          strcpy(tmp, list[j-1][k]);
          strcpy(list[j-1][k], list[j][k]);
          strcpy(list[j][k], tmp);
          }
          }
          }
          }
          if(l==n-1)
          break;
          else
          l++;
          }*/
    for(i=0;i<n;i++){
        printf("%s\n", list[i][2]);
    }
    return 0;

}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll l,k; cin >> l >> k;
    ll res = 0;
    
    vector<vector<ll>> dp(l+100,vector<ll>(3));
    vector<ll> cost{1,1,k};
    dp[0][0] = 1;
    for(int i = 0; i <= l;i++){
        for(int j = 0; j < 3;j++){
            if(dp[i][j] == 0) continue;
            if(j == 0){
                dp[i+1][1] += dp[i][j];
                dp[i+k][2] += dp[i][j];
            }else{
                dp[i+1][0] += dp[i][j];
            }
        }
        if(i!=0){
            res += dp[i][1];
            res += dp[i][2];
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3232
#include <iostream>
using namespace std;
const int MAX = 100002;

int main(){
  int n,ans[MAX],a,b;

  fill(ans,ans+MAX,0);

  cin >> n;
  while(n--){
    cin >> a >> b;
    ans[a]++; ans[b+1]--;
  }

  for(int i = 1 ; i < MAX ; i++)
    ans[i] += ans[i-1];

  int fri = 0;
  for(int i = 1 ; i < MAX ; i++){
    if(ans[i]+1 >= i) fri = i-1; 
  }

  cout << fri << endl;
  
  return 0;
}

Measured memory_bytes: 1552
#!/usr/bin/env python3
k ,n = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
# 全体k から一番離れている２点間の距離をひく
dist = [0]*n
for i in range(n-1):
    dist[i] = a[i+1] -a[i]
dist[-1] = a[0]+k - a[-1]
print(k-max(dist))

Measured memory_bytes: 78852
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    for (int i = 0; ; ++i) {
        if (i % 2 == 0) {
            c -= b;
            if (c <= 0) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            a -= d;
            if (a <= 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3612
n = int(input())
spi_list = []
for i in range(n):
    s,p = map(str,input().split())
    spi_list.append([str(s),int(p),i+1])

spi_list.sort(key = lambda x: x[1], reverse = 1)
spi_list.sort(key = lambda x: x[0])
for i in range(n):
    print(spi_list[i][2])

Measured memory_bytes: 3060
test = False


def solve_a(test=False, a=0, b=0, c=0):
    if not test:
        a, b, c = map(int, input().split())
    d = max(c - (a - b), 0)
    print(d)


def solve_b(test=False, n=0):
    if not test:
        n = int(input())
    res = 0
    for i in range(1, n + 1):
        if len(str(i)) % 2 == 1:
            res += 1
    print(res)


def solve_c(test=False, n=0, h_list=[]):
    if not test:
        n = int(input())
        h_list = list(map(int, input().split()))
    res = 'Yes'
    new_h_list = [0] * n
    new_h_list[0] = h_list[0] - 1

    for i in range(1, n):
        # cannot down
        if h_list[i] == new_h_list[i - 1]:
            new_h_list[i] = h_list[i]
        elif h_list[i] < new_h_list[i - 1]:
            new_h_list[i] = h_list[i]
            res = 'No'
        else:
            new_h_list[i] = h_list[i] - 1
    print(res)


if __name__ == "__main__":
    if test:
        solve_a(test=True, a=6, b=4, c=3)
        solve_a(test=True, a=8, b=3, c=9)
        solve_a(test=True, a=12, b=3, c=7)
        solve_b(test=True, n=11)
        solve_b(test=True, n=136)
        solve_b(test=True, n=100000)
        solve_c(test=True, n=5, h_list=[1, 2, 1, 1, 3])
        solve_c(test=True, n=4, h_list=[1, 3, 2, 1])
        solve_c(test=True, n=5, h_list=[1, 2, 3, 4, 5])
        solve_c(test=True, n=1, h_list=[1000000000])
    else:
        # solve_a()
        solve_b()
        # solve_c()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    string s;
    cin >> s;
    ll n = s.size()+1;

    ll con = 1;
    vector<ll> ans(n, 0);
    FOR(i, 1, n-1) {
        if(s[i]==s[i-1]) con++;
        else {
            if(s[i-1]=='<') {
                ll idx = 0;
                FOR(j, i-con, i+1) {
                    chmax(ans[j], idx);
                    idx++;
                }
            } else {
                ll idx = con;
                FOR(j, i-con, i+1) {
                    chmax(ans[j], idx);
                    idx--;
                }
            }
            con = 1;
        }
    }
    if(s[n-1]=='<') {
        ll idx = 0;
        FOR(j, n-1-con, n) {
            chmax(ans[j], idx);
            idx++;
        }
    } else {
        ll idx = con;
        FOR(j, n-1-con, n) {
            chmax(ans[j], idx);
            idx--;
        }
    }

    dump(ans);

    ll ret = 0;
    REP(i, n) ret += ans[i];
    cout << ret << endl;

    return 0;
}

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

ll Lu(ll a, ll b)  
{  
    ll temp;  
    if (a < b)  
    {  
        temp = a;  
        a = b;  
        b = temp;  
    }  
    if (a%b == 0)  
        return b;  
    else  
        return Lu(b, a%b);  
}  
  
ll Zheng(ll a, ll b)  
{  
    return a/Lu(a, b)*b;  
}  
int main()
{
	
	int n;
	cin>>n;
	long long x;
	long long ans = 1LL;
	for(int i=1;i<=n;i++){
		cin>>x;
		ans=Zheng(x,ans);
	}	
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		String s[]=String.valueOf(n).split("");
		int nl=s.length;
		String x[]={"3","5","7"};
		dfs("",nl,n,x);
		System.out.println(cnt);
	}

	static int cnt=0;
	private static void dfs(String s, int nl, int n, String[] x) {
		if(!s.equals("")){
		int tmp=Integer.parseInt(s);
		if(check(s)&&tmp<=n){
			cnt++;
		}
		}
		if(s.length()==nl){
			return;
		}
		dfs(s+x[0],nl,n,x);
		dfs(s+x[1],nl,n,x);
		dfs(s+x[2],nl,n,x);
	}
	private static boolean check(String s) {
		int cnt3=0;
		int cnt5=0;
		int cnt7=0;
		for(int i=0;i<s.length();i++){
			char c=s.charAt(i);
			if(c=='3'){
				cnt3++;
			}
			if(c=='5'){
				cnt5++;
			}
			if(c=='7'){
				cnt7++;
			}
		}
		if(cnt3>0&&cnt5>0&&cnt7>0){
			return true;
		}
		return false;
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  for(int i=0;i<M;i++) cin >> a.at(i) >> b.at(i);
  vector<int> num(N);
  for(int i=0;i<M;i++){
    num.at(a.at(i)-1)++;
    num.at(b.at(i)-1)++;
  }
  for(int i=0;i<N;i++){
    cout << num.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ma=0;
  if(a>=b&&a>=c){
    cout<<a*10+b+c<<endl;
  }
  else if(b>=a&&b>=c){
    cout<<b*10+a+c<<endl;
  }
  else{
    cout<<c*10+a+b<<endl;
  }
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string N;
    cin >> N;
    vector<vector<int>> dp(N.size() + 1, vector<int>(2, -1));
    dp[0][0] = 0;
    for(int i = 0; i < N.size(); i++) {
        if (dp[i][0] != -1) {
        	// j = 0
            for(int k = 0; k <= N[i] - '0'; k++) {
                chmax(dp[i + 1][k != N[i] - '0'], dp[i][0] + k);
            }
        }
        if (dp[i][1] != -1) {
            // j = 1
            for(int k = 0; k <= 9; k++) {
                chmax(dp[i + 1][1], dp[i][1] + k);
            }
        }
    }

    cout << max(dp[N.size()][0], dp[N.size()][1]) << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

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

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

int main()
{
	int a,b;
	while(~scanf("%d%d",&a,&b))
	{
		cout<<gcd(a,b)<<' '<<lcm(a,b)<<endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include<algorithm>
#include<iomanip>
#include<math.h>
using namespace std;



int main()
{
	long long A, B, K;

	cin >> A >> B >> K;

	if (A >= K) {
		A = A - K;
		cout << A <<" "<< B;
		return 0;
	}else{
		K = K - A;
		A = 0;
	}

	if (B >= K) {
		B = B - K;

	}else {
		B = 0;

	}


	cout << A <<" "<< B;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
/*
ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}*/

string s;

int main(){
	cin>>s;
	cout<<s.substr(0,3)<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <utility>
#include <set>
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(1)
#define lli long long int

using namespace std;

int main() {
  
  string tmp;
  int n;
  
  loop {
  
    cin >> tmp;
    if (tmp == "-") {
      break;
    }
    
    cin >> n;
    int queuesize = tmp.size() * 2;
    vector<char> deck(queuesize, '0');

    //Initialize
    rep (i, tmp.size()) {
      deck[i] = tmp[i];
    }

    int h;
    int top = 0;

    rep (i, n) {
      cin >> h;
      for (int j = top; j < top + h; j++) {
        deck[(j + tmp.size()) % queuesize] = deck[j % queuesize];
      }
      top = (top + h) % queuesize;
    }

    for (int i = top; i < top + tmp.size(); i++) {
      cout << deck[i % queuesize];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3164
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

double R;

signed main(){
    cin >> R;
    cout << fixed << setprecision(16) << 2*R*3.141592653589 << endl;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> bool chmax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> p(n), c(n), w(n + 1);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i, n) {
        cin >> c[i];
    }

    ll ans = -1e18;
    for (int i = 0; i < n; ++i) {
        int pos = i, cyc = 0;
        fill(all(w), 0);
        for (int j = 1; j <= n; ++j) {
            pos = p[pos];
            w[j] = w[j - 1] + c[pos];
            cyc++;
            if (pos == i)
                break;
        }
        ll max_all = *max_element(&w[1], &w[cyc + 1]);
        ll max_mod = *max_element(&w[1], &w[k % cyc + 1]);
        ll t = max_mod;
        if (k >= cyc) {
            chmax(t, max_all);
            chmax(t, (k / cyc) * w[cyc] + (k % cyc == 0 ? 0LL : max(0LL, max_mod)));
            chmax(t, ((k / cyc) - 1) * w[cyc] + max_all);
        }
        chmax(ans, t);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  int h[N];
  for(int i=0;i<N;i++)cin>>h[i];
  
  int costs[N] = {0};
  for (int i=1; i < N; i++){
    int mincost = INT_MAX;
    for (int j=i-1; j >= 0 && j >= i-K; j--){
      int cost = abs(h[i]-h[j]) + costs[j];
      if (cost < mincost) mincost = cost;
    }
    costs[i] = mincost;  
  }
  cout << costs[N-1];
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String A = scan.next();
		String B = scan.next();
		String C = scan.next();
		  if(A.charAt(A.length()-1) == B.charAt(0) && B.charAt(B.length()-1) == C.charAt(0)){
		      System.out.println("YES");
		    }else{
		      System.out.println("NO");
		    }
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int n;
ll cost[305][305];
ll a[305][305];

void warshall_floyd(int n){
    rep(k, n){
        rep(i, n){
            rep(j, n) cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        }
    }
}

int main(){
    cin >> n;
    rep(i, n) rep(j, n){
        int A;
        cin >> A;
        a[i][j] = A;
        cost[i][j] = A;
    }

    warshall_floyd(n);

    bool flag = true;
    rep(i, n) rep(j, n) flag &= (cost[i][j] == a[i][j]);
    if (!flag) {
        cout << -1 << endl;
        return 0;
    }
    ll cnt = 0;
    rep(i, n) rep(j, n) {
        bool flag = true;
        if (i == j) continue;
        rep(k, n) {
            if (k == i || k == j) continue;
            if (a[i][j] >= a[i][k] + a[k][j]) flag = false;
        }
        if (flag) cnt += a[i][j];
    }
    cout << cnt / 2 << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, M;
  cin >> N >> M;
  ll a, b;
  vector<pair<ll, ll>> p(N);
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    p.emplace_back(a, b);
  }
  sort(p.begin(), p.end());
  ll ans = 0;
  ll i = 0;
  ll cnt = 0;
  while (cnt < M) {
    if (cnt + p[i].second < M) {
      ans += p[i].first * p[i].second;
    } else {
      ans += p[i].first * (M - cnt);
    }
    cnt += p[i].second;
    i++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6372
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def dfs(i, ws, d, W):
    if i >= len(ws):
        return 0
    w = ws[i]

    ans = dfs(i + 1, ws, d, W)
    total = 0
    for j in range(len(d[w])):
        total += d[w][j]
        if (j + 1) * w <= W:
            ans = max(ans, dfs(i + 1, ws, d, W - (j + 1) * w) + total)
    return ans


def main():
    N, W = map(int, input().split())

    d = defaultdict(list)
    for _ in range(N):
        w, v = map(int, input().split())
        d[w].append(v)
    for w in d.keys():
        d[w].sort(reverse=True)

    print(dfs(0, list(d.keys()), d, W))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4204
#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>;

int main() {
  int N;
  cin >> N;
  int ans = N/2;
  if (N%2 != 0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
using namespace std;
int main() {
	int N;
	int p=1;
	int cnt = 0;
	cin >> N;
	for (int i = 0; i < 100000; i++) {
		if (2 * p <= N) {
			cnt++;
			p = 2 * p;
		}
	}
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 3580
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

void Main() {
	int N, K; string S;
	cin >> N >> K >> S;
	int cnt = 0;
	rep(i, N-1){
	    if(S[i] == S[i+1]) cnt++;
	}
    cnt = min(N-1, cnt + K*2);
	
	cout << cnt << endl; 
    return;
}

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

Measured memory_bytes: 512
W,H,N = map(int,input().split())
x = [0]*N
y = [0]*N
a = [0]*N
for i in range(N):
    x[i],y[i],a[i] = map(int,input().split())
x_min = 0
y_min = 0
x_max = W
y_max = H
for i in range(N):
    if a[i] == 1:
        x_min = max(x_min,x[i])
    if a[i] == 2:
        x_max = min(x_max,x[i])
    if a[i] == 3:
        y_min = max(y_min,y[i])
    if a[i] == 4:
        y_max = min(y_max,y[i])
#print(x_min,x_max,y_min,y_max)
x_sub = max(x_max-x_min,0)
y_sub = max(y_max-y_min,0)
print(x_sub*y_sub)

Measured memory_bytes: 3064
#include  <stdio.h>
#include <stdlib.h>

void QSort(int *x, int *y, int left, int right);
void Swap(int *x, int *y, int i, int j);
void ShowData(int *x, int *y, int n);


/* クイックソートを行う */
void QSort(int *x, int *y, int left, int right)
{
	int i, j;
	int pivot;

	i = left;                      /* ソートする配列の一番小さい要素の添字 */
	j = right;                     /* ソートする配列の一番大きい要素の添字 */

	pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

	while (1) {                    /* 無限ループ */

		while (x[i] < pivot)       /* pivot より大きい値が */
			i++;                   /* 出るまで i を増加させる */

		while (pivot < x[j])       /* pivot より小さい値が */
			j--;                   /*  出るまで j を減少させる */
		if (i >= j)                /* i >= j なら */
			break;                 /* 無限ループから抜ける */

		Swap(x, y, i, j);             /* x[i] と x[j]を交換 */
		i++;                       /* 次のデータ */
		j--;
	}


	if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
		QSort(x, y, left, i - 1);     /* 左の配列を Q ソートする */
	if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
		QSort(x, y, j + 1, right);    /* 右の配列を Q ソートする */
}

/* 配列の要素を交換する */
void Swap(int *x, int *y, int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;

	temp = y[i];
	y[i] = y[j];
	y[j] = temp;


}


/* n 個のデータを表示する */
void ShowData(int *x, int *y, int n)
{
	int i;

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

int main() {


	int i, j, N, *A, *B, tmp, tmp2, time = 0;


	scanf("%d", &N);

	A = (int*)malloc(N * sizeof(int));
	B = (int*)malloc(N * sizeof(int));

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

	QSort(B, A, 0, N-1);

	for (i = 0; i < N; i++) {
		time += A[i];
		if (time > B[i]) {
			printf("No\n");
			return 0;
		}

	}

	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1792
import numpy as np

N = int(input())
P = list(map(float,input().split()))

dp = np.zeros(N + 1,dtype=float)
dp[0] = 1

for i in P:
    tmp = dp * (1-i)
    #スライスさせて掛算
    tmp[1:] += dp[:-1] * i
    dp = tmp

print(np.sum(dp[N//2 + 1:]))

Measured memory_bytes: 12520
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    
    vector<string> a(h);
    rep(i, h) cin >> a[i];
    
    rep(i, w + 2) cout << "#";
    cout << endl;
    rep(i, h) cout << "#" << a[i] << "#" << endl;
    rep(i, w + 2) cout << "#";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3584
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int64 a, b;
  cin >> a >> b;
  int ret;
  if (a * b >= 0) {
    if (a > b) {
      ret = a - b + (a * b == 0 ? 1 : 2);
    } else {
      ret = b - a;
    }
  } else {
    ret = abs(abs(a) - abs(b)) + 1;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e18
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

int main(){
	string s,t;
	cin >> s >> t;
	char ch,ch2;
	

	rep(j, 2) {
		vector<char> cnt(26, '-');
		rep(i, s.size()) {
			int x = s[i] - 'a';
			int y = t[i] - 'a';
			//cout << x << " " << y << endl;
			if (cnt[x] == '-') {
				cnt[x] = y;
			} else {
				if (cnt[x] != y) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
		swap(s, t);
	}
	cout << "Yes" << endl;
	return 0;
}






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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';

const int MAX_N = 200010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void init(int x) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[x] = pow_mod(fact[x],-1);
    for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}
int n;
void dfs1(int i,int p,vector<vector<int>>& edges,vector<ll>& ch,vector<int>& sz) {
    for (int& j : edges[i]) if (j != p) {
        dfs1(j,i,edges,ch,sz);
        sz[i] += sz[j];
        (ch[i] *= ch[j]*combi(sz[i]-1,sz[j])%mod) %= mod;
    }
}

void dfs2(int i,int p,vector<vector<int>>& edges,vector<ll>& ch,vector<ll>& ans,vector<int>& sz) {
    for (int& j : edges[i]) if (p != j) {
        ll a = ans[i]*pow_mod(ch[j]*combi(n-1,sz[j])%mod,-1)%mod;
        ans[j] = ch[j]*a%mod*combi(n-1,sz[j]-1)%mod;
        dfs2(j,i,edges,ch,ans,sz);
    }
}

int main() {
    // int n;
    cin >> n;
    init(200000);
    vector<vector<int>> edges(n);
    for (int i = 0;i < n-1;++i) {
        int u,v;
        scanf("%d%d",&u,&v);
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    vector<ll> ans(n),ch(n,1);
    vector<int> sz(n,1);
    dfs1(0,-1,edges,ch,sz);
    ans[0] = ch[0];
    dfs2(0,-1,edges,ch,ans,sz);
    for (int i = 0;i < n;++i) cout << ans[i] << newl;
}

Measured memory_bytes: 22516
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, q;
    cin >> n >> q;
    dsu d(n);
    REP(i, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) d.merge(u, v);
        else cout << (d.same(u, v) ? 1 : 0) << endl;
    }
}


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

typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef priority_queue <int, vector <int>, greater <int> > min_pq;

const int MOD	= 1e9 + 7;

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define init(a)         memset(a,0,sizeof(a))    
#define pb              push_back  
#define all(a)          a.begin(),a.end()  
#define loop(i,n)       for(int i=0;i<n;i++)  
#define loops(i,s,n)    for(int i=s;i<n;i++)
#define rloop(i,n)      for(int i=n-1;i>=0;i--)
#define rloops(i,s,n)   for(int i=n-1;i>=s;i--)

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }


double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
//---------------------------------------------------------------------------------------------


int main(){
    fastio;

    // #ifndef ONLINE_JUDGE
	// 	freopen("in.txt", "r", stdin);
	// #endif

    priority_queue <int> q;

    int n,m;
    cin>>n>>m;
    int x;
    loop(i,n){
        cin>>x;
        q.push(x);
    }

    int c;
    loop(i,m){
        c= q.top();
        q.pop();
        c/=2;
        q.push(c);
    }

    lli s = 0;
    while(!q.empty()){
        s+=q.top();
        q.pop();
    }
    cout<<s<<endl;
    
    // cout<<"Execution time : "<<tick()<<"\n";

    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j;
    boost;

    string s,t;
    cin>>s>>t;
    int ans=0;
    rep(i,0,3) if(s[i]==t[i]) ans++;
    cout<<ans;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

class Dice{
public:
	Dice(){
		number = new int[6];
		work = new int[6];
	};
	~Dice(){
		delete[] number;
		delete[] work;
	};

	void setNumber(int index,int num){
		number[index] = num;
	};

	void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	int returnPeek(){
		return number[0];
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* work;
};

int main(){
	Dice dice;
	int label;
	char ch;
	for(int i = 0; i < 6; i++){
		scanf("%d",&label);
		dice.setNumber(i,label);
	}
	getchar(); //skip first line's \n
	while((ch = getchar()) != '\n'){
		dice.roll(ch);
	}
	printf("%d\n",dice.returnPeek());
}

Measured memory_bytes: 1036
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	bool f=true;
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++)
	{
		if(i%2==0) // odd
		{
			if(s[i]!='R' and s[i]!='U' and s[i]!='D')
				f=false;
		}
		else
		{
			if(s[i]!='L' and s[i]!='U' and s[i]!='D')
				f=false;
		}
	}

	cout << (f ? "Yes":"No") << endl;





}


Measured memory_bytes: 256
using System;

namespace PowerSocket_20190901
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int tap = int.Parse(input[0]);  //電源タップの差込口の数
            int outlet = int.Parse(input[1]);   //目標の差込口の数
            int calc_tap = 1;   //最初の差込口の数　計算用
            int answer = 0; //必要な電源タップの個数

            for (int i = 0; i < int.MaxValue; i++)
            {
                if (outlet == 1)        //差込口が1個の場合はループしない
                    break;
                calc_tap--;     //1個差込口を消費
                calc_tap += tap;        //tap個口の電源タップを差し込む
                answer++;       //差し込んだ数をカウント
                if (calc_tap >= outlet)     //目標と等しいあるいは目標以上の差込口の数になったら抜ける
                    break;
            }
            Console.WriteLine(answer.ToString());        }
    }
}

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

int main() {
    int M, N;
    while(cin >> M >> N, M | N) {
        vector<bool> sieve(7500000, false);
        int cnt = 0;
        for(int i = M; cnt < N; i++) {
            if(!sieve[i]) {
                cnt++;
                sieve[i] = true;
                for(int j = 2 * i; j < 7500000; j += i) {
                    sieve[j] = true;
                }
            }
        }
        for(int i = M;; i++) {
            if(sieve[i] == false) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4036
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		String result = "NO";

		if (a.charAt(a.length() - 1) == b.charAt(0)) {
			if (b.charAt(b.length() - 1) == c.charAt(0)) {
				result = "YES";
			}
		}

		System.out.println(result);

		sc.close();


	}
}




Measured memory_bytes: 21972
#include <cstdio>
#include <cstring>

using namespace std;

const int MAXN = 100;
const int MAXV = 100000;
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

int f[MAXV + 5];
int main() {
	memset(f, 0x3f, sizeof (f));
	f[0] = 0;
	int n, W;
	scanf("%d%d", &n, &W);
	for (int i = 1; i <= n; ++ i) {
		int w, v;
		scanf("%d%d", &w, &v);
		for (int j = MAXV; j >= v; -- j) {
			f[j] = min(f[j - v] + w, f[j]);
		}
	}
	for (int i = MAXV; i >= 0; -- i) {
		if (f[i] <= W) {
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main() {
    int N, M, X, Y;
    scanf("%d%d%d%d", &N, &M, &X, &Y);

    int tmp;
    int max_x = X;
    for (int i = 0; i < N; i++) {
        scanf("%d", &tmp);
        if (max_x < tmp) {
            max_x = tmp;
        }
    }

    int min_y = Y;
    for (int i = 0; i < M; i++) {
        scanf("%d", &tmp);
        if (min_y > tmp) {
            min_y = tmp;
        }
    }

    if (max_x < min_y) {
        printf("No War");
    } else {
        printf("War");
    }

    return 0;
}

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

#define MAX 1200

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    vector<string> input(n);
    vector<int> index(n);
    vector<vector<int> > nofdot(MAX);
    for(int i = 0; i < n; i++){
      cin >> input[i];
      for(size_t j = 0; j < input[i].size(); j++)
        if(input[i][j] != '.'){
          index[i] = j;
          nofdot[j].push_back(i);
          break;
        }
    }

    vector<vector<char> > outputMap(n, vector<char>(MAX, '0'));
    for(int i = 1; i < MAX; i++){
      if(nofdot[i].size() >= 1)
        outputMap[nofdot[i][0]][i - 1] = '+';
      
      for(size_t j = 1; j < nofdot[i].size(); j++){
        int start = nofdot[i][j - 1];
        int end = nofdot[i][j];
        outputMap[end][i - 1] = '+';
        for(int k = start + 1; k < end; k++){
          outputMap[k][i - 1] = '|';
        }
      }
    }

    for(int i = 0; i < n; i++){
      bool flag = false;
      for(int j = MAX - 1; j >= 0; j--){
        if(outputMap[i][j] == '+'){ flag = true; }
        else if(!flag && outputMap[i][j] == '|'){ outputMap[i][j] = '0'; }
        else if(flag && outputMap[i][j] == '0'){ outputMap[i][j] = ' '; }
      }
    }

    for(int i = 1; i < n; i++){
      for(int j = 0; j < MAX; j++){
        if(outputMap[i][j] == '|' && outputMap[i - 1][j] != '|' && outputMap[i - 1][j] != '+'){
          outputMap[i][j] = ' ';
        }
      }
    }
    for(int i = n - 2; i >= 0; i--){
      for(int j = 0; j < MAX; j++){
        if(outputMap[i][j] == '|' && outputMap[i + 1][j] != '|' && outputMap[i + 1][j] != '+'){
          outputMap[i][j] = ' ';
        }
      }
    }
    

    for(int i = 0; i < n; i++){
      for(int j = 0; outputMap[i][j] != '0'; j++){ cout << outputMap[i][j]; }
      for(int j = index[i]; j < (int)input[i].size(); j++){ cout << input[i][j]; }
      cout << endl;
    }
    
  }

  return 0;
}

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i < c; i++) {
    if (i % 2 == 0) {
      if (a % 2 != 0) {
        a--;
        b += a / 2;
        a /= 2;
      }
      else {
        b += a / 2;
        a /= 2;
      }
    }
    else {
      if (b % 2 != 0) {
        b--;
        a += b / 2;
        b /= 2;
      }
      else {
        a += b / 2;
        b /= 2;
      }
    }
  }
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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


    int delta = b - a - 1;
    if (delta % 2)
        cout << "Alice" << endl;
    else
        cout << "Borys" << endl;
}

Measured memory_bytes: 256
def resolve():

    from itertools import accumulate

    N = int(input())  # len(A)
    A = list(map(int, input().split()))

    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成

    minans=10**10
    # この問題は長さが1-Nの連続部分の和の最大値を出せというものなので以下の通り
    for i in range(1, N):
        snuke=B[i]
        arai=B[-1]-B[i]
        minans = min(minans,abs(snuke-arai))
    print(minans)


resolve()

Measured memory_bytes: 24172
#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;

vector<int> g[200020];
bool used[200020];

void dfs(int now){
  used[now]=true;
  for(int i=0;i<g[now].size();i++){
    int u=g[now][i];
    if(used[u]) continue;

    dfs(u);
  }
  return;
}

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int l;
      cin>>l;
      l--;
      g[i].push_back(l+n);
      g[l+n].push_back(i);
    }
  }

  dfs(0);
  bool flag=false;
  for(int i=0;i<n;i++){
    if(used[i]==false) flag=true;
  }
  if(flag) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;

  return 0;
}


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

int main(void){
	int n;
	int a[200];
	int swap = 0;

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

	for(int i=0; i<n; i++){
		int mini = i;
		for(int j=i; j<n; j++){
			if(a[j] < a[mini]){
				mini = j;
			}
		}
		int temp = a[mini];
		a[mini] = a[i];
		a[i] = temp;
		if(i!=mini)swap++;
	}
	
	for(int i=0; i<n; i++){
		if(i!=n-1)printf("%d ", a[i]);
		else printf("%d\n", a[i]);
	}
	printf("%d\n", swap);

	return 0;
}

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

using namespace std;

#define int long long

signed main()
{
	int N, M, A, P[1000], Q[1000];
	while (cin >> N >> M >> A, N || M || A)
	{
		vector<pair<int, int> > e;
		for (int i = 0; i < M; i++)
		{
			int h;
			cin >> h >> P[i] >> Q[i];
			e.push_back(make_pair(1000 - h, i));
		}
		sort(e.begin(), e.end());
		for (int i = 0; i < e.size(); i++)
		{
			int id = e[i].second;
			if (A != P[id]) swap(P[id], Q[id]);
			if (A != P[id]) continue;
			A = Q[id];
		}
		printf("%lld\n", A);
	}
	return 0;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll K, A, B;
    cin >> K >> A >> B;
    for(i = A; i <= B; i++) {
        if(i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}

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

int memo[111]={0};

int fib(int n){
  if(n==0||n==1)return memo[n]=1;
  if(memo[n]!=0)return memo[n];
  return memo[n]=fib(n-1)+fib(n-2);
}

int main(){
  int a;

  scanf(" %d",&a);

  fib(a);

  cout << memo[a] << endl;

  return 0;

}

Measured memory_bytes: 3232
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A,B;
  cin>>A>>B;
  cout<<A-B+1;
return 0;}

Measured memory_bytes: 3528