akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int go_imp(int from, int to, vector<vector<bool>> &cap, vector<vector<bool>> &flow, vector<bool> &used){
    if(used[from]) return 0;
    used[from] = true;
    if(from == to) return 1;
    int n = cap.size();
    for(int i=0; i<n; i++){
        if(cap[from][i] and !flow[from][i]){
            if(go_imp(i, to, cap, flow, used)){
                if(flow[i][from]){
                    flow[i][from] = false;
                }else{
                    flow[from][i] = true;
                }
                return 1;
            }
        }
    }
    return 0;
}
int go(int from, int to, vector<vector<bool>> &cap, vector<vector<bool>> &flow){
    vector<bool> used(cap.size(), false);
    return go_imp(from, to, cap, flow, used);
}

int main(){
    int n,m,q;
    cin >> n >> m >> q;
    vector<vector<bool>> cap(n, vector<bool>(n, false));
    vector<vector<bool>> flow(n, vector<bool>(n, false));
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        cap[a][b] = cap[b][a] = true;
    }
    int total = 0;
    while(go(0, n-1, cap, flow)) total++;
    for(int i=0; i<q; i++){
        int s,a,b;
        cin >> s >> a >> b;
        a--; b--;
        if(s == 1){
            cap[a][b] = cap[b][a] = true;
            total += go(0, n-1, cap, flow);
        }else{
            cap[a][b] = cap[b][a] = false;
            if(flow[b][a]){
                swap(a, b);
            }
            if(flow[a][b]){
                flow[a][b] = false;
                if(!go(a, b, cap, flow)){
                    go(n-1, b, cap, flow);
                    go(a, 0, cap, flow);
                    total--;
                    total += go(0, n-1, cap, flow);
                }
            }
        }
        cout << total << endl;
    }
    return 0;
}


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

using namespace std;

long long dp[20001];

int main() {
    int h, n;
    int a[1000];
    int b[1000];
    int ans = 0;

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

    //init

    dp[0] = 0;
    for (int i = 1; i <= h; i++) {
        dp[i] = 1e9;
        for (int j = 1; j <= n; j++) { 
            dp[i] = min(dp[i], dp[max(0, i - a[j])] + b[j]);
        }
    }
    /*
    for (int i = 0; i <= h+100; i++) {
        cout << i << " " << dp[i] << "\n"; 
    }
    cout << "\n"; 
    */

    ans = dp[h];

    cout << ans << "\n"; 
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n, ans=0;
	cin >> n;
	int a[n+1];
	for(int i=1;i<=n;i++)cin >>a[i];
	for(int i=1;i<=n;i++)
	{
		ans+=a[i]-1;
	}
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	var o string
	for i, r := range s {
		if i == 0 {
			o += string(r)
		}
		if i == len(s)-1 {
			o += strconv.Itoa(len(s) - 2)
			o += string(r)
		}
	}
	fmt.Println(o)
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<cctype>
#include <fstream>
#include <time.h>
#include <iterator>





#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define fil(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

int X[11][11], N, D;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> D;
	REP(i, N) {
		REP(j, D) {
			cin >> X[i][j];
		}
	}
	int ans = 0;
	REP(i, N-1) {
		FOR(j, i + 1, N) {
			int res = 0;
			REP(k, D) {
				res += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
			}
			/*pe(i)pe(j)print(res);
			print(sqrt(res));*/
			if ((int)sqrt(res)*(int)sqrt(res) == res)ans++;
		}
	}
	print(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
using namespace std;
 
int main(){

  int a, b, x, y;
  cin >> a >> b;

  if(9>=b){
    x=a*10+b;
  } else if(100>b && b>=10){
    x=a*100+b;
  } else {
    x=a*1000+b;
  }

  for(int i=1; i<1000; i++){
    y=i*i;
    if(y==x){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define MX 100010
using namespace std;

char b;

int main(){
        cin >> b;
        if (b == 'A') cout << 'T' << endl;
        if (b == 'C') cout << 'G' << endl;
        if (b == 'G') cout << 'C' << endl;
        if (b == 'T') cout << 'A' << endl;
        

       
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

class RangeCount {
    const int ST_SIZE = (1 << 20) - 1;
    int n;
    vi data;
    vvi segtree;

    void init(int k, int l, int r) {
        if (r - l == 1) {
            segtree[k].push_back(data[l]);
        } else {
            int lch = k * 2 + 1;
            int rch = k * 2 + 2;
            init(lch, l, (l + r) / 2);
            init(rch, (l + r) / 2, r);
            segtree[k].resize(r - l);

            merge(segtree[lch].begin(), segtree[lch].end(), segtree[rch].begin(), segtree[rch].end(), segtree[k].begin());
        }
    }

    // number of x in [i, j)
    int query(int i, int j, i64 x, int k, int l, int r) {
        if (j <= l || r <= i) {
            return 0;
        }

        if (i <= l && r <= j) {
            return upper_bound(segtree[k].begin(), segtree[k].end(), x) - segtree[k].begin();
        }

        int lc = query(i, j, x, k * 2 + 1, l, (l + r) / 2);
        int rc = query(i, j, x, k * 2 + 2, (l + r) / 2, r);
        return lc + rc;
    }

public:
    RangeCount(vi v) {
        n = v.size();
        data = vi(v);
        segtree = vvi(ST_SIZE);
        init(0, 0, n);
    }

    int exact(int i, int j, i64 x) {
        return query(i, j, x, 0, 0, n) - query(i, j, x - 1, 0, 0, n);
    }

    int le(int i, int j, i64 x) {
        return query(i, j, x, 0, 0, n);
    }

    int lt(int i, int j, i64 x) {
        return query(i, j, x - 1, 0, 0, n);
    }

    int ge(int i, int j, i64 x) {
        return query(i, j, 1e18, 0, 0, n) - query(i, j, x - 1, 0, 0, n);
    }

    int gt(int i, int j, i64 x) {
        return query(i, j, 1e18, 0, 0, n) - query(i, j, x, 0, 0, n);
    }
};

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

    RangeCount cnt(as);

    int q;
    cin >> q;
    while (q--) {
        int b, e, k;
        cin >> b >> e >> k;
        cout << cnt.exact(b, e, k) << endl;
    }
}



Measured memory_bytes: 27728
#include<cstdio>

int main(){
  int a, b, d, e, f, g;
  char op;

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

  if( op == '?'){
    break;
    }else if( op == '+'){
    d = a + b;
    printf("%d\n", d);
    }else if( op == '-'){
    e = a - b;
    printf("%d\n", e);
    }else if( op == '*'){
    f = a * b;
    printf("%d\n", f);
    }else if( op == '/'){
    g = (float)a / (float)b;
    printf("%d\n", g);
    }else{
    return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 2656
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

int main(void){
    int N;scanf("%d",&N);
    long long int a[300004];
    long long int t_b[300004];//前半の終わりがiだった時の前半の得点
    long long int t_a[300004];//前半の終わりがiだった時の後半の得点
    rep(i,N*3){
        scanf("%lld",&a[i]);
    }
    multiset<long long int> min1;
    rep(i,2*N){
        if(i<N){
            if(i>0)t_b[i]=a[i]+t_b[i-1];
            else t_b[i]=a[i];
            min1.insert(a[i]);
        }else{
            t_b[i]=t_b[i-1];
            auto ite=min1.begin();
            if(*ite<a[i]){
                t_b[i]+=a[i]-*ite;
                min1.erase(ite);
                min1.insert(a[i]);
            }
        }
    }
    multiset<long long int> max2;
    int ite2=N-1;
    for(int i=3*N-1;i>N-1;i--){
        if(i>=2*N){
            if(i<3*N-1)t_a[i-1]=a[i]+t_a[i-1+1];
            else t_a[i-1]=a[i];
            max2.insert(a[i]);
        }else{
            t_a[i-1]=t_a[i];
            auto ite=max2.end();
            ite--;
            if(*ite>a[i]){
                t_a[i-1]+=a[i]-*ite;
                max2.erase(ite);
                max2.insert(a[i]);
            }
        }
        
    }
    long long int ans=-LLINF;
    for(int i=N-1;i<2*N;i++){
        ans=max(ans,t_b[i]-t_a[i]);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 16640
H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(list(input()))

if H > 1:
    for w in range(W):
        if S[0][w] == ".":
            S[0][w] = str(S[0][max(0,w-1):min(W, w+2)].count("#")
                        +S[1][max(0,w-1):min(W, w+2)].count("#"))

    for h in range(1, H-1):
        for w in range(W):
            if S[h][w] == ".":
                S[h][w] = str(S[h-1][max(0,w-1):min(W, w+2)].count("#")
                            +S[h][max(0,w-1):min(W, w+2)].count("#")
                            +S[h+1][max(0,w-1):min(W, w+2)].count("#"))

    for w in range(W):
            if S[H-1][w] == ".":
                S[H-1][w] = str(S[H-2][max(0,w-1):min(W, w+2)].count("#")
                            +S[H-1][max(0,w-1):min(W, w+2)].count("#"))

else:
    for w in range(W):
        if S[0][w] == ".":
            S[0][w] = str(S[0][max(0,w-1):min(W, w+2)].count("#"))
for h in range(H):
    print("".join(S[h]))

Measured memory_bytes: 3192
#include <algorithm>
#include <cstdio>
#include <vector>

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

using namespace std;

const int MOD=998244353;

const int N_MAX=200000;

template<class T>
class Fenwick_tree{
	int n;
	T a[N_MAX];

public:
	void build(int n){
		this->n=n;
		rep(i,n) a[i]=0;
	}

	void add(int i,T v){
		for(;i<n;i|=i+1) a[i]+=v;
	}

	T sum(int i,int j){
		if(i==0){
			T s=0;
			for(;j>=0;j=(j&(j+1))-1) s+=a[j];
			return s;
		}
		return sum(0,j)-sum(0,i-1);
	}
};

struct point{
	int x,y;
	bool operator<(const point &a)const{ return x!=a.x?x<a.x:y<a.y; }
};

int main(){

	int n; scanf("%d",&n);
	vector<point> P(n);
	rep(i,n) scanf("%d%d",&P[i].x,&P[i].y);

	vector<long long> two(n);
	two[0]=1;
	rep(i,n-1) two[i+1]=two[i]*2%MOD;

	sort(P.begin(),P.end());

	// coordinate compression
	vector<int> Y;
	rep(i,n) Y.emplace_back(P[i].y);
	sort(Y.begin(),Y.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());
	rep(i,n) P[i].y=lower_bound(Y.begin(),Y.end(),P[i].y)-Y.begin();

	Fenwick_tree<int> L,R;
	L.build(n);
	R.build(n);
	rep(i,n) R.add(P[i].y,1);

	long long ans=0;
	rep(i,n){
		L.add(P[i].y,1);

		int ld=L.sum(0,P[i].y-1);
		int lu=(i+1)-ld-1;
		int rd=R.sum(0,P[i].y-1);
		int ru=(n-i)-rd-1;
		// include P[i]
		ans+=two[n-1];
		// not include P[i]
		ans+=(two[n-1]-1)
			 -(two[i]-1)-(two[n-i-1]-1)-(two[P[i].y]-1)-(two[n-P[i].y-1]-1)
			 +(two[ld]-1)+(two[lu]-1)+(two[rd]-1)+(two[ru]-1);
		ans%=MOD; if(ans<0) ans+=MOD;

		R.add(P[i].y,-1);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 5876
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
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;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<int> A0, A1;
  for (int i = 0; i < N; i++) 
  {
    int a;
    cin >> a;
    if (i % 2 == 0) A0.push_back(a);
    else A1.push_back(a);
  }
  
  if (N % 2 == 0)
  {
    reverse(A1.begin(), A1.end());
  
    for (int i = 0; i < A1.size(); i++)
    {
      cout << A1.at(i) << " ";
    }
    for (int i = 0; i < A0.size(); i++)
    {
      if (i == A0.size() - 1) cout << A0.at(i) << endl;
      else cout << A0.at(i) << " ";
    }
  }
  else
  {
    reverse(A0.begin(), A0.end());
  
    for (int i = 0; i < A0.size(); i++)
    {
      cout << A0.at(i) << " ";
    }
    for (int i = 0; i < A1.size(); i++)
    {
      if (i == A1.size() - 1) cout << A1.at(i) << endl;
      else cout << A1.at(i) << " ";
    }
  }
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

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

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

int main(void){
    int N,M; cin >> N >> M;
    int dp[1<<N][N], dist[N][N];
    REP(i,N)REP(j,N) dist[i][j] = 1e6;
    REP(i,N) dist[i][i] = 0;
    REP(i,M){
        int s,t,d; cin >> s >> t >> d;
        dist[s][t] = d;
    }
    REP(i,1<<N)REP(j,N)REP(k,N) dp[i][j] = 1e6;

    dp[0][0] = 0;
    REP(i,1<<N)REP(j,N){
        REP(k,N){
            if((i & 1<<k) == 0) chmin(dp[i | 1<<k][k], dp[i][j] + dist[j][k]);
        }
    }
    int ans = dp[(1<<N)-1][0];
    cout << (ans<1e6 ? ans : -1) << en;

    return 0;
}


Measured memory_bytes: 5024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n, a, b; cin >> n >> a >> b;
	cout << min(n * a, b);

	return 0;
}

Measured memory_bytes: 3192
/**
        	C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    
    vector<int> L(M);
    vector<int> R(M);
    
    for(int i = 0 ; i < M ; i++){
        cin >> L[i] >> R[i];
    }

    int LL = *std::max_element(L.begin(),L.end());
    int RR = *std::min_element(R.begin(),R.end());

    if(LL <= RR){
        cout <<  RR - LL  + 1  << endl;
    }
    else{
        cout<< 0 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using LL=long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    LL N;
    cin >> N;
    vector<LL> dp( 86 + 1 );
    dp[ 0 ] = 2;
    dp[ 1 ] = 1;
    for( LL i = 2; i <= N; i++ )
    {
        dp[ i ] = dp[ i - 1 ] + dp[ i - 2 ];
    }
    cout << dp[ N ] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author Arles
 */
public class Main {

    static int MAX_WEIGHT = 100001;//Peso maximo de la mochila
    static int MAX_N = 101; //Numero maximo de objetos
    static int N;//Numero de objetos 
    static long prices[] = new long[MAX_N];//precios de cada producto
    static int weights[] = new int[MAX_N];//pesos de cada producto
    static long memo[][] = new long[MAX_N][MAX_WEIGHT];//tabla dp

//El metodo debe llamarse con 0 en el id, y la capacidad de la mochila en w
    static long knapsack(int id, int w) {
        if (id == N || w == 0) {
            return 0;
        }
        if (memo[id][w] != -1) {
            return memo[id][w];
        }
        if (weights[id] > w) {
            memo[id][w] = knapsack(id + 1, w);
        } else {
            memo[id][w] = Math.max(knapsack(id + 1, w), prices[id] + knapsack(id + 1, w - weights[id]));
        }
        return memo[id][w];
    }
    //Antes de llamar al metodo, todos los campos de la tabla memo deben iniciarse a -1   
    
    public static void main(String[] args) throws IOException {
        int W;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        N = Integer.parseInt(line[0]);
        W = Integer.parseInt(line[1]);
        
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < MAX_WEIGHT; j++) {
                memo[i][j] = -1;
            }
        }
        
        for (int i = 0; i < N; i++) {
            line = br.readLine().split(" ");
            weights[i] = Integer.parseInt(line[0]);
            prices[i] =  Long.parseLong(line[1]);
        }
        
        System.out.println(knapsack(0, W));
        
    }
}


Measured memory_bytes: 138388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

ll N, A, B, C, D, T;

map<ll, ll> memo;
ll solve(ll n) {
    if(n == 0) return 0;
    if(n == 1) return D;
    if(memo.count(n)) return memo[n];

    ll ret = 1e18;
    // オーバーフローに注意
    if(n < ret / D) chmin(ret, n * D);

    ll l2 = (n/2) * 2;
    ll r2 = ((n+1)/2) * 2;
    chmin(ret, solve(l2/2) + A + abs(n - l2) * D);
    chmin(ret, solve(r2/2) + A + abs(n - r2) * D);

    ll l3 = (n/3) * 3;
    ll r3 = ((n+2)/3) * 3;
    chmin(ret, solve(l3/3) + B + abs(n - l3) * D);
    chmin(ret, solve(r3/3) + B + abs(n - r3) * D);

    ll l5 = (n/5) * 5;
    ll r5 = ((n+4)/5) * 5;
    chmin(ret, solve(l5/5) + C + abs(n - l5) * D);
    chmin(ret, solve(r5/5) + C + abs(n - r5) * D);

    memo[n] = ret;
    return memo[n];
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    cin >> T;
    rep(i,T) {
        memo.clear();
        cin >> N >> A >> B >> C >> D;
        cout << solve(N) << endl;
    }
}


Measured memory_bytes: 4484
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		int n = int.Parse(Console.ReadLine());
		var w = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		
		int lowest = 100000;
		int s1 = 0;
		int s2 = 0;
		int hantei = 0;
		
		for(int b=1; b!=n+1; b++){
			
			s1=0;
			s2=0;
			
			for (int c=0; c!=b; c++){s1 = s1 + w[c];}
			for (int d=n-1; d!=b-1; d--){s2 = s2 + w[d];}
			
			if(s1>=s2){
				hantei = s1-s2;
			}else{
				hantei = s2-s1;
			}
			
			if(hantei < lowest){
				lowest = hantei;
			}
		}
		
		Console.WriteLine(lowest);
		
	}
}

Measured memory_bytes: 13396
/*
      author : Nishikawa
      created: 07.08.2020 21:34:33
*/

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


int main(){
    int hl,ml,h,m;
    cin >> hl >> ml >> h >> m;
    double hx,hy,mx,my;
    hx = hl*cos((60.0*h+m)/720.0*2.0*M_PI);//時針
    hy = hl*sin((60.0*h+m)/720.0*2.0*M_PI);
    mx = ml*cos(m/60.0*2.0*M_PI);//分針
    my = ml*sin(m/60.0*2.0*M_PI);
    printf("%.12lf\n",sqrt( (hx-mx)*(hx-mx) + (hy-my)*(hy-my) ));
    return 0;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n >> m >> x >> y;
	int a[105], b[105];
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];

	sort(a, a+n, greater<int>());
	sort(b, b+m);

	if(a[0] < b[0] && x < b[0] && a[0] < y) cout << "No War";
	else cout <<  "War";
}

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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var goal = IOUtils.ReadLong();

            var res = 0;
            var money = 100L;

            while (true)
            {
                if (goal <= money)
                {
                    break;
                }

                money = (long)Math.Floor(money * 1.01);
                res++;
            }


            Console.WriteLine(res);
        }
    }

    static class IOUtils
    {
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


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

#define lli long long
#define pb push_back
#define mp make_pair
#define gc getchar_unlocked
#define DEBUG(x) cout<<">value ("<<#x<<") : "<<x<<endl;
#define mod 1000000007

const int lmt = 1000005;

int main(){
    string s;
    cin>>s;
    int n = s.size();
    string my="";
    for(int i=0;i<n;i++){
        if(i&1)
            my += 'p';
        else
            my += 'g';
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(s[i]==my[i]) continue;
        if(s[i]=='p') ans--;
        else if(my[i]=='p') ans++;
    }
    //cout<<my<<endl;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
)

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func reverse(bs []byte) {
	var beforeHarfStart, afterHarfStart, loopCnt int
	length := len(bs)
	if length%2 == 0 {
		beforeHarfStart = length/2 - 1
		afterHarfStart = length / 2
		loopCnt = length / 2
	} else {
		beforeHarfStart = (length - 1) / 2
		afterHarfStart = (length - 1) / 2
		loopCnt = (length + 1) / 2
	}

	for i := 0; i < loopCnt; i++ {
		s1 := bs[beforeHarfStart-i]
		s2 := bs[afterHarfStart+i]
		bs[beforeHarfStart-i] = s2
		bs[afterHarfStart+i] = s1
	}
}

func extract(s, t string) string {
	// Definition of DP
	var dp [3001][3001]int

	for i := 0; i < len(s); i++ {
		for j := 0; j < len(t); j++ {
			if s[i] == t[j] {
				dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
			}
			dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
			dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])
		}
	}

	var result []byte
	i, j := len(s), len(t)
	for i > 0 && j > 0 {
		if dp[i][j] == dp[i-1][j] {
			// (i-1, j) -> (i, j) と更新されていた場合
			i-- // DP の遷移を遡る
		} else if dp[i][j] == dp[i][j-1] {
			// (i, j-1) -> (i, j) と更新されていた場合
			j-- // DP の遷移を遡る
		} else {
			// (i-1, j-1) -> (i, j) と更新されていた場合
			result = append(result, s[i-1]) // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
			i--                             // DP の遷移を遡る
			j--
		}
	}

	reverse(result)
	return string(result)
}

func main() {
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)

	fmt.Println(extract(s, t))
}


Measured memory_bytes: 73216
N, K = map(int, input().split())
maxK = (N-1)*(N-2)//2

if(K<=maxK):
    nokori = maxK-K
    print(N+nokori-1)
    for i in range(N-1):
        print(1, i+2)
    u = 2
    v = 2
    while(nokori != 0):
        v += 1
        if(v==N+1):
            u += 1
            v = u+1
        print(u, v)
        nokori -= 1
else:
    print(-1)

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

int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k;
    else if(a<k && k<=a+b) cout<<a;
    else cout<<a-(k-a-b);
    return 0;
}


Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
char z[20]={'0','1'};
void zhuan(int n,int m)
{
    if(n==0)return;
    else
    {
        if(n>0||n%m==0){zhuan(n/m,m);printf("%c",z[n%m]);return;}
        else {zhuan(n/m+1,m);printf("%c",z[-m+n%m]); return;}
    }
}
int main(){
    int n,m=-2;
    scanf("%d",&n);
    if(!n)std::cout<<'0';
    zhuan(n,m);
    return 0;
}


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

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



int main(){
    int N,M;
    cin>>N>>M;
    int numN,numM;
    N>0?numN=N*(N-1)/2:numN=0;
    M>0?numM=M*(M-1)/2:numM=0;
    cout<<numM+numN<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;




int main(){
    int N;
    string S;
    cin>>N;
    cin>>S;
    vector<int> R;
    vector<int> G;
    vector<int> B;
    for(int i=0;i<N;i++){
        if(S[i]=='R'){
            R.push_back(i);
        }else if(S[i]=='G'){
            G.push_back(i);
        }else{
            B.push_back(i);
        }
    }
    int dele=0;
    for(int i=1;i<=N/2;i++){
        
        for(int start=0;(start+i*2)<N;start++){
            if((S[start]!=S[start+i])&&(S[start+i]!=S[start+2*i])&&(S[start]!=S[start+2*i])){
                dele++;
            }    
            
        }
    }
    long int ans=R.size()*G.size()*B.size();

    ans=ans-dele;
    cout<<ans;
}



Measured memory_bytes: 3644
import sys
sys.setrecursionlimit(500000)

N = int(input())

g = [[] for _ in range(N)]
hen = []
dic = {}
for i in range(N-1):
  #iが辺のID
  a,b = map(int,input().split())
  a -= 1; b -= 1
  g[a].append((b,i))
  g[b].append((a,i))

#これが答え。
ans = [-1 for _ in range(N-1)]

#vという頂点からpという親にcolorという色で繋がっている。
def dfs(v, color, p):
  k = 1 #色の初期値
  for i in range(len(g[v])): #vから繋がっている頂点をtoとして探す
    TO = g[v][i][0]
    ID = g[v][i][1]
    if TO == p: #親は一つでそれ以外は子。親の時だけ無視すればよい。
      continue
    if k == color: #親から繋がっている色と被ったらダメ。
      k += 1
    ans[ID] = k
    k += 1 #ここで足す1をしないとこのfor loopの中の辺で色が被る。
    dfs(TO,ans[ID],v)

dfs(0,0,-1) #根を0として、仮想親の-1から仮想色0で繋がっている。
print(max(ans))
for i in ans:
  print(i)

Measured memory_bytes: 74360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define debug(x) cout << #x << '=' << x << '\n'
const long long MOD=1e9+7;
//const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?'\n':' ');
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int now=0,n=S.size();
    vector<int> cnt(2019,0),po(n,1);
    for (int i=0;i<n-1;++i) po[i+1]=po[i]*10%2019;
    ++cnt[now];
    ll ans=0;
    for (int i=n-1;i>=0;--i){
        (now+=(S[i]-'0')*po[n-1-i])%=2019;
        ans+=cnt[now]; ++cnt[now];
    }
    cout << ans << '\n';
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    string s; cin >> s;
    int n = s.size();
    vector<vector<int> > dp(n, vector<int>(2, 0));
    dp[0][0] = s[0]-'0'-1;
    dp[0][1] = s[0]-'0';
    REP(i, 1, n){
        if(s[i] != '0'){
            dp[i][0] = max(dp[i-1][0] + 9 , dp[i-1][1] + (s[i]-'0')-1);
        }else{
            dp[i][0] = dp[i-1][0] + 9;
        }
        dp[i][1] = dp[i-1][1] + (s[i]-'0');
    }
    cout << max(dp[n-1][0], dp[n-1][1]) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if (n>=30)
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}

Measured memory_bytes: 3756
eN, K = map(int, input().split())
d = {}
for a in input().split():
    a = int(a)
    d[a] = d.get(a, 0) + 1
if len(d) <= K:
    print(0)
else:
    aa = list(sorted(d, key=lambda a: d[a]))
    print(sum(d[a] for a in aa[:len(aa)-K]))


Measured memory_bytes: 41120
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

void primeNumber(int N, vector<bool>& prime)
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int MAX = 500;
vector<int> prime;
map<long long, double> m;

void solve(int i, long long a, long long sum)
{
    if(a > 1000000000000000LL)
        return;

    m[a] = sum / (double) a;
    map<long long, double>::iterator it = m.find(a);
    while(it != --m.end()){
        map<long long, double>::iterator it2 = it;
        ++ it2;
        if(it2->second < it->second){
            m.erase(it2);
        }else{
            break;
        }
    }
    if(it != m.begin()){
        map<long long, double>::iterator it2 = it;
        -- it2;
        if(it2->second > it->second)
            m.erase(it);
    }

    if(i > prime.size())
        return;

    long long tmp = 1;
    long long sum2 = sum;
    for(;;){
        a *= prime[i];
        if(a > 1000000000000000LL)
            return;

        tmp *= prime[i];
        sum2 += sum * tmp;

        solve(i+1, a, sum2);
    }
}

int main()
{
    vector<bool> isPrime;
    primeNumber(MAX, isPrime);
    for(int i=0; i<=MAX; ++i){
        if(isPrime[i])
            prime.push_back(i);
    }

    solve(0, 1, 1);
    m[LLONG_MAX] = 0.0;

    for(;;){
        long long k;
        cin >> k;
        if(k == 0)
            return 0;

        map<long long, double>::iterator it = m.upper_bound(k);
        -- it;
        printf("%.10f\n", it->second);
    }
}

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

vector<bool> visited;
vector<vector<int>> G;

void dfs(int v) {
    visited[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        if (G[v][i] == 1 && !visited[i]) dfs(i);
    }
}

int main() {
    int N, M; cin >> N >> M;
    G.resize(N, vector<int>(N, 0));
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a][b] = 1;
        G[b][a] = 1;
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (G[i][j] == 0) continue;
            
            visited.clear();
            visited.resize(N, false);
            
            G[i][j] = 0; G[j][i] = 0;
            dfs(0);
            for (int k = 0; k < N; k++) {
                if (!visited[k]) {
                    ans++;
                    break;
                }
            }
            G[i][j] = 1; G[j][i] = 1;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
# 169A

#1.入力をちゃんと受け取ること
#ex：｢2 5」⇒ a = 2,  b = 5　みたいにしないといけない。
a, b = map(int, input().split())
#print(a)
#print(b)

#2.目的通りの計算をする
#ex：２つの整数ＡとＢの掛け算をやる
answer = a * b

#3.計算の結果を出力する
print(answer)

Measured memory_bytes: 9016
sx,sy,gx,gy = list(map(int,input().split()))
dx,dy=gx-sx,gy-sy
out = []
out.append("R"*dx)
out.append("U"*dy)
out.append("L"*dx)
out.append("D"*dy)
out.append("D")
out.append("R"*(dx+1))
out.append("U"*(dy+1))
out.append("L")
out.append("U")
out.append("L"*(dx+1))
out.append("D"*(dy+1))
out.append("R")
print("".join(out))


Measured memory_bytes: 61648
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N,A,B;
  	cin>>N>>A>>B;
  	long long k=N/(A+B);
	long long amari=N%(A+B);
    if(amari>=A){
		cout<<k*A+A<<endl;
	}
  	else{
	  cout<<k*A+amari<<endl;
	}
}

Measured memory_bytes: 256
N,M = map(int,input().split())
place = [list(map(int,input().split())) for _ in range(N)]
check = [list(map(int,input().split())) for _ in range(M)]
for x,y in place:
    tmp = 10**9
    for i in range(M):
        dis = abs(x-check[i][0]) + abs(y-check[i][1])
        if tmp > dis:
            tmp = dis
            ans = i+1
    print(ans)

Measured memory_bytes: 67576
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	vector<string> a;
	string s;
	while(cin>>s)
		if(s!=string(w,'.'))
			a.push_back(s);
	for(int j=0;j<a[0].size();j++){
		bool e=true;
		for(int i=0;i<a.size();i++)
			e&=a[i][j]=='.';
		if(e){
			for(int i=0;i<a.size();i++)
				a[i].erase(j,1);
			j--;
		}
	}
	for(int i=0;i<a.size();i++){
		for(int j=0;j<a[0].size();j++)
			cout<<a[i][j];
		cout<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
    int main(){
    int H,W;
    cin >> W >> H;
    string S[27][27];
    for(int x=0; x<W; x++){
        for(int y=0; y<H; y++){
            cin >> S[x][y];
            if(S[x][y]=="snuke"){
                cout << (char)(y+'A') << x+1 << endl;
            }
        }
    }
    return 0;
    }

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


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

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

using namespace std;

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

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

#endif

void Main() {
    ll X, A; cin >> X >> A;
    if (X < A){cout << 0 << endl;}else{cout << 10 << endl;}
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N;
long A[2<<17],B[2<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)cin>>B[i];
	long ans=0;
	for(int t=0;t<80;t++)
	{
		for(int i=t&1;i<N;i+=2)
		{
			long s=B[(i+N-1)%N]+B[(i+1)%N];
			long t=(B[i]-A[i])/s;
			ans+=t;
			B[i]-=t*s;
		}
	}
	for(int i=0;i<N;i++)
	{
		if(A[i]!=B[i])
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define pb push_back
//#define mp make_pair

string s;
int cnt =0;

int main(){

cin >> s ;
int ans = s.size();

rep(i, 0, s.size()-1){

if(s[i]=='S')cnt++;
else if(s[i]=='T'&&cnt>0){
    cnt--;
    ans-=2;
}

}
cout << ans << endl;

return 0;}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, 0, 1000) {
        string t;
        int x = i;
        rep(j, 0, 3) {
            t += '0' + x % 10;
            x /= 10;
        }
        int ti = 0;
        rep(j, 0, n) {
            if (s[j] == t[ti]) {
                ti++;
                if (ti == 3) break;
            }
        }
        if (ti == 3) ans++;
    }
    cout << ans << "\n";
}

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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  int ans = n*(n-1)/2 + m*(m-1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
 
string x;
cin>>x;
if (x=="A"){
    cout<<"T";
}
else if (x=="T"){
    cout<<"A";
}
else if (x=="G"){
    cout<<"C";
}
else if (x=="C"){
    cout<<"G";
}
    return 0;
}
 
 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	int n;
	string s1,s2;

	bool pattern = true;

	cin >> n >> s1 >> s2;

	lld i = 0;
	lld sol = 0;


	while(i < n)
	{
		if (i == 0)
		{
			if (s1[i] == s2[i])
			{
				sol = 3;
				i++;
			}else
			{
				pattern = false;
				sol = 6;
				i += 2;
			}
		}else
		{
			if (s1[i] == s2[i])
			{
				if (pattern)
				{
					sol = sol * 2 % mod;
					i++;
				}else
				{
					pattern = true;
					i++;
				}
			}else
			{
				if (pattern)
				{
					pattern = false;
					sol = sol * 2 % mod;
					i += 2;
				}else
				{
					sol = sol * 3 % mod;
					i += 2;
				}
			}
		}
	}

	cout << sol << endl;

	return 0;
}

Measured memory_bytes: 256
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define slow ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define set_bits(x) __builtin_popcount(x)
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007

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

#define int long long

int32_t main(){
    double n, x, t;
    cin >> n >> x >> t;
    int val = ceil(n / x);
    val = t*val;
    cout << val;
}

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

#define fst first
#define snd second
#define pb push_back

template<typename T> bool chkmin(T&a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool chkmax(T&a, T b) { return a < b ? a = b, 1 : 0; }

int N, A, B;
deque<int> Q;
int main() {

    cin >> N;
    for(int i=1; i <= N; i++) { cin >> A; if(((i&1) + (N&1))%2 == 0) Q.push_front(A); else Q.push_back(A); }

    while(!Q.empty()) { printf("%d ", Q.front()); Q.pop_front(); }
    return 0;
}


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

int main(){
	int N;
	cin>>N;
	int total;
	int ans=0;
	for(int c=0;c<=N/4;++c){
		for(int d=0;d<=N/7;++d){
			total=4*c+7*d;
			if(total==N) {
				ans=1;
				break;
			}
		}
	}
	if (ans==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
from itertools import*
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for p,q in list(combinations(a,2)):
  d=p[:];d[3],d[4]=d[4],d[3]
  e=q[:];e[3],e[4]=e[4],e[3]
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[k]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print(f())


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

#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
const int MOD=1e9+7;

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
ll mul(int base,int n){
	ll ans=1;
	FOR(n){
		ans=(ans*base)%MOD;
	}
	return ans%MOD;
}
int solve(int n){
	ll a=mul(10,n);
	ll b=mul(9,n);
	ll c=mul(8,n);
	return ((a%MOD)-((2*b)%MOD)+(c%MOD)+MOD)%MOD;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	if(n<2){cout<<0<<'\n';return 0;}
	if(n==2){cout<<2;return 0;}
	cout<<solve(n);
	return 0;
}


Measured memory_bytes: 3616
import sys
from itertools import permutations
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, M = readnums()
    ab = [list(readnums()) for _ in range(M)]
    l = range(2, N + 1)
    ans = 0
    for v in permutations(l):
        if [1, v[0]] in ab:
            flag = 1
            for i in range(N - 2):
                if [v[i], v[i + 1]] not in ab and [v[i + 1], v[i]] not in ab:
                    flag = 0

            if flag:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    
    if(s=="SUN"){
        cout << 7 << endl;
    }else if(s == "MON"){
        cout << 6 << endl;
    }else if(s == "TUE"){
        cout << 5 << endl;
    }else if(s == "WED"){
        cout << 4 << endl;
    }else if(s == "THU"){
        cout << 3 << endl;
    }else if(s == "FRI"){
        cout << 2 << endl;
    }else if(s == "SAT"){
        cout << 1 << endl;
    }
    
    
}


Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    count = 0
    for i in range(1, N + 1):
        divisor_num = 0
        if i % 2 == 0:
            continue
        for j in range(1, i + 1):
            if i % j == 0:
                divisor_num += 1
        if divisor_num == 8:
            count += 1
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3316