akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int mod = 200003;


long long powmod(long long b, long long p) {
  long long r = 1;
  for (; p; p >>= 1, b = b * b % mod)
    if (p & 1)
      r = r * b % mod;
  return r;
}

int find_primitive_root() {
  int totient = mod - 1;
  vector<int> checks;
  int tmp = totient;
  for (int p = 2; p * p <= tmp; ++p) {
    if (tmp % p) continue;
    checks.push_back(totient/p);
    while ((tmp % p) == 0) tmp /= p;
  }
  if (tmp > 1)
    checks.push_back(totient/tmp);
  for (int r = 2; ; ++r) {
    bool ok = 1;
    for (int f : checks) {
      if (powmod(r, f) == 1) {
        ok = 0;
        break;
      }
    }
    if (ok)
      return r;
  }
  assert(false);
}

int pw[mod], pp[mod];

/***************** FFT dengan complex ******************/
typedef complex<double> cd;
typedef vector< cd > vcd;

// asumsi ukuran as = 2^k, dengan k bilangan bulat positif
vcd fft(const vcd &as) {
  int n = (int)as.size();
  int k = 0;
  while((1<<k) < n) k++;
  vector< int > r(n);
  r[0] = 0;
  int h = -1;
  for(int i = 1; i<n; i++) {
    if((i & (i-1)) == 0)
      h++;
    r[i] = r[i ^ (1 << h)];
    r[i] |= (1<<(k-h-1));
  }
  vcd root(n);
  for(int i = 0; i<n; i++) {
    double ang = 2.0*M_PI*i/n;
    root[i] = cd(cos(ang), sin(ang));
  }

  vcd cur(n);
  for(int i = 0; i<n; i++)
    cur[i] = as[r[i]];

  for(int len = 1; len < n; len <<= 1 ) {
    vcd ncur(n);
    int step = n/(len << 1);
    for(int pdest = 0; pdest <n;) {
      for(int i = 0; i<len; i++) {
        cd val = root[i*step]*cur[pdest + len];
        ncur[pdest] = cur[pdest] + val;
        ncur[pdest + len] = cur[pdest] - val;
        pdest++;
      }
      pdest += len;
    }
    cur.swap(ncur);
  }
  return cur;
}

vcd inv_fft(const vcd& fa) {
  int nn = fa.size();
  vcd res = fft(fa);
  for(int i = 0; i<nn; i++) {
    res[i] /= nn;
  }
  reverse(res.begin() + 1, res.end());
  return res;
}

int main() {
  int root = find_primitive_root();
  for (int i = 0, cur = 1; i < mod - 1; ++i) {
    pp[i] = cur;
    pw[cur] = i;
    cur = cur * root % mod;
  }
  int sz = mod + mod;
  while ((sz - 1) & sz) ++sz;
  vector<int> cnt(sz, 0);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    if (x == 0) continue;
    x = pw[x];
    ++cnt[x];
  }
  vcd f(cnt.size());
  for (int i = 0; i < (int)cnt.size(); ++i)
    f[i] = cd(cnt[i], 0);
  f = fft(f);
  for (int i = 0; i < (int)f.size(); ++i) {
    f[i] *= f[i];
  }
  f = inv_fft(f);
  vector<long long> fcnt(f.size());
  for (int i = 0; i < (int)f.size(); ++i) {
    fcnt[i] = (long long)floor(f[i].real() + 0.5);
  }
  for (int i = 0; i < mod; ++i) {
    fcnt[i * 2] -= cnt[i];
  }
  long long ans = 0;
  for (int i = 0, z = 0; i < (int)fcnt.size(); ++i, ++z) {
    if (z >= mod-1)
      z -= mod - 1;
    ans += (long long)pp[z] * fcnt[i];
  }
  ans /= 2;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 48336
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main(){
    int n,m,ans= 0;
    cin>>n>>m;
    vector<int> l(m),r(m);
    rep(i,m) cin>>l[i]>>r[i];
    int lmax = l[0],rmin = r[0];
    rep(i,m){
        lmax = max(lmax,l[i]);
        rmin = min(rmin,r[i]);
    }
    if(lmax<=rmin) cout<<rmin-lmax+1<<endl;
    else cout<<0<<endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed_=(b);i<=_ed_;++i)
#define DREP(i,a,b) for(int i=(a),_ed_=(b);i>=_ed_;--i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)((x).size())
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int P=200003,G=2;
int N,num[P],a[200005];

const double pi=acos(-1.0);
struct cmplx{
    double x,y;
    cmplx(double x=0,double y=0):x(x),y(y){}
    cmplx operator+(const cmplx& o){return cmplx(x+o.x,y+o.y);}
    cmplx operator-(const cmplx& o){return cmplx(x-o.x,y-o.y);}
    cmplx operator*(const cmplx& o){return cmplx(x*o.x-y*o.y,x*o.y+y*o.x);}
    cmplx operator/(int t){return cmplx(x/t,y/t);}
};

int tr[525000];cmplx w[525000];
void DFT(cmplx* f,int n){
    REP(i,0,n-1)if(i<tr[i])swap(f[i],f[tr[i]]);
    for(int len=2,d=1;len<=n;d=len,len<<=1)
	for(int p=0;p<n;p+=len)
	    for(int i=p;i<p+d;++i){
		cmplx t=f[i+d]*w[d+i-p];
		f[i+d]=f[i]-t,f[i]=f[i]+t;
	    }
}

cmplx f[525000],g[525000];
ll F[525000];

int main(){
    //freopen("in.in","r",stdin);
    int t=1;
    REP(i,0,P-2)num[t]=i,t=1ll*t*G%P;
    N=read();ll ans=0;
    REP(i,1,N){
	a[i]=read();
	if(!a[i])continue;
	++f[num[a[i]]].x,++g[num[a[i]]].x;
    }
    int n=1;for(;n<P+P-1;n<<=1);
    REP(i,0,n-1)tr[i]=(tr[i>>1]>>1)|(i&1?(n>>1):0);
    for(int len=2,d=1;len<=n;d=len,len<<=1){
	cmplx e=cmplx(cos(2*pi/len),sin(2*pi/len));
	w[d]=cmplx(1,0);REP(i,1,d-1)w[d+i]=w[d+i-1]*e;
    }
    DFT(f,n),DFT(g,n);
    REP(i,0,n-1)f[i]=f[i]*g[i];
    DFT(f,n);reverse(f+1,f+n);
    REP(i,0,n-1)f[i]=f[i]/n;
    t=1;
    REP(i,0,n-1)F[i]=(f[i].x+0.5);
    REP(i,1,N)if(a[i])--F[num[a[i]]<<1];
    REP(i,0,n-1)F[i]>>=1;
    REP(i,0,P+P-2){
	ans+=1ll*t*F[i];
	t=1ll*t*G%P;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 36332
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
using namespace std;


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


int main(){
  string s;
  int k;
  cin >> s;
  cin >> k;
  set<string> st;
  for(int i = 0; i < s.length(); ++i){
    for(int j = 1; j <= k; ++j){
      st.insert(s.substr(i, j));
    }
  }

  auto itr = st.begin();
  advance(itr, k - 1);
  cout << *itr << endl;



}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
char s[maxn];
int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	if(s[1] == s[n])
	{
		if(n & 1)
			puts("Second");
		else
			puts("First");
	}
	else
	{
		if(n & 1)
			puts("First");
		else
			puts("Second");
	}
	return 0;
}

Measured memory_bytes: 3860
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<numeric>
#include<limits>
#include<bitset>
#include<unordered_map>
#include<functional>
using namespace std;

#define rep(i,s,n) for(int i=s;i<n;i++)
#define dow(i,n,s) for(int i=n-1;i>=s;i--)
#define all(a) a.begin(),a.end()
#define rng(a,b,e) a.begin()+b,a.begin()+e
#define DEBUG
typedef pair<int,int> II;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e+9;
const int SIZE = 10;

int x[SIZE][SIZE];

void solve();

int main() {
  rep(i,0,SIZE) rep(j,0,SIZE) cin>>x[i][j];
  solve();
  return 0;
}

void solve() {
  int res = 0;
  rep(a,0,SIZE) {
    rep(b,0,SIZE) {
      rep(c,0,SIZE) {
        rep(d,0,SIZE) {
          int e = x[x[x[x[0][a]][b]][c]][d];

          rep(a_,0,SIZE) {
            if(a_ != a && x[x[x[x[x[0][a_]][b]][c]][d]][e] == 0) { res++; goto EXIT; }
          }
          rep(b_,0,SIZE) {
            if(b_ != b && x[x[x[x[x[0][a]][b_]][c]][d]][e] == 0) { res++; goto EXIT; }
          }
          rep(c_,0,SIZE) {
            if(c_ != c && x[x[x[x[x[0][a]][b]][c_]][d]][e] == 0) { res++; goto EXIT; }
          }
          rep(d_,0,SIZE) {
            if(d_ != d && x[x[x[x[x[0][a]][b]][c]][d_]][e] == 0) { res++; goto EXIT; }
          }
          rep(e_,0,SIZE) {
            if(e_ != e && x[x[x[x[x[0][a]][b]][c]][d]][e_] == 0) { res++; goto EXIT; }
          }

          if(a != b && x[x[x[x[x[0][b]][a]][c]][d]][e] == 0) { res++; goto EXIT; }
          if(b != c && x[x[x[x[x[0][a]][c]][b]][d]][e] == 0) { res++; goto EXIT; }
          if(c != d && x[x[x[x[x[0][a]][b]][d]][c]][e] == 0) { res++; goto EXIT; }
          if(d != e && x[x[x[x[x[0][a]][b]][c]][e]][d] == 0) { res++; goto EXIT; }
          EXIT: ;
        }
      }
    }
  }

  cout<<res<<endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
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;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int a,b,c,d,e,k;
cin >> a >> b >> c >> d >> e >> k; 

int M = e - a;
if(M <= k) cout << "Yay!" << endl;
else cout << ":(" << endl;


return 0;
}

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

int main() {
	// your code goes here
	ll n;
	cin>>n;
	vll v(n, vl(3, 0));
	rep(i,0,n){
		cin>>v[i][0]>>v[i][1]>>v[i][2];
	}
	vll dp(n, vl(3, 0));
	rep(i,0,3){
		dp[0][i] = v[0][i];
		// cout<<"dp[][]: "<< "0"<< " "<< i<<" "<<dp[0][i]<<" ";
	}
	// cout<<endl;
	
	rep(i,1,n){
		rep(j,0,3){
			int actv1=(j+1)%3;
			int actv2=(j+2)%3;
			dp[i][j]=max(dp[i-1][actv1]+v[i][j], dp[i-1][actv2]+v[i][j]);//#1,2 
			// cout<<"dp[][]: "<< i<< " "<< j<<" "<<dp[i][j]<<" ";
		}
		// cout<<endl;
	}
	auto idx = max_element(dp[n-1].begin(), dp[n-1].end());
	cout<<*idx<<endl;
	return 0;
}
/*
- Har dp mai states consider karo. Idhar, dp[i][j] liya...i -> no. of days and 
j -> the activity (a,b or c).
Our final ans depends on these 2 things na, so we take a 2D dp of these 2 factors

#1: We want to consider the other 2 activities. So ij say j=1, 
(j+1)%3=2 and (j+2)%3=0..so we've got the activities other than the 1 
i'm considering now

#2: A stupid mistake i was doing here was adding v[i][actv1] & v[i][actv2]
instead of v[i][j]
*/

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


int main(){
	int X, N;
	cin >> X >> N;
	vector<tuple<bool, int, int>> c(111);
	rep(i,N){
		int p;cin >> p;
		get<0>(c[p]) = true;
	}
	rep(i,111){
		if(!get<0>(c[i])){
				get<1>(c[i]) = abs(X-i);
				get<2>(c[i]) = i;
		}	
	}	
	sort(c.begin(),c.end());
	cout << get<2>(c[0]) << endl;

}














Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n,min=1000000000,num,g;
  bool is_changed=true;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    min=(a[i]>min)?min:a[i];
  }
  num = min;
  while(is_changed){
    is_changed=false;
    num = min;
    min = 1000000000;
    for(int i=0;i<n;i++){
      if(a[i]%num!=0){
        is_changed=true;
        a[i]%=num;
        min=(a[i]>min)?min:a[i];
      }
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 640
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int a[maxn];
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  return 1;
}

void solve() {
  sort(a, a + n);

  int l = -1, r = n - 1;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    long long x = a[m];
    bool ok = 1;
    for (int i = 0; i < n; ++i) {
      if (i == m) {
        continue;
      }
      if (a[i] > 2 * x) {
        ok = 0;
        break;
      }
      x += a[i];
    }

    if (ok) {
      r = m;
    } else {
      l = m;
    }
  }
  printf("%d\n", n - r);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int main(){
	int N;
	cin >> N;
	vector<int> V(N);
	for(int i=0; i<N; i++) cin >> V[i];

	sort(V.begin(), V.end());
	double ans = V[0];
	for(int i=1; i<N; i++){
		ans = (ans+V[i])/2;
	}
	cout << setprecision(20) << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<chrono>
#include<random>
#define ll long long
#define int ll
#define INF 1e+18
#define EPS 1e-18
#define pii pair<int,int>
#define endl "\n"
#define all(mas) mas.begin(),mas.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define forn_(i,n) for(int i = n - 1; i >= 0; i--)
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 1e5 + 1;
int a, b, mas[MAXN];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> a >> b;

	if (a >= 13) {
		cout << b;
	}
	else if (a <= 5) {
		cout << 0;
	}
	else {
		cout << b / 2;
	}

	return 0;
}

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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define lcm(a,b)     (a*b)/__gcd(a,b)
#define bs(v,x)      binary_search(v.begin(),v.end(),x)
#define ub(v,x)      upper_bound(v.begin(),v.end(),x)
#define lb(v,x)      lower_bound(v.begin(),v.end(),x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) (a).begin(),(a).end() 
#define inp(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cerr<<endl;
#define printv(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout<<"\n";
#define Pi 3.14159265
#define reset(x) memset(x,'z',sizeof(x))
#define f first
#define s second
//#define m make_pair
#define PII pair<ll, ll> 
#define pq1 priority_queue<ll>
#define pq2 priority_queue<ll, vector<ll>,greater<ll>>
typedef long long ll;
typedef vector<ll> vll;
typedef bool B;
typedef double ff;
const ll INF=1e10;
const ll N = 100005;
char en='\n';   
ll m[100001];
         void solve()
         {
            ll n; cin>>n;
            ll a[n],ans=0;
            rep(i,0,n)
            cin>>a[i];
            rep(i,1,n)
            {
               if(a[i]<a[i-1])
               {
                  ans+=a[i-1]-a[i];
                  a[i]=a[i-1];
               }
            }
            cout<<ans;
         } 
         int main() 
         { 
            ios_base::sync_with_stdio(false);cin.tie(NULL); 
            
            #ifndef ONLINE_JUDGE 
            freopen("input.txt", "r", stdin); 
            freopen("error.txt", "w", stderr); 
            freopen("output.txt", "w", stdout); 
            #endif 
            
            int t=1; 
            //cin>>t; 
            while(t--) 
            { 
               solve(); 
               cout<<"\n"; 
            } 
            
            cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
            return 0; 
         }                 


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

#define DEBUG 1

#if (DEBUG == 1)

#endif

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

  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int ans = -1;

  int from_num = 1;
  for (int i = 0; i < N; i++) {
    int next_num = a.at(from_num-1);
    if (next_num == 2) {
      ans = i+1;
      break;
    } else {
      from_num = next_num;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
MOD = 10**9+7
a = set()
for i in range(M):
    a.add(int(input()))
step = [0]*(N+1)
step[0] = 1
for i in range(N+1):
    if i == 0:
        pass
    elif i in a:
        step[i] = 0
    elif i == 1:
        step[i] = step[0]
    else:
        step[i] = step[i-1]+step[i-2]
    step[i] %= MOD
print(step[N])


Measured memory_bytes: 11884
from pprint import pprint
 
# import math
# import collections
 
n = int(input())
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
t, x, y = [0], [0], [0]
d = [0]
dd = [0]
td = [0]
 
for i in range(1, n + 1):
    _t, _x, _y = map(int, input().split(' '))
    t.append(_t)
    x.append(_x)
    y.append(_y)
 
    d.append(abs(x[i] - x[0]) + abs(y[i] - y[0]))
    dd.append(abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]))
    td.append(t[i] - t[i-1])
 
# 時刻の奇遇と距離の奇遇は一致する
# d <= t である
movable = [False] * (n + 1)
 
for i in range(n + 1):
    if d[i] <= t[i] and (t[i] % 2 == d[i] % 2) and dd[i] <= td[i]:
        movable[i] = True
 
if all(movable):
    res = 'Yes'
else:
    res = 'No'
 
# pprint(d)
# pprint(movable)
print(res)

Measured memory_bytes: 24832
n=int(input())
L={}
ans=0
for i in range(n):
    s=''.join(sorted(list(input())))
    if s in L:
        L[s]+=1
    else:
        L[s]=1

for i in L.values():
    if i>1:
        ans+=(i*(i-1))//2
    else:
        continue
print(ans)


Measured memory_bytes: 17808
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpcombination[10000][10000];

ll modi = 1000000007;
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) % modi + combination(n - 1, r) % modi; }
}

void clockman(int time1) {

	cout << 1.0*(clock() - time1) / CLOCKS_PER_SEC << endl;
	return;
}
//cout << fixed << setprecision(10)



int main() {



	ll a;
	long double b;
	cin >> a >> b;
	//ll c = 100 * b;
	ll ans = a * b / 1;

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3736
import java.util.Scanner;

public class Main {
	void slore(){
		int a,b;
		Scanner s1 = new Scanner(System.in);
		a = s1.nextInt();
		b = s1.nextInt();
		if(a > b){
			System.out.println("a > b");
		}else if(a < b){
			System.out.println("a < b");
		}else{
			System.out.println("a == b");
		}
	}
	public static void main(String args[]){
		Main m1 = new Main();
		m1.slore();
	}
}

Measured memory_bytes: 26140
from collections import defaultdict, Counter
class UF():
  def __init__(self, N):
    self.parents = [-1] * (N+1)

  def union(self, f, t):
    p1 = self.find(f)
    p2 = self.find(t)
    if p1 == p2:
      return

    if self.parents[p1] > self.parents[p2]:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

  def find(self, node):
    if self.parents[node] < 0:
      return node
    else:
      self.parents[node] = self.find(self.parents[node])
      return self.parents[node]

  # def members(self, n):
  #   root = self.find(n)
  #   if root == -1:
  #     return []
  #   import pdb; pdb.set_trace()
  #   return [ i for i, p in enumerate(self.parents) if self.find(i) == root]

N,K,L = map(int, input().split())
uf_road = UF(N)
uf_railway = UF(N)

for _ in range(K):
  f,t = map(int, input().split())
  uf_road.union(f,t)

for _ in range(L):
  f,t = map(int, input().split())
  uf_railway.union(f,t)

l = []
for i in range(1, N+1):
  l.append((uf_road.find(i), uf_railway.find(i)))

c = Counter(l)
for i in range(N):
  print(c[l[i]], end=" ")


Measured memory_bytes: 108704
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int q;
    cin >> q;
    multiset<ll> sl, sr;
    sl.emplace(-LINF);
    sr.emplace(LINF);
    ll suma = 0, sumb = 0;
    REP(i,q){
        int Q;
        cin >> Q;
        if(Q == 1){
            ll a,b;
            cin >> a >> b;
            sumb += b;
            auto itr = sl.end();
            itr--;
            if((sl.size() + sr.size()) % 2 == 0){
                if(a < *itr) suma += *itr - a;
                else if(*sr.begin() < a) suma += a - *sr.begin();
            }else{
                suma += abs(*itr - a);
            }
            if(a < *itr) sl.emplace(a);
            else sr.emplace(a);
            if(sl.size() < sr.size()){
                sl.emplace(*sr.begin());
                sr.erase(sr.begin());
            }else if(sr.size() < sl.size() - 1){
                auto itr = sl.end();
                itr--;
                sr.emplace(*itr);
                sl.erase(itr);
            }
        }else{
            auto itr = sl.end();
            itr--;
            ll x = *itr;
            cout << x << " " << suma + sumb << endl;
        }
    }
    return 0;
}

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

S = input()

A = set(S)

for x in ascii_lowercase:
	if not x in A:
		print(S+x)
		break
else:
	B = [S[-1]]
	for i in range(len(S)-2, -1, -1):
		for X in B:
			if S[i] < X:
				print(S[:i]+X)
				exit()
		else:
			insort(B, S[i])
	else:
		print(-1) 



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

int main()
{
    string org = "CODEFESTIVAL2016";
    string in;
    int ans = 0;

    cin >> in;
    for (int i = 0; i < 16; i++) {
        if (org[i] != in[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100000
#define INFTY 100000000

typedef struct{
  char suit;
  int num;
}Card;

void quicksort(Card *,int,int);
int partition(Card *,int,int);
void merge(Card *,int,int,int);
void mergesort(Card *,int,int);
void swap(Card *,Card *);

Card L[MAX/2 + 2],R[MAX/2 + 2];

int main(){
  Card c1[MAX],c2[MAX];
  int i,n,v;
  char P[20];
  int stable = 1;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",P,&v);
    c2[i].suit = c1[i].suit = P[0];
    c2[i].num = c1[i].num = v;
  }
  
  mergesort(c1,0,n);
  quicksort(c2,0,n-1);

  for(i=0;i<n;i++){
    if(c1[i].suit != c2[i].suit)stable = 0;
  }
  
  if(stable == 1)printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++){
    printf("%c %d\n",c2[i].suit,c2[i].num);
  }

 
          
  return 0;
}


void merge(Card A[],int left,int mid,int right){
  int n1=0;
  int n2=0;
  int i,j,k;

  n1 = mid - left;
  n2 = right - mid;

  for(i=0;i<=n1;i++)L[i]=A[left + i];
  for(i=0;i<=n2;i++)R[i]=A[mid + i];

  L[n1].num =INFTY;
  R[n2].num =INFTY;

  i=j=0;
  for(k=left;k<right;k++){
    
    if(L[i].num <= R[j].num){
      A[k]=L[i++];
    }

    else {
      A[k]=R[j++];
    }
  }
}

void mergesort(Card A[],int left,int right){
  int mid=0;

  if(left + 1 < right){
    mid = (left + right) / 2;

    mergesort(A,left,mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
}


void swap(Card *in,Card *out){
  Card temp;

  temp = *in;
  *in = *out;
  *out = temp;
}

int partition(Card A[],int p,int r){
  Card x;
  int i=0;
  int j;
   
  x = A[r];
  i = p-1;

  for(j=p;j<r;j++){
    if(A[j].num <= x.num){
      i = i+1;
      swap(&A[i],&A[j]);

    }
  }
  swap(&A[i+1],&A[r]);
  
  return i+1;
}

void quicksort(Card A[],int p,int r){
  int q;

  if(p<r){
    q = partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}



Measured memory_bytes: 4080
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=1e5+10;

int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll value[mx];
ll n;
cin>>n;
for(int i=0;i<n;i++) cin>>value[i];
sort(value, value+n);

ll q;
cin>>q;

for(ll i=1;i<=q;i++){
    ll k;
    cin>>k;
    ll sub=lower_bound(value, value+n, k)-value;
    printf("%lld\n", sub);
}

#ifdef LOCAL
fin.close();
#endif // LOCAL
}



Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FORE(x,c) for(auto &x:c)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is>>*i; return is; }
//------------------------------------------------------------------------------

signed main() {
    int N;
    cin>>N;
    string s,t,u;
    cin>>s>>t;
    u=s+t;
    int ans=SZ(u);
    FOR(i,1,N+1) {
        if(s.substr(N-i,i)==t.substr(0,i)) {
            ans=min(ans,SZ(u)-i);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		sc.fill(a);

		Set<Integer> used = new HashSet<>();
		int next = a[0];
		int count = 1;
		do {
			if (next == 2) {
				System.out.println(count);
				return;
			}

			count++;
			next = a[next - 1];
		} while (used.add(next));

		System.out.println(-1);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 28500
#include <stdio.h>

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

int gcd_arr(int a[], int n){
    if(n==2){
        return gcd(a[0], a[1]); 
    }else{
        a[n-2] = gcd(a[n-2], a[n-1]);
        /* 後ろの2つをgcd処理 */

        return gcd_arr(a, n-1);
        /* 再帰する */
    }
}

int main(){
    int K;scanf("%d", &K);
    int a, b, c;
    long long sum=0;
    int n[3];
    for(a=1;a<=K;a++)for(b=1;b<=K;b++)for(c=1;c<=K;c++){
        n[0]=a;n[1]=b;n[2]=c;
        sum += gcd_arr(n, 3);
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 1732
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
k = int(arr_data[0][2])

#print(a,b,k)

s1=set()

cnt=0

for i in range(a,b+1):
    
#    print(i)

    if cnt<k:
        
        s1.add(i)
        cnt+=1
    else:
        break
        
cnt=0
for i in range(b,a-1,-1):
    
    if cnt<k:
        
        s1.add(i)
        cnt+=1
    else:
        
        break
        
#print(s1)
list01=sorted(list(s1),reverse=False)
#print(list01)
#print(list(map(str, list01)))
print("\n".join(list(map(str, list01))))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  for(int b=0;b<(1<<3);++b){
    int ans = S[0] - '0';
    for(int i=1;i<4;++i){
      if(b & (1<<(i-1))){
        ans += S[i] - '0';
      }else{
        ans -= S[i] - '0';
      }
    }
    if (ans == 7){
      for(int i=0;i<3;++i){
        cout << S[i];
        if(b & (1<<i)){
          cout << '+';
        }else{
          cout << '-';
        }
      }
      cout << S[3] << "=7" << endl;
      return 0;
    }
  }



}


Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define md 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
}
ll mem[(int)1e5 + 10];
int main()
{
	Mohammed_Atef_Hassan
		int n, k;
	cin >> n >> k;
	vector<ll>v(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	for (int i = 0; i <= v[0]; i++)
	{
		mem[i] = 1;
	}
	for (int i = 1; i <= k; i++)
		mem[i] += mem[i - 1];
	for (int i = 1; i < n; i++)
	{
		for (int j = k; j >=0; j--)
		{
			if (j - v[i] > 0)mem[j] -= mem[j - v[i] - 1];
			mem[j] %= md; mem[j] += md; mem[j] %= md;
		}
		for (int j = 1; j <= k; j++)
			mem[j] += mem[j - 1],mem[j]%=md;
	}
	cout << ((mem[k] - (k==0?0:mem[k - 1])) % md + md) % md;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)



using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}


int main() {
    int n;
    float t,a;
    float Min = 10000000;
    float ans = 0;
    float tmp;

    cin >> n >> t >> a;

    for(int i = 0; i < n; i ++){
        cin >> tmp;
        if(Min > abs(a-(t-tmp*0.006f))){
            Min = abs(a-(t-tmp*0.006f));
            ans = i;
        }
    }

    cout << ans+1;
    return 0;
}











Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, M; cin >> N >> M;
  vector<bool> bs(N + 1);
  while (M--)
    {int a; cin >> a;
    bs[a] = true;}
  vector<long long> dp(N + 1);
  dp[0] = 1;
  for (int i = 1; i <= N; ++i)
    {if (!bs[i]) dp[i] = (dp[i - 1] + (i < 2 ? 0 : dp[i - 2])) % 1000000007;}
  cout << dp[N] << endl;}

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

using namespace std;

char s[10];

int main() {
	scanf("%s", s);
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
		puts("3");
	else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))
		puts("2");
	else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
		puts("1");
	else 
		puts("0");
	return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] odd = str.split("");
		str = br.readLine();
		String[] even = str.split("");
		for (int i = 0; i < even.length; i++) {
			System.out.print(odd[i] + even[i]);
		}
		if (odd.length > even.length)
			System.out.println(odd[odd.length - 1]);
		else
			System.out.println();
	}
}


Measured memory_bytes: 21460
#include <cstdio>
#include <algorithm>
#include <stdint.h>

int64_t as[200005];

int main(){
  int64_t N,X;
  scanf("%ld %ld",&N,&X);
  for(int i=1;i<=N;i++){
    scanf("%ld",&as[i]);
    as[i]+=as[i-1];
  }
  int64_t best=9e18;
  for(int64_t k=1;k<=N;k++){
    int64_t cost=(N+k)*X+5*as[N];
    for(int i=N-2*k;i>0;i-=k){
      if(cost>9e18-2*as[i]){
	cost=9e18;
	break;
      }
      cost+=2*as[i];
    }
    best=std::min(best,cost);
  }
  printf("%ld\n",best);
  return 0;
}


Measured memory_bytes: 1664
import java.util.*;
 class Main {
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int x = sc.nextInt();
      int t = sc.nextInt();
      int a = 0;
      
      if(n%x > 0) a = 1;
      System.out.println(((n / x) + a )* t) ;
      
      sc.close();
      
    }
 }


Measured memory_bytes: 35780
#include<bits/stdc++.h>
using namespace std;
char s[105];
char a[105];
char b[]="keyence";
int main()
{
	int flag=0;
	scanf("%s",s);
	int len = strlen(s);
	if(strcmp(s,b)==0)
		printf("YES\n");
	else
	{
		for(int i=0;i<len;i++)
		{
			for(int j=i;j<len;j++)
			{
				int tot=0; 
				for(int k=0;k<len;k++)
				{
					if(k<i || k>j)
					{
						a[tot++]=s[k];
					}
				}
				a[tot]='\0';
				if(strcmp(a,b)==0)
					flag=1;
			}
		} 
		if(flag)
			printf("YES\n");
		else
			printf("NO\n");
	}
	  
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod2=1000000007;
ll mod=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int h,w;cin>>h>>w;
    int a[h][w];rep(i,0,h)rep(j,0,w)cin>>a[i][j];
    int nh=0,nw=0;
    vector<pii> v,vv;
    int cnt=0;
    for(;;){
        cnt++;
        if(cnt==h*w)break;
        int tw=nw,th=nh;
        if(nh%2==0){
            tw++;
            if(tw==w){
                tw=w-1;
                th++;
            }
        }
        else{
            tw--;
            if(tw==-1){
                tw=0;
                th++;
            }
        }
        if(a[nh][nw]%2==1){
            v.push_back(make_pair(nh,nw));
            vv.push_back(make_pair(th,tw));
            a[th][tw]++;
        }
        nh=th;nw=tw;
    }
    cout<<v.size()<<endl;
    rep(i,0,v.size()){
        cout<<v[i].first+1<<" "<<v[i].second+1<<" "<<vv[i].first+1<<" "<<vv[i].second+1<<endl;
    }
}


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

void solve(long long K, std::string S)
{
    long long size = S.size();
    if (size <= K)
    {
        cout << S << endl;
    }
    else if (size > K)
    {
        cout << S.substr(0, K) << "..." << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long K;
    scanf("%lld", &K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


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

public class ABC137_A {
    private static void Main(string[] args) {
      	var inputs1 = Read1LineAsIntArray();
      	var h = inputs1[0];
        var n = inputs1[1];
      	var a = Read1LineAsIntArray();
        
        if (a.Sum() >= h) 
			Console.WriteLine("Yes");
        else
			Console.WriteLine("No");
    }
  
    private static int[] Read1LineAsIntArray() => Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray();
}

Measured memory_bytes: 17632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ull bin(ull a, ull b)
{
    if(a%mod==0) return 0;
    ull res = 1;
    a %= mod;
    while(b)
    {
        if(b&1) res = (res*a)%mod;
        b >>= 1;
        a *= a;
        a%=mod;
    }
    return res%mod;
}

int main()
{
    int n, a;
    cin>>n>>a;
    cout<<int(ceil(float(n)/a))<<endl;
}

Measured memory_bytes: 256
import java.util.*;

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

    double x1 = sc.nextDouble();
    double y1 = sc.nextDouble();
    double x2 = sc.nextDouble();
    double y2 = sc.nextDouble();

    System.out.println(Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)));
  }
}



Measured memory_bytes: 27980
// luogu-judger-enable-o2
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstring>
#define ll long long
#define maxn 100005
#define ll long long
#define re(i,a,b) for(int i=a;i<=b;i++)
#define for_edge(x) for(int i=head[x];i;i=e[i].nxt)
using namespace std;
inline int read(){char c=getchar();int f=1;int ans = 0;while(c>'9'||c<'0'){if(c=='-')f=-f;c=getchar();}while(c<='9'&&c>='0'){ans =ans*10+c-'0';c=getchar();}return ans*f;}
//______________________________________________________________________________________
int n;
int v[maxn]; 
int cnt[16];
bool bo[1<<15];
int dp[1<<15];
int main()
{
	//freopen("0.in","r",stdin);
	n = read();
	re(i,1,n-1)
	{
		int x = read() ,y =read(), k=read();
		v[x] ^=k; v[y] ^= k;
	}
	re(i,0,n-1)	
		cnt[ v[i] ]++;
	ll ans = 0,s=0;;
	re(i,1,15)
	{
		ans += cnt[i] /2 ;
		//printf("%d ",cnt[i]);
		s|=(cnt[i]&1)<<i-1;
	}
	//printf("%\d",s);
	re(i,0,(1<<15)-1)
	{
		int sum = 0;
		re(j,1,15)
			if((i>>j-1)&1)
				sum^=j;
		if(!sum) bo[i] = 1;
	}
	re(i,1,(1<<15)-1)
		if(bo[i])
		{
			
			for(int j=i;j;j-=j&-j,dp[i]++);dp[i]--;
			for(int j=i;j;j=(j-1)&i)
				if(bo[j])
					dp[i] = min( dp[i] , dp[j] + dp[j^i] );
			//for(int j=15;j;j--) 
			//printf("%d",(i>>j-1)&1);printf(" %d\n",dp[i]);
		}
	printf("%\d",ans+dp[s]);
	
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

constexpr int MAX = 10000;

bool isPrime(int n);

int main()
{
    vector<int> prime_list;
    prime_list.reserve(MAX);

    int p = 2;
    while (prime_list.size() != MAX) {
        if (isPrime(p)) {
            prime_list.push_back(p);
        }
        p++;
    }

    int n;
    while (cin >> n && n != 0) {
        int sum = 0;
        for (auto i = 0; i < n; i++) {
            sum += prime_list.at(i);
        }
        cout << sum << endl;
    }

    return 0;
}

bool isPrime(int n)
{
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
int main() {
	int n; cin >> n;
	vint a(n);
	ll ans=0;
	rep(i,n) {
		cin >> a[i];
		ans+=a[i];
	}
	cout << ans-n << endl;
}


Measured memory_bytes: 3632
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int a = sc.nextInt();
    if(h%a!=0)
    System.out.println((h/a)+1);
    else{
	System.out.println((h/a));
    }
  }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
 
public class Main {
	static List<Long> a;
	static List<Long> b;
	static List<Long> c;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int k = sc.nextInt();
		a = new ArrayList<>();
		b = new ArrayList<>();
		c = new ArrayList<>();
		for(int i =0; i < x; i++)
			a.add(Long.parseLong(sc.next()));
		for(int i = 0; i < y; i++)
			b.add(Long.parseLong(sc.next()));
		for(int i = 0; i < z; i++)
			c.add(Long.parseLong(sc.next()));
		
		Collections.sort(a, Collections.reverseOrder());
		Collections.sort(b, Collections.reverseOrder());
		Collections.sort(c, Collections.reverseOrder());
		
		List<Long> ab = new ArrayList<>();
		for(int i = 0; i < x; i++)
			for(int j = 0; j < y; j++)
				ab.add(a.get(i) + b.get(j));
		Collections.sort(ab, Collections.reverseOrder());
		int size = Math.min(k, ab.size());
		List<Long> abc = new ArrayList<>();
		
		for(int i = 0; i < size; i++) 
			for(int j = 0; j < z; j++)
				abc.add(ab.get(i) + c.get(j));
		
		Collections.sort(abc, Collections.reverseOrder());

		for(int i = 0; i < k; i++)
			System.out.println(abc.get(i));
	}
}
class Scanner {
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = -1;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == -1)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
}

Measured memory_bytes: 189172
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n1 = sc.nextInt();
	int n2 = sc.nextInt();
	System.out.println(euc(n1,n2));
    }
    private static int euc(int n1, int n2){
	if(n1 < n2) return euc(n2,n1);
	if(n2 == 0) return n1;
	return euc(n2,n1%n2);
    }
}



Measured memory_bytes: 26340
n, m = gets.split.map(&:to_i)
p = Array.new()
s = Array.new()
m.times do
    pi, si = gets.chomp.split
    p.push(pi.to_i)
    s.push(si)
end


ac = Array.new(n+1, false)
wa = Array.new(n+1, 0)
account = 0
wasum = 0
for i in 0..m-1
    if ac[p[i]] then
       next
    end

    if s[i] == 'WA'
        wa[p[i]] += 1
    else
        account += 1
        wasum += wa[p[i]]
        ac[p[i]] = true
    end
end

puts "#{account} #{wasum}"


Measured memory_bytes: 11900