akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

const ll INF = 1LL << 60;

vi dp(100010,INF);
vi h(100100,0);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    rep(i,n) cin >> h[i];
    dp[0] = 0;
    rep(i,n){
        for(int j = 1;j <= k;j++){
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout << dp[n-1] << endl;
}

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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


int solve(int N, int T, int A, vi& H) {
    int diff_min = INT_MAX, diff_min_at = -1;
    T *= 1000;
    A *= 1000;
    rep(i, N) {
        int temp_i = T - 6 * H[i];
        int diff = abs(temp_i - A);
        if (diff < diff_min) {
            diff_min = diff;
            diff_min_at = 1+i;
        }
    }
    return diff_min_at;
}

int main() {
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    vi H(N);
    rep(i, N) cin >> H[i];
    cout << solve(N, T,A, H) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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


Measured memory_bytes: 256
n=int(input())
arr=[]
for _ in range(n):
  s,t=map(str,input().split())
  arr.append([s,int(t)])
x=input()
ans=0
flag=False
for i in range(n):
  if flag==True:
    ans+=arr[i][1]
  if arr[i][0]==x:
    flag=True
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<list>
#include<algorithm>

#define ll long long

using namespace std;

int main() {
	ll n, m;
	vector<ll> h,a,b;
	ll temp,t1,t2;
	vector<int> q(100000,1);
	ll cnt = 0;
	cin >> n >> m;
	for (ll nn = 0; nn < n;++nn) {
		cin >> temp;
		h.push_back(temp);
	}
	for (ll mm = 0; mm < m; ++mm) {
		cin >> t1 >> t2;
		//a.push_back(t1);
		//b.push_back(t2);
		if (h[t1 - 1] < h[t2 - 1]) q[t1 - 1] = 0;
		else if (h[t1 - 1] > h[t2 - 1]) q[t2 - 1] = 0;
		else { q[t1 - 1] = 0; q[t2 - 1] = 0;}
	}
	for (ll nn = 0; nn < n; ++nn) {
		cnt += q[nn];
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 4720
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n;
  cin >> n;
  long* a = new long[200000];
  long sum = 0;
  long* rui = new long[200000];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i==0) rui[i] = a[i];
    else rui[i] = rui[i-1] + a[i];
  }

  int lm = 0;
  int rm = 0;
  long cand = rui[n-1];
  for(int med=1;med<n-2;med++){
    long ls = rui[med];
    long ll,lr;
    for(int j=lm;j<med;j++){
      if(rui[j]>ls/2) {
        if(j==0){
          ll = rui[j];
          lr = rui[med]-rui[j];
          lm = j;
          break;
        }
        long lcl = rui[j];
        long lcr = rui[med]-rui[j-1];
        if(lcl<lcr){
          ll = lcl;
          lr = rui[med] - ll;
          lm = j;
        } else {
          ll = rui[j-1];
          lr = rui[med] - ll;
          lm = j-1;
        }
        break;
      }
      if(j==med-1){
          ll = rui[j];
          lr = rui[med]-rui[j];
          lm = j;
      }
    }
    long rs = rui[n-1] - rui[med];
    long rl,rr;
    for(int j=max(rm,med+1);j<n-1;j++){
      if(rui[j]-rui[med]>rs/2){
        if(j==max(rm,med+1)){
          rl = rui[j]-rui[med];
          rr = rui[n-1]-rui[j];
          rm = j;
          break;
        }
        long rcl = rui[j]-rui[med];
        long rcr = rui[n-1]-rui[j-1];
        if(rcl<rcr){
          rl = rui[j]-rui[med];
          rr = rui[n-1] - rui[j];
          rm = j;
        } else {
          rl = rui[j-1]-rui[med];
          rr = rui[n-1] - rui[j-1];
          rm = j-1;
        }
        break;
      }
      if(j==n-2){
          rl = rui[j]-rui[med];
          rr = rui[n-1]-rui[j];
          rm = j;
      }
    }
    long ma = max(max(lr,ll),max(rr,rl));
    long mi = min(min(lr,ll),min(rr,rl));
    //cout << ll << ","<< lr << ","<< rl << ","<< rr << endl;
    cand = min(cand,ma-mi);
  }
  cout << cand << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
int n,k,pos[N],a[N];
const int INF=0x3f3f3f3f;
struct SegT{
    int t[N<<2];
    void build(int x,int l,int r){
        int mid=(l+r)>>1;
        t[x]=INF;if(l==r)return ;
        build(x<<1,l,mid);build(x<<1|1,mid+1,r);
    }
    void chg(int x,int l,int r,int pos,int sum){
        int mid=(l+r)>>1;
        t[x]=min(t[x],sum);
        if(l==r)return;
        if(pos>mid)chg(x<<1|1,mid+1,r,pos,sum);
        else chg(x<<1,l,mid,pos,sum);
    }
    int qry(int x,int l,int r,int ql,int qr){
        if(ql>qr)return INF;
        int mid=(l+r)>>1,ans=INF;
        if(ql<=l&&qr>=r)return t[x];
        if(ql<=mid)ans=min(ans,qry(x<<1,l,mid,ql,qr));
        if(qr>mid)ans=min(ans,qry(x<<1|1,mid+1,r,ql,qr));
        return ans;
    }
}T;
int hed[N],to[N*3],nxt[N*3],cnt,d[N];
inline void adde(int u,int v){swap(u,v);++cnt;to[cnt]=v,nxt[cnt]=hed[u];hed[u]=cnt;d[v]++;}
priority_queue<int>Q;
int ans[N],top;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        pos[a[i]]=i;
    }
    T.build(1,1,n);
    for(int i=n;i;i--){
        int p=pos[i];
        int R=T.qry(1,1,n,p+1,min(n,p+k-1));
        int L=T.qry(1,1,n,max(1,p-k+1),p-1);
        if(R<=n)adde(pos[i],pos[R]);
        if(L<=n)adde(pos[i],pos[L]);
        T.chg(1,1,n,pos[i],i);
    }
    for(int i=1;i<=n;i++)if(!d[i])Q.push(i);
    int top=0;
    while(!Q.empty()){
        int u=Q.top();Q.pop();
        ans[u]=++top;
        for(int i=hed[u];i;i=nxt[i]){
            int v=to[i];d[v]--;
            if(!d[v])Q.push(v);
        }
    }
    for(int i=1;i<=n;i++)printf("%d\n",n+1-ans[i]);
}


Measured memory_bytes: 31352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n;
  cin>>n;
  int a,b;
  cin>>a>>b;
  bool ex=false;
  for(int i=a;i<=b;i++)
    if(i%n==0) ex=true;
  if(ex) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}

Measured memory_bytes: 3588
#include<stdio.h>
int main(){
  char s[1001];
  int i;
  scanf("%s",s);
  for(i=0;s[i];i++){
    s[i]-=3;
    if(s[i]<'A')s[i]+=26;
    printf("%c",s[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};


int main(){
    int n;
    string x;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i,n) cin >> s[i] >> t[i];
    cin >> x;
    int begin = 0;
    int ans = 0;
    rep(i,n){
        if (begin){
            ans+= t[i];
        }
        if (s[i] == x){
            begin = 1;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();

        if(line.equals("a")||
        line.equals("b")||
        line.equals("c")||
        line.equals("d")||
        line.equals("e")||
        line.equals("f")||
        line.equals("g")||
        line.equals("h")||
        line.equals("i")||
        line.equals("j")||
        line.equals("k")||
        line.equals("l")||
        line.equals("m")||
        line.equals("n")||
        line.equals("o")||
        line.equals("p")||
        line.equals("q")||
        line.equals("r")||
        line.equals("s")||
        line.equals("t")||
        line.equals("u")||
        line.equals("v")||
        line.equals("w")||
        line.equals("x")||
        line.equals("y")||
        line.equals("z")){
          System.out.println("a");
        }else{
          System.out.println("A");
        }
      
    }
}



Measured memory_bytes: 35568
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	int ma=0,sum=0;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		sum+=a;
		ma=max(ma,a);
	}
	cout<<sum-ma/2<<endl;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

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;
}

int main() {
	ll a[3], m[3], p[3];
	
	while (true) {
		REP(i, 3) scanf("%lld %lld", &a[i], &m[i]);
		
		bool f = true;
		REP(i, 3) if (a[i] != 0 || m[i] != 0) f = false;
		if (f) break;
		
		ll mem[3];
		REP(i, 3) {
			ll cnt = 0;
			p[i] = 1;
			while (true) {
				p[i] = a[i] * p[i] % m[i];
				cnt++;
				if (p[i] == 1) break;
			}
			mem[i] = cnt;
		}
		
		
		
		cout << lcm(lcm(mem[0], mem[1]), mem[2]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  
  int n, x; cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    x -= a[i];
  }
  sort(ALL(a));
  int ans = n;
  while (1) {
    if (x >= a[0]) {
      ans++;
      x -= a[0];
    } else {
      break;
    }
  }
  
  cout << ans << endl;

  return 0;
}


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

int N, X, m;
int min_m = 1000, total = 0;

main()
{
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        cin >> m;
        total += 1;
        X -= m;
        if (m < min_m) {
            min_m = m;
        }
    }
    total += X / min_m;
    cout << total << endl;
}

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

int main() {
    vector<int> c(3);
    for (int i = 0; i < 3; i++){
        cin >> c[i];
    }
    int ans = 0;
    int s_A = c[0], s_B = c[1], s_C = c[2];
    vector<int> s = c;
    for (int i = 0; ; i++){
        if(c[0]%2 != 0 || c[1]%2 != 0 || c[2]%2 != 0){
            break;
        }

        s[0] = c[1]/2 + c[2]/2;
        s[1] = c[0]/2 + c[2]/2;
        s[2] = c[0]/2 + c[1]/2;
        ans ++;

        c = s;

        if(c[0] == s_A && c[1] == s_B && c[2] == s_C){
            ans = -1;
            break;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		System.out.println((Math.abs(A-C) <= D) || (Math.abs(A-B) <= D && Math.abs(B-C) <= D) ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
def main():
    n = int(input())
    s = input()
    dp = [[0 for i in range(n+1)] for j in range(n+1)]
    
    from itertools import product
    for i,j in product(reversed(range(n)),repeat=2):###for を置き換え
        if j>i:
            continue
        if s[i]!=s[j]:
            dp[i][j] = 0 #continueではない	    
        else:
           	dp[i][j] = dp[i+1][j+1] +1
           	"""
            これでは結局ループしている
            cnt = 0
            for k in range(min(n-j,j-i)):
                if s[i+k] ==s[j+k]:
                    cnt += 1
                else:
                    break
            dp[i][j] = cnt
            """
    mx = 0
    #print(dp)
    for i in range(n):
      	for j in range(i):###
        	mx = max(mx,min(i-j,dp[i][j]))###i-jで抑える
    print(mx)

if __name__ =='__main__':main()
            
            
            


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

#define x first
#define y second

pair<int, int> su[100001];
char ch[100001];

int dap[2001];

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        int aa, bb;
        char cc;
        scanf("%d %d %c", &aa, &bb, &cc);
        su[i] = {aa, bb};
        ch[i] = cc;
    }
    int ans = 0;
    for(int i=0;i>-2*m;i--){
        for(int j=0;j<2*m;j++) dap[j] = 0;
        for(int j=0;j<n;j++){
            int yy = (su[j].y-i);
            yy %= (2 * m);
            bool b1 = (yy < m);
            bool b2 = (ch[j] == 'B');
            dap[((b1 ^ b2) * m + su[j].x) % (2 * m)]++;
        }
        int cnt = 0;
        for(int j=0;j<m;j++){
            cnt += dap[j];
        }
        for(int j=0;j<m;j++){
            ans = max(ans, max(cnt, n-cnt));
            cnt -= dap[j];
            cnt += dap[j+m];
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
	static void Main(string[] args) {
		new Calc().calc();
	}
	public class Calc {
		public Calc() { }
		public void calc() {
			int N = ReadLine<int>();
			var A = ReadLine<int>(' ').OrderBy(_ => _).ToList();
			var B = A.Distinct().Count();
			if (B%2==0) {
				(B - 1).WriteLine();
			} else {
				B.WriteLine();
			}
			return;
		}
	}

	public static T ReadLine<T>() {
		return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
	}

	public static T[] ReadLine<T>(params char[] separators) {
		return Console.ReadLine()
			.Split(separators)
			.Select(_ => (T)Convert.ChangeType(_, typeof(T)))
			.ToArray();
	}

	public static List<T> ReadLines<T>(int readCount) {
		List<T> rt = new List<T>();
		for (int i = 0; i < readCount; i++) {
			rt.Add(ReadLine<T>());
		}
		return rt;
	}
}
public static class Utils {
	public static string Docking<T>(this IEnumerable<T> s, int sequenceRange, Func<T, string> filter = null) {
		string str = "";
		int c = 0;
		foreach (var item in s) {
			str += filter == null ? item.ToString() : filter(item);
			c++;
			if (c == sequenceRange) break;
		}
		return str;
	}

	public static string Docking<T>(this IEnumerable<T> s, Func<T, string> filter = null) {
		return s.Docking(s.Count(), filter);
	}

	public static string RangeDocking<T>(this IEnumerable<T> s, int start, int end, Func<T, string> filter = null) {
		string str = "";
		end = end < s.Count() ? end : s.Count();
		var items = s.ToArray();
		for (int i = start; i < end; i++) {
			str += filter == null ? items[i].ToString() : filter(items[i]);
		}
		return str;
	}
	public static int IntParse(this string n) {
		return int.Parse(n);
	}
	public static void WriteLine<T>(this IEnumerable<T> list) {
		foreach (var item in list) {
			item.WriteLine();
		}
	}
	public static void WriteLine(this object obj) {
		Console.WriteLine(obj);
	}
	public static void AddTo<T>(this T obj,List<T> list) {
		list.Add(obj);
	}
}

Measured memory_bytes: 30556
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n;
    cin >> n;
    vector<int> f(n+1, 0);
    for(int x=1;x*x<=n;x++){
      for (int y = 1; y * y <= n; y++){
          for(int z = 1; z*z<=n;z++){
              int res = x*x + y*y + z*z + x*y + y*z + z*x;
              if(res<=n){
                  f[res]++;
              }
          }
      }
    }
    rep2(i, 1, n+1){
        cout << f[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
int a[200001];
int main()
{
	int n,y;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a,a+n+1);
	for(int i=1;i<n;i++)
		if(a[i]==a[i+1])
		{
			cout<<"NO";
			return 0;
		}
	cout<<"YES";
} 

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll=long long;
using namespace std;
const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
int main()
{
    ll a,b;
    cin>>a>>b;
    ll k=GCD(a,b);
   // vector<ll> vec(1e6,0);
    int c=0;
   // cout<<k<<endl;
    for(int i=2;i<=sqrt(k);i++){
        if(k%i==0){
            c++;
          //  cout<<i<<endl;
       //     vec[i]=1;
            while(1){
                k/=i;
                if(k%i!=0){
                    break;
                }
            }
        }
      //  cout<<k<<endl;
      //  cout<<endl;
        if(k==1){
            break;
        }
        
    }
    if(k==1){
        cout<<c+1<<endl;
    }else{
        cout<<c+2<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int ans;
  rep(i, 5){
    int x;
    cin >> x;
    if(x == 0) ans = i+1;  
  }


  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  int n,i,j;
  char s[1003];
  scanf("%d",&n);
  if(n==0)return 0;
  for(i=0;i<=n;i++){
    fgets(s,1002,stdin);
    for(j=0;s[j]!=0;){
        if(s[j++]=='H'){
	  /*if(j==1||((!('a'<=s[j-2]&&s[j-2]<='z'))
		&&(!('A'<=s[j-2]&&s[j-2]<='Z'))
		&&(!('0'<=s[j-2]&&s[j-2]<='9')))){*/
	  if(s[j]=='o'){j++;
	    if(s[j]=='s'){j++;
	      if(s[j]=='h'){j++;
		if(s[j]=='i'){j++;
		  if(s[j]=='n'){j++;
		    if(s[j]=='o'){j++;
	  /*if(!('a'<=s[j]&&s[j]<='z')){
        if(!('A'<=s[j]&&s[j]<='Z')){
	if(!('0'<=s[j]&&s[j]<='9')){*/
	  s[j-1]='a';
	}
	}}}}}}//}}}}
    }
    if(i!=0)printf("%s",s);
  }
  return 0;
}

Measured memory_bytes: 600
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-5 20:21:16
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, X;
int m[110];

int main()
{
  cin >> N >> X;
  for (auto i = 0; i < N; i++)
  {
    cin >> m[i];
  }
  X -= accumulate(m, m + N, 0);
  int ans = N;
  int mini = *min_element(m, m + N);
  ans += X / mini;
  cout << ans << endl;
}

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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

#define int ll
#define pb(x) push_back(x)
#define INF (int)1e17
#define PI 3.14159265358979323846
 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};


void solve(){
	int ans = 0;
	string s; cin >> s;
	int n=s.length();
	For(i,n){
		if(s[i]=='R'){
			int j=i;
			while(s[j]=='R')j++;
			ans = max(ans,j-i);
			i=j-1;
		}
	}
	cout << ans <<"\n";
}

int32_t main(){ 
	ios_base:: sync_with_stdio(false); 
	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
}

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

int main() {
    int n,i,j;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    int sum=0;
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            sum+=a[i]*a[j];
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3592
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

cnt = 0
flg = False

for i in range(n):
    a, b = map(int, input().split())
    if a==b:
        cnt += 1
    else:
        cnt =0

    if cnt>=3:
        flg = True

if flg:
    print('Yes')
else:
    print('No')

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

using namespace std;

int main()
{

    string s,t;
    cin >> s >> t;

    if(s == t)
    {
        cout << "Yes" << endl;

    } else
    {
        int n = 100;
        while(n--)
        {
            char tmp = s[s.length()-1];
            for(int i = s.length()-1 ; i > 0; --i)
            {
                s[i] = s[i-1];
            }
            s[0] = tmp;
            if(s == t)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }

    return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var ans = 700;

            for (var i = 0; i < 3; i++) if (S.Substring(i, 1) == "o") ans += 100;

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <numeric>
#include <map>
#include <cstring>
using namespace std;

void AddScore(map<long long, vector<long long>>& C, long long* S, long long i, bool* visited)
{
    if (C[i].size() == 0) {
        return;
    }
    auto r = C[i];
    auto s = S[i - 1];
    visited[i] = true;
    for (auto j : r) {
        if (visited[j]) {
            continue;
        }
        S[j - 1] += s;
        AddScore(C, S, j, visited);
    }
}

int main()
{
    long long N, Q;
    cin >> N;
    cin >> Q;

    map<long long, vector<long long>> C;
    for (long long i = 0; i < N - 1; i++) {
        long long a, b;
        cin >> a;
        cin >> b;
        C[a].push_back(b);
        C[b].push_back(a);
    }

    long long S[200001];
    memset(S, 0, sizeof(S));
    for (long long i = 0; i < Q; i++) {
        long long p, x;
        cin >> p;
        cin >> x;
        S[p - 1] += x;
    }

    bool visited[200001];
    memset(visited, 0, sizeof(visited));

    AddScore(C, S, 1, visited);

    for (long long i = 0; i < N; ++i) {
        cout << S[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 57216
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll n,p;
string s;
ll get(ll i){
    return (s[n-1-i]-'0');
}
Vi table;
Vi pp;
void set_ta(){//
    table.resize(s.size()+1); rep(i,table.size())table[i]=0;
    pp.resize(p+1); rep(i,pp.size())pp[i]=0;
    table[0]=0; pp[0]=1;
    ll tens=1;
    rep(i,s.size()){
        tens *= 10; tens %= p;
        table[i+1] = (table[i] + tens*(get(i)%p ) )%p;
        //cout<<10*table[i]<<" "<<get(i)<<" "<<10*table[i] + get(i)<<" "<<i<<endl;
        pp[(table[i+1])%p]++;
    }
}

ll sum(ll l,ll r){//return [l,r)
    return (table[r] + p -table[l])%p;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>p>>s;
   // rep(i,s.size())princ(s[i]);
   // print("");
    set_ta();
    ll ans = 0;
    if(p==2 || p==5){
        rep(i,n){
            if(get(i)%p ==0)ans += n-i;
        }
        print(ans);
        return 0;
    }
    rep(i,pp.size()){
        //princ("i: ");princ(i);princ(" , ");print(pp[i]);
        if(pp[i]>=2){
            ans += pp[i]*(pp[i]-1)/2;
        }
    }
    
    print(ans);
    return 0;
}

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

int main(){
	string s;
  	cin>>s;
  	if(s[0]=='R'){
    	if(s[1]=='R'){
        	if(s[2]=='R'){
            	cout<<'3';
              	return 0;
            } else {
            	cout<<'2';
              	return 0;
            }
        } else {
			cout<<'1';
          	return 0;
        }
    } else {
    	if(s[1]=='R'){
        	if(s[2]=='R'){
            	cout<<'2';
              	return 0;
            } else {
            	cout<<'1';
              	return 0;
            }
        } else {
        	if(s[2]=='R'){
            	cout<<'1';
              	return 0;
            } else {
            	cout<<'0';
              	return 0;
            }
        }
    }
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int counter=0;
  
  for ( int i=0; i<3; i++) {
    
    if ( S.at(i) == T.at(i)) {
      counter++;
    }
  }
  cout << counter << endl;
}

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

const int N = 1e5L + 10;
vector<int> adj[N];
int dp[N];

int dfs(int u)
{
  if(dp[u] != -1)
  {
    return dp[u];
  }
  for(auto x : adj[u])
  {
    dfs(x);
    dp[u] = max(dp[u], dp[x]);
  }
  return ++dp[u];
}

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  memset(dp, -1, sizeof dp);
  for(int i = 0; i < m; i++)
  {
    int x, y;
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
  }
  // now call dfs for all the connected components
  // and find out the length of the largest path
  int sol = 0;
  for(int i = 1; i <= n; i++)
  {
    int temp = 0;
    if(dp[i] != -1)
      temp = dp[i];
    else
      temp = dfs(i);
    sol = max(sol, temp);  
  }
  printf("%d", sol);
  
  return 0;
}


Measured memory_bytes: 8192
#[allow(unused_imports)]
use std::cmp::{min,max};
use std::collections::BTreeMap;

fn main() {
    let mut tree = BTreeMap::new();
    for &k in [1,-1].iter() {
        let n = read_i64();
        for _i in 0..n {
            let ss = read_line();
            if tree.contains_key(&ss) {
                if let Some(x) = tree.get_mut(&ss) {
                    *x += k;
                }
            }
            else {
                tree.insert(ss,k);
            }
        }
    }
    let res = tree.iter().max_by(|tx,ty| (tx.1).cmp(ty.1)).unwrap().1;
    println!("{}", max(&0,res));
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    let mut ret :i64 = 0;
    for c in ss.chars() {
        if ! ('0' <= c && c <= '9') { break; }
        let t = c.to_digit(10).unwrap() as i64;
        ret = ret * 10 + t;
    }
    return ret;
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let ss = read_line();
    let mut res = Vec::new();
    let mut edited = false;
    let mut x:i64 = 0;
    for c in ss.chars() {
        if !('0' <= c && c <= '9') {
            if edited {
                edited = false;
                res.push(x);
                x = 0;
            }
        }
        else {
            let t = c.to_digit(10).unwrap() as i64;
            x = x * 10 + t;
            edited = true;
        }
    }
    if edited {
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 4352
import math

class Dice():
    top   = 0 #上
    left  = 0 #左
    right = 0 #右
    front = 0 #前面
    back  = 0 #後面
    below = 0 #真下

    DEBUG_MODE = False
    def __init__(self,lst,dbg = False):
        if len(lst) == 6:
            self.top   = lst[0]
            self.front = lst[1]
            self.right = lst[2]
            self.left  = lst[3]
            self.back  = lst[4]
            self.below = lst[5]

        if dbg == True:
            self.DEBUG_MODE = True
        else:
            self.DEBUG_MODE = False
    
    def rotate(self,string):
        
        for ch in string:
            if   ch == 'W':
                self.left,self.top,self.right,self.below = self.top,self.right,self.below,self.left

            elif ch == 'E':
                self.left,self.top,self.right,self.below = self.below,self.left,self.top,self.right

            elif ch == 'S':
                self.top,self.back,self.below,self.front = self.back,self.below,self.front,self.top

            elif ch == 'N':
                self.top,self.back,self.below,self.front = self.front,self.top,self.back,self.below
            
            # デバッグモードなら全部の値をモニタする
            if self.DEBUG_MODE:
                self.dbg_PRINT_ALL_VALUE()

    def front_and_top_to_right(self,top,front):

        for i in range(4):
            for j in range(4):
                if self.top == top and self.front == front:
                    return self.right
                self.rotate("W")
            self.rotate("S")
        
        self.rotate("NES") #ヨコ回転
        
        for i in range(2):
            for j in range(4):
                if self.top == top and self.front == front:
                    return self.right
                self.rotate("W")
            self.rotate("SS")
        
        return None


        
    def get_topvalue(self):
        return self.top
    
    def dbg_PRINT_ALL_VALUE(self):
        print(f"        bk:{self.back:04} ")
        print(f"le:{self.left:04} tp:{self.top:04} ri:{self.right:04} be:{self.below:04}")
        print(f"        fr:{self.front:04} ")

lst = list(map(int,input().split()))
#lst = [1,2,3,4,5,6]
rep = int(input())
for i in range(rep):
    dice = Dice(lst)
    top,front = list(map(int,input().split()))
    print(dice.front_and_top_to_right(top,front))


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

int main()
{
  int r, g, ans=0;
  cin >> r >> g;
  cout << r + (g - r) * 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    h = min(h, 2 * q);
    s = min(s, 2 * h);
    // cout << s << ' ' << d << endl;
    // cout << n / 2 * d + (n % 2) * s << endl;
    cout << min(n * s, n / 2 * d + (n % 2) * s) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
        int K = fs.nextInt();
        int N = fs.nextInt();
        List<Integer> list = new ArrayList<>();
        long max = 0;

        for(int i=0; i<N; i++){
            int dis = fs.nextInt();
            list.add(dis);
        }

        if(list.contains(0)){
            max = K-list.get(N-1);
        }else{
            max = K-list.get(N-1)+list.get(0);
        }

        for(int i=1; i<N; i++){
            long distance = list.get(i)-list.get(i-1);
            if(distance>max){
                max = distance;
            }
        }
        
		System.out.println(K-max);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

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

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

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

	}
}


Measured memory_bytes: 47056
eval"N,*A="+`dd`.split*?,
x=[h=(Hash.new 0),h.dup]
A.map{|a|x[$.^=1][a]-=1}
((a,b),(c,d)),((e,f),(g,h))=x.map{|a|a.sort_by &:last}
p N.+a!=e ?b+f:[b+=h||0,f+=d||0].min

Measured memory_bytes: 33216
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define mod 			1000000007
#define siz 			105
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
	ll n,i,j,w,flag = 1,v = 0;
	cin>>n>>w;
	ll weights[n],values[n];
	
	for(i = 0;i<n;i++)	cin>>weights[i]>>values[i],
	v+=values[i];
	
	ll dp[2][v+1];
	for(i = 0;i<=1;i++)
	for(j = 0;j<=v;j++)
	dp[i][j] = INT_MAX;
	
	dp[0][0] = 0;
	
	for(i = 1;i<=n;i++)
	{
		for(j = 0;j<=v;j++)
		{
			dp[flag][j] = dp[flag^1][j];
			
			if(j >= values[i-1])
			dp[flag][j] = min(dp[flag][j],dp[flag^1][j-values[i-1]]+weights[i-1]);
			
//			cerr<<dp[i][j]<<" ";
			
		}
//		cerr<<endl;
		
		flag ^= 1;
		
	}
	
	for(i = v;i>=0;i--)
	{
		if(dp[flag^1][i] <= w)
		{
//			cerr<<dp[n][i]<<" -> ";
			cout<<i<<endl;
			break;
		}
	}
	
	
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll N;
ll A[105];
bool U[105];

string solve()
{
    sort(A, A + N);
    memset(U, 0, sizeof(U));
    vector<pll> v;
    v.push_back(pll(A[N - 1], 0));
    U[N - 1] = true;
    if (A[N - 1] != A[N - 2])
        return "Impossible";
    while (true)
    {
        bool e = false;
        REP(i, N)
        {
            if (U[i])
                continue;
            ll a = A[i];
            REP(j, v.size())
            {
                ll f = v[j].first;
                ll s = v[j].second;
                ll b = std::max(f - 1, s + 1);
                if (a != b)
                    continue;
                if ((f - 1 <= s + 1 && f > s) || (f - 1 >= s + 1))
                {
                    if (j != v.size() - 1)
                        continue;
                }
                e = true;
                v.push_back(pll(a, s + 1));
                U[i] = true;
                break;
            }
            if (e)
                break;
        }
        if (!e)
            break;
    }

    REP(i, N)
    {
        if (!U[i])
            return "Impossible";
    }
    return "Possible";
}

int main()
{
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
from decimal import Decimal
 
def solve():
	n = int(input())
 
	sum = Decimal("0")
	for i in range(n):
		amount, type = input().split()
		if type == "JPY":
			sum += Decimal(amount)
		else:
			sum += Decimal(amount)*Decimal("380000.0")
	return sum
  
print(solve())

Measured memory_bytes: 5332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << c - (d-b) << " " <<d - (a-c) << " "<<c - (d-b) - (c-a)<< " "<<d - (a-c) - (d-b)<<endl;;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int x[100002], y[100002];
    vector<int> vx[100002], vy[100002];
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        vx[x[i]].push_back(i);
        vy[y[i]].push_back(i);
    }
    ll ans = 0;
    bool looked[100002];
    fill(looked, looked + n, false);
    queue<int> que;
    for(int i = 0; i < n; i++){
        if((int)vx[x[i]].size() >= 2 && (int)vy[y[i]].size() >= 2 && !looked[i]){
            set<int> stb;
            set<int> sts;
            que.push(i);
            looked[i] = true;
            while(que.size()){
                int now = que.front();
                que.pop();
                stb.insert(y[now]);
                sts.insert(x[now]);
                ans--;
                for(int next : vx[x[now]]){
                    if(!looked[next]){
                        looked[next] = true;
                        que.push(next);
                    }
                }
                for(int next : vy[y[now]]){
                    if(!looked[next]){
                        looked[next] = true;
                        que.push(next);
                    }
                }
            }
            ll ctb = stb.size();
            ll cts = sts.size();
            ans += ctb * cts;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13696
n=int(input())
cnt=0
A,B=[],[]
for i in range(n):
  a,b=list(map(int,input().split()))
  A.append(a)
  B.append(b)

for i in range(n)[::-1]:
  if (A[i]+cnt)%B[i]==0:
    continue
  else:
    cnt+=(B[i]*((A[i]+cnt)//B[i]+1)-(A[i]+cnt))
print(cnt)


Measured memory_bytes: 11064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    char a; cin >> a;
    if ((a >= 'A') && (a <= 'Z')) {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
}

Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;
use std::cmp::max;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    println!("{}", max(max(a+b, a-b), a*b));

}


Measured memory_bytes: 2136
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

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

	vector<ll> num(N+1, 1);
	ll ans = 1;
	for (int i = 2; i <= N; ++i)
	{
		if (num[i] == 1)
		{
			++num[i];
			for (int j = i * 2; j <= N; j += i)
			{
				int H = j;
				int b = 1;
				while (true)
				{
					if (H % i != 0) break;
					++b;
					H /= i;
				}
				num[j] *= b;
			}
		}

		ans += i * num[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 81396
#include<iostream>
using namespace std;
int main(){

	int N,A,B,C,D,s,c,q,w;
	cin>>N>>A>>B>>C>>D;
		s=N/A;
		if(N%A>0){s=s+1;}
		c=N/C;
		if(N%C>0){c=c+1;}
		q=s*B;
		w=c*D;
		if(q<w){cout<<q<<endl;}
		else{cout<<w<<endl;}

	return 0;
}


Measured memory_bytes: 3092