akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
bool able[1024][1024];
int dp[1024];
 
int main()
{
    int n;
    int c[1024], w[1024];
    int r[1024];
 
    scanf("%d", &n);
 
    memset(r, 0, sizeof(r));
 
    for (int i = 0; i < n; i++){
        scanf("%d %d", c + i, w + i);
        if (i) r[i] = r[i - 1] + w[i];
        else r[i] = w[i];
    }
 
    memset(able, false, sizeof(able));
 
    for (int d = 0; d < n; d++){
        for (int x = 0; x + d < n; x++){
            if (d == 0){
                able[x][x] = true;
            }
            else {
                if (able[x + 1][x + d] && r[x + d] - r[x] <= c[x]){
                    able[x][x + d] = true;
                }
                if (able[x][x + d - 1] && r[x + d - 1] - (x ? r[x - 1] : 0) <= c[x + d]){
                    able[x][x + d] = true;
                }
            }
        }
    }
 
    for (int i = 0; i < n; i++){
        dp[i] = n - i;
    }
 
    for (int i = n - 1; i >= 0; i--){
        for (int j = i; j >= 0; j--){
            if (able[j][i]){
                dp[j] = min(dp[j], (i + 1 == n ? 0 : dp[i + 1]) + 1);
            }
        }
    }
 
    printf("%d\n", dp[0]);
 
    return (0);
}

Measured memory_bytes: 2236
int main(void)
{
	int a;			/* ??\?????? */
	int b;			/* ??\?????? */
	int tmp;		/* ????\???¨ */
	
	/* input */
	scanf("%d %d", &a, &b);
	
	/* process	*/
	tmp = a - b;
	
	/* output */
	if( tmp > 0 ){
		printf("a > b\n");
	}
	else if( tmp == 0 ){
		printf("a == b\n");
	}
	else{
		printf("a < b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
n = int(input())
T = [0]*n
c,s,f = [0]*(n-1),[0]*(n-1),[0]*(n-1)
 
for i in range(n-1):
	c[i],s[i],f[i] = map(int,input().split())

for	i in range(n-1):
	T[i] = s[i] + c[i]
	for j in range(i+1,n-1):
		if T[i] > s[j]:
			T[i] += (-T[i])%f[j] + c[j]
		else:
			T[i] = s[j] + c[j]
	print(T[i])
print(0)

Measured memory_bytes: 9100
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<stack>
#include<queue>
#include<stdlib.h>
#include<string.h>
#include<vector>
#define LL long long
#define  long long
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const double INF=1e9+7;
LL Find[100005];
LL find(int x) {return Find[x]==x?x:Find[x]=find(Find[x]);}
struct node{
    LL a,b;
}v[100005];
int cmp(node x,node y)
{
    return x.a<y.a;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
         scanf("%lld%lld",&v[i].a,&v[i].b);
    }
    sort(v+1,v+n+1,cmp);
   LL ans=0,sum=0;
    for(int i=1;i<=n;i++)
    {
        if(ans+v[i].b>=m)
        {
            printf("%lld\n",sum+=(m-ans)*v[i].a);return 0;
        }
        ans+=v[i].b;
        sum+=v[i].a*v[i].b;
    }
    return 0;
}


Measured memory_bytes: 1792
import java.io.File;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

//    	File file = new File("input.txt");
//    	Scanner sc = new Scanner(file);
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        sc.nextLine();
        String[] ary = sc.nextLine().split(" ");
        boolean flg_3 = true;
        for(String str : ary){
        	if(str.equals("Y")){
        		flg_3 = false;
        	}
        }
        System.out.println(flg_3 ? "Three" : "Four");
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

typedef struct shiranui {
    ll id, p;
    string s;
} flare;

int main(){
    ll n;
    cin >> n;
    vector<flare> a(n);
    rep(i, 0, n) {
        cin >> a[i].s >> a[i].p;
        a[i].id = i + 1;
    }
    sort(a.begin(), a.end(), [](flare l, flare r){
        if(l.s < r.s) return true;
        else if(l.s == r.s) return (l.p > r.p);
        else return false;
    });
    rep(i, 0, n) cout << a[i].id << endl;
    return 0;
}

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

int main() {
  string A = "abcdefghijklmnopqrstuvwxyz";
  char C;
  cin >> C;
  for (int i = 0; i < 25; i++) {
    if (A.at(i) == C) {
      cout << A.at(i+1);
    }
  }
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    using namespace std;
    int32_t W, H, N;
    cin >> W >> H >> N;
    
    int32_t xl = 0, xr = W, yt = 0, yb = H;
    for (auto j = 0; j < N; ++j) {
        int32_t x, y, a;
        cin >> x >> y >> a;
        switch(a) {
            case 1:
                xl = max(xl, x);
                break;
            case 2:
                xr = min(xr, x);
                break;
            case 3:
                yt = max(yt, y);
                break;
            case 4:
                yb = min(yb, y);
                break;
        }
    }
    
    auto area = max(0,xr-xl)*max(0,yb-yt);
    cout << area << endl;
}

Measured memory_bytes: 256
import numpy as np
import math
import collections

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


ans = 0
node_num = 1
pre_node_num = 1
B = [1 - A[0]]
ruisekiA = [0 for i in range(N + 2)]
ruisekiA[N] = A[N]
ruisekiA[N + 1] = 0
for i in range(N - 1, -1, -1):
    ruisekiA[i] = ruisekiA[i + 1] + A[i]


for i in range(1, N + 1):
    tmpB = min(2 * B[i - 1] - A[i], ruisekiA[i + 1])
    #print(tmpB, B[i - 1] - A[i])
    if (tmpB < 0) or (tmpB < B[i - 1] - A[i]):
        ans = -1
        break
    if i == N:
        tmpB = 0
    B.append(tmpB)

if N == 0 and A[0] != 1:
    ans = -1

if ans != -1:
    ans = sum(A) + sum(B)
print(ans)


Measured memory_bytes: 40580
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] H = new int[N];
    boolean[] ii = new boolean[N];
    int[] A = new int[M];
    int[] B = new int[M];
    for(int i = 0; i<N;i++){
      H[i] = sc.nextInt();
      ii[i] = true;
    }
    for(int i = 0; i<M;i++){
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    for(int i = 0; i<M;i++){
      if(H[A[i]-1] == H[B[i]-1]){
        ii[B[i]-1] = false;
        ii[A[i]-1] = false;
      }else if(H[A[i]-1] > H[B[i]-1]){
        ii[B[i]-1] = false;
      }else{
        ii[A[i]-1] = false;
      }
    }
    int count = 0;
    for(int i=0;i<N;i++){
      // System.out.println(ii[i]);  
      if(ii[i]==true){

        count++;
      }
    }
    System.out.println(count);  
  }
}





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

#define MAX_INT 0x3f3f3f3f 
#define precision(x) setprecision(x)
#define boost ios_base::sync_with_stdio(false); 	cin.tie(NULL);

int main()
{
	boost;
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << "\n";
}

Measured memory_bytes: 3604
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
ll h[100001][3];
ll dp[100001][3];

void solve()
{
    REP (i, N) {
        REP (j, 3) {
            dp[i+1][j] = max(dp[i][(j+1)%3], dp[i][(j+2)%3]) + h[i][j];
        }
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP (i, N) {
        cin >> h[i][0] >> h[i][1] >> h[i][2];
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 4992
#include <stdio.h>

int main(void)
{
  char string[100000];
  char a[100000];
  int  key, number, i;

	if(scanf("%d", &key)== 1);
	if(scanf("%s", string)== 1);

    i = 0;
  while(string[i] != '\0'){
    number = (string[i] - 'A' + key) % 26;
    a[i] = 'A' + number;
    ++i;
  }
  a[i] = '\0';
  
  printf("%s\n", a);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
int main(){
  using namespace std;
  int L,R,now_min;
  now_min = 2019;
  cin >> L >> R;
  for(int i=L;i<R;i++){
    for(int j=i+1;j<=R;j++){
      now_min = min(((i%2019)*(j%2019))%2019, now_min);
      if(now_min==0){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  cout << now_min << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int S,h,m,s;
        //?¨??????\??????????????????????????§????????????
    	Scanner scanner = new Scanner(System.in);
    	//??\????????????int??????????????????
    	S = scanner.nextInt();
    	//??????????±??????????1??????=60*60?§????S???60*60??§?????£???????????????
    	h = S/(60*60);
    	//????§???????????±???????
    	m = (S-h*60*60)/60;
    	//????§?????§?????±???????
    	s = S-h*60*60-m*60;
        System.out.println(h + ":" + m + ":" + s);
    }
}

Measured memory_bytes: 25912
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  int B;
  cin >>A>>B;
  int x=A+B;
  if(x<24) {
cout << x<< endl;
  }
else {
cout << x-24 << endl;
}
}


Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

ll vs[100000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  int positive = 0;
  int negative = 0;
  REP(i, n) {
    scanf("%lld", &vs[i]);
    if(vs[i] > 0) {
      ++positive;
    } else if(vs[i] < 0) {
      ++negative;
    }
  }
  sort(vs, vs + n);
  if(negative == 0) {
    ll sum = 0;
    REP(i, n) {
      sum += vs[i];
    }
    sum -= 2 * vs[0];
    printf("%lld\n", sum);
    ll cur = vs[0];
    REP(i, n-2) {
      printf("%lld %lld\n", cur, vs[i+1]);
      cur -= vs[i+1];
    }
    printf("%lld %lld\n", vs[n-1], cur);
  } else if(positive == 0) {
    ll sum = 0;
    REP(i, n) {
      sum += vs[i];
    }
    sum -= 2 * vs[n-1];
    printf("%lld\n", -sum);
    ll cur = vs[n-1];
    REP(i, n-1) {
      printf("%lld %lld\n", cur, vs[n-2-i]);
      cur -= vs[n-2-i];
    }
  } else {
    ll res;
    {
      ll neg = vs[0];
      ll pos = vs[n-1];
      for(int i = 1; i < n-1; ++i) {
        if(vs[i] >= 0) {
          neg -= vs[i];
        } else {
          pos -= vs[i];
        }
      }
      res = pos - neg;
    }
    printf("%lld\n", res);
    ll neg = vs[0];
    ll pos = vs[n-1];
    for(int i = 1; i < n-1; ++i) {
      if(vs[i] >= 0) {
        printf("%lld %lld\n", neg, vs[i]);
        neg -= vs[i];
      } else {
        printf("%lld %lld\n", pos, vs[i]);
        pos -= vs[i];
      }
    }
    printf("%lld %lld\n", pos, neg);
  }
  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,K,A;
	cin>>N>>K;
	A=1;
	for(int i=0; i<N; i++){
	if( A<=K ){
		A *= 2;
	}
	else{
		A += K;
	}
	}
	cout<<A<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a,b;
  cin>>a>>b;
  if((a+b)%2==1){
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  cout<<(a+b)/2<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

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




}


Measured memory_bytes: 3732
S = input()

while S != '' :
    if len(S) >= 5 and S[-5:] == 'dream' :
        S = S[:-5]
        continue
    if len(S) >= 7 and S[-7:] == 'dreamer' :
        S = S[:-7]
        continue
    if len(S) >= 5 and S[-5:] == 'erase' :
        S = S[:-5]
        continue
    if len(S) >= 6 and S[-6:] == 'eraser' :
        S = S[:-6]
        continue
    
    break
    
if S == '' :
    print('YES')
else :
    print('NO')

Measured memory_bytes: 134044
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  double t,x;
  cin >> t >> x;
  double ans = t/x;
  printf("%.10lf", ans);
  return 0;
}


Measured memory_bytes: 3728
#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    let k = a + b;
    let t1 = n / k;
    let t2 = min(n % k, a);
    println!("{}", t1 * a + t2);
}


Measured memory_bytes: 4352
from collections import deque
K = int(input())
dist = {1: 1}

deq = deque([1])
while deq:
    v = deq.popleft()
    # x10: +0
    w = (10 * v) % K
    if dist[v] < dist.get(w, 10**9):
        dist[w] = dist[v]
        deq.appendleft(w)
    # +1: +1
    w = (v + 1) % K
    if dist[v] + 1 < dist.get(w, 10**9):
        dist[w] = dist[v] + 1
        deq.append(w)
print(dist[0])

Measured memory_bytes: 15596
x = int(input())

fs = []
for e in range(-1000, 1001):
    fs.append(e ** 5)

for a in range(-1000, 1001):
    for b in range(-1000, 1001):
        if fs[a + 1000] - fs[b + 1000] == x:
            print(a, b)
            exit()


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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

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

  int N;
  cin >> N;
  long cnt = 0;
  while (N--) {
    int a, b;
    cin >> a >> b;
    if (a == b) cnt++;
    else cnt = 0;
    if (cnt == 3) return cout << "Yes" << "\n", 0;
  }
  cout << "No" << "\n";
}

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

int main(){
    int n;
    while(cin >> n, n){
        vector<int> a(n), b(n);
        for(int i = 0; i < n; i++)  cin >> a[i];
        for(int i = 0; i < n; i++)  cin >> b[i];
        sort(a.rbegin(), a.rend());
        sort(b.rbegin(), b.rend());
        vector<int> wod(n, 0);
        int acur = 0, bcur = 0;
        while(acur < n && bcur < n){
            while(acur < n && b[bcur] < a[acur])    acur++;
            if(acur < n){
                wod[acur]++;
                bcur++;
            }
        }
        for(int i = 1; i < n; i++)  wod[i] += wod[i-1];
        int k;
        for(k = 0; k < n; k++){
            if((k+1) - wod[k] > (k+1)/2)    break;
        }
        if(k >= n-1)    cout << "NA" << endl;
        else            cout << k+1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3400
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

string s, last, cur;

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> s;
    int res = 0;
    for (int i = 0; i < s.size(); i++){
        cur += s[i];
        if (cur != last){
            last = cur;
            cur = "";
            res++;
        }
    }
    cout << res;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

struct UnionFind {
    vector<int> par,si; 

    UnionFind(int N) : par(N), si(N,1) { 
        rep(i,0,N) par[i] = i;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x); 
        y = root(y); 
        if (x == y) return; 
        si[y]+=si[x];
        par[x] = y; 
    }

    bool same(int x, int y) { 
      return root(x)== root(y);
    }
    int size(int x){
       return si[root(x)];
    }

};

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

  ll n,m,k;
  cin >> n >> m >> k;
  UnionFind u(n);
  vll f(n,0);
  rep(i,0,m){
   ll a,b;
    cin >> a>> b;
    
    f[--a]--;
    f[--b]--;
    u.unite(a,b);  
  }
  
  rep(i,0,k){
   ll c,d;
    cin >> c >> d;
    if(u.same(--c,--d)) f[c]--,f[d]--;
  }
  
  rep(i,0,n-1) cout << u.size(i)+f[i]-1 << " ";
  cout <<  u.size(n-1)+f[n-1]-1;
  
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<P> done_work[N];
    
    while (true) {
        int si, ti, ei; cin >> si >> ti >> ei;
        if (si==0) break;
        done_work[si-1].push_back(P(ti-1, ei));
    }
    
    int L; cin >> L;
    long long prev_b[M], ans[N];
    
    for (int i=0; i<M; i++) prev_b[i] = 0;
    for (int i=0; i<N; i++) ans[i] = 0;
    
    for (int i=0; i<L; i++) {
        long long b[M];
        for (int j=0; j<M; j++) cin >> b[j];
        for (int j=0; j<N; j++) {
            for (int k=0; k<done_work[j].size(); k++) {
                int ti = done_work[j][k].first, ei = done_work[j][k].second;
                int diff = b[ti]-prev_b[ti];
                ans[j] += diff*ei;
            }
        }
        for (int j=0; j<N; j++) {
            if (j<N-1) cout << ans[j] << " ";
            else cout << ans[j] << endl;
        }
        for (int j=0; j<M; j++) prev_b[j] = b[j];
    }
}


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


int main() {
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  for (int i = 1; i < n; ++i) { 
    int cnt = 0;
    int best = 0;
    for (int j = 0; j < n-i; ++j) { 
      if (s[j] != s[j+i]) {
        best = max(best, cnt);
        cnt = 0;
        continue;
      }
      ++cnt;
    }
    best = max(best, cnt);
    best = min(best, i);
    ans = max(ans, best);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def gcd(a,b):
  if a < b:
    a, b = b, a
  while b:
    a, b = b, a % b
  return a

N, X = map(int, input().split())

x = list(map(int, input().split()))
x.append(X)
x.sort()


if len(x) == 2:
  tmp = (x[1] - x[0])
else:
  tmp = gcd((x[2] - x[1]), (x[1] - x[0]))
  for i in range(2, N):
    tmp = gcd(x[i+1] - x[i], tmp)

    
print(tmp)

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

int main(){
  int N; cin >> N;
  int w[110];
  int w_sum = 0;
  for (int i = 0; i < N; i++){
    cin >> w[i];
    w_sum += w[i];
  }
  
  int ans = 100000000;
  int s1 = 0,s2 = 0;
  for (int i = 0; i < N - 1; i++){
    s1 += w[i];
    s2 = w_sum - s1;
    int temp = abs (s1 - s2);
    ans = min(ans, temp);
  }
  cout << ans << endl;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>a>>b>>c;
      YES((a*100+b*10+c)%4==0);
     

       
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
struct ice{
	int money;
	double v;
	double ms;
}a[4];
 
bool cmp(ice a, ice b)
{
	return a.ms<b.ms;
}
 
int main()
{
	int q, h, s, d;
	double n;
	cin >> q >> h >> s >> d >> n;
	a[0].v = 0.25, a[0].money = q, a[0].ms = q*1.0/0.25;
	a[1].v = 0.5, a[1].money = h, a[1].ms = h*1.0/0.5;
	a[2].v = 1, a[2].money = s, a[2].ms = s*1.0/1.0;
	a[3].v = 2, a[3].money = d, a[3].ms = d*1.0/2.0;
	sort(a, a+4, cmp);
	long long sum = 0;
	while(n)
	{
		for(int i=0; i<4; i++)
		{
			if(a[i].v>n||n-a[i].v<0)
				continue;
			int mid = n/a[i].v;
			while(mid--)
			{
				sum += a[i].money;
				n -= a[i].v;
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var s string
  var k, t int

  fmt.Scan(&s, &k)

  ans := []byte(s)

  for i := 0; i < len(s); i++ {
    t = int( (26 - s[i] + 'a') % 26 )
    if t <= k {
      ans[i] = byte('a')
      k -= t
    } else {
      ans[i] = byte(s[i])
    }
  }

  if k != 0 {
    t = int( 'a' + ( int(ans[len(s)-1]) - 'a' + k) % 26 )
    ans[len(s)-1] = byte(t)
  }

  fmt.Println( string(ans) )
}

Measured memory_bytes: 1664
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int xs, ys, xt, yt, n;
    cin >> xs >> ys >> xt >> yt >> n;
    VI x(n), y(n), r(n);
    REP(i, n) {
        cin >> x[i] >> y[i] >> r[i];
    }


    vector<vector<double>> edge(n + 2, vector<double>(n + 2, 0));
    REP(i, n) {
        FOR(j, i + 1, n) {
            double l = max(sqrt(pow((double) x[i] - x[j], 2) + pow((double) y[i] - y[j], 2)) - r[i] - r[j], 0.0);
            edge[i][j] = l;
            edge[j][i] = l;
        }
    }

    REP(i, n) {
        double l = max(sqrt(pow((double) x[i] - xs, 2) + pow((double) y[i] - ys, 2)) - r[i], 0.0);
        edge[i][n] = l;
        edge[n][i] = l;
    }

    REP(i, n) {
        double l = max(sqrt(pow((double) x[i] - xt, 2) + pow((double) y[i] - yt, 2)) - r[i], 0.0);
        edge[i][n+1] = l;
        edge[n+1][i] = l;
    }

    double l = max(sqrt(pow((double) xs - xt, 2) + pow((double) ys - yt, 2)), 0.0);
    edge[n][n+1] = l;
    edge[n+1][n] = l;

    priority_queue<pair<double,int>> pq;
    vector<bool> vb(n+2,false);
    vector<double>  ans(n+2,-0.0);
    pq.push(MP(0,n));

    while (!pq.empty()){
        pair<double,int> t = pq.top();
        pq.pop();
        if(vb[t.SND]){ continue; }
        vb[t.SND] = true;
        ans[t.SND] = -t.FST;
        REP(i,n+2){
            if(vb[i]){ continue; }
            else{
                pq.push(MP(t.FST-edge[t.SND][i],i));
            }
        }
    }

    cout << abs(ans[n+1])  << endl;

    return 0;
}

Measured memory_bytes: 16500
#include<iostream>

using namespace std;

int main()
{
	int N;

	cin >> N;

	if(N%4== 0 || N%7==0)
	{
		cout << "Yes" << endl;
		return 0;
	}

	for(int i=0;i*4 < N;i++)
	{
		if( (N-i*4)%7==0 )
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = [input() for _ in range(n)]
c = list(Counter(s).items())
c.sort(key = itemgetter(1),reverse=1)
m = c[0][1]
lst = []
for i,j in c:
    if m == j:
        lst.append(i)
lst.sort()
for i in lst:
    print(i)

Measured memory_bytes: 121860
#include <iostream>

using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    long long bal = 1000, stocks = 0;
    for(int i = 0; i < n; ++i){
        if(i != n - 1 && a[i] < a[i + 1] && stocks != 0){
            continue;
        }
        else if(i != n - 1 && a[i] < a[i + 1]){
            stocks = bal / a[i];
            bal = bal % a[i];
        }
        else if(i != 0 && a[i] > a[i - 1]){
            bal = bal + stocks * a[i];
            stocks = 0;
        }
        //if(i == n - 1)
           // bal = bal + stocks * a[i]; 
        
    }
    cout << bal << endl;
    return 0;
    
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
ll x[10], y[10];

double dist(ll i, ll j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx * dx + dy * dy, 0.5);
}

int main() {
  ll n, cnt = 0;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];
  double len = 0.0;
  rep(i, n) rep(j, i) len += dist(i, j);

  ll fac = 1, num = 2;
  for (int i = 1; i <= n; ++i) fac *= i;
  for (int i = 1; i <= n - 1; ++i) num *= i;
  double ans = (len * num) / fac;

  cout << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ARemainingBalls {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s, t; cin >> s >> t;
      int a, b; cin >> a >> b;
      string u; cin >> u;
      if (s==u) {
        a--;
      } else {
        b--;
      }
      cout << a << ' ' << b << endl;
    }
};

signed main() {
  ARemainingBalls solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i, ans = 0, c;
    
    for(i=1;i<=n;i++)
    {
        cin>>c;
        if(i%2 && c%2) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3608
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


class Combination:
    def __init__(self,N):
        self.fac = [1]*(N+1)
        for i in range(1,N+1):
            self.fac[i] = (self.fac[i-1]*i)%mod
        self.invmod = [1]*(N+1)
        self.invmod[N] = pow(self.fac[N],mod-2,mod)
        for i in range(N,0,-1):
            self.invmod[i-1] = (self.invmod[i]*i)%mod

    def C(self,n,k):#nCk
        if n < k:
            return 0
        return self.fac[n]*self.invmod[k]%mod *self.invmod[n-k] %mod

    def P(self,n,k):# nPk
        if n < k or k < 0:
            return 0
        return self.fac[n]*self.invmod[k]%mod


N,K = inpl()
lines = defaultdict(set)
for _ in range(N-1):
    x,y = inpl()
    x,y = x-1,y-1
    lines[x].add(y)
    lines[y].add(x)

lines2 = defaultdict(set)
visited = [False]*N
def dfs(s):
    visited[s] = True
    for t in lines[s]:
        if not visited[t]:
            lines2[s].add(t)
            dfs(t)
dfs(0)

def solve(s,first):
    L = len(lines2[s])
    if L == 0:
        return 1
    if first:
        ans = Comb.P(K-1,K-1-L)
    else:
        ans = Comb.P(K-2,K-2-L)
    for t in lines2[s]:
        ans *= solve(t,False)
        ans %= mod
    return ans

Comb = Combination(max(K,N)+3)

print(solve(0,True)*K%mod)


Measured memory_bytes: 143216
#include <iostream>
#include <algorithm>

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

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

    long long count = 0;
    for (int i=1; i<=n; i++) {
        if(i%3 != 0 && i%5 != 0)
            count += i;
    }
    cout << count << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int k, a, b;
  cin >> k >> a >> b;
  
  bool flag = false;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) flag = true;
  }
  
  if (flag) cout << "OK\n";
  else cout << "NG\n";
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

const ll N=1e5+10;
vector<set<ll>> G(N);
vec b(N),w(N);
ll n;

void dfs(ll cur,ll pre) {
  b[cur]=1,w[cur]=1;
  for(ll nex:G[cur]) {
    if(nex==pre) continue;
    dfs(nex,cur);
    (b[cur]*=w[nex])%=mod;
    (w[cur]*=(w[nex]+b[nex])%mod)%=mod;
  }
}
 
int main() {
  cin >> n;
  for(ll i=1;i<n;i++) {
    ll x,y;
    cin >> x >> y;
    x--,y--;
    G[x].insert(y);
    G[y].insert(x);
  }
  dfs(0,-1);
  cout << (b[0]+w[0])%mod << endl;
}

Measured memory_bytes: 22784
/*
ID: tohoast1
TASK: gymnastics
LANG: C++
*/
#include <bits/stdc++.h>
#define speedup ios_base::sync_with_stdio(NULL)
#define fin freopen("allcodefs.in", "r", stdin)
#define fout freopen("allcodefs.out", "w", stdout)
#define FILENAME
#define PUBG push_back
#define p_b pop_back
#define mp make_pair
#define fi first
#define se second
#define cls clear
#define INF const int ci = 1e6 + 100
#define K_INF 1e9 + 7
#define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define MIN_INT -999999999
#define MOD 1000000007
#define d109 1000000000
#define basay break
#define bmbr exit(0)

using namespace std;
typedef long long LL;
typedef long L;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef string STR;
STR s;
int a_pos, z_pos;

int main() {
    #ifdef FILENAMEs
        fin;
        fout;
    #endif // FILENAME
    cin >> s;
    for (int i = 0 ; i < s.size() ; ++ i) {
        if (s[i] == 'A') {
            a_pos = i;
            break;
        }
    }
    for (int i = s.size() - 1 ; i != 0 ; i --) {
        if (s[i] == 'Z') {
            z_pos = i;
            break;
        }
    }
    cout << z_pos - a_pos + 1;
    ///time;
    return 0;
}


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


int main(void) {
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  rep(i, n) cin >> a[i];
  vector<string> b(m);
  rep(i, m) cin >> b[i];

  for (int posy = 0; posy <= n - m; ++posy) {
    for (int posx = 0; posx <= n - m; ++posx){
      bool ok = true;
      for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
          if (b[i][j] != a[posy + i][posx + j]) {
            ok = false;
            break;
          }
        }
        if (!ok) {
          break;
        }
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  
  return 0;
}

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

int main() {
  int n; cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  REP(i, 2) REP(j, n) cin >> a[i][j];
  
  vector<vector<int>> s(2, vector<int>(n+1));
  s[0][0] = 0; s[1][0] = 0;
  REP(i, 2) REP(j, n) s[i][j+1] = s[i][j] + a[i][j];
  
  int ans = 0;
  REP(i, n) ans = max(ans, s[0][i+1] + s[1][n] - s[1][i]);
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

int main() {

    int N, Y, r;
    int x=-1, y=-1, z=-1;
    cin >> N >> Y;

    for(int p = 0; p <= N; p++) {
        for(int q = 0; q <= N; q++) {
            r = N - p - q;

            if(10000*p+5000*q+1000*r == Y && p+q+r == N && r >= 0) {
                x=p; y=q; z=r;
                goto OUT;
            }

        }
    }

    OUT:

    cout << x << " " << y << " " << z << endl;

    return 0;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()

typedef long long ll;
typedef long double ld;

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(all(a));
    ll sum = 0;
    for (auto el : a) sum += el;
    if (sum == x) {
        cout << n;
        return 0;
    }
    int pos = 0;
    sum = 0;
    while (pos < n - 1 && sum + a[pos] <= x) sum += a[pos++];
    cout << pos;
    return 0;
}


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

int main() {
	int n, a[31] = {0,1,2,4};
	while (1) {
		cin >> n;
		if (n == 0) break;

		for (int i = 4; i <= n; i++) {
			a[i] = a[i - 1] + a[i - 2] + a[i - 3];
		}
		cout << (a[n] / 10 + 1) / 365 + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
for i in range(N):
  B[i] = A[i] - 1 - i
  
#print(B)
B = sorted(B)

if len(B) % 2 == 1:
  ans = B[int((len(B) - 1) / 2)]
else:
  ans = int((B[int(len(B) / 2)] + B[int(len(B) / 2) - 1]) / 2)

score = 0
for i in range(N):
  score += abs(A[i] - ans - 1 - i)
  
print(score)  
  
  


Measured memory_bytes: 104296
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
#define int ll
 
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
 
using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;
 
template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}
 
template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}
 
int read(){
	int i;
	scanf("%" PRId64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}
 
char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}
 
template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}
 
template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}
 
template<class T>
T Sq(const T& t){
	return t*t;
}
 
const int inf=LLONG_MAX/3;
 
const int Nmax=364;
int dist[Nmax][Nmax];
bool dame[Nmax][Nmax];
 
signed main(){
	int n=read(),ans=0;
	REP(i,n)REP(j,n)
		dist[i][j]=read();
	REP(i,n)REP(j,n)REP(k,j)if(i!=j&&i!=k){
		if(dist[i][j]+dist[i][k]<dist[j][k]){
			cout<<-1<<endl;
			return 0;
		}
		if(dist[i][j]+dist[i][k]==dist[j][k])
			dame[j][k]=1;
	}
	REP(i,n)REP(j,i)if(!dame[i][j])
		ans+=dist[i][j];
	cout<<ans<<endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  string s,t;
  cin >> s;
  for (int i=0; i<s.size(); i++) {
    if (i%2==0) {
      cout << s[i];
    }
  }
  cout << endl;
}

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

int main(){
    string s, t;
    while(cin >> s >> t){
        int a, b;
        cin >> a >> b;
        string m; cin >> m;
        if( s == m ){
            a--;
        }else{
            b--;
        }
        cout << a << " " << b << "\n";
    }
}
/*
7 2
0 1 0 0 0 1 0
*/


Measured memory_bytes: 256
#input
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]

points = [K-Q] * N

for ans in A:
    points[ans - 1] += 1

for point in points:
    if (point > 0):
        print("Yes")
    else:
        print("No")

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

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    string S;cin>>S;
    int cnt=0;
    for(int i=0;i<N;i++){
        if(S[i]=='1') cnt++;
    }
    
    for(int q=-1;q<=1;q++){
        ll now=1;
        if(cnt+q<=0) continue;
        now%=(cnt+q);
        for(int j=N-1;j>=0;j--){
            rui[j][q+1]=now;
            now*=2;
            now%=(cnt+q);
        }
        
        for(int j=0;j<N;j++){
            if(S[j]=='1') sum[q+1]+=rui[j][q+1];
            sum[q+1]%=(cnt+q);
        }
    }
    
    for(int i=0;i<N;i++){
        int res=0;
        if(S[i]=='1'){
            if(cnt>=2){
                ll now=sum[0];
                now+=(cnt-1)-rui[i][0];
                now%=(cnt-1);
                res=1;
                
                while(now){
                    int d=__builtin_popcountll(now);
                    now=now%d;
                    res++;
                }
            }
        }else{
            ll now=sum[2];
            now+=rui[i][2];
            now%=(cnt+1);
            res=1;
            
            while(now){
                int d=__builtin_popcountll(now);
                now=now%d;
                res++;
            }
        }
        
        cout<<res<<"\n";
    }
}


Measured memory_bytes: 8472
import itertools, numpy
n, m, x = map(int, input().split())
l = list(list(map(int, input().split())) for i in range(n))
sm = numpy.sum(l, axis=0)
ad = -1
kk = []

for k in range(n):
    com = list(itertools.combinations(l,k+1))
    sm = numpy.sum(com, axis=1)
    for i in range(len(sm)):
        kk.append(sm[i])
    
kk.sort(key=lambda z: z[0])

for i in range(len(kk)):
    if all(s >= x for s in kk[i][1:]) == True:
        ad = kk[i][0]
        break
print(ad)

Measured memory_bytes: 28572
#include<iostream>
#include<cstdio>
using namespace std;
main(){
  while(1){
    int a,b;
    scanf("%d %d",&a,&b);
    if(!a && !b) break;
    int o = b-a;
    printf("%d %d %d\n",(o%500)/100,(o%1000)/500,o/1000);
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<Int> A(N);
	for (int i = 0; i < N; ++i) { cin >> A[i]; }

	vector<Int> res(N, 0);
	for (int i = 0; i < N; ++i) {
		res[0] += (i % 2 == 0 ? A[i] : -A[i]);
	}
	for (int i = 1; i < N; ++i) {
		res[i] = 2*A[i - 1] - res[i - 1];
	}

	for (int i = 0; i < N; ++i) {
		cout << res[i] << (i < N - 1 ? " " : "\n");
	}

	return 0;
}


Measured memory_bytes: 2816
#include <cstdio>

const int N = 300;

char a[N][N + 1];

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%s", a[i]);
    }
    int result = 0;
    for (int d = 0; d < n; ++ d) {
        bool ok = true;
        for (int i = 0; i < n; ++ i) {
            int x0 = (d + i) % n;
            int y0 = i;
            for (int k = 0; k < n; ++ k) {
                ok &= a[(x0 + k) % n][y0] == a[x0][(y0 + k) % n];
            }
        }
        if (ok) {
            result += n;
        }
    }
    printf("%d\n", result);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	map<char, int> mp;
	for(auto& c : s) mp[c]++;
	vi v;
	int a = 0;
	for(auto& p : mp) {
		if(p.fi == '+') continue;
		if(p.se == 1) a++;
		else v.pb(p.se); 
	}
	int ans = (v.size()+a)*2 -1 + v.size()*2;
	map<int, int> mp2;
	for(auto& a : v) {
		mp2[a]++;
	}
	for(auto& p : mp2) {
		if(p.se > 2) {
			ans -= (p.se-2)*2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll n,a,b,ans=0;

int main(void){
	cin>>n>>a>>b;
	ans+=n/(a+b) * a;
	n %= a+b;
	if(n>0){
		if(n>=a){
			ans+=a;
		}else{
			ans+=n;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [-a for a in A]
heapq.heapify(B)
for _ in range(M):
    v = heapq.heappop(B)
    v = -(abs(v)//2)
    heapq.heappush(B, v)
print(-sum(B))

Measured memory_bytes: 16692