akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        String s = sc.next();
        if(s.length() % 2 == 0){
            for(int i = 2; i < s.length(); i+=2){
                String tmp = s.substring(0,s.length()-i);
                if(tmp.substring(0,tmp.length()/2).equals(tmp.substring(tmp.length()/2, tmp.length()))){
                    System.out.println(tmp.length());
                    return;
                }
            }
        }else{
            for(int i = 1; i < s.length(); i+=2){
                String tmp = s.substring(0,s.length()-i);
                if(tmp.substring(0,tmp.length()/2).equals(tmp.substring(tmp.length()/2, tmp.length()))){
                    System.out.println(tmp.length());
                    return;
                }
            }
        }
        System.out.println(s.length());
    }
}

class Restaurant implements Comparable<Restaurant>{
    int p,i;
    String c;
    public Restaurant(int p,int i,String c){
        this.p = p;
        this.i = i;
        this.c = c;
    }
    
    public int compareTo(Restaurant r){
        if(this.c.compareTo(r.c) <= -1){
            return -1;
        }else if(this.c.compareTo(r.c) >= 1){
            return 1;
        }else{
            if(this.p > r.p){
                return -1;   
            }else if(this.p < r.p){
                return 1;
            }else{
                return 0;
            }
        }
    }
}

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: 20308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
    int sum =0;
  while(n>0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n;
  cin>>n;
  int sum=findSumOfDigits(n);
  if(n%sum==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 501
#define MAX 1e308
int main(void){
  int n;
  double p[N],q[N];
  double psum[N][N],qsum[N][N]; // e.g. psum[0][2]=p[0]+p[1]+p[2], used for making tree deeper
  double et[N][N];
  int i,j,k,h;
  double tmp;
  scanf("%d",&n);
  for(i=0;i<n;++i) scanf("%lf",&p[i]);
  for(i=0;i<n+1;++i) scanf("%lf",&q[i]);
  // calc psum,qsum
  for(i=0;i<n;++i){
    psum[i][i]=p[i];
    qsum[i][i]=q[i];
    for(j=i+1;j<n;++j){
      psum[i][j]=psum[i][j-1]+p[j];
      qsum[i][j]=qsum[i][j-1]+q[j];
    }
    qsum[i][n]=qsum[i][n-1]+q[n];
  }
  qsum[n][n]=q[n];
  // calc et
  for(h=0;h<n+1;++h){
    for(i=0;i<n+1-h;++i){
      if(h==0) et[i][i]=q[i];
      else{
        et[i][i+h]=MAX;
        for(k=0;k<h;++k){
          tmp=et[i][i+k]+et[i+k+1][i+h]+psum[i][i+h-1]+qsum[i][i+h]; // combine 2 tree and make it deeper once
          if(tmp<et[i][i+h]) et[i][i+h]=tmp;
        }
      }
      //printf("et[%d][%d]=%f\n",i,i+h,et[i][i+h]);
    }
  }
  printf("%lf\n",et[0][n]);
  return 0;
}



Measured memory_bytes: 7656
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        int A[] = new int[N];
        for (int I = 0; I < N; I++) {
            A[I] = Input.nextInt();
        }
        
        int M = Input.nextInt();
        for (int I = 0; I < M; I++) {
            int Sum=0;
            int P1 = Input.nextInt();
            int X1 = Input.nextInt();

            for (int J = 0; J < N; J++) {
                if (J == P1 - 1) {
                    Sum+=X1;               
                }else{
                Sum+=A[J];}
            }
            System.out.println(Sum);

        }
    }
}


Measured memory_bytes: 23124
import java.io.*;
import java.util.*;
import java.lang.Math;

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

        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            String buf = sc.next();
            char op = buf.charAt(0);
            int b = sc.nextInt();
            if(op == '+')System.out.println(a + b);
            else if(op == '-')System.out.println(a - b);
            else if(op == '*')System.out.println(a * b);
            else if(op == '/')System.out.println(a / b);
            else break;
        }

    }
  
}


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

int main(){
	int n;
	int cnt = 0;
	cin >> n;
	bool flag = 1;
	for(int i=11; i<=60010; i+=10){
		flag = 1;
		for(int j=2; j<=sqrt(i); j++){
			if(i%j == 0){
				flag = 0;
				break;
			}
		}
		if(flag){
			cnt++;
			if(cnt > n) break;
			cout << i << " ";
		}
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n);
    vector<PII> pos, neg;
    int bb = 0;
    for (int i = 0; i < n; ++i) {
        make(string, s);
        int b = 0, mnb = 0;
        for (auto &c : s) {
            b += (c == '(' ? 1 : -1);
            mnb = min(mnb, b);
        }
        bb += b;
        if (b >= 0) {
            pos.emplace_back(-mnb, b);
        } else {
            neg.emplace_back(b - mnb, -b);
        }
    }
    sort(ALL(pos));
    sort(ALL(neg));
    bool ok = bb == 0;
    int b = 0;
    for (int i = 0; ok && i < pos.size(); ++i) {
        ok = pos[i].first <= b;
        b += pos[i].second;
    }
    b = 0;
    for (int i = 0; ok && i < neg.size(); ++i) {
        ok = neg[i].first <= b;
        b += neg[i].second;
    }
    cout << (ok ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 19060
a, b, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = []
for _ in range(m):
    xyc.append(list(map(int, input().split())))
ans = min(a) + min(b)

for x, y, c in xyc:
    tmp = a[x - 1] + b[y - 1] - c
    ans = min(ans, tmp)
print(ans)

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

int main(){
  int N;
  cin >> N;
  int num=0;
  for(int i=1; i<=N; i+=2){
    int count=0;
    for(int j=1; j<=N; j++){
      if(i%j==0) count++;
    }
    if(count==8) num++;
  }
  cout << num << endl;
  return 0;
}

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

int A, B;

int main(){
    cin >> A >> B;

    if(A == B){
        cout << "Draw";
    }else if(A == 1){
        cout << "Alice";
    }else if(B == 1){
        cout << "Bob";
    }else if(A > B){
        cout << "Alice";
    }else{
        cout << "Bob";
    }
    }

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  vector<bool> visited(n, false);
  vll a(n);

  REP(i, n){
    cin >> a[i];
    a[i]--;
  }

  ll now = 0;
  ll cnt = 0;
  ll ans = -1;
  while(!visited[now]){
    visited[now] = true;
    now = a[now];
    cnt++;
    if(now == 1){
      ans = cnt;
      break;
    }
  }

  cout << ans << endl;
}


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

int main() {
	
	string s;
	int k;
	cin>>s>>k;
	
	int l = 0;
	int j = 0;
	while(s[j] == '1' and j < s.size())
	{
		j++;
		l++;
	}
	if(k <= l)
	{
		cout<<1;
	}
	else
	{
		cout<<s[j];
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(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 DEBUG(x) cout << #x << ": " << x << endl

ll calc_score(ll D, const vector<ll> &c, const vector<vector<ll>> &s, const vector<ll> &t) {
  vector<ll> last(26, -1);
  ll score = 0;
  REP(d, D) {
    ll i = t[d];
    score += s[d][i];
    last[i] = d;
    REP(j, 26) {
      score -= c[j] * (d - last[j]);
    }
  }
  return score;
}

ll area(ll D, ll d, const vector<ll> &t, ll target) {
  ll l = -1;
  for (int i = d - 1; i >= 0; i--) {
    if (t[i] == target) {
      l = i;
      break;
    }
  }
  ll r = D;
  FOR(i, d + 1, D) {
    if (t[i] == target) {
      r = i;
      break;
    }
  }
  ll x = r - d;
  ll y = d - l;
  return x * y;
}

ll calc_diff(ll D, ll pre, ll next, const vector<ll> &c, const vector<vector<ll>> &s, ll d, const vector<ll> &t) {
  ll diff = s[d][next] - s[d][pre];
  diff += c[next] * area(D, d, t, next);
  diff -= c[pre] * area(D, d, t, pre);
  return diff;
}

void solve(ll D, vector<ll> c, vector<vector<ll>> s) {
  vector<ll> t(D);
  REP(d, D) {
    ll m = LLONG_MIN;
    ll cur = 0;
    REP(i, c.size()) {
      t[d] = i;
      ll score = calc_score(d + 1, c, s, t);
      if (score > m) {
        m = score;
        cur = i;
      }
    }
    t[d] = cur;
  }
  REP(d, D) {
    cout << t[d] + 1 << "\n";
  }
}

int main() {
  ll D;
  scanf("%lld", &D);
  vector<ll> c(26);
  for (int i = 0; i < 26; i++) {
    scanf("%lld", &c[i]);
  }
  vector<vector<ll>> s(D, vector<ll>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%lld", &s[i][j]);
    }
  }
  solve(D, move(c), move(s));
  return 0;
}


Measured memory_bytes: 3784
#include <iostream>
using namespace std;
 
int S[100000];
 
int main(){
 
  int n, q;
  int min, max, mid;
  int tmp;
  int count=0;
 
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> S[i];
  }
 
  cin >> q;
  for(int i=0; i<q; i++){
    cin >> tmp;
    min = 0;
    max = n;
    while(min <= max){
      mid = (min + max) / 2;
      if(S[mid] == tmp){
    count+=1;
    break;
      }else if(S[mid] > tmp){
    max = mid - 1;
      }else{
    min = mid + 1;
      }
    }
//cout << S[mid] << ":" << tmp << "\n";
  }
 
  cout << count << "\n";
 
return 0;
 
}

Measured memory_bytes: 1552
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
ks = [LIST() for _ in range(M)]
p = LIST()

ans = 0

for i in range(1<<N):
	flg = True
	i = list("{:b}".format(i).zfill(N))
	#print(i)
	for j in range(M):
		cnt_sk = 0
		for k in range(ks[j][0]):
			#print(k, ks[j][k+1])
			#print(i[ks[j][k+1]-1] == "1")
			if i[ks[j][k+1]-1] == "1":
				cnt_sk += 1
		#print(cnt_sk)
		if cnt_sk%2 != p[j]:
			flg = False
	if flg:
		ans += 1

print(ans)



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


int main(){
  int N;
  cin>>N;
  vector<int64_t> vec(N+1); 
  vec.at(0)=2;
  vec.at(1)=1;
  if(N>1){
  for(int i=2;i<=N;i++){
    vec.at(i)=vec.at(i-1)+vec.at(i-2);  
  }
  }
  
  cout<<vec.at(N)<<endl;

}


Measured memory_bytes: 384
def calculate(n):
    mod = 1000000000 + 7

    result = pow(10, n, mod)

    # has 0 exists  9 not exists
    # 0 - 8
    s1 = pow(9, n, mod) - pow(8, n, mod)

    # has 9 exists 0 not exists
    # 1 - 9
    s2 = pow(9, n, mod) - pow(8, n, mod)

    # 9 not exists and 8 not exists
    # 1-8
    s3 = pow(8, n, mod)

    result = result - (s1 + s2 + s3)

    print(result % mod)


calculate(int(input()))


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

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

int main(void){
    int n; cin >> n;
    map<int,int> even,odd;
    
    for(int i=0; i<n; i++){
        int a; cin >> a;
        if(i%2==1) even[a]++;
        else odd[a]++;
    }

    int e1=0, e2=0, o1=0, o2=0;
    int eMode=0, oMode=0;

    for(auto itr=odd.begin(); itr!=odd.end(); ++itr){
        if(itr->second>=o1){
            oMode=itr->first;
            o1=itr->second;
        }
    }

    for(auto itr=odd.begin(); itr!=odd.end(); ++itr){
        if(itr->second>=o2 && itr->first!=oMode){
            o2=itr->second;
        }
    }

    for(auto itr=even.begin(); itr!=even.end(); ++itr){
        if(itr->second>=e1){
            eMode=itr->first;
            e1=itr->second;
        }
    }

    for(auto itr=even.begin(); itr!=even.end(); ++itr){
        if(itr->second>=e2 && itr->first!=eMode){
            e2=itr->second;
        }
    }

    if(eMode!=oMode){
        cout << n-o1-e1 << endl;
    }
    else{
        cout << min(n-o1-e2, n-o2-e1) << endl;
    }

}

Measured memory_bytes: 4992
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)

using namespace std;

typedef long long ll;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	vector<pair<int, int>> result;
	REP(i, n) {
		int tmp;
		scanf("%d", &tmp);
		result.push_back(make_pair(tmp, i));
	}
	sort(ALL(result));
	for(auto&& e : result) {
		printf("%d ", e.second + 1);
	}
	return 0;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vi x(n), y(n), a(n);
  rep(i, n) cin >> x[i] >> y[i];
  a[0] = 0;
  rep(i, n - 1) a[i + 1] = a[i] + 1;
  double sum = 0;
  do {
    double d = 0;
    rep(i, n - 1) {
      d += sqrt(pow(x[a[i]] - x[a[i + 1]], 2) + pow(y[a[i]] - y[a[i + 1]], 2));
    }
    sum += d;
  } while(next_permutation(all(a)));
  double fact = 1;
  rep(i, n) fact *= i + 1;
  double ans = sum / fact;
  printf("%.10f\n", ans);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100100
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

int n, x, y;
vector<int> ans;
void bfs(int s){
	queue<pair<int, int>> que; //(ノード, コスト) 
	que.push(make_pair(s, 0));
	vector<int> dp(n, INF);
	while(!que.empty()){
		pair<int, int> p = que.front(); que.pop();
		int pos = p.first;
		int cost = p.second;
		if(pos < 0 || n <= pos) continue;
		if(dp[pos] <= cost) continue;
		dp[pos] = cost;
		que.push(make_pair(pos-1, cost+1));
		que.push(make_pair(pos+1, cost+1));
		if(pos == x) que.push(make_pair(y, cost+1));
		if(pos == y) que.push(make_pair(x, cost+1));
	}
	rep(i, n){
		if(s < i){
			ans[dp[i]-1]++;
		}
	}
}

int main(void){
	cin >> n >> x >> y;
	x--; y--;
	ans.resize(n);
	rep(i, n-1){
		bfs(i);
	}
	rep(i, n-1){
		cout << ans[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
		int x,y;
		scanf("%d %d",&x,&y);
			while(1){
				if(x==0 && y==0) break;
				if(x>y){
						printf("%d %d\n",y,x);
						}
				else {
						printf("%d %d\n",x,y);
					}
				scanf("%d %d",&x,&y);
			}
		return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int64 n, m, s, t;
vector<PLL> G1[112345], G2[112345];
int64 d1[112345], d2[112345];

int main(void){
	cin >> n >> m >> s >> t; s--; t--;
	REP(i, 112345) d1[i] = d2[i] = INF_LL;
	REP(i, m){
		int64 u, v, a, b;
		cin >> u >> v >> a >> b; u--; v--;
		G1[u].push_back(PLL(a, v));
		G2[u].push_back(PLL(b, v));
		G1[v].push_back(PLL(a, u));
		G2[v].push_back(PLL(b, u));
	}
	
	auto dijkstra = [](vector<PLL> *G, int64 *d, int32 u){
		priority_queue<PLL,vector<PLL>,greater<PLL>> pq;
		pq.push(PLL(0, u));
		d[u] = 0;
		while(pq.size()){
			int64 dd, v;
			tie(dd, v) = pq.top(); pq.pop();
			if(dd > d[v]) continue;
			REP(i, G[v].size()){
				if(d[G[v][i].sc] > d[v]+G[v][i].fs){
					d[G[v][i].sc] = d[v]+G[v][i].fs;
					pq.push(PLL(d[G[v][i].sc], G[v][i].sc));
				}
			}
		}
	};
	dijkstra(G1, d1, s);
	dijkstra(G2, d2, t);
	priority_queue<PLL> pq;
	REP(i, n){
		pq.push(PLL(1e15-d1[i]-d2[i], i));
	}
	REP(i, n){
		while(pq.top().sc < i) pq.pop();
		cout << pq.top().fs << endl;
	}
}

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

int main(){
    int c[3][3];
    for(int i=0;i<3; i++){
        for(int j=0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    bool b = true;
    for(int i=0; i < 2; i++){  // i,j は左上のcの値
        for( int j=0; j<2; j++){
            for(int k=i+1; k<3;k++){  // k,l は右下のcの値
                for(int l=j+1; l<3; l++){
                    if( (c[i][j]+c[k][l]) != (c[i][l]+c[k][j]) ){
                        b = false;
                    }
                }
            }
        }
    }

    if(b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>
 size_t strlen(const char *s);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int N=100010;
const int P=1000000007;
int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;//a-b昇順
}
//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ
//	cout<<(n-2)*180<<endl;
//	string s="hoge";
//	cout<<ans<<endl;
//	int  n  ,a  ,b  ,c  ,d  ,e  ,f  ;
//	cin  >>n  >>a  >>b  >>c  >>d  >>e  >>f  ;

/*
	memset(b, '\0', sizeof(b));
初期化*/
/*
	len = strlen(s);
文字列長さ*/
/*
	string s;
	s.size()
*/
/*ソート
	qsort(b, 10, sizeof(int), compare_int);
*/
/*
	char s[N];
	strlen(s)
/*
	if(  <  )puts("YES");
	else puts("NO");
*/

int main(){
	long long int n, k,ans=0,a=1,b=1;
//	memset(b, '\0', sizeof(b));
	cin>>n>>k;
	b=n-k+1;
	printf("%lld\n",b);
	for(int i=2;i<=k;i++){
		a=mt(a,k-i+1,P);
		a=mt(a,modinv(i-1,P),P);
		b=mt(b,n-k-i+2,P);
		b=mt(b,modinv(i,P),P);
		printf("%lld\n",mt(a,b,P));
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,a[55],sum;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;++i) cin>>a[i];
	sort(a,a+n,greater<int>());
	for(int i=0;i<m;++i){
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline

def main():
    n, m = input_list()
    if n >= m:
        print(0)
        exit(0)
    x = list(sorted(input_list()))
    diffs = []
    for i in range(1, m):
        a = abs(x[i] - x[i-1])
        diffs.append((i, a))
    dd = list(sorted(diffs, key=lambda v: v[1], reverse=True))
    ans = 0
    for i, v in enumerate(dd):
        if i < n-1:
            continue
        ans += v[1]
    print(ans)
    # args = [d[0] for d in dd[:n-1]]
    # r = divide_list(x, args)
    # ans = 0
    # for xx in r:
    #     ans += max(xx) - min(xx)
    # print(ans)


def divide_list(l, args):
    result = []
    pre = 0
    for i, a in enumerate(args):
        if i != 0:
            pre = args[i-1]
        result.append(l[pre:a])
        if i == len(args) - 1:
            result.append(l[a:])
    return result

def divide_two(n):
    c = 0
    while True:
        if c >= 2:
            break
        if n % 2 != 0:
            break
        n //= 2
        c += 1
    return c

def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
  int N, Y;
  cin >> N >> Y;
  int man, gosen, sen;
  for (man = 0; man <= N; ++man) {
    for (gosen = 0; gosen <= N - man; ++gosen) {
      int sen = N - man - gosen;
      if (1000 * sen == Y - 10000 * man - 5000 * gosen) {
        cout << man << " " << gosen << " " << sen;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ans=0

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

for i in range(n):
	for j in range(n):
		if math.gcd(i+1,j+1)==1:
			ans+=n
			continue
		else:
			for k in range(n):
				ans+=gcd(i+1,j+1,k+1)
print(ans)

Measured memory_bytes: 9624
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,A;
    cin >> N;
    int ans = INF;
    for(int i = 0;i < N;i++){
        cin >> A;
        ans = min(ans,__builtin_popcount((~A) & (A-1)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define int long long
using namespace std;
const int N = 2e5 + 50;
const int mod = 1e9 + 7;
const int inf = 1e17;
int dx[] = {0, 1, -1, 0, -1, 1, 1, -1};
int dy[] = {1, 0, 0, -1, -1, 1, -1, 1};
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);	
	int n, m;
	cin >> m >> n;
	int arr[n];
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	sort(arr, arr + n);
	vector<int> v;
	int sum = 0;
	for(int i = 1; i < n; i++){
		v.push_back(arr[i] - arr[i - 1]);
		sum += (arr[i] - arr[i - 1]);
	}
	sort(v.rbegin(), v.rend());
	int sz = min((int)v.size(), m - 1);
	for(int i = 0; i < sz; i++){
		sum -= v[i];
	}
	cout << sum;
}

Measured memory_bytes: 2168
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[32];
	int i;

	scanf("%s", str);

	for (i = 0; i < strlen(str) / 2; i++){
		str[i] ^= str[strlen(str) - 1 - i];
		str[strlen(str) - 1 - i] ^= str[i];
		str[i] ^= str[strlen(str) - 1 - i];
	}

	printf("%s\n", str);

	return (0);
}

Measured memory_bytes: 520
"use strict";

function main(input) {
  input = input.trim().split("\n");
  if (input[0] == "1") {
    if (input[1] == "2") {
      console.log(3);
      return;
    } else {
      console.log(2);
      return;
    }
  } else if (input[0] == "2") {
    if (input[1] == "1") {
      console.log(3);
      return;
    } else {
      console.log(1);
      return;
    }
  } else {
    if (input[1] == "1") {
      console.log(2);
      return;
    } else {
      console.log(1);
      return;
    }
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


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

string s,t,c;
int a,b;

int main(){
	cin>>s>>t>>a>>b>>c;
	if(s==c) a--;
	if(t==c) b--;
	cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long arr[100005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	long long val = 1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	for(int i=0;i<n;i++)
	{
		long long tmp = arr[i];
		if(!tmp)
		{
			val = 0;
			break;
		}
		if(1000000000000000000/val<tmp)
		{
			val = -1;
			break;
		}
		val *= tmp;
	}
	cout<<val;
}

Measured memory_bytes: 4400
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int a[1005];

int main()
{
    NO_TLE
    int n;
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <bits/stdc++.h>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
ll N;
ll M;
int As[100000+10];
int Bs[100000+10];
vector<ll> ans;
int parent[100000+10];
int ufrank[100000+10];
ll size[100000+10];
int getRoot(int x) {
  return parent[x]==x ? x:parent[x]=getRoot(parent[x]);
}
void unite(int x,int y) {
  x=getRoot(x),y=getRoot(y);
  if (x==y)return;
  ll s=size[x]+size[y];
  if (ufrank[x]<ufrank[y]) {
    parent[x]=y;
  }else {
    parent[y]=x;
    if (ufrank[x]==ufrank[y]) ufrank[x]++;
  }
  size[parent[x]]=s;
}
int main() {
  cout << fixed << setprecision(15);
  cin >> N >> M;
  REP(i,M)
    cin >> As[i] >> Bs[i],As[i]--,Bs[i]--;
  REP(i,N)
    parent[i]=i,ufrank[i]=0,size[i]=1;

  ans.pb(N*(N-1)/2);
  for(int i=M-1;i>0;--i) {
    ll n=ans[ans.size()-1];
    if (getRoot(As[i])!=getRoot(Bs[i])) {
      n-=size[getRoot(As[i])]*size[getRoot(Bs[i])];
      unite(As[i],Bs[i]);
    }
    ans.pb(n);
  }
  FEACHR(it,ans)
    cout << *it << endl;
  return 0;
}


Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;
int main()
{
	long n,k,a;
	cin >> n;
	cin >> k;
	double aa = min(n, k);
	a =long(sqrt(aa));
	//vector<int> xn(a + 1);

	//for (int i = 0; i < n; i++) {
	//	cin >> a[i];
	//}
	long s=1;
	for (long i = 2; i < a + 1; i++) {
		long x=0, y=0;
		while (n % i == 0 || k % i==0) {
			if (n % i == 0) {
				x++;
				n = n / i;
			}
			if (k % i == 0) {
				y++;
				k = k / i;
			}
			}
		if (x > 0 && y > 0) {
			s++;
		}
	}

	if (k > 1 && n > 1) {
		if (k % n == 0 || n% k == 0) {
			s++;
		}
	}
	
	cout << s;

}

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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    long long B = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        B ^= A[i];
    }
    for (int i = 0; i < N; ++i) cout << (B^A[i]) << endl;
}

Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define tii tuple<int,int,int>
signed main(){
  int N,sum=0;
  cin>>N;
  vi B(N+1);
  rep(i,1,N+1){
    int X;
    cin>>X;
    sum+=X;
    B[i]=X;
    }
  int ans=0;
  sort(ALL(B));
  REP(i,0,N){
    if((sum-B[i])%10!=0){
      ans=sum-B[i];
      break;
      }
    }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int main()
{
    fio;
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll x;
        cin>>x;
        ll p=100;
        ll t=0;
        while(true)
        {
            ll a=p/100;
            p+=a;
            t++;
            if(p>=x)
            break;
        }
        cout<<t<<endl;
    }
}

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

using namespace std;
using ll = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    ll n = 0;
    cin >> n;
    ll x = 0;
    for(ll i = sqrt(n);i >= 1;i--){
        if(n % i == 0){
            x = i;
            break;
        }
    }
    ll y = n / x;
    cout << x - 1 + y - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 100005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);srand(time(NULL));
vector<ll> v1[N],v2[N];
struct DSU
{
    ll parent[N+1],connected[N+1];
    void intialize(int x)
    {
        for(ll i=1;i<=x;i++)
        {
            parent[i]=i;
            connected[i]=1;
        }
    }
    ll getparent(ll k)
    {
        while(k!=parent[k])
        {
            parent[k]=parent[parent[k]];
            k=parent[k];
        }
        return k;
    }
    ll getsize(ll k)
    {
        return connected[getparent(k)];
    }
    void unionn(ll u,ll v)
    {
        ll parent1=getparent(u),parent2=getparent(v);
        if(parent1==parent2)    return ;
        if(connected[parent1]>connected[parent2])  swap(parent1,parent2);
        connected[parent2]+=connected[parent1];
        connected[parent1]=0;
        parent[parent1]=parent[parent2];
    }
};
void solve()
{
    DSU dsu;
    dsu.intialize(N);	
    ll n,m,k;
    cin >> n >> m >> k;
    for(ll i=0;i<m;i++)
    {
    	ll x,y;
    	cin >> x >> y;
    	v1[x].pb(y);
    	v1[y].pb(x);
    	dsu.unionn(x,y);
    }
    for(ll i=0;i<k;i++)
    {
    	ll x,y;
    	cin >> x >> y;
    	v2[x].pb(y);
    	v2[y].pb(x);
    }
    for(ll i=1;i<=n;i++)
    {
    	ll ans = dsu.getsize(i);
    	ans--;
    	ans -= v1[i].size();
    	ll P = dsu.getparent(i);
    	for(auto X:v2[i])
    	{
    		ll p1 = dsu.getparent(X);
    		if(p1==P)  ans--;
    	}
    	cout<<ans<<" ";
    }

}

int32_t  main()
{
    FAST;
    ll t = 1;
    //  cin >> t;
    while(t--)
    {
    	solve();
    }
}


Measured memory_bytes: 14580
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    if(n - 2 * k >= -1){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

int main() {
   int n, k;
   cin >> n >> k ;
   vi a(n);
   rep(i, n) cin >> a.at(i);
   //二分探索
   int l = 0, r = 1e9;
   while(r-l > 1) {
       int x = (l+r)/2;
       auto f = [&](int x) {
           ll now = 0;
           //丸太を切る回数を求める
           rep(i, n) now += (a.at(i)-1)/x;
           return now <= k;
       };
       if (f(x)) r = x; else l = x;
   }
   cout << r << endl;
   return 0;
}

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

int n,W;
int weight[110],value[110];

int dp[110][10010];

int main(){
    cin>>n>>W;
    for(int i=0;i<n;i++) cin>>value[i]>>weight[i];
    for(int w=0;w<=W;w++) dp[0][w]=0;
    for(int i=0;i<n;i++){
        for(int w=0;w<=W;w++){
            if(w>=weight[i]) dp[i+1][w]=max(dp[i][w-weight[i]]+value[i],dp[i][w]);
            else dp[i+1][w]=dp[i][w];
        }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}


Measured memory_bytes: 7024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
//        long readhp = long.Parse(ReadLine());
        int number= int.Parse(ReadLine());
        string[] reader = ReadLine().Split(' ');
//        int monster = int.Parse(reader[0]);
//        int wazasu = int.Parse(reader[1]);
//        string[] readerhp = ReadLine().Split(' ');
//        long total = 0;
//        int leng = readerhp.Length;
        int readerleng = reader.Length;
        int[] readernum = new int[readerleng];
        for(int i=0;i<readerleng;i++){
            readernum[i] = int.Parse(reader[i]);
        }
        int min = readernum[0];
        int count = 0;
        for(int i=0;i<readerleng;i++){
            if(min >= readernum[i]){
                min = Min(min,readernum[i]);
                count++;
            }
        }
        WriteLine(count);


    }
}

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const double PI=3.14159265358979323846;
int main(){
    int N;  cin>>N;
    vector<int>A(N,0);
    vector<int>ans(N,0);
    for(int i=1;i<N;i++){
        cin>>A[i];
        ans[A[i]-1]+=1;
    }
    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>

#define INF 100000000
#define ll long long

using namespace std;
int n, a;
int x[10] = {};
int main() {
	int min = 0;
	int max = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		
		if (a > 3200) {
			x[8]++;
		}
		else {
			x[a / 400]++;
		}
	}

	if (x[8] == n) {
		cout << 1 << " " << n << endl;
		return 0;
	}

	for (int i = 0; i < 8; i++)
	{
		if (x[i] != 0) {
			min++;
		}
	}
	max = min;
	for (int i = 0; i < x[8]; i++)
	{
			max++;
	}

	printf("%d %d\n", min, max);
	return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int C1[50][50], C2[50][50], C3[50][50], C4[50][50];

long long GCD(long long a, long long b)
{
	for(;b;a%=b,swap(a,b));
	return a;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, z=0;
	string s;
	long long ans=0;
	cin>>N;
	for(int i=0;i<N;i++) {
		int d=1, m=1, u2=0, u5=0, d2=0, d5=0;
		long long u=0, g;
		cin>>s;
		for(auto c: s) {
			if(c=='.') {
				m=10;
				continue;
			}
			d*=m;
			u=u*10+c-'0';
		}
		g=GCD(u,d);
		u/=g; d/=g;
		for(;u%2==0;u/=2) u2++;
		for(;u%5==0;u/=5) u5++;
		for(;d%2==0;d/=2) d2++;
		for(;d%5==0;d/=5) d5++;
		if(d2 && d5) C4[d2][d5]++;
		else if(d2) C2[u5][d2]++;
		else if(d5) C1[u2][d5]++;
		else {
			z++;
			C3[u2][u5]++;
		}
	}
	ans=z*(z-1LL)/2;
	for(int a=0;a<50;a++) for(int b=0;b<50;b++) for(int c=0;c<50;c++) for(int d=0;d<50;d++) {
		if(a>=d && c>=b) ans+=1LL*C1[a][b]*C2[c][d];
		if(d>=b) ans+=1LL*C1[a][b]*C3[c][d];
		if(c>=b) ans+=1LL*C2[a][b]*C3[c][d];
		if(a>=c && b>=d) ans+=1LL*C3[a][b]*C4[c][d];
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3676
import java.util.*;
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner (System.in);
    int N = sc.nextInt();
    ArrayList<Long> list = new ArrayList<Long>();
    for (int i=0; i<N; i++) {
      long h = sc.nextLong();
      list.add(h);
    }
    int ans = 0;
    int[] array = new int [N];
    for (int i=N-2; 0 <= i; i--) {
      if (list.get(i) >= list.get(i+1)) {
        array[i] =  array[i+1] + 1; 
        ans = Math.max(ans,array[i]);
      } 
    }
    
    System.out.println(ans);

  }
}

Measured memory_bytes: 60272
a1,b1 = map(int, input().split())
a2,b2 = map(int, input().split())
a3,b3 = map(int, input().split())

count_1 = 0
count_2 = 0
count_3 = 0
count_4 = 0

if a1 == 1:
    count_1 += 1
if a1 == 2:
    count_2 += 1
if a1 == 3:
    count_3 += 1
if a1 == 4:
    count_4 += 1

if b1 == 1:
    count_1 += 1
if b1 == 2:
    count_2 += 1
if b1 == 3:
    count_3 += 1
if b1 == 4:
    count_4 += 1

if a2 == 1:
    count_1 += 1
if a2 == 2:
    count_2 += 1
if a2 == 3:
    count_3 += 1
if a2 == 4:
    count_4 += 1

if b2 == 1:
    count_1 += 1
if b2 == 2:
    count_2 += 1
if b2 == 3:
    count_3 += 1
if b2 == 4:
    count_4 += 1

if a3 == 1:
    count_1 += 1
if a3 == 2:
    count_2 += 1
if a3 == 3:
    count_3 += 1
if a3 == 4:
    count_4 += 1

if b3 == 1:
    count_1 += 1
if b3 == 2:
    count_2 += 1
if b3 == 3:
    count_3 += 1
if b3 == 4:
    count_4 += 1

if 1 <= count_1 and count_1 <=2 and 1 <= count_2 and count_2 <=2 and 1 <= count_3 and count_3 <=2 and 1 <= count_4 and count_4 <=2:
    print("YES") 
else:
    print("NO")

Measured memory_bytes: 3064
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import re

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

S = raw_input()
T = raw_input()

ans = 0

for i in range(3):
    if S[i] == T[i]:
        ans += 1

print ans

Measured memory_bytes: 2812
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

class combination
{
public:
  vector<int> fac, finv, inv;

  combination(int M)
  {
    fac = vector<int>(M, 1);
    finv = vector<int>(M, 1);
    inv = vector<int>(M, 1);

    for (int i = 2; i < M; i++)
    {
      fac.at(i) = fac.at(i - 1) * i % MOD;
      inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
      finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
  }

  int P(int N, int K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * finv.at(N - K) % MOD;
  }

  int C(int N, int K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
  }

  int H(int N, int K)
  {
    return C(N + K - 1, K);
  }
};

signed main()
{
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  combination com(H + W);
  
  int ans = 0;
  for (int i = 0; i < H - A; i++)
  {
    int tmp = com.C(B - 1 + i, i);
    tmp *= com.C(W - 1 - B + H - 1 - i, H - 1 - i);
    tmp %= MOD;
    
    ans += tmp;
    ans %= MOD;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
int main(){
    long long N;
    cin >> N;
    vector<long long> A(N), B(N);
    vector<P> vec(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if(N % 2 == 1){
        cout << B[N / 2] - A[N / 2] + 1 << endl;
    }
    else{
        int ind = (N - 1)/ 2;
        cout << (B[ind + 1] + B[ind]) - (A[ind + 1] + A[ind]) + 1 << endl;
    }
}

Measured memory_bytes: 9564
#include <stdio.h>

int main(void)
{
int a,b,c,n,m,i,count=0;

while(1){
scanf("%d %d",&a,&b);

i,n,m=0;
if(a==0&&b==0)break;
for(i=1;i<=a-2;i++)
{
	for(n=i+1;n<=a-1;n++)
	{
		for(m=n+1;m<=a;m++)
		{
			if(b==i+n+m)count++;

		}
	}
}

printf("%d\n",count);
count=0;
}
return 0;

}

Measured memory_bytes: 600