akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;
pair<ll, ll> ps[1 << 20];

int main(void) {

  int n;
  ll k, a[100010];
  cin >> n >> k;
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  ll v[50] = {}, w[50] = {};
  rep(i, 41) {
    w[i] = 1LL << i;
    rep(j, n) {
      if (!((a[j] >> i) & 1)) v[i]++;
    }
    v[i] = (2LL * v[i] - (ll)n) * w[i];
  }
  
  for (int i = 0; i < 1 << 20; i++) {
    ll sw = 0, sv = 0;
    for (int j = 0; j < 20; j++) {
      if (i >> j & 1) {
	sw += w[j];
	sv += v[j];
      }
    }
    ps[i] = make_pair(sw, sv);
  }
  sort(ps, ps + (1 << 20));
  int m = 1;
  for (int i = 1; i < 1 << 20; i++) {
    if (ps[m - 1].second < ps[i].second) {
      ps[m++] = ps[i];
    }
  }

  ll res = 0;
  for (int i = 0; i < 1 << 20; i++) {
    ll sw = 0, sv = 0;
    for (int j = 0; j < 20; j++) {
      if (i >> j & 1) {
	sw += w[20 + j];
	sv += v[20 + j];
      }
    }
    if (sw <= k) {
      ll tv = (lower_bound(ps, ps + m, make_pair(k - sw, LLONG_MAX)) - 1)->second;
      res = max(res, sv + tv);
    }
  }

  cout << sum + res << endl;

  return 0;

}
  
  


Measured memory_bytes: 17408
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 ans = a >= 13 ? b : a >= 6 ? b / 2 : 0;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 3005;
const lo mod = 1000000007;

int n,m,b[li],k,flag,t;
double cev;
double a[li],dp[li][li];
string s;
vector<int> v;

int main(void){
	scanf("%d",&n);
	FOR{
		scanf("%lf",&a[i]);
	}
	dp[0][0]=1;
	FOR{
		for(int j=0;j<=n;j++){
			if(j==0){
				dp[i][j]=dp[i-1][j]*(((double)1)-a[i]);
				continue;
			}
			dp[i][j]=dp[i-1][j]*(((double)1)-a[i])+dp[i-1][j-1]*a[i];
		}
	}
	for(int i=(n+2)/2;i<=n;i++){
		cev+=dp[n][i];
		//~ cout<<dp[n][i]<<endl;
	}
	printf("%.18lf\n",cev);
	return 0;
}



Measured memory_bytes: 74284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  string a,b,c;
  int A,B;
  cin >>a>>b>>A>>B>>c;
  if(a==c)
    A--;
  else
    B--;
  cout <<A << " "<<B<<endl;
}


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

int main(){
    int n;
    cin >> n;
    ll ans=0;
    for(int i=0; i<n; i++){
        ll k;
        cin >> k;
        ans+=(k-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(fabs(c-a)<=d)cout<<"Yes"<<endl;
    else if(fabs(b-c)<=d&&fabs(a-b)<=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int p,q,r;
  int ln,ct;
  string s,t;
  while(cin>>s&&s[0]!='.'){
    ct=0;
    for(p=0;p<3;p++){
      for(q=0;q<3;q++){
	for(r=0;r<3;r++){
	  t=s;
	  ln=t.length();
	  for(i=0;i<ln;i++){
	    if(0){
	    }else if(t[i]=='P'){
	      t[i]='0'+p;
	    }else if(t[i]=='Q'){
	      t[i]='0'+q;
	    }else if(t[i]=='R'){
	      t[i]='0'+r;
	    }
	  }
	  while((ln=t.length())!=1){
	    do{
	      h=0;
	      for(i=0;i<ln-1;i++){
		if(t[i]=='-'&&'0'<=t[i+1]&&t[i+1]<='3'){
		  t.erase(i,1);
		  t[i]=2-t[i]+'0'+'0';
		  h=1;
		}
	      }
	    }while(h);
	    do{
	      h=0;
	      for(i=0;i<ln-4;i++){
		if(t[i]=='('&&t[i+4]==')'){
		  if(0){
		  }else if(t[i+2]=='*'){
		    if(0){
		    }else if(t[i+1]=='0'||t[i+3]=='0'){
		      t[i+4]='0';
		    }else if(t[i+1]=='2'&&t[i+3]=='2'){
		      t[i+4]='2';
		    }else{
		      t[i+4]='1';
		    }
		    t.erase(i,4);
		    h=1;
		  }else if(t[i+2]=='+'){
		    if(0){
		    }else if(t[i+1]=='2'||t[i+3]=='2'){
		      t[i+4]='2';
		    }else if(t[i+1]=='0'&&t[i+3]=='0'){
		      t[i+4]='0';
		    }else{
		      t[i+4]='1';
		    }
		    t.erase(i,4);
		    h=1;
		  }
		}
	      }
	    }while(h);
	  }
	  if(t[0]=='2')
	    ct++;
	}
      }
    }
    cout<<ct<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int inf=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > p;
typedef long long ll;

int n;
int k;
int c[102];

void solve() {
    int maxi1,maxi2;
    maxi1=0;
    maxi2=0;
    rep(i,n) cin>>c[i];

    rep(i,n+1-k) {
        int tmp=1;
        rep(j,k) {
            tmp*=c[i+j];
        }
        maxi1=max(maxi1,tmp);
    }
    rep(i,n) rep(j,n) if(i<j) {
        swap(c[i],c[j]);
        rep(a,n+1-k) {
            int tmp=1;
            rep(b,k) tmp*=c[a+b];
            maxi2=max(maxi2,tmp);
        }
        
        swap(c[i],c[j]);
    }

    if(maxi2-maxi1<0) 
        cout<<"no game"<<endl;
    else
        cout<<maxi2-maxi1<<endl;

}

int main() {
    while(cin>>n>>k) {
        if(k+n==0) break;
        solve();
    }
    return 0;
}

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

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int parent[N], vis[N];
multiset<int> key[N], val[N];

int Find(int a) {
    return parent[a] == a ? a : parent[a] = Find(parent[a]);
}

bool Check(int a, int b) {
    return Find(a) == Find(b);
}

void UnionOS(int a, int b) {
    parent[b] = a;
    for (auto i : key[b]) {
        key[a].insert(i);
    }
    for (auto i : val[b]) {
        val[a].insert(i);
    }
}

void Union(int a, int b) {
    a = Find(a);
    b = Find(b);
    if (a != b) {
        if (val[a].size() >= val[b].size()) {
            UnionOS(a, b);
        } else {
            UnionOS(b, a);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        parent[i] = i;
        key[i].insert(i);
        val[i].insert(a);
    }
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        Union(u, v);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (vis[Find(i)]) {
            continue;
        }
        int p = Find(i);
        vis[p] = 1;
        for (auto x : key[p]) {
            if (val[p].find(x) != val[p].end()) {
                ans++;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 97520
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long sum = 1;
		for(int i=1; i <= n ;i++){
			sum *= i;
		}
		System.out.println(sum);
		
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}

Measured memory_bytes: 11000
import java.io.*;
import java.util.*;
 
public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;
 
  private static PrintWriter _err = new PrintWriter(System.err);
 
  private void solve(Scanner sc, PrintWriter out) {
    String s = sc.nextLine();
 
    int score = 0;
    for (int i = 0; i < s.length(); ++i) {
      char ch = s.charAt(i);
      char hand = (i % 2 == 0 ? 'g' : 'p');
      if (ch == 'g' && hand == 'p') {
        ++score;
      } else if (ch == 'p' && hand == 'g') {
        --score;
      }
    }
    out.println(score);
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();
 
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();
 
    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N; cin >> N;
    vector<ll> a(N); REP(i, N) cin >> a[i];
    vector<ll> b(N); REP(i, N) cin >> b[i];
    
    ll sum_a = 0;
    ll sum_b = 0;
    REP(i, N) {
        sum_a += a[i];
        sum_b += b[i];
    }
    
    ll mini = 0;
    REP(i, N) {
        if (a[i] < b[i]) mini += (b[i] - a[i] + 1) / 2;
        //if (a[i] > b[i]) mini += a[i] - b[i];
    }
    
    if (mini <= sum_b - sum_a) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 384
s = gets.chomp
odd_str = ["R", "U", "D"]
even_str = ["L", "U", "D"]
result = true
s.chars.each_with_index{|x, i|
  if (i + 1).odd?
    if odd_str.find{|y| y == x}.nil?
      result = false
    end
  else
  	if even_str.find{|y| y == x}.nil?
      result = false
    end
  end
}
if result
  puts "Yes"
else
  puts "No"
end

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;

int main(void) {
    // Here your code !

    scanf("%d", &n);

    int sum = 0;

    int maxelem = -1;

    for (int i = 0; i < n; ++i) {
      int tmp;
      scanf("%d", &tmp);

      maxelem = max(maxelem, tmp);
      sum += tmp;
    }

    printf("%d\n", sum - maxelem / 2);

    return 0;
}


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

int main(){
	string n;
	string qwert = "qwertasdfgzxcvb";
	string yuiop = "yuiophjklnm";

	while(1){
		cin >> n;
		if(n[0] == '#') break;

		int typ = 0;
		int count = 0;
		for(int i = 0; i < n.size(); i++){
			if(typ){
				for(int j = 0; j < qwert.size(); j++){
					if(n[i] == qwert[j]){
						typ = 0;
						count++;
						if(i == 0) count--;
					}
				}
			}else{
				for(int j = 0; j < yuiop.size(); j++){
					if(n[i] == yuiop[j]){
						typ = 1;
						count++;
						if(i == 0) count--;
					}
				}
			}
		}

		cout << count << endl;
	}


	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;
 
const double pi = 3.14159265358979323846;
 
// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >
 
// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  string s;
  cin >> s;
 
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  ll a ,b;
  cin >> n >> a>> b;
  ll d = a-b;
  vl h(n);
  rep(i,n)cin >> h[i];

  ll l = -1, r = 1e9;
  
  auto f = [&](ll cnt){
    vl r = h;
    rep(i,n)r[i] -= b*cnt;
    ll x = 0;
    rep(i,n){
      if(r[i]>0)x+=r[i]/d + (r[i]%d>0);
    }
    return (x <= cnt);
  };

  while(r-l>1){
    ll mid = l+(r-l)/2;
    if(f(mid)) r = mid;
    else l = mid;
  }
  cout<<r<<endl;
  return 0;
}

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

int main(){
    int A, B, T;
    cin >> A >> B >> T;
    double tl = T + 0.5;
    int t = A;
    int temp = 0;
    
    while(t < tl){
        t = t + A;
        temp = temp + B;
    }
    
    cout << temp;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int nxpt(char *s){
  int i,l=strlen(s),max=0,f[260]={0};
  for(l--;l+1&&max<=s[l];l--)f[max=s[l]]++;
  if(l<0)return 0;
  f[s[l]]++;
  for(i=s[l]+1;f[i]==0;i++);
  f[s[l]=i]--;
  for(i=0;s[++l];f[s[l]=i]--){
    while(f[i]==0)i++;
  }
  return 1;
}
int main(){
  int n,i,j,l,M=1e9+7;
  long long s[10]={};
  long long d[100010]={1};
  char c[100010],m[]={"0123456789"};
  scanf("%d %s",&n,c);
  for(l=0;c[l];l++);
  for(i=0;i<100005;i++)d[i+1]=(d[i]*10)%M;
  for(i=0;c[i];i++){
    j=c[l-i-1]-'0';
    s[j]=(s[j]+d[i])%M;
  }
  do{
    j=0;
    for(i=0;i<10;i++)j=(j+(s[i]*(m[i]-'0'))%M)%M;
    if(j==n&&(m[c[0]-'0']-'0'||l==1))goto YES;
  }while(nxpt(m));
  printf("-1\n");
  return 0;
 YES:;
  for(i=0;c[i];i++)printf("%c",m[c[i]-'0']);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2576
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int ans=0;
        for (int i=1; i<=n; i+=2) {
            int e=i,d=1, s=0;
            while(e>=d*d){
                if(e%d==0){
                    s+=2;
                    if(d*d==e)s--;
                }
                d++;
            }
            if(s==8)ans++;
        }

        out.println(ans);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 22356
{-# OPTIONS_GHC -O2 -fexpose-all-unfoldings #-}
import Control.Applicative
import qualified Data.HashMap.Strict as Map

main = do
    [_,capa] <- map (read :: String -> Int) . words <$> getLine
    goods <- map (map (read :: String -> Int) . words) . lines <$> getContents
    print $ maximum $ map snd $ Map.toList (resolve capa (Map.fromList (zip [0..capa] [0,0..])) goods)

resolve capa capaMap ([v,w]:xs)
  | xs == []  = koushin'
  | otherwise = resolve capa koushin' xs
  where
    koushin' =  koushin capaMap [v,w] 0
    koushin capaMap [v,w] n
      | n == 0 && capaMap Map.! w <= v      = next'
      | n > (capa - w)                      = capaMap
      | capaMap Map.! (n+w) >= v + oldValue = next
      | otherwise                           = next'
      where
        oldValue = capaMap Map.! n
        next     = koushin capaMap [v,w] (n+1)
        next'    = koushin (Map.insert (n+w) (v + oldValue) capaMap) [v,w] (n+1)

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

using namespace std;
typedef long long ll;


ll gcd(ll c, ll d){
		return d ? gcd(d, c % d) : c;
	}

ll lcm(ll c, ll d){
		return c / gcd(c, d) * d;
	
	}

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans;
    ans = lcm(a,b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <string>
#include <cmath>
#include <map>
using namespace std;

#define INF ((1LL << 31) - 1)
#define fi first
#define se second

using ll = long long;

ll n, k, ans;
vector<ll> a, b;

// bitwiseorがr以下のものをすべて使う
ll solve(int r) {
  ll ret = 0;
  ll mask = (1LL << r), K = k;

  // r桁目のbitが立っていた場合はそこを0にしてそれ以下の桁を1にする
  if ((K & mask) != 0) {
    K ^= mask; // xorでr桁目のbitを0にする
    K |= (mask - 1); // 0からr-1桁目までを1で埋める
  }

  for (int i = 0; i < n; ++i) {
    // orをとってKでなければ,r桁以降で,0でなければならないどこかのbitが立っている
    if ((a[i] | K) == K) {
      ret += b[i];
    }
  }

  cout << endl;
  return ret;
}

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

  cin >> n >> k;
  a.resize(n);
  b.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }

  for (int i = 0; i < 32; ++i) {
    ans = max(ans, solve(i));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1920
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    n=int(input())
    s=[0,0,0,0]
    for i in range(n):
        a=input()
        if a=="AC":
            s[0]+=1
        elif a=="WA":
            s[1]+=1
        elif a=="TLE":
            s[2]+=1
        else:
            s[3]+=1
    print("AC x "+str(s[0]))
    print("WA x " + str(s[1]))
    print("TLE x " + str(s[2]))
    print("RE x " + str(s[3]))



if __name__ == "__main__":

    main()

Measured memory_bytes: 74656
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll dp[51][1 << 20];

vector<int> V[51];
vector<pair<int, int>> E[51];
void dfs(int p, vector<int> v, int mae) {
	V[p] = v;
	for (auto pr : E[p]) {
		int to = pr.first;
		if (mae != to) {
			v.pb(pr.second);
			dfs(to, v, p);
			v.pop_back();
		}
	}
}

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


	int N;
	cin >> N;
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		E[a].pb(mp(b, i));
		E[b].pb(mp(a, i));
	}

	vector<int> kari;
	dfs(1, kari, 0);

	int M;
	cin >> M;
	int list[51] = {};
	rep(i, M) {
		int u, v;
		cin >> u >> v;

		for (int j : V[u]) list[j] ^= 1 << i;
		for (int j : V[v]) list[j] ^= 1 << i;
	}

	dp[0][0] = 1;
	rep(i, N - 1) {
		rep(j, 1 << M) {
			if (dp[i][j]) {
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j | list[i]] += dp[i][j];
			}
		}
	}

	co(dp[N - 1][(1 << M) - 1]);


	Would you please return 0;
}

Measured memory_bytes: 362752
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int i, n, cut=0;
	char s[101];
	scanf("%s", s);
	n = strlen(s);

	for(i=0; i<n-1-i; i++){
		if(s[i] != s[n-1-i]) cut++;
	}
	printf("%d", cut);
	return 0;
}

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

int main(){

    int n;
    cin>>n;
    int ans=n;
    for(int i=0;i<=n;i++){
        int t=i;
        int cnt=0;
        int s=1;
        while(t>0){
            cnt+=(t/s)%6;
            t-=((t/s)%6)*s;
            s*=6;
        }
        s=1;
        t=n-i;
        while(t>0){
            cnt+=(t/s)%9;
            t-=((t/s)%9)*s;
            s*=9;
        }
        ans=min(ans,cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  string x;
  cin >> x;
  int size = x.size();
  int ssize = 0;
  rep(i,(int)x.size()){
    if(x[i] == 'S'){
      ssize++;
    }else{
      if(ssize > 0){
        size-=2;
        ssize--;
      }
    }
  }
  cout << size << endl;
	return 0;
}


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

using namespace std;

typedef long long LL;
const int MAXN=100000+100;
const int MOD=1e9+7;
LL dp[MAXN][128],dgt[MAXN];
LL d,len;
string k;

LL dfs(LL pos,LL num,bool lim){
	if(!lim&&dp[pos][num]!=-1) return dp[pos][num];
	if(pos==len+1) return dp[pos][num]=(num==0);
	LL up=lim?dgt[pos]:9;
	LL ret=0;
	for(int i=0;i<=up;i++){
		ret+=dfs(pos+1,(num+i)%d,lim&&(i==up));
		ret%=MOD;
	}
	if(!lim) dp[pos][num]=ret;
	return ret;
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>k>>d;
	len=k.size();
	k='$'+k;
	for(int i=1;i<=len;i++) dgt[i]=k[i]-'0';
	LL ans=dfs(1,0,1)-1+MOD;
	cout<<ans%MOD<<endl;
	return 0;
}
 

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

int main() {
  int x1,y1,x2,y2,x3,y3,x4,y4;
  cin>>x1>>y1>>x2>>y2;
  x3=x2+y1-y2;
  y3=y2+x2-x1;
  x4=x1+y1-y2;
  y4=y1+x2-x1;

  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4;
    
  
}


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

void A()
{
    string N;
    cin >> N;
    
    if( N.find("7") != string::npos )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void B()
{
    int N;
    cin >> N;
    
    long long int ans = 0;
    
    for( int i = 1; i < N+1; ++i )
        if( (i % 3 != 0) && (i % 5 != 0) )
            ans += i;
    
    cout << ans << endl;
}

int main()
{
    //A();
    B();
    
    return 0;
}

Measured memory_bytes: 3628
a,b,c = map(int, input().split())
list_abc = list((a,b,c))
list_abc.sort()
count = 0
while True:
    if list_abc[0] == list_abc[1] == list_abc[2]:
        break
    elif list_abc[0] < list_abc[1]:
        list_abc[0] += 2
    else:
        list_abc[0] += 1
        list_abc[1] += 1
    count += 1
    list_abc.sort()

print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main() {
	while(1){
		int n,x,ptn=0;
		cin>>n>>x;
		if(n==0&&x==0)break;
		for(int i=1;i<=n;i++){
			for(int j=(i+1);j<=n;j++){
				for(int k=(j+1);k<=n;k++){
					if(i!=j){
						if(i!=k){
							if(j!=k){
								if((i+j+k)==x){
									ptn+=1;
								}
							}
						}
					}
				}
			}
		}
		cout<<ptn<<endl;
	}
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if (U == S) A--;
  if (U == T) B--;
  cout << A << ' ' << B << '\n';
  return 0;
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define pb push_back
#define x first
#define y second

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;

const int N = 1e5 + 10;
const LL oo = 1ll << 60;

int n, sz[N];
vector<PII> G[N];
LL dp[N][3];

void chkmax(LL &x, LL y){
	x = x > y ? x : y;
}

void DFS(int o, int f, int w){
	sz[o] = 1;
	dp[o][0] = dp[o][1] = 0, dp[o][2] = -oo;

	for(auto s : G[o]){
		if(s.x == f) continue;
		DFS(s.x, o, s.y);
		sz[o] += sz[s.x];
		Forr(i, 2, 0) Forr(j, 2 - i, 0) chkmax(dp[o][i + j], dp[o][i] + dp[s.x][j]);	
	}

	For(i, 0, 2){
		int coe = min(2 * sz[o] - i, 2 * (n - sz[o]) - (2 - i));
		dp[o][i] += 1ll * coe * w;
	}
}

int main(){
	scanf("%d", &n);
	For(i, 2, n){
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		G[u].pb(PII(v, w)), G[v].pb(PII(u, w));
	}

	DFS(1, 0, 0);
	printf("%lld\n", dp[1][2]);
	return 0;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

typedef long long ll;

ll pow_mod(ll x,int k) {
  ll ans=1;
  while (k) {
  	if (k&1) ans=ans*x%MOD;
  	x=x*x%MOD;
  	k>>=1;
  }
  return ans;
}

inline void add(int &x,ll y) {
  x=(x+y)%MOD;
}

ll facd[70005],facv[70005];

void pre(int n) {
  facd[0]=1;
  for(int i=1;i<=n;i++) facd[i]=facd[i-1]*i%MOD;
  facv[n]=pow_mod(facd[n],MOD-2);
  for(int i=n-1;i>=0;i--) facv[i]=facv[i+1]*(i+1)%MOD;
}

inline ll C(int n,int m) {
  return (n<m)?0:facd[n]*facv[m]%MOD*facv[n-m]%MOD;
}

int f[17][1<<16],num[17];

int dp(int n,int m) {
  f[0][0]=1;
  for(int i=1;i<=m;i++)
    for(int j=0;j<(1<<n);j++)
      if (f[i-1][j]) {
      	add(f[i][j],f[i-1][j]);
      	for(int k=0;k<n;k++)
      	  if (!((j>>k)&1)&&j+(1<<k)<=num[i]) 
			add(f[i][j^(1<<k)],(MOD-f[i-1][j])*C(num[i]-j-1,(1<<k)-1));
	  }
  int ans=0;
  for(int i=0;i<(1<<n);i++)
    if (f[m][i]) {
    	int s=(1<<n)-i-1;
    	ll v=f[m][i];
    	for(int j=0;j<n;j++)
    	  if (!((i>>j)&1)) {
    	  	v=v*C(s,1<<j)%MOD;
    	  	s-=(1<<j);
		  } 
		add(ans,v);
	}
  for(int i=0;i<n;i++) ans=ans*facd[1<<i]%MOD;
  return ans;
}

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  pre(1<<n);
  for(int i=1;i<=m;i++) {
  	int x;
  	scanf("%d",&x);
  	num[i]=(1<<n)-x+1;
  }
  reverse(num+1,num+m+1);
  printf("%lld\n",(ll)dp(n,m)*(1<<n)%MOD);
  return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rushb() scanf("%d",&t);while(t--)
#define rusha() scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define debug() cout<<"LBWNB"<<'\n'
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define p() puts("");
using namespace std;
typedef long long ll;
const int mod=998244353;
const int inf=1e9+7;
const int maxn=5e5+7;
int n;
int a[maxn];
struct pp{string s;int v;};
vector <pp> s1,s2;
int main(){
    scanf("%d",&n);
    s1.pb({"a",0});
    for(int i=2;i<=n;i++){
        int g=s1.size();
        for(int j=0;j<g;j++){
            int k=s1[j].v;
            for(int p=0;p<=k+1;p++){
                char ss='a'+p;
                s2.pb({s1[j].s+ss,max(p,k)});
            }
        }
        s1=s2;
        s2.clear();
    }
    for(auto f:s1) cout<<f.s<<'\n';
    return 0;
}





//const int M=1<<20;
//ll t1[M*2+5],t2[M*2+5],ans,ca[M],cb[M];
//inline void upd(int i){t1[i]=t1[i<<1]+t1[i<<1|1];t2[i]=max(t2[i<<1],t1[i<<1]+t2[i<<1|1]);}
//inline void add(int i,int v){for(t1[i+=M]+=v;i>>=1;upd(i));}
//int n,m,p,x,y,i,j;
//struct mons{int x,y,z;}a[M];
//int main(){
//	for(i=0;i<M;++i)ca[i]=cb[i]=1ll<<60;ans=-(1ll<<60);
//	scanf("%d%d%d",&n,&m,&p);
//	for(i=1;i<=n;++i)scanf("%d%d",&x,&y),ca[x]=min(ca[x],(ll)y);
//	for(i=1;i<=m;++i)scanf("%d%d",&x,&y),cb[x]=min(cb[x],(ll)y);
//	for(i=0;i<M;++i)t2[i+M]=-cb[i];for(i=M-1;i;--i)upd(i);
//	for(i=1;i<=p;++i)scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
//	sort(a+1,a+p+1,[&](const mons&a,const mons&b){return a.x<b.x;});
//	for(i=0,j=1;i<M;++i){
//		for(;j<=p && a[j].x<i;++j)add(a[j].y,a[j].z);
//		ans=max(ans,t2[1]-ca[i]);
//	}
//	printf("%lld\n",ans);
//	return 0;
//}


Measured memory_bytes: 11940
#include "bits/stdc++.h"

#define gOdSpEeD ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0)
#define Int long long
#define all(x) x.begin(), x.end()
#define el '\n'
#define ints unsigned
#define cy cout << "YES" << end 
#define cn cout <<"NO" << end
#define elif else if
#define test int t; cin>>t; while(t--)

using namespace std;

int main () {
    gOdSpEeD;
    string s; cin >> s;
    string t; cin >> t;
    int cnt{};
    for(int i {};i<s.size();i++){if(s[i]!=t[i]) cnt++;}
    cout << cnt;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  map<int,int> R;
  for(int i = 0; i < N; ++i){
    ++R[i-A[i]];
  }
  long long ans = 0;
  for(int i = 0; i < N; ++i){
    --R[i-A[i]];
    ans += R[A[i]+i];
  }
  cout << ans << endl;
}


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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;

int n;
int X[103],Y[103],H[103],mn=INF;

int absi(int x){
	if (x<0) re -x;
	re x;
}

bool check(int x,int y,int h){
	rep(i,n){
		if (max(h-absi(x-X[i])-absi(y-Y[i]),-mn)!=H[i]) re 0;
	}
	re 1;
}

int main(){
	cin>>n;
	rep(i,n){
		cin>>X[i]>>Y[i]>>H[i];
		mn=min(mn,H[i]);
	}
	rep(i,n){
		H[i]-=mn;
	}
	rep(i,101){
		rep(j,101){
			rep(k,202){
				if (check(i,j,k)){
					cout<<i<<" "<<j<<" "<<k+mn;
				}
			}
		}
	}
	re 0;
}

Measured memory_bytes: 256
n = int(input())
s = []
for _ in range(n):
    s.append(input())

AC = s.count("AC")
TLE = s.count("TLE")
WA = s.count("WA")
RE = s.count("RE")


print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))

Measured memory_bytes: 16292
#include <bits/stdc++.h>
#include <queue>
#define ll long long int
#define inf 3e18+1
#define all(v) (v).begin(),(v).end() 
#define N 200005
#define F first
#define S second
using namespace std;
ll mod=1e9+7;
int main()
{
    // added the two lines below 
    ios_base::sync_with_stdio (false); 
    cin.tie(NULL);
    cout.tie(0);    
  
    ll test=1;//cin>>test;
    while(test--){
        ll n;
        cin>>n;
        ll a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        ll pre[n];
        pre[0]=a[0];
        for(int i=1;i<n;i++) {
            pre[i]=(a[i]+pre[i-1])%mod;
        }
        ll ans=0;
        for(int i=0;i<n;i++){
            ans=(ans+(a[i]*(pre[n-1]-pre[i]+mod)%mod)%mod)%mod;
        }
        cout<<ans<<endl;

        
    }
    return 0;
}




Measured memory_bytes: 6716
#include<stdio.h>
int main(void)
{
	int h,s=0,n,k,i,flg;
	while(1){
		flg=0;
		scanf("%d",&n);
		if(n==0)break;
		s=n;
		for(i=0;i<n;i++){
			scanf("%d",&k);
//			printf("%d\n",k);
			if(k==0){
				s=s-1;
			}
			if(k>=2){
				flg=1;
			}
		}
		if(flg==1){
			printf("%d\n",s+1);
		}
		else{
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

#define N_MAX 100000

int main(){
	int n;
	cin >> n;
	int c[N_MAX];
	fill(c, c+N_MAX, 0);
	int a;
	for(int i=0; i<n; i++){
		cin >> a;
		c[a]++;
		if(a != 0) c[a-1]++;
		if(a != N_MAX-1) c[a+1]++;
	}
	sort(c, c+N_MAX);
	cout << c[N_MAX-1] << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        //int a = stdIn.nextInt();
        //int b = stdIn.nextInt();
        //String s = stdIn.next();
        //int size[] = new int[n];
        //int sum = 0;
        //char c[] = s.toCharArray();
        
        //for(int i = 0; i < n; i++){
            //size[i] = stdIn.nextInt();
        //}
        
        if(n % 2 == 0){
            System.out.println(n / 2 - 1);
        }else{
            System.out.println(n / 2);
        }
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] k = line.split(" ");
		int v = Integer.parseInt(k[0]);
		int v2 = Integer.parseInt(k[1]);
		if (v == v2) {
			System.out.println("a == b");
		} else if (v > v2) {
			System.out.println("a > b");
		} else if (v < v2) {
			System.out.println("a < b");
		}

	}
}

Measured memory_bytes: 26020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,k;
    cin >> t;
    k=t;
    vector <long long> side;
    long long n;
    while(k--)
    {
        cin >> n;
        side.push_back(n);
    }
    sort(side.begin(),side.end(),greater<long long >());
    long long a=0,b=0,i,f=0;
    for(i=0;i<t-1;i++)
    {
        if(side[i]==side[i+1])
        {
            if(f==0){
                a=side[i];
                f++;
            }
            else if(f==1){
                b=side[i];
                f++;
            }
            i++;
        }
       // if(a>0 && b>0) break;
    }
    cout << a*b*1LL << endl;
}

Measured memory_bytes: 4236
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int a;
  string s;
  cin>>a>>s;
  cout<<(a>=3200?s:"red");

}

// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val uv = List.fill(n-1)((sc.nextLong()-1, sc.nextLong()-1))
  var ans = 0L

  for (i <- 0L until n) {
    ans += (i+1) * (n-i)
  }

  for ((u, v) <- uv) {
    ans -= (u.min(v) + 1) * (n - u.max(v))
  }

  println(ans)
}


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

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

// memset(arr, value, size);
void A() {
	string s;
	cin >> s;
	cout << s << (s[s.length() - 1] - 's' ? "s" : "es");
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	A();

	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

ll op(lvector A,ll sign) {
  ll ret=0,S=0;
  for(ll a:A) {
    sign*=-1;
    S+=a;
    if(S*sign>0) continue;
    if(sign>0) ret+=(1-S),S=1;
    else ret+=(1+S),S=-1;
  }  
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  lvector A(n);rep(i,n) cin>>A[i];
  print(min(op(A,1),op(A,-1)));
  return 0;
}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, A, B;
    string s;
    cin >> N >> A >> B >> s;
    int sum = A + B; // 参加できる最大の人数
    int tmp = 0;     // 現在の参加が確定した人数
    int tmp_b = 0;   // 参加が確定している海外の選手の人数
    rep(0, i, N)
    {
        if (tmp < sum)
        {
            if (s.at(i) == 'a')
            {
                cout << "Yes" << endl;
                tmp++;
            }
            else if (s.at(i) == 'c')
            {
                cout << "No" << endl;
            }
            else if (tmp_b < B)
            {
                cout << "Yes" << endl;
                tmp++;
                tmp_b++;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
from collections import defaultdict as dd

N=int(input())

A=list(map(int,input().split()))
B=[A[0]]
for i in range(1,N):
    B.append(B[i-1]+A[i])
    
D=dd(int)
Z=0
for i in range(N):
    if B[i]==0:
        Z+=1
    
    D[B[i]]+=1
    
ans=0
for i in D:
    
    ans+=((D[i]-1)*D[i]//2)
if Z>0:
    ans+=Z
    
print(ans)
#print(D)

Measured memory_bytes: 41680
#include <cstdio>

const int MAX_S = 200000;

char s[MAX_S + 1];

int main() {
  scanf("%s", s);

  int b_cnt = 0;
  long cnt = 0;
  for (int i = 0; i < MAX_S; i++) {
    if (!s[i]) break;

    if (s[i] == 'B') b_cnt++;
    if (s[i] == 'W') cnt += b_cnt;
  }
  printf("%ld\n", cnt);
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/2/2018
 
 25:30-25:15 give up
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_V=2e5+1;
int V,K,L;

struct UF {
public:
  int groupNum;
  UF(int N) {
    uf=vector<int>(N);
    rank=vector<int>(N);
    for(int i=0; i<N; ++i) uf[i]=i,rank[i]=0;
    groupNum=N;
  }
  
  int find(int i) {
    return uf[i]==i?i:uf[i]=find(uf[i]);
  }
  
  bool same(int x, int y) {
    return find(x)==find(y);
  }
  
  void unite(int x, int y) {
    x=find(x);
    y=find(y);
    if(x==y) return;
    groupNum--;
    
    if (rank[x]==rank[y]) {
      uf[x]=y;
      rank[y]++;
      return;
    }
    
    if (rank[x]<rank[y]) {
      uf[x]=y;
    } else {
      uf[y] =x;
      if(rank[x]==rank[y]) ++rank[x];
    }
  }
private:
  vector<int> rank;
  vector<int> uf;
};

vector<UF> uf(2,UF(MAX_V));

void solve() {
  map<II,int> M;
  REP(i,V) M[{uf[0].find(i),uf[1].find(i)}]++;
  REP(i,V) cout<<M[{uf[0].find(i),uf[1].find(i)}]<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>V>>K>>L;
  int A[2]={K,L};
  REP(i,2) REP(_,A[i]) {
    int u,v; cin>>u>>v;
    --u,--v;
    uf[i].unite(u,v);
  }
  solve();
  
  return 0;
}


Measured memory_bytes: 12384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+1;
int n,m,head[N],cnt;
struct nd{int ne,to;}e[N*2];
void in(int x,int y)
{
	e[++cnt].to=y;e[cnt].ne=head[x];head[x]=cnt;
	e[++cnt].to=x;e[cnt].ne=head[y];head[y]=cnt;
}
bool flag=0;
int dfs(int x,int f,int dep)
{
	if(dep==2){if(x==n)flag=1;return 0;}
	for(int i=head[x];i;i=e[i].ne)
	{
		int y=e[i].to;
		dfs(y,x,dep+1);
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1,x,y;i<=m;++i)
	cin>>x>>y,in(x,y);
	dfs(1,0,0);
	if(flag)cout<<"POSSIBLE";
	else    cout<<"IMPOSSIBLE";
}


Measured memory_bytes: 8448
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

const MOD = 1000000007

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var H, W int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &H, &W)

	mat := make([][]string, H+1)
	for i := 0; i < len(mat); i++ {
		mat[i] = make([]string, W+1)
	}

	for i := 1; i < H+1; i++ {
		var str string
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%s", &str)
		chars := strings.Split(str, "")
		for j := 1; j < W+1; j++ {
			mat[i][j] = chars[j-1]
		}
	}

	dp := make([][]int, H+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, W+1)
	}

	dp[1][1] = 1
	for i := 1; i < H+1; i++ {
		for j := 1; j < W+1; j++ {
			if i == 1 && j == 1 {
				continue
			}
			if mat[i][j] == "#" {
				dp[i][j] = 0
				continue
			}
			dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD
		}
	}
	fmt.Println(dp[H][W])
}


Measured memory_bytes: 34304