akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 998244353
using namespace std;


int main(){
    int X,Y;
    cin >> X >> Y;
    int ans =0;
    
    if(X==1 && Y==1){
        ans +=300000+300000+400000;
    }else{
        if(X==1){
            ans += 300000;
            
        }else if(X==2){
            ans+=200000;
        }else if(X==3){
            ans+=100000;
        }
        
        if(Y==1){
            ans+=300000;
        }else if(Y==2){
            ans+=200000;
        }else if(Y==3){
            ans+=100000;
        }
    }
    cout<<ans<<endl;
    return 0;
    
}


Measured memory_bytes: 256
a = list(input())
k = 0
for i in range(len(a)):
	if i == 0 and a[i] != "A":
		k = 1
		break
	elif i == 0:
		k = k
	elif i >= 2 and i <= len(a)-2:
		if a[i] == "C":
			k += 2
		elif a[i] <= "z" and a[i] >= "a":
			k = k
		else:
			k = 1
			break
	else:
		if a[i] <= "z" and a[i] >= "a":
			k = k
		else:
			k = 1
			break
if k == 2:
	print("AC")
else:
	print("WA")


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int K,i,j,d[11][10];
    scanf("%d",&K);
    for(i=0;i<10;i++)
        d[1][i]=1;
    for(i=1;i<11;i++){
        if(i==1)continue;
        for(j=0;j<10;j++){
            d[i][j]=0;
            if(j-1>=0)
                d[i][j]+=d[i-1][j-1];
            d[i][j]+=d[i-1][j];
            if(j+1<=9)
                d[i][j]+=d[i-1][j+1];  
        }
    }
    int s[11][10];
    for(i=1;i<11;i++){
        for(j=0;j<=9;j++){
            if(i==1)
                s[i][j]=j;
            else if(j-1>=0)
                s[i][j]=d[i][j]+s[i][j-1];
            else 
                s[i][j]=s[i-1][9];
        }
    }

    int ans[100],k=0,flag=0;
    int up,down;
    for(i=1;i<11;i++){
        for(j=1;j<=9;j++){
            ans[k]=j;
            if(s[i][j]>=K){
                K-=s[i][j-1];
                flag=1;
                break;
            }
        }
        if(flag)break;
    }
//    printf("keta=%d\n",i);

    for(k=0;i-k-1>=1;k++){
        down = ans[k]-1>0? ans[k]-1:0;
        up = ans[k]+1<=9? ans[k]+1:9;
        for(j=down;j<=up;j++){
            ans[k+1]=j;
            if(d[i-k-1][j]>=K){
                break;
            }
            else{
                K-=d[i-k-1][j];
            }
        }
    }
    for(k=0;k<i;k++)
        printf("%d",ans[k]);
    puts("");
//    int a,b;
//    while(~scanf("%d%d",&a,&b)){
//        printf("%d\n",s[a][b]);
//    }



return 0;
}

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

int main()
{
    int n,k,x,y,a,sum;
    cin>>n>>k>>x>>y;

    sum = 0;
    if(n>k)
    {
        a = n-k;
        while(k--)
            sum += x;
        while(a--)
            sum += y;
    }
    else
    {
        while(n--)
            sum += x;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main()
{
    int n;
    cin >> n;
    V dic(9, 0);
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a >= 1 && a <= 399)
        {
            dic[0]++;
        }
        else if (a >= 400 && a <= 799)
        {
            dic[1]++;
        }
        else if (a >= 800 && a <= 1199)
        {
            dic[2]++;
        }
        else if (a >= 1200 && a <= 1599)
        {
            dic[3]++;
        }
        else if (a >= 1600 && a <= 1999)
        {
            dic[4]++;
        }
        else if (a >= 2000 && a <= 2399)
        {
            dic[5]++;
        }
        else if (a >= 2400 && a <= 2799)
        {
            dic[6]++;
        }
        else if (a >= 2800 && a <= 3199)
        {
            dic[7]++;
        }
        else
        {
            dic[8]++;
        }
    }
    int ma = 0, mi = 0;
    for (int i = 0; i < 8; i++)
    {
        if (dic[i] > 0)
        {
            mi++;
        }
    }
    ma = mi + dic[8];
    if (mi == 0)
    {
        mi = 1;
    }
    cout << mi << " " << ma << endl;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  int ans=1;
  for(int i=0;i<N;i++){
    if(ans<K){
      ans*=2;
    }else{
      ans+=K;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<sstream>
using namespace std;
typedef long long ll;
string i2s(ll x){
  if(x==0) return "0";
  string y;
  ll k=1;
  while(x>=k) k*=10;
  k/=10;
  for(ll i=k;i>0;i/=10){
    y+=(x/i)%10+'0';
  }
  return y;
}
ll s2i(string x){
  for(ll i=0;i<x.size();i++) if(x[i]=='.') x[i]=' ';
  stringstream ss(x);
  ll y;
  ss >> y;
  return y;
}
int main(){
  //cout << i2s(100) << endl;
  ll n;
 
  while(cin>>n,n){
    string buf;
    vector<string> v;
    vector<ll> d;
    ll i,j,k;
    for(i=0;i<n;i++){
      cin >> buf;
      j=0;
      while(buf[j]=='.') j++;
      v.push_back(buf);
      d.push_back(j);
    }
    while(v.size()!=1){
      //for(i=0;i<v.size();i++) cout << v[i] << endl;
      //cout << endl;
      //cout << v.size() << endl;
      k=1;
      for(i=0;i<v.size();i++){
        if(d[k]<d[i]) k=i;
      }
      //cout << k << ":" << v[k-1][v[k-1].size()-1] << endl;
      if(v[k-1][v[k-1].size()-1]=='+'){
        i=0;j=0;
        while(1) {
          if(d[k]!=d[k+i]) break;
          //j*=(v[k+i][v[k+i].size()-1]-'0');
          j+=s2i(v[k+i]);
          i++;
          if(k+i==d.size()) break;
        }
        //cout << i << ":" << j << endl;
        v[k-1]=v[k-1].substr(0,v[k-1].size()-1);
        v[k-1]+=i2s(j);
        v.erase(v.begin()+k,v.begin()+k+i);
        d.erase(d.begin()+k,d.begin()+k+i);
      }
      if(v[k-1][v[k-1].size()-1]=='*'){
        i=0;j=1;
        while(1) {
          if(d[k]!=d[k+i]) break;
          //j*=(v[k+i][v[k+i].size()-1]-'0');
          j*=s2i(v[k+i]);
          i++;
          if(k+i==d.size()) break;
        }
        //cout << i << endl;
        v[k-1]=v[k-1].substr(0,v[k-1].size()-1);
        v[k-1]+=i2s(j);
        v.erase(v.begin()+k,v.begin()+k+i);
        d.erase(d.begin()+k,d.begin()+k+i);
      }
       
    }
    cout << v[0] << endl;
  }
  return 0;
}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int N,M;

vector< pair<int, int> > p;

int cnt,temp;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> M;

    REP(j,M){
        int x,y;
        cin >> x >> y;

        p.push_back(pair<int, int>(x, y));

    }

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


/*    for (int i = 0; i < M; i++) {
      printf("(%d,%d) ", p[i].first, p[i].second);
    }
*/
    temp = p[0].second;

    REP(i, M){

        if( i >= 1){

            if( p[i].first <=  p[i-1].second){

                if( temp > p[i].second){
                    temp = p[i].second;
                }
            }
            //dump(temp);

            if( p[i].first >=  temp){
                //dump(p[i].first);
                //dump(p[i].second);
                cnt++;
                temp = p[i].second;
            }

        }

    }

    cout << cnt + 1<< endl;








    return 0;
}


Measured memory_bytes: 1528
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    string s;
    int ans=0;
    cin>>s;
    for(int i=1;i<s.length();i++)
    {
        if(s[i]!=s[i-1]){ans++;}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char n;
    cin>>n;
    
    if(n=='A')
    { cout<<'T';}
    
    else if(n=='G')
    { cout<<'C';}
    
    else if(n=='T')
    { cout<<'A';}
    
    else cout<<'G';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[2005];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,x,y,hhh;
	cin >> n >> x >> y;
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			hhh=min(abs(i-j),abs(i-x)+abs(j-y)+1);
			//cout << i << " " << j << " " << hhh << endl;
			a[hhh]++;
		}
	}
	for(int i=1;i<n;i++){
		cout << a[i] << endl;
	} 
	return 0;
}

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

int main() {
	string s,t;
  	cin>>s>>t;
  
  	int seikai;
  
  	if(s[0]==t[0]){
    	seikai++;
    }
  	if(s[1]==t[1]){
    	seikai++;
    }
  
  	if(s[2]==t[2]){
    	seikai++;
    }  
  
  cout<<seikai<<endl;
  
}

Measured memory_bytes: 256
program prob3
    implicit none
    integer(8) :: a,b,c,cnt,tmp1, tmp2
    read(*,*) a,b,c

    if(.not.(mod(a,2) == 0 .and. mod(b,2) == 0 .and. mod(c,2) == 0)) then
        write(*,*) '0'
        stop
    end if

    if(a == b .and. b == c) then
        write(*,'(a)') '-1'
        stop
    end if

    cnt = 0
    do while(mod(a,2) == 0 .and. mod(b,2) == 0 .and. mod(c,2) == 0)
        tmp1 = (a+b)/2
        tmp2 = (b+c)/2
        b = (c+a)/2
        c = tmp1
        a = tmp2
        cnt = cnt + 1
    end do

    write(*,'(i9)') cnt 


    stop
contains
end program prob3

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring> 
using namespace std;
bool vis[10];
bool judge(int x){
    while(x){
        int temp=x%10;
        if(vis[temp])
            return false;
        x/=10;
    }
    return true;
}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
 
    memset(vis,false,sizeof(vis));
    for(int i=1;i<=k;i++){
        int x;
        scanf("%d",&x);
        vis[x]=true;
    }
 
    for(int i=n; ;i++){
        if(judge(i)){
            printf("%d\n",i);
            break;
        }
    }
    return 0;
} 


Measured memory_bytes: 3216
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

#define UNDEF -1

struct node{
	int parent = 0;
	int left = 0;
	int right = 0;
};

void Preorder_Rec(vector<node> tree, int root){
	cout << " " << root;
	if (tree[root].left != UNDEF) Preorder_Rec(tree, tree[root].left);
	if (tree[root].right != UNDEF) Preorder_Rec(tree, tree[root].right);
	return;
}

void Inorder_Rec(vector<node> tree, int root){
	if (tree[root].left != UNDEF) Inorder_Rec(tree, tree[root].left);
	cout << " " << root;
	if (tree[root].right != UNDEF) Inorder_Rec(tree, tree[root].right);
	return;
}

void Postorder_Rec(vector<node> tree, int root){
	if (tree[root].left != UNDEF) Postorder_Rec(tree, tree[root].left);
	if (tree[root].right != UNDEF) Postorder_Rec(tree, tree[root].right);
	cout << " " << root;
	return;
}

int main(){

	int n;
	cin >> n;
	int id, left, right, prec;
	node nullnode;
	nullnode.parent = UNDEF;
	nullnode.left = UNDEF;
	nullnode.right = UNDEF;
	vector<node> tree(n, nullnode);
	for (int i = 0; i < n; i++){
		cin >> id >> left >> right;
		tree[id].left = left;
		tree[id].right = right;
		if (left != UNDEF) tree[left].parent = id;
		if (right != UNDEF) tree[right].parent = id;
	}

	int root;
	for (int i = 0; i < tree.size(); i++){
		if (tree[i].parent == UNDEF){
			root = i;
			break;
		}
	}
	cout << "Preorder" << endl;
	Preorder_Rec(tree, root);
	cout << endl << "Inorder" << endl;
	Inorder_Rec(tree, root);
	cout << endl << "Postorder" << endl;
	Postorder_Rec(tree, root);
	cout << endl;

	return 0;
}


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

use std::collections::HashMap;

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let mut ans: usize = 0;
    let mut b: Vec<usize> = Vec::new();
    for i in 0..n {
        b.push(i + a[i]);
    }
    let mut c: Vec<isize> = Vec::new();
    for j in 0..n {
        c.push(j as isize - a[j] as isize);
    }
    let mut map = HashMap::new();
    for i in 0..n {
        let count = map.entry(b[i]).or_insert(0);
        *count += 1;
    }
    
    for j in 0..n {
        if c[j] < 0 {
            continue;
        }
        let number = map.get(&(c[j] as usize));
        match number {
            Some(&i) => ans += i,
            _ => (),
        }
    }
    println!("{}", ans);
}


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

int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    int t;
    int p = 1;
    string pre = "";
    string post = "";
    for (int i = 0; i < q; i++) {
        cin >> t;
        if (t == 1) p *= -1;
        else {
            char c;
            int f;
            cin >> f >> c;
            if ((p > 0 & f == 1) | (p < 0 & f == 2)) pre += c;
            else post += c;
        }
    }
    if (p < 0) {
        reverse(post.begin(), post.end());
        reverse(s.begin(), s.end());
        cout << post << s << pre << endl;
    }
    else {
        reverse(pre.begin(), pre.end());
        cout << pre << s << post << endl;
    }
}


Measured memory_bytes: 960
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i, n)
    {
        cin >> b[i];
    }
    ll mi = 0, pl = 0;
    ll diff = 0;
    rep(i, n)
    {
        c[i] = a[i] - b[i];
    }
    rep(i, n)
    {
        if (c[i] > 0)
        {
            pl += c[i];
        }
        else
        {
            mi -= c[i] / 2;
        }
        cerr << c[i] << " ";
    }
    cerr << endl;
    cerr << pl << " " << mi << " " << diff << endl;
    if (pl <= mi)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
 string order;
 int price = 700;
 cin >>  order;
 for(int i=0; i<3; ++i)
  if( order[i] == 'o' )
   price += 100;

 cout << price; 

 return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	//ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI w(N);
		REP(i, N) cin>>w[i];
		sort(ALL(w));
		ll ans = w[N-1]-w[0];
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
use std::io::{self, Read};

fn main() {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).unwrap();
    let mut iter = buffer.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();

    if n == 1 {
        println!("Hello World");
    } else {
        let a: usize = iter.next().unwrap().parse().unwrap();
        let b: usize = iter.next().unwrap().parse().unwrap();
        println!("{}", a + b);
    }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
using ll = long long;

int a,b;
string s, t;

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> s >>t;
        if(s == t)a++,b++;
        else if(s > t)a+=3;
        else b+=3;
    }
    cout << a << " " << b << endl;
}


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

#define ll long long
#define value(x) cout<<#x<<" "<<x<<'\n';
#define print_vec(vec) for(auto x: vec) cout<<x<<" "; \
                        cout<<endl;

void solve()
{
	ll n;
	cin >> n;
	ll temp = n;
	string alpha = "abcdefghijklmnopqrstuvwxyz";
	string res = "";

	while (temp > 0) {
		temp --;
		int temp1 = (temp) % 26;
		res += alpha[temp1];

		temp = temp / 26;
		// value(temp);

	}
	reverse(res.begin(), res.end());
	cout << res << '\n';
}

int main()
{
	int t = 1;
	// cin >> t;
	while (t--)
		solve();
}


Measured memory_bytes: 3516
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
ab=[]
for _ in range(m):
	a,b=map(int,input().split())
	ab.append((a-1,b-1))
ab.reverse()
def same(x,y):
	return root(x)==root(y)
def unite(x,y):
	rx=root(x)
	ry=root(y)
	if rank[rx]<rank[ry]:
		if not same(rx,ry):
			size[ry]+=size[rx]
		parent[rx]=ry
	else:
		if not same(rx,ry):
			size[rx]+=size[ry]
		parent[ry]=rx
		if rank[rx]==rank[ry]:
			rank[rx]+=1
def root(x):
	if x!=parent[x]:
		x=root(parent[x])
	return x
rank=[0]*n
size=[1]*n
parent=list(range(n))
p=n*(n-1)//2
ans=[p]
for a,b in ab:
	if not same(a,b):
		ra=root(a)
		rb=root(b)
		p+=size[ra]*(size[ra]-1)//2
		p+=size[rb]*(size[rb]-1)//2
		unite(a,b)
		ra=root(a)
		e=size[ra]
		p-=e*(e-1)//2
	ans.append(p)
ans.reverse()
for i in range(m):
	print(ans[i+1])

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

void solve() {
	int n;
	cin >> n;
	long double a;
	long double ans = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		ans += (1.0 / a);
	}
	cout << fixed << setprecision(12) << 1 / ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3784
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
const int INF=0x3f3f3f3f;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int arr[MAXN],brr[MAXN];
int main()
{
    int a,b,m;
    while(cin>>a>>b>>m)
    {
        int sum=0;
        int a1=INF;
        int b1=INF;
        for(int i=1;i<=a;i++)cin>>arr[i],a1=min(a1,arr[i]);
        for(int i=1;i<=b;i++)cin>>brr[i],b1=min(b1,brr[i]);
        sum=a1+b1;
        while(m--)
        {
            int x,y,c;cin>>x>>y>>c;
            sum=min(sum,arr[x]+brr[y]-c);
        }
        cout<<sum<<endl;
    }
    return 0;
}


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

const int mod = 1e9 + 7;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; ++i)cin >> a[i];
	ll ans = 0;
	for (ll bit = 0; bit < 60; ++bit) {
		ll zero = 0;
		ll one = 0;
		for (ll i = 0; i < n; ++i) {
			if ((1ll << bit) & a[i]) ++one;
			else ++zero;
		}
		ll preans = 1;
		for (ll j = 0; j < bit; ++j) {
			preans *= 2;
			preans %= mod;
		}
		preans *= (zero * one) % mod;
		preans %= mod;
		ans = (ans + preans) % mod;

	}
	cout << ans << endl;
}


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

int main(){
	string s;
	cin >> s;
	long ans = 0;
	int n = s.size();
	for(long i=0; i < (1 << (n-1)); i++) {
		long pre = 0;
		string post = "";
		post += s.at(0);
		for(int j=1; j < n; j++) {
			if(i & (1 << (j-1))) {
				pre += stoll(post);
				post = "";
			}
			post += s.at(j);
		}
		ans += pre + stoll(post);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
mp = list(map(int,input().split()))
save = []
isSaved = [False]*(n+1)
s_queue = [[1,0]]
while(len(s_queue)>0):
    i,cnt = s_queue.pop()
    if(cnt==k):
        break
    if(isSaved[i]):
        last=mp[i-1]
        break
    nexti = mp[i-1]
    isSaved[i] = True
    save.append(nexti)
    s_queue.append([nexti,cnt+1])


ls = len(save)

if(k<=ls):
    print(save[k-1])
else:
    for i in range(ls):
        if(save[i]==last):
            si = i
    k -= si
    save = save[si:]
    ls = len(save)
    amari = k%ls
    print(save[amari-1])


Measured memory_bytes: 32400
program ABC111A
    implicit none
    integer(8)::i
    character(3)::n

    read(5,*)n

    do i=1,3
        if(n(i:i)=='9')then
            n(i:i)='1'
        else if(n(i:i)=='1')then
            n(i:i)='9'
        end if
    end do
    
    print'(A)',n
end program ABC111A

Measured memory_bytes: 256
import java.util.Scanner;

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

        for (int i = a; i < a + k && i <= b; i++) {
            System.out.println(i);
        }

        for (int i = Math.max(a + k, b - k + 1); i <= b; i++) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 21716
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int r;
    scanf("%d", &r);
    double ans = (double)r * 2 * 3.141592653589;
    printf("%.10lf\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 1744
import numpy as np

# 入力行N，列D
N, D = map(int, input().split())
points = [list(map(int, input().split())) for i in range(N)]

def calc_distance(p1, p2):
    sum = 0
    for i in range(len(p1)):
        sum += (p1[i] - p2[i]) ** 2
    return np.sqrt(sum)

count = 0
for i, point in enumerate(points):
    for point2 in points[i + 1:]:
        outp = calc_distance(point, point2)
        if outp.is_integer():
            count += 1

print(count)

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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;

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

    int t;
    cin>>t;

    if(t>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3608
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    long long i;
    long long n_human;
    long long capa[5];
    long long min_capa = LLONG_MAX;
    long long ans = 0;

    if ( scanf("%lld%lld%lld%lld%lld%lld",
               &n_human, &capa[0], &capa[1], &capa[2], &capa[3], &capa[4]) != 6 )
    {
        fprintf(stderr, "Invalid input\n");
        return EXIT_FAILURE;
    }

    for ( i=0; i<5; i++ ) {
        if ( min_capa > capa[i] )
            min_capa = capa[i];
    }

    /* bottleneck */
    ans += (n_human - 1) / min_capa + 1;
    /* other than bottleneck */
    ans += 4;

    printf("%lld\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll xl=-1e9;
const ll yl=-1e9;
const ll xr=1e9;
const ll yr=-1e9;
 
int main()
{
        ll Max1=-4e9, Max2=-4e9;
        ll Min1=4e9, Min2=4e9;
        int n;
        scanf("%d", &n);
        ll x, y;
        for(int i=1;i<=n;i++){
            scanf("%lld%lld", &x, &y);
            Max1=max(abs(x-xl)+abs(y-yl), Max1);
            Min1=min(abs(x-xl)+abs(y-yl), Min1);
            Max2=max(abs(x-xr)+abs(y-yr), Max2);
            Min2=min(abs(x-xr)+abs(y-yr), Min2);
        }
        ll ans=max(Max1-Min1, Max2-Min2);
        printf("%lld\n", ans);
    
}

Measured memory_bytes: 3824
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+50;
typedef long long ll;
ll a[maxn],b[maxn],c[maxn];
ll num1[maxn],num2[maxn];
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int i=0; i<n; i++)
    {
        cin>>b[i];
    }
    for(int i=0; i<n; i++)
    {
        cin>>c[i];
    }
    sort(a,a+n,cmp);
    sort(b,b+n,cmp);
    sort(c,c+n,cmp);
    memset(num1,0,sizeof(num1));
    memset(num2,0,sizeof(num2));

    for(int i=0; i<n; i++)
    {
        int pre,pos;
        pre=lower_bound(a,a+n,b[i])-a;
        //cout << pre <<endl;
        num1[i]=pre;
        pos=upper_bound(c,c+n,b[i])-c;
        //cout << pos <<" "<< c[pos] << endl;
        //while(c[pos]==b[i])
          //  pos++;
        num2[i]=n-pos;
        //cout << num2[i] <<endl;
    }
    ll all=0;
    for(int i=0; i<n; i++)
    {
        //cout << num1[i] << " " <<num2[i] <<endl;
        all+=num1[i]*num2[i]*1ll;
    }
    cout << all << endl;
    //cout << "Hello world!" << endl;
    return 0;
}
/*
6
2 3 14 159 6 53
58 9 79 323 84 6
2643 383 2 79 50 288
*/


Measured memory_bytes: 4096
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 10**10
for i in range(n-k+1):
    tmp = min(abs(a[k+i-1] - a[i]) + abs(a[i]), abs(a[k+i-1] - a[i]) + abs(a[k+i-1]))
    if ans > tmp:
        ans = tmp
print(ans)

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

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){

  /* your task */
  long long n,i;
  for(i=0;;i++){
    n=(h1(getKey(str))+i*h2(getKey(str)))%M;
    // printf(" n:%d",n);
    // printf("\n%s %s\n",H[n],str);
    if(strcmp(H[n],str)==0) return 1;
    else if(H[n][0]=='\0')return NULL;
 
  }
  return 0;
}

int insert(char str[]){
  long long i,n;
  /* your task */
  for(i=0;;i++){
    n=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(strcmp(H[n],str)==0)return 1;
       else if(H[n][0]=='\0'){
	 strcpy(H[n],str);
	 return 0;
       }
       }
    return 0;
  }

  int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15456
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n; i++){
		int temp = i;
		while(temp){
			if(!(i%3)||temp%10 == 3){
				printf(" %d",i);
				break;
			}
			temp /= 10;
		}
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 2104
n = int(input())
odd = n % 2 == 1

if sorted(list(input().split())) == ["0"] * odd + sorted([str(i) for i in range(1 + odd, n, 2)] * 2):
    cnt = 1
    for i in range(n//2):
        cnt *= 2
        cnt = cnt % (10 ** 9 + 7)
    print(cnt)
else:
    print(0)

Measured memory_bytes: 14164
N = gets.to_i
num = gets.strip.split.map(&:to_i)
i = 0
ary = Array.new(N,0)
while i < N do
  ary[num[i]-1] += 1
  i += 1
end
sum = 0
j = 0
while j < N do
  sum += ary[j]*(ary[j]-1)/2 #すべての場合
  j += 1
end
k = 0
while k < N do
  puts sum-ary[num[k]-1]+1
  k += 1
end

Measured memory_bytes: 35888
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

/*
 update : [s,t) に xを加算
 query  : [s,t) の　最大(小)値を出力する
 */

/* [0..N-1] */
const ll INIT = 0; // 問題に合わせる
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node, lazy;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
        lazy.resize(2 * N - 1, init_v);
    }
    
    void lazy_evaluate(int l, int r,int k){
        node[k] += lazy[k];
        if(r - l > 1){
            lazy[2 * k + 1] += lazy[k];
            lazy[2 * k + 2] += lazy[k];
        }
        lazy[k] = 0;
    }
    
    /* [a,b) 引数の範囲に注意!! s~tまでを更新→update(s,t+1,~) */
    void update(int a, int b, ll x) { update(a, b, 0, 0, N, x); }
    void update(int a, int b, int k, int l, int r, ll x) {
        lazy_evaluate(l,r,k);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] += x;
            lazy_evaluate(l,r,k);
        }
        else {
            update(a, b, 2 * k + 1, l, (l + r) / 2, x);
            update(a, b, 2 * k + 2, (l + r) / 2, r, x);
            node[k] = max(node[2 * k + 1],node[2 * k + 2]);
        }
    }
    
    /* [a,b) 引数の範囲に注意!! */
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r) {
        lazy_evaluate(l, r, k);
        if (r <= a || b <= l) return LLONG_MIN; // min : LLONG_MAX , max : LLONG_MIN
        if (a <= l && r <= b) {
            return node[k];
        }
        else {
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
};

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,T; cin >> N >> T;
    SegTree st(2*T);
    for(int i = 0; i < N;i++){
        ll l,r; cin >> l >> r;
        st.update(2*l,2*r,1);
    }
    cout << st.query(0,2*T+1) << endl;
    return 0;
}



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

namespace MyProgram{
    class AtCoder{
        static void Main(){
            var N = int.Parse(Console.ReadLine());
            var v = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var dict_odd = new Dictionary<int,int>();
            var dict_even = new Dictionary<int,int>();
            for(var i=0;i<N;i++){
                if(i%2==0){
                    if(!dict_odd.ContainsKey(v[i]))dict_odd[v[i]]=0;
                    dict_odd[v[i]]++;
                }else if(i%2==1){
                    if(!dict_even.ContainsKey(v[i]))dict_even[v[i]]=0;
                    dict_even[v[i]]++;
                }
            }
            var odd_list = new List<Arr>();
            var even_list = new List<Arr>();
            foreach(var key in dict_odd.Keys){
                var a = new Arr();
                a.key = key;
                a.value = dict_odd[key];
                odd_list.Add(a);
            }
            foreach(var key in dict_even.Keys){
                var a = new Arr();
                a.key = key;
                a.value = dict_even[key];
                even_list.Add(a);
            }
            odd_list.Sort(delegate(Arr a,Arr b){return b.value-a.value;});
            even_list.Sort(delegate(Arr a,Arr b){return b.value-a.value;});
            int result;
            if(odd_list[0].key != even_list[0].key){
                result = N - odd_list[0].value - even_list[0].value;
            }else if(odd_list.Count()>1){
                result = Math.Min(N - odd_list[1].value - even_list[0].value,N - odd_list[0].value - even_list[1].value);
            }else{
                result = N/2;
            }

            System.Console.WriteLine(result);
        }

    }
    public class Arr{
        public int key;
        public int value;
    }
}


Measured memory_bytes: 34652
N = int(input())
A = list(map(int, input().split()))
m = 10000000000
for i in range(N):
    cnt = 0
    temp = A[i]
    while temp % 2 == 0:
        temp = temp / 2
        cnt += 1
    if m > cnt:
        m = cnt
print(m)

Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int K,A,B;
  cin >> K;
  cin >> A >> B;
  int x = (B/K)*K;
  if(A <= x){
    cout << "OK" << endl;
  }else{
  cout << "NG" << endl;
  }
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main()
{
  int t;
  cin>>t;
  int remain=t%10;
  if(remain==3)
  {
    cout<<"bon\n";
  }
  else if(remain==0||remain==1||remain==6||remain==8)
  {
    cout<<"pon\n";
  }
  else
  {
    cout<<"hon\n";
  }
}

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

int main(void){
    int a, b;
    string s;
    cin >> a >> b >> s;
    for (int i=0; i<s.size(); i++){
        if ((i==a && s[i]!='-') || (i!=a && !(0<=s[i]-'0' && s[i]-'0'<=9))){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
namespace my_std {
using namespace std;
#define reg register
#define Rint register int
#define FOR(i, a, b) for (register int i = (a), ed_##i = (b); i <= ed_##i; ++i)
#define ROF(i, a, b) for (register int i = (a), ed_##i = (b); i >= ed_##i; --i)
typedef long long i64;
#define Templ(T) template <typename T>
Templ(T) inline T read() {
    reg T ans = 0;
    reg char c = getchar();
    while (!isdigit(c)) c = getchar();
    for (; isdigit(c); c = getchar()) ans = (ans << 1) + (ans << 3) + (c ^ 48);
    return ans;
}
Templ(_Tp) inline int chkmin(_Tp &x, _Tp y) { return x > y ? x = y, 1 : 0; }
Templ(_Tp) inline int chkmax(_Tp &x, _Tp y) { return x < y ? x = y, 1 : 0; }
} // namespace my_std
using namespace my_std;

#define N 200010

int n;
i64 a[N], c[N];
int b[N];

struct Point{
    i64 x, y;
    inline Point(i64 _x = 0, i64 _y = 0){ x = _x, y = _y; }
    inline Point operator -(const Point &t)const{
        return Point(x - t.x, y - t.y);
    }
}d[N];
inline i64 cross(const Point &l, const Point &r){
    return l.x * r.y - r.x * l.y;
}

void init(){
    i64 *aa = new i64[N], mx(-1);
    int *bb = new int[N], pos(0);
    n = read<int>();
    FOR(i, 1, n){
        if(chkmax(mx, aa[i] = read<i64>()))
            pos = i;
    }
    FOR(i, 1, n) bb[i] = read<int>();
    memcpy(a + 1, aa + pos, sizeof(i64) * (n - pos + 1));
    memcpy(a + n - pos + 2, aa + 1, sizeof(i64) * pos);
    memcpy(b + 1, bb + pos, sizeof(int) * (n - pos + 1));
    memcpy(b + n - pos + 2, bb + 1, sizeof(int) * pos);
    delete aa;
    delete bb;
}

int main() {
    init();
    c[1] = 0, ++n;
    FOR(i, 2, n) c[i] = 2 * (c[i - 1] + b[i - 1]) - c[i - 2];
    reg Point t;
    Rint h(0);
    FOR(i, 1, n){
        t = Point(i, a[i] - c[i]);
        while(h > 1 && cross(d[h] - d[h - 1], t - d[h]) > 0) --h;
        d[++h] = t;
    }
    reg i64 ans(0);
    FOR(i, 2, h){
        ans += (d[i].x - d[i - 1].x) * (d[i].y + d[i - 1].y);
    }
    ans += d[1].y + d[h].y;
    ans -= 2 * a[1];
    FOR(i, 1, n) ans += 2 * c[i];
    printf("%.12lf", 0.5 * ans / (n - 1.0));
    return 0;
}

Measured memory_bytes: 11160
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int add(int a, int b){return  a + b > mod ? a + b - mod : a + b;}
int mul(int a, int b){return a * b >= mod ? a * b % mod : a * b;}  
int n, k;
int v[105];
int dp[2][N], prefixsum[N]; 
int f(int i, int w){
    if(w < 0)return 0;
    if(i == 0){
        return w == 0 ? 1 : 0;
    }
    int &ans = dp[i][w];
    if(ans == -1){
        ans = 0;
        for(int j = 0; j <= v[i]; j++)
            ans = add(ans, f(i - 1, w - j));
    }
    return ans;
} 
int main(){
    //FL;
    FIN;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    for(int i = 0; i <= n; i++){
        if(i){
            prefixsum[0] = dp[(i - 1) & 1][0];
            for(int j = 1; j <= k; j++)
                prefixsum[j] = add(prefixsum[j - 1], dp[(i - 1) & 1][j]);
        }

        for(int w = 0; w <= k; w++){
            int &ans = dp[i & 1][w];
            if(i == 0){
                ans = (!w ? 1 : 0);
                continue;
            }
            ans = 0;
            ans = prefixsum[w];
            if(w - v[i] - 1 >= 0)
                ans = ((ans - prefixsum[w - v[i] - 1] + mod) % mod) % mod;
        }
    }

    cout << dp[n & 1][k] << '\n';

    EjecuteTime;
    return 0;
}       


Measured memory_bytes: 4964
// Medha's code  :


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 0x3f3f3f3f3f
#define MOD 1000000007

int main() {

    fastio;

    ll h , w;

    cin >> h >>w;

    vector<vector<bool>> grid(h+5 , vector<bool> (w+5));
    vector<vector<ll>> count(h+5 , vector<ll> (w+5));

    char x;

    for( ll i = 1 ; i <= h ; i++)
    {
        for( ll j =1 ; j <= w ; j++)
        {
            cin >> x;
            if(x== '.') grid[i][j] = true;
            else grid[i][j] = false;
        }
    }

    ll k = 1;
    while ( grid[k][1] == true)
    {
        count[k][1] = 1;
        k++;
    }

    for( ll i = k ; i<=h ; i++)
    {
        count[i][1] = 0;
    }

    k = 1;
    while ( grid[1][k] == true)
    {
        count[1][k] = 1;
        k++;
    }

    for( ll i = k ; i<=w ; i++)
    {
        count[1][i] = 0;
    }

    for( ll i = 2 ; i <= h ; i++)
    {
        for( ll j = 2 ; j <= w ; j++)
        {
            if( grid[i][j] == true)
            {
                count[i][j] = ((count[i][j - 1])%MOD + (count[i - 1][j])%MOD)%MOD;
            }
            else
            {
                count[i][j] = 0;
            }
        }
    }
    cout<< (count[h][w])%MOD;

    return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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; }
typedef long long ll;
int main()
{
  int n, m;cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> sum(n+1);
  sum[0] = 0;
  rep(i,n) sum[i+1] = (sum[i] + a[i]) % m;
  
  map<int,ll> mp;
  ll res = 0;
  rep(i,n+1) {
    res += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 4992
#include"bits/stdc++.h"
using namespace std;

bool isPrime(int x)
{
    if (x < 2) return false;
    else if (x == 2) return true;
    // else if (x % 2 == 0) return false;

    double sqrtx = sqrt(x);
    for (int i = 3; i < sqrtx; i++) {
        if (x % i == 0) return false;
    }

    return true;
}

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

    if (X == 2) {
        cout << X << endl;
        return 0;
    }
    else if (X % 2 == 0) X++;

    while(!isPrime(X)) {
        X += 2;
    }

    cout << X << endl;

    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	if(a*b%2==0) cout << "Even" << endl;
	else cout << "Odd" << endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll a, b, x;
    cin >> a >> b >> x;
    cout << (b / x) - (max(0LL, a - 1)) / x + (a == 0);
    return 0;
}


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

typedef unsigned long long ll;

ll md = 1000000007;

int main(int, char**)
{
	ll n, d, ans = 0;
	cin >> n >> d;
	ll x = 2 * d + 1;

	ll y = n / x;
	if (n % x > 0) y ++;

	cout << y << endl;
	return 0;
}


Measured memory_bytes: 256