akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = []
B = []
C = []
ans = 0
equal = True
for i in range(N):
    t = tuple(map(int, input().split()))
    if t[0] != t[1]:
        equal = False
    A.append(t[0])
    B.append(t[1])
if A == B:
    print(ans)
else:
    for i in range(N):
        if A[i] > B[i]:
            C.append(B[i])
    print(sum(A) - min(C))

Measured memory_bytes: 4972
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<tgmath.h>
using namespace std;

#define lld long long

lld gcd(lld x, lld y){
    while (y > 0)
    {
        lld r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main(){
    lld a,b;
    cin >> a >> b;
    cout << gcd(a,b) << endl;   
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<typename T>
class BinaryIndexedTree {
    int N;
    vector<T> data;
public:
    BinaryIndexedTree(int N) : N(N) {
        data.resize(N + 1, 0);
    }

    T sum(int k) {
        T res = 0;
        for (; k > 0; k -= k & -k) {
            res += data[k];
        }
        return res;
    }

    void add(int k, T x) {
        for (; k <= N; k += k & -k) {
            data[k] += x;
        }
    }

    /**
     * v1 + v2 + ⋯ + vx ≧ W となる最小の 𝑥 を求める
     */
    int lowerBound(int w) {
        if (w <= 0) return 0;
        int x = 0;
        int k = 1;
        while (k * 2 <= N) k *= 2;
        for (; k > 0; k /= 2) {
            if (x + k <= N && data[x + k] < w) {
                w -= data[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

void Main() {
    ll N, Q;
    cin >> N >> Q;
    BinaryIndexedTree<ll> bit(N);
    rep(q, Q) {
        ll com, x, y;
        cin >> com >> x >> y;
        if (com) {
            ll ans = bit.sum(y) - bit.sum(x-1);
            cout << ans << '\n';
        }else{
            bit.add(x, y);
        }
    }
}

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



Measured memory_bytes: 3548
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int n,a,b,ans;
vector<int> h(100010);

int isok(int k,int h[]){
    int K = k;
    REP(i,n){
        // cerr << (h[i]) << " ";
        if(h[i]-b*k <= 0);
        else if((h[i]-b*k)%(a-b) != 0) K -= (h[i]-b*k)/(a-b) +1;
        else K -= (h[i]-b*k)/(a-b);
    }
    // cerr << " " <<  K;
    if(K >= 0) return 1;
    else return 0;
}

signed main(){

    cin >> n >> a >> b;
    int h[100010];
    REP(i,n){
        cin >> h[i];
        // cerr << h[i] <<" ";
    }
    sort(h,h+n);

    int ok = 1000000001;//解が存在
    int ng = 0;//解が存在しない
    while(abs(ok - ng) > 1){
        int mid = (ok + ng)/2;
        // cerr << mid;
        if(isok(mid,h)) {ok = mid; }
        else {ng = mid;}
    }

    cout << ok << endl;

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, memo[3];
  string S, rgb = "RGB";

  void init() {
    scanf("%lld", &N);
    cin >> S;
    rep(i, N) rep(j, 3) {
      memo[j] += (S[i]==rgb[j]);
    }
  }

  void solve() {
    ll ans = 0;
    rep(i, N-1) for(ll j=i+1; j<N; j++) {
      if(S[i] == S[j]) continue;
      rep(k, 3) {
        if(rgb[k] == S[i] || rgb[k] == S[j]) continue;
        ans += memo[k];
        ll left = i-(j-i);
        ll right = j+(j-i);
        ll mid = (i+j)/2;
        if(0<=left && S[left]==rgb[k]) ans--;
        if(right<N && S[right]==rgb[k]) ans--;
        if(left+right==mid*2 && S[mid]==rgb[k]) ans--;
      }
    }
    printf("%lld\n", ans/3);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (auto&& e : v) cin >> e;
  int ans = 0;

  for (int l = 0; l <= k; l++) {
    for (int r = 0; r <= k - l; r++) {
      if (l + r > n) break;
      int score = 0;
      vector<int> jewel;
      for (int i = 0; i < l; i++) {
        score += v[i];
        jewel.push_back(v[i]);
      }
      for (int i = n - r; i < n; i++) {
        score += v[i];
        jewel.push_back(v[i]);
      }
      sort(begin(jewel), end(jewel));
      int d = k - l - r;
      for (int i = 0; i < d; i++) {
        if (i >= int(jewel.size())) break;
        if (jewel[i] >= 0) break;
        score -= jewel[i];
      }
      ans = max(ans, score);
    }
  }
  cout << ans << endl;
}


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

int main() {
  double a,b,c,d,e,f,ad,bd,ae,cd,af,x,y;
  while(cin>>a>>b>>c>>d>>e>>f){ 
    ad=a*d;
    bd=b*d;
    cd=c*d;
    ae=a*e;
    af=a*f;
    y=(cd-af)/(bd-ae);
    x=(c-b*((cd-af)/(bd-ae)))/a;
    cout<<fixed<<setprecision(3)<<x<<' '<<y<<endl;
  }
  return 0;
}




Measured memory_bytes: 3184
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	count := 0
	for i := 1; i <= n; i++ {
		for j := 1; j <= n/i; j++ {
			if n > i*j {
				count += 1
			}
		}
	}

	fmt.Println(count)
}

Measured memory_bytes: 1788
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

int main(){
    int N,T;cin>>N>>T;
    vec A(3010),B(3010);
    for(int i=1;i<=N;i++) cin>>A[i]>>B[i];
    
    //dp0[i]:1~iの中から選んだ最大値
    //dp1[i]:i~Nの中から選んだ最大値
    mat dp0(3010,vec(3010)),dp1(3010,vec(3010));
    //初期化
    for(int t=0;t<=3000;t++){
        dp0[0][t]=dp1[N+1][t]=0;
    }
    //漸化式
    for(int i=1;i<=N;i++){
        for(int t=0;t<=3000;t++){
            if(t>=A[i]) dp0[i][t]=max(dp0[i-1][t],B[i]+dp0[i-1][t-A[i]]);
            else        dp0[i][t]=dp0[i-1][t];
        }
    }
    for(int i=N;i>=1;i--){
        for(int t=0;t<=3000;t++){
            if(t>=A[i]) dp1[i][t]=max(dp1[i+1][t],B[i]+dp1[i+1][t-A[i]]);
            else        dp1[i][t]=dp1[i+1][t];
        }
    }
    ll ans=0;
    for(int i=1;i<=N;i++){
        ll rev=0;
        for(int t=0;t<T;t++){
            rev=max(rev,dp0[i-1][t]+dp1[i+1][T-1-t]);
        }
        ans=max(ans,B[i]+rev);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 142080
A,B,C = map(int,input().rstrip().split(" "))
K = int(input())
ans = False
for i in range(K):
    if A >= B:B *= 2
    elif B >= C:C *= 2
    else:
        ans = True
        break
if A < B < C:ans = True
if ans:print("Yes")
else:print("No")


Measured memory_bytes: 61664
MOD = 10**9 + 7

N, M = map(int,input().split())
a = [int(input()) for k in range(M)] + [-1]

dp = [0]*(N+1)
i = 0

dp[0] = 1
if a[0] == 1:
    dp[1] = 0
    i += 1
else:
    dp[1] = 1

for k in range(2,N+1):
    if k == a[i]:
        dp[k] = 0
        i += 1
    else:
        dp[k] = dp[k-1] + dp[k-2]
        dp[k] %= MOD
print(dp[N])


Measured memory_bytes: 51672
import Data.Char

conv :: Int -> Char -> Char
conv n c = let i = ord c - 65
            in alpha!!(n+i)
  where
    alpha = ['A'..'Z'] ++ ['A'..'Z']

main :: IO ()
main = do
    n <- readLn :: IO Int
    s <- getLine :: IO String
    putStrLn $ map (conv n) s


Measured memory_bytes: 1404
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;



public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	   	int s = sc.nextInt();
	   	int w = sc.nextInt();
	   	if(s<=w) {
	   		System.out.println("unsafe");
	   	}
	   	else {
	   		System.out.println("safe");
	   	}
	 }
}

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

using namespace std;

typedef long long LL;

const int N = 1010;

int g, w, y, p;
int n;

int main()
{
    cin >> n;
    while(n--)
    {
        char c;
        cin >> c;
        if(c == 'G') g = 1;
        else if(c == 'W') w = 1;
        else if(c == 'Y') y = 1;
        else if(c == 'P') p = 1;
    }

    if(g + w + y + p == 3) puts("Three");
    else puts("Four");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;

#define MAX 1000000000000

map<ll,ll> st;



int main(void) {
	string s, t; cin >> s >> t;
	rep(i, s.size()) {
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll h,w; cin>>h>>w;
  map<char,ll> m;
  rep(i,h) rep(j,w) {
    char c; cin>>c;
    m[c]++;
  }
  
  ll gu=0, ki=0, yo=0;
  for(auto e: m){
    // cout<<e.first<<' '<<e.second<<endl;
    if(e.second>=4){
      yo+=e.second/4;
      e.second%=4;
    }
    
    if(e.second>=2){
      gu+=e.second/2;
      e.second%=2;
    }
    
    if(e.second>0) ki++;
  }
  
  // cout<<ki<<' '<<gu<<' '<<yo<<endl;
  
  string ans;
  if(h%2==0 && w%2==0){
    if(ki>0 || gu>0) ans="No";
    else ans="Yes";
  }else if(h%2==1 && w%2==1){
    ll cross=(h+w-2)-2*gu;
    if(ki==1 && cross>=0 && cross%4==0) ans="Yes";
    else ans="No";
  }else{
    ll x;
    if(h%2) x=w;
    else x=h;
    ll cross=x-2*gu;
    if(ki%2==0 && cross>=0 && cross%4==0) ans="Yes";
    else ans="No";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt
    val vs = in.readLine().split("\\s+").map(_.toInt)

    val evenCount = Array.ofDim[Int](100000)
    val oddCount = Array.ofDim[Int](100000)

    for (i <- 0 until (n / 2) ) {
      evenCount(vs(i * 2) - 1) += 1
      oddCount(vs(i * 2 + 1) - 1) += 1
    }

    val evenCountDesc = evenCount.zipWithIndex.sorted(Ordering.by[(Int, Int), Int](_._1).reverse)
    val oddCountDesc = oddCount.zipWithIndex.sorted(Ordering.by[(Int, Int), Int](_._1).reverse)

    out.println(
      n - {
        if (evenCountDesc(0)._2 == oddCountDesc(0)._2) {
          Math.max(
            evenCountDesc(0)._1 + {
              if (oddCountDesc.length == 1) {
                0
              } else {
                oddCountDesc(1)._1
              }
            },
            oddCountDesc(0)._1 + {
              if (evenCountDesc.length == 1) {
                0
              } else {
                evenCountDesc(1)._1
              }
            }
          )
        } else {
          evenCountDesc(0)._1 + oddCountDesc(0)._1
        }
      }
    )

    out.flush()
  }
}


Measured memory_bytes: 48932
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

int n;
char s[1001];
map<char,bool> mp;

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&s[i]);
        mp[s[i]]=true;
    }
    cout<<(mp['Y'] ? "Four":"Three")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <numeric>
using namespace std;


int main()
{
    long long N;
    cin>>N;
    long long sum=0;
    for(long long p=1;p<2*pow(N,0.5);p++){
        if((N-p)%p==0){
            if((N-p)/p>p){
            sum+=(N-p)/p;
            }
        }
    }
    cout<<sum<<endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

struct Sugar {
  int a, b;
  double con;
};

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  Sugar s = {0, 0, 0};
  FOR(i, 0, 31) FOR(j, 0, 31) {
    int a = 100 * (A * i + B * j);
    if (a == 0) continue;
    FOR(k, 0, ceil((F - a) / C)) FOR(m, 0, ceil((F - a) / D)) {
      int b = C * k + D * m;
      double con = (double)b / (a + b) * 100.0;
      if (a == 0 || b > a / 100 * E || a + b > F) continue;
      if (con > s.con) s = {a, b, con};
    }
  }
  if (s.con == 0) s.a = 100 * A;

  cout << s.a + s.b << " " << s.b << endl;
}

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


class Program
{


    static void Main(string[] args)
    {

        char[] cs = new char[] { ' ', ',' };
        //int val = int.Parse(Console.ReadLine());
        //int[] vals = parseAry(Console.ReadLine().Split(cs));
        //string str = Console.ReadLine();
        //string[] strs = Console.ReadLine().Split(cs);

        //string res="";
        //int res = 0; ;
        //int t = int.Parse(Console.ReadLine());
        //string str = Console.ReadLine();
        ///int[] vals = parseAry(Console.ReadLine().Split(cs));
        //int n = int.Parse(Console.ReadLine());

        string res ="";

		int[] vals = parseAry(Console.ReadLine().Split(cs));
		if ( vals[0] % 2 == 1 ) { vals[0]++; }
		if ( vals[0] / 2 >= vals[1] ) { res = "YES"; } else { res = "NO"; }


        //int[] vals = parseAry(Console.ReadLine().Split(cs));

        Console.WriteLine(res);

        return;
    }

    //　String[]  ----->  int[]
    static int[] parseAry(string[] str)
    {
        int[] nums = new int[str.Length];
        for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
        return nums;
    }
    //　String[]  ----->  long[]
    static long[] parseAryL(string[] str)
    {
        long[] nums = new long[str.Length];
        for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
        return nums;
    }

    //文字列を1文字ずつString[]に入れる
    static string[] strAry(String str)
    {
        string[] re = new string[str.Length];
        for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
        return re;
    }

}

Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		long[] a = new long[m];
		long[] b = new long[m-1];
		for(int i = 0; i < m; i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		long ans = 0;
		
		if(n < m) {
			for(int i = 0; i < m-1; i++) {
				b[i] = a[i+1] - a[i];
				ans += b[i];
			}
			Arrays.sort(b);
			long sub = 0;
			for(int i = 0; i < n-1; i++) {
				sub += b[m-2-i];
			}
			ans -= sub;
		}
		
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 44844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
signed main(void){
    int n; cin>>n;
    vector <int> a(n+1), b(n); 
    rep(i,n+1) cin>>a[i];
    rep(i,n) cin>>b[i];
    int cnt = 0;
    for(int i=0;i<n;i++){
        //片方しか倒せない
        if(a[i]>b[i]){
            cnt += b[i];
            a[i]-= b[i];
        }
        //片方は全滅
        else {
            cnt += a[i];
            b[i] -= a[i];
            if(a[i+1]>b[i])
            {cnt += b[i]; a[i+1]-= b[i];}
            else
            { cnt += a[i+1]; a[i+1] = 0;}
        }
    }
    cout<<cnt<<endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int64_t, int64_t>> table(N);
  
  for (int i = 0; i < N; i++) {
    int64_t a, b;
    cin >> a >> b;
    table.at(i) = make_pair(a, b);
  }
  
  sort(table.begin(), table.end()); //安い順にソート
  
  int i = 0;
  int64_t money = 0;
  while(true) {
    int64_t a = table.at(i).first;
    int64_t b = table.at(i).second;
    if (b < M) {
      money += a*b;
      i++;
      M = M - b;
    }
    else {
      money += a*M;
      break;
    }
  }
  cout << money << endl;
}

  

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

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

cake_array = [[0] * N for _ in range(8)]

for i in range(N):
    X, Y, Z = map(int, input().split())
    for j in range(8):
        x = X if j & 1 else -X
        y = Y if j & 2 else -Y
        z = Z if j & 4 else -Z
        cake_array[j][i] = x+y+z

ans = 0
if M > 0:
    for cake in cake_array:
        cake.sort()
        ans = max(ans, sum(cake[-M:]))

print(ans)


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

int main(){
    string S;
    cin >> S;
    
    ll lose = 0;
    for(int i = 0; i < S.size(); i++)
        if(S[i] == 'x')
            lose++;
    if(lose >= 8)
        cout << "NO" <<  "\n";
    else
        cout << "YES" << "\n";
    return 0;
} 


Measured memory_bytes: 256
class UnionFind(object):
    def __init__(self, N):
        self.parent = [-1] * N #parent[i] は(i+1)番目の要素が含まれる要素数の(-1)倍
    #要素が負-->その数を親とするグループに属する要素の数×(-1)
    #要素が正-->親のindex

    #Aがどのグループに属しているかを調べる
    def root(self, A):
        if self.parent[A-1] < 0: #負の数-->その数は親
            return A
        self.parent[A-1] = self.root(self.parent[A-1]) #負では無い時、親の場所が入っているから、親が属しているグループを、自分自身に入れる(一度確認したところは直接親を見れるようにする)
        return self.parent[A-1] #親の位置を返す

    #Aが含まれているグループに属している数を返す
    def size(self, A):
        return -1 * self.parent[self.root(A)-1]

    #AとBをくっ付ける
    def connect(self, A, B):
        A = self.root(A) #Aを含むグループの親を返す
        B = self.root(B) #Bを含むグループの親を返す
        if A == B: #親が同じならなにもしない
            return False
        
        #大きい方(A)に小さい方(B)をつなぎたい
        if self.size(A) < self.size(B): #大小関係が逆の時は入れ替える
            A, B = B, A
        
        self.parent[A-1] += self.parent[B-1] #大きい方に小さい方を加える　（負の数＋負の数 = 新しいグループに含まれる数×(-1)）
        self.parent[B-1] = A #加えられた親の値を、加えた先の親の位置に書き変える
        return True
    
    def same(self, A, B):
        if self.root(A) == self.root(B):
            return True
        else:
            return False
            
# N, Q = map(int, input().split())
# uni = UnionFind(N)
# for _ in range(Q):
#     P, A, B = map(int, input().split())
#     if P == 1:
#         if uni.root(A) == uni.root(B): #親が同じかどうか
#             print ('Yes')
#         else:
#             print ('No')
#     else:
#         uni.connect(A, B)

import sys
input = sys.stdin.readline

N, M, K = map(int, input().split())

direct = [0] * (N + 1)

uni = UnionFind(N + 1)

for _ in range(M):
    A, B = map(int, input().split())
    direct[A] += 1
    direct[B] += 1
    uni.connect(A, B)

ans = [0] * (N + 1)
for i in range(1, N + 1):
    ans[i] = uni.size(i) - direct[i] - 1 #直接の友達と自分自身を引く

for _ in range(K):
    C, D = map(int, input().split())
    if uni.root(C) == uni.root(D):
        ans[C] -= 1
        ans[D] -= 1

for i in range(1, N):
    print (max(0, ans[i]), end = ' ')

print (max(0, ans[N]))



Measured memory_bytes: 12584
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
X = LI()

X_np = np.array(X)

costs = []
for p in range(1,101):
    costs.append(np.sum((X_np - p)**2))
ans = min(costs)
print(ans)


Measured memory_bytes: 27348
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int main(){
  int N; cin >> N;
  cout << N * N * N << endl;
  return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef char CHAR;
typedef unsigned char UCHAR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef int INT;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

#define LengthOf(x)    (sizeof(x) / sizeof(x[0]))

int main() 
{
	INT X;
	cin >> X;

	LLONG sum = 0;
	for (int i = 1; i <= X; ++i) {
		if ((i % 3 != 0) && (i % 5 != 0)) {
			sum += i;
		}
	}

	cout << sum;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,X,K,Q;
ll A,B,C,D;

ll ans;
bool F=false;

int main(){
    cin>>A>>B>>N;
    ll x=min(B-1,N);
    ans=(A*x/B)-A*(x/B);


    cout<<ans<<endl;
}


Measured memory_bytes: 3648
X = int(input())

if X == 2 or X == 3 or X == 5:
    print(X)
else:
    find = True
    ans = X + 1 if X % 2 == 0 else X
    while True:
        for i in range(3, int(ans**0.5)+1, 2):
            if ans % i == 0:
                ans += 2
                find = False
                break
        if find:
            break
        find = True
    print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;


int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    vector<ll> a(N + 1,0);
    for(int i = 1; i <= N; i++){
        cin >> a[i];
        if(i % 2 == 1 && a[i] % 2 == 1){
            ans++;
        }
    } 
    cout << ans << endl;
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
pub const M: i32 = 1000000007;
fn main() {
    let ans = solve();
    println!("{}",ans );
}
fn solve() -> i32{
    let n = read::<i32>();
    let mut an = read_vec::<i32>();
    let len:i32 = an.len() as i32;

    let mut v:Vec<i32>  =Vec::new();
    let mut ans:i32= 1;
    for i in 0..len/2{
        v.push(len -(2*i + 1));
        v.push(len -(2*i + 1));
    }
    if len  % 2 != 0{
        v.insert(0, 0);
    }
    an.sort();
    v.sort();
    let flag = an.iter().zip(v.iter()).fold(false,|x,y| if y.0 == y.1 {
        x
    }else {
        true
    });
    if flag == true{
        0
    } else {
        for _ in 0..len/2{
            ans = ans *2 % M;
        }
        ans
    }
}


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

struct V {
  int min;
  int max;
};

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  V x = {0, W};
  V y = {0, H};
  int tx, ty, ta;
  for(int i = 0; i < N; ++i) {
    cin >> tx >> ty >> ta;
    switch(ta) {
    case 1:
      x.min = max(x.min, tx);
      break;
    case 2:
      x.max = min(x.max, tx);
      break;
    case 3:
      y.min = max(y.min, ty);
      break;
    case 4:
      y.max = min(y.max, ty);
      break;

    default:
      break;
    }
  }
  int lx = max(x.max - x.min, 0);
  int ly = max(y.max - y.min, 0);
  cout << lx * ly << endl;
  return 0;
}

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

int main(){
  int n; cin >> n;
  string s,t;
  cin >> s >> t;
  
  int ans = 2 * n;
  for(int i=0; i<n; ++i){
    string s_substr = s.substr(n-1-i, i+1);
    string t_substr = t.substr(0, i+1);
    if (s_substr == t_substr){
      ans = min(ans, 2*n-i-1);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int A;
	int B;
	
	cin>>A>>B;
	
	if(A > 8 || B > 8){
		
			cout<<":("<<endl;
	}
	else{
		cout<<"Yay!"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    ll n;
    ll k;
    ll q;
    cin>>n>>k>>q;
    ll a[100001];ll b[100001]={0};
    rep(i,q){
        ll x;
        cin>>x;
        b[x-1]+=1;
    }
    string ans="Yes";
    
    rep(i,n){
        ans=(k-(q-b[i])>0)?"Yes":"No";
        cout<<ans<<endl;
    }
    //cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
map<int, vector<pair<int, int>>> r, c;
const int maxn = 1e5 + 10;
int n;
int p[maxn];
int f(int x) { return x == p[x] ? x : p[x] = f(p[x]); }
vector<pair<int, int>> a;
 
uint64_t solve(vector<pair<int, int>> v) {
  map<int, int> c1, c2;
  for (auto &x : v) c1[x.F]++, c2[x.S]++;
  for (auto &it : v) {
    if (c1[it.F] >= 2 && c2[it.S] >= 2) return 1LL * c1.size() * c2.size() - v.size();
  }
  return 0;
}
 
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    p[i] = i;
    int x, y;
    scanf("%d%d", &x, &y);
    r[x].push_back({y,i});
    c[y].push_back({x,i});
    a.emplace_back(x, y);
  }
  for (auto &v : r) {
    for (int i = 1; i < v.S.size(); ++i) {
      p[f(v.S[i].S)] = f(v.S[i-1].S);
    }
  }
  for (auto &v : c) {
    for (int i = 1; i < v.S.size(); ++i) {
      p[f(v.S[i].S)] = f(v.S[i-1].S);
    }
  }
  map<int, vector<pair<int, int>>> b;
  for (int i = 0; i < n; ++i) b[f(i)].push_back(a[i]);
  uint64_t ans = 0;
  for (auto &it : b) ans += solve(it.S);
  cout << ans << endl;
  return 0;
}
 

Measured memory_bytes: 19060
import math
while 1==1:
    a,op,b = map(str,input().split())
    if op == "+":
        s = int(a)+int(b)
        print(s)
    elif op == "-":
        sa = int(a)-int(b)
        print(sa)
    elif op == "*":
        seki = int(a)*int(b)                                                
        print(seki)
    elif op == "/":
        syou=math.floor(int(a)/int(b))
        print(syou)
    else:
        break

Measured memory_bytes: 7748
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(s.size() > k)
		s = s.substr(0, k), s+="...";
	cout << s;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

int main() {
    string c1, c2;
    cin >> c1 >> c2;
    for(int i = 0; i < 3; i++) {
        if(c1[i] != c2[2 - i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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>;
const int inf{int(1e9)};
int main(void){
  string S;
  cin >> S;

  vector <bool> app(26, false);  //現れたらtrue
  int N = S.length();
  for (int i = 0; i < N; i++){
    app[S[i] - 'a'] = true;
  }
  for (int i = 0; i < 26; i++){
    if (! app[i]){
      cout << char('a' + i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 3732
def main():
    K = int(input())
    s = 0
    import math
    for i in range(1,K+1):
        for j in range(1,K+1):
            ij = math.gcd(i,j)
            if ij == 1:
                s += 1 * K
            else:
                for k in range(1,K+1):
                    s += math.gcd(ij,k)
    print(s)



if __name__ == "__main__":
    main()

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

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

	vector<int> a;

	for (int i = 0; i < n * 2; i++)
		a.push_back(i + 1);

	for (int i = 0; i < m; i++) {
		int k;
		cin >> k;

		if (k > 0) {
			for (int i = 0; i < k; i++)
				a.push_back(a[i]);
			a.erase(a.begin(), a.begin() + k);
		}
		else {
			vector<int> b;

			for (int i = 0; i < n * 2; i++) {
				int j = i / 2 + (i % 2) * n;
				b.push_back(a[j]);
			}

			a = b;
		}
	}

	for (int i = 0; i < n * 2; i++)
		cout << a[i] << endl;

	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() {return sz;}
};

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

    
    UnionFind uf(n + 5);
    vector<ll> sum(1, 0);

    for (int i = m - 1; i >= 1; i--) {
        if (uf.findSet(a[i], b[i])) {
            sum.push_back(0);
            continue;
        }
        sum.push_back(uf.size(a[i]) * uf.size(b[i]));
        uf.unionSet(a[i], b[i]);
    }

    for (int i = 1; i < m; i++) {
        sum[i] += sum[i - 1];
    }

    ll nC2 = (ll) n * (n - 1) / 2;
    for (int i = m - 1; i >= 0; i--) {
        cout << nC2 - sum[i] << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; i--)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	int x;
	int a[6] = {100, 101, 102, 103, 104, 105 };
	int b[6] = { 1000000 , 1000000 ,1000000 ,1000000 ,1000000 ,1000000 };
	int dp[100001];

	memset(dp, -1, sizeof(dp));
	
	cin >> x;

	dp[0] = 0;
	rep(i, 6) {
		for (int j = 0; j <= x; j++) {
			if (dp[j] >= 0)
				dp[j] = b[i];
			else if (j < a[i] || dp[j - a[i]] <= 0)
				dp[j] = -1;
			else
				dp[j] = dp[j - a[i]] - 1;
		} 
	}

	if (dp[x] >= 0)
		cout << "1" << endl;
	else
		cout << "0" << endl;
	


	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict as ddict

h,w,m=map(int,input().split())

xs=[0]*w
ys=[0]*h
xsmx=ysmx=0
pts=set()
for _ in range(m):
    y,x=map(int,input().split())
    x,y=x-1,y-1
    xs[x]+=1
    ys[y]+=1
    pts.add((x,y))
    xsmx=max(xsmx,xs[x])
    ysmx=max(ysmx,ys[y])

xsc=[x for x in range(w) if xs[x]==xsmx]
ysc=[y for y in range(h) if ys[y]==ysmx]
ans=xsmx+ysmx-1
ok=False
for y in ysc:
    for x in xsc:
        if (x,y) not in pts:
            ans+=1
            ok=True
            break
    if ok:
        break

print(ans)


Measured memory_bytes: 176792
def resolve():
    X, K, D = map(int, input().split())
    x = abs(X)
    cnt = x // D

    if K < cnt:
        ans = x - (K * D)
    else:
        ans = x - (cnt * D)
        if (K - cnt) % 2:
            ans -= D
    print(abs(ans))


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9108
import java.util.Scanner;

public class Main {

	private static Scanner sc;

	public static void main(String[] args) {

		sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		sb.append(sc.next()).append(sc.next()).append(sc.next());
		int a = Integer.valueOf(sb.toString());
		if (a % 4 == 0) {
			System.out.print("YES");
		} else {
			System.out.print("NO");
		}
	}
}

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

int main(){
	int N, D;
	cin >> N >> D;
	vector<vector<int>> X(N, vector<int>(D));
	for(int i = 0; i < N; i++){
		for(int j = 0; j < D; j++){
			cin >> X.at(i).at(j);
		}
	}
	
	int cnt = 0;
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			int dis = 0;
			for(int k = 0; k < D; k++){
				dis += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
			}
			double diss = sqrt(dis);
			if(diss == floor(diss)) cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

//DP法
//a より b の方が小さかったら、a を b に置き換える (true)、そうでなかったら、何もしない(false)
template <class T>
inline bool chmin(T &a, T b) //change minimum
{
        if (a > b)
        {
                a = b;
                return true;
        }
        return false;
}

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

typedef long long ll; //64bit型
using namespace std;
// const long long INF = 1LL << 60; //無限大の値
const ll INF = 10000000000;

int main()
{
        int N;
        ll W, weight[110], value[110];
        cin >> N >> W;

        ll dp[110][100100] = {0};
        rep(i, N) { cin >> weight[i] >> value[i]; }

        rep(i, N)
        {
                rep(sum_w, W + 1)
                {
                        if (sum_w - weight[i] >= 0)
                        {
                                chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
                        }
                        chmax(dp[i + 1][sum_w], dp[i][sum_w]);
                }
        }
        cout << dp[N][W] << endl;
        return 0;
}

Measured memory_bytes: 86272
#include <stdio.h>
 
int main() {
	int n, k;
	scanf ("%d %d",&n,&k);
	int a[n];	
	
	for (int i=0; i<n; i++) 
	{
		scanf("%d", &a[i]);
	}
	
	for (int j=0; j<n-k; j++) 
	{
		if ( a[j]<a[j+k]) 
		{
		    printf("Yes\n");
		} 
		else 
		{
			printf("No\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 3940
#include<stdio.h>
#include<string.h>
char s[110][11000];
char temp[11000];
int main(){
	int n,l,isSorted;
	while(~scanf("%d%d",&n,&l)){
		for(int i=0;i<n;i++){
			scanf("%s",s[i]);
		}
		for(int i=0;i<n-1;i++){
			isSorted = 1;
			for(int j=0;j<n-1-i;j++){
				if(strcmp(s[j],s[j+1])>0){
					memset(temp,'\0',sizeof(temp));
					strcpy(temp,s[j]);
					strcpy(s[j],s[j+1]);
					strcpy(s[j+1],temp);
					isSorted = 0;
				}
			}
			if(isSorted) break;
		}
		
		for(int i=0;i<n;i++)
			printf("%s",s[i]);
		printf("\n");
	}
} 

Measured memory_bytes: 640
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>>data(n);
	for (int i = 0; i < n; i++) {
		data[i].first = i;
		cin >> data[i].second;
	}
	int now = 0;
	for (int i = 0; i < n; i++) {
		now = data[now].second - 1;
		if (now == 1) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;
  string ans = "";
  for (int i = 0; i < s.size(); i += 2)
    ans += s[i];
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;


int main(){
    int N; ll K; 
    cin >> N >> K;
    vector<vector<int>> next(60, vector<int>(N));
    rep(v,N) cin >> next[0][v], next[0][v]--;
    rep(d,59){
        rep(v, N){
            next[d+1][v] = next[d][next[d][v]];
        }
    }
    int v = 0;
    for(int d = 0; d < 60; d++){
        if(K & (1LL << d)) v = next[d][v];
    }
    cout << v + 1 << endl;
}

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

using namespace std;

int main()
{
    int a,b,c,i=0;
    
    cin>>a;
    cin>>b;
    int x[a];
    for(i=0;i<a;i++)
    {
        cin>>x[i];
    }
    int sum=0;
    int count=1;
    for(int y=0;y<a;y++)
    {
        sum=x[y]+sum;
        if(sum<=b)
        {
            count++;
        }
    }
    std::cout << count << std::endl;
    
}

Measured memory_bytes: 256