akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

struct Node{
  int key;
  Node* left;
  Node* right;
  Node(){
    left = right = NULL;
  }
};

class Tree{
  Node* root = NULL;
  public:
  void insert(Node* n){
    Node* y = NULL;
    Node* x = root;
    while(x!=NULL){
      y = x;
      if(n->key < x->key){
        x = x->left;
      }else{
        x = x->right;
      }
    }
    if(y==NULL){
      root = n;
    }else if(n->key < y->key){
      y->left = n;
    }else{
      y->right = n;
    }
  }

  void print(){
    print_inorder(root);
    printf("\n");
    print_preorder(root);
    printf("\n");
  }

  void print_preorder(Node* n){
    if(n==NULL) return;
    printf(" %d",n->key);
    print_preorder(n->left);
    print_preorder(n->right);
  }
  void print_inorder(Node* n){
    if(n==NULL) return;
    print_inorder(n->left);
    printf(" %d",n->key);
    print_inorder(n->right);
  }

};

int main(){
  int n;cin>>n;
  Tree t;
  for(int i=0;i<n;i++){
    string ope; cin>>ope;
    if(ope=="insert"){
      int k; cin>>k;
      Node* node = new Node();
      node->key = k; 
      t.insert(node);
    }else if(ope=="print"){
      t.print(); 
    }
  }
  return 0;
}

Measured memory_bytes: 18868
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    L,R,d=MI()
    
    cnt=0
    for i in range(L,R+1):
        if i%d==0:
            cnt+=1
            
    print(cnt)

main()


Measured memory_bytes: 61748
#選択ソート
#最小値を毎回計算して一番左にぶち込む直感的なソート

length = int(input())
list = list(map(int, input().split()))

count = 0
for i in range(length):
    minpos = i
    for j in range(i+1, length):
        if list[minpos] > list[j]:
            minpos = j

    if i != minpos:
        count += 1
    list[i], list[minpos] = list[minpos], list[i]

result = ''
for l in list:
    result += str(l) + ' '

print(result[:-1])
print(count)


Measured memory_bytes: 5600
#include <cstdio>
#include <algorithm>

using namespace std;

int f[100005];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    f[x - 1]++;
    f[x]++;
    f[x + 1]++;
  }
  int ans = 0;
  for (int i = 0; i <= 100001; ++i)
    ans = max(ans, f[i]);
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    int t[n];
    for(int i=0;i<n;i++){
        if(s[i]=='E'){
            t[i]=-1;
            cnt++;
        }
        else{
            t[i]=1;
        }
    }
    int ans=t[0];
    for(int i=0;i<n-1;i++){
        t[i+1]+=t[i];
        ans=min(ans,t[i+1]);
    }
    cout<<cnt+min(0,ans)<<endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define ll long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n+m);
    for(ll i = 0; i < n; i++) {
        cin >> a[n-1-i];
    }
    for(ll i = 0; i < m; i++) {
        cin >> a[n+i];
    }

    ll len=0;
    ll r=0;
    ll sum=0;

    if(a[n]>k && a[n-1]>k){
        cout << 0 << "\n";
        return 0;
    }

    for(ll l = 0; l < n+m; l++) {
        while(r < n+m && sum+a[r]<=k) {
            sum+=a[r];
            r++;
        }
        if(r>=n-1 && l<=n) len=max(len,r-l);

        if(r==l) r++;
        else sum-=a[l];
    }
    cout << len << "\n";

    return 0;
}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int main(){
  int X,A,B;

  cin>>X>>A>>B;

  if (B-A <= 0) {
    cout<<"delicious"<<endl;
  } else if (B-A <= X) {
    cout<<"safe"<<endl;
  }else{
    cout<<"dangerous"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
#define N 210000
#define ls i<<1
#define rs i<<1|1
int maxm[N<<2],tag[N<<2];
struct ques{
	int l,r,d;
	bool operator < (const ques &B) const {return r<B.r;}
}md[N<<2];
void build(int i,int l,int r)
{
	if (l==r) {maxm[i]=1-l;return;}
	int mid=l+r>>1;
	build(ls,l,mid);build(rs,mid+1,r);
	maxm[i]=max(maxm[ls],maxm[rs]);
}
void pushdown(int i,int l,int r)
{
	if (tag[i])
	{
		int mid=l+r>>1,&x=tag[i];
		maxm[ls]+=x;tag[ls]+=x;
		maxm[rs]+=x;tag[rs]+=x;
		x=0;
	}
}
void update(int i,int l,int r,int L,int R,int d)
{
	if (L<=l&&r<=R)
	{
		maxm[i]+=d;
		tag[i]+=d;
		return;
	}
	int mid=l+r>>1;
	pushdown(i,l,r);
	if (L<=mid) update(ls,l,mid,L,R,d);
	if (mid<R) update(rs,mid+1,r,L,R,d);
	maxm[i]=max(maxm[ls],maxm[rs]);
}
int query(int i,int l,int r,int L,int R)
{
	if (L<=l&&r<=R) return maxm[i];
	pushdown(i,l,r);
	int mid=l+r>>1;
	if (R<=mid) return query(ls,l,mid,L,R);
	else if (L>mid) return query(rs,mid+1,r,L,R);
	return max(query(ls,l,mid,L,R),query(rs,mid+1,r,L,R));
}
inline int read(){
	int n=0;char a;bool z=false;
	while(a=getchar())
	{
		if (a>'9'||a<'0')
			if (z) break;
			else continue;
		if (!z) z=true;
		n=(n<<3)+(n<<1)+(a^48);
	}
	return n;
}
int main()
{
	int n=read(),m=read(),c=0,l,r,ans=max(n,m);
	for (int i=1;i<=n;++i)
	{
		l=read()+1;r=read()-1;
		if (l>r) continue;
		md[++c]=(ques){r,l,1};
		md[++c]=(ques){l,r+1,-1};
	}
	sort(md+1,md+1+c);build(1,1,m);
	for (int i=1,j=1;i<=m;++i)
	{
		while(j<=c&&md[j].r==i)
		{
			l=md[j].l;r=md[j].r;
			if (l>r) swap(l,r);
			update(1,1,m,l,r,md[j].d);
			++j;
		}
		ans=max(ans,i+maxm[1]);
	}
	printf("%d",ans-m);
	return 0;
}

//by qlwpc

Measured memory_bytes: 14592
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

string yorn(bool a){if(a) return"Yes" ; return "No" ;}
string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s ;
	cin >> s ;
	int n = s.size() ;
	bool a,b,c ;
	a = b = c = true ;
	for(int i=0;i<n/2;i++){
		if(s.at(i)!=s.at(n-1-i)) a = false ;
	}
	for(int i=0;i<n/2;i++){
		if(s.at(i)!=s.at(n/2-1-i)) b = false ;
	}
	for(int i=0;i<n/2;i++){
		if(s.at(n/2+1+i)!=s.at(n-1-i)) c = false ;
	}
	cout << yorn(a&&b&&c) << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
ll nCr(ll n, ll r){
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
  ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
  return ret;
}

//cの数字iよりも右にある, 色jのうちk以下の数字の個数(c==jならばk<i)
ll memo[2][2001][2][2001];

int main(void){
  int n;cin>>n;
  vector<int> W[2];
  rep(i,n+1){
    rep(j,2){
      W[j].push_back(0);
    }
  }
  reps(i,2*n){
    int a; char c;
    cin>>c>>a;
    W[(c=='B'?1:0)][a] = i;
  }

  rep(c,2){
    reps(i,n){
      rep(j,2){
        memo[c][i][j][0] = 0;
        reps(k,n){
          if(c==j && k>=i){
            memo[c][i][j][k] = 0;
            break;
          }
          if(W[j][k] > W[c][i]){
            memo[c][i][j][k] = 1;
          }else{
            memo[c][i][j][k] = 0;
          }
        }
        rep(k,n){
          memo[c][i][j][k+1] += memo[c][i][j][k];
          //cerr<<memo[c][i][j][k]<<" ";
        }
        //cerr<<endl;
      }
    }
  }
  cerr<<"hoge"<<endl;
  //i番目までを決めて, Wの個数がjであるものの最短手数
  vector<vector<ll>> dp;
  dp.push_back(vector<ll>());
  rep(j,n+1){
    dp[0].push_back(LINF/10);
  }
  dp[0][0] = 0;

  reps(i,2*n){
    dp.push_back(vector<ll>());
    rep(j,n+1){
      ll addW = LINF/10;
      if(j-1 >= 0 && i-j >= 0 && i-j <= n){
        addW = max((ll)0, (W[0][j] - i + memo[0][j][0][j-1] + memo[0][j][1][i-j]));
      }
      //cerr<<"huga"<<endl;
      ll addB = LINF/10;
      if(i-j-1 >= 0 && i-j <= n){
        addB = max((ll)0, (W[1][i-j] - i + memo[1][i-j][0][j] + memo[1][i-j][1][i-j-1]));
      }
      //cerr<<"nya"<<endl;
      dp[i].push_back(dp[i-1][j] + addB);
      if(j-1 >= 0){
        chmin(dp[i][j], dp[i-1][j-1] + addW);
      }
      chmin(dp[i][j], LINF/10);
      //cerr<<j<<endl;
    }
  }
  /*rep(i,2*n+1){
    rep(j,n+1){
      cerr<<dp[i][j]<<" ";
    }
    cerr<<endl;
  }*/
  cout<<dp[2*n][n]<<endl;
  return 0;
}


Measured memory_bytes: 189568
#include <stdio.h>
main()
{
 int x;
  int i = 0 ;
 
  while(1)
    {
      ++i;
       
      scanf("%d", &x);
      if( x == 0)
          break;
 
      printf("Case %d: %d\n", i, x);
 
    }
 
 
  return 0;
 
}

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

using namespace std;

const int ms = 1e5 + 17;
int arr[ms], dist[ms];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    for(int i = 1; i <= n; ++i)
        cin >> arr[i];

    for(int i = 1; i <= n; ++i)
        dist[i] = dist[i - 1] + abs(arr[i] - arr[i - 1]);

    //cout << dist[n]  + abs(arr[n])<< '\n';

    for(int i = 1; i < n; ++i)
    {
        cout << dist[i - 1] + (dist[n] + abs(arr[n]) - dist[i + 1]) + abs(arr[i - 1] - arr[i + 1])<< '\n';
    }

    cout << dist[n - 1] + abs(arr[n - 1]) << '\n';

}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
//      std macros
typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll ,ll> pll;
//      dereference
#define F first
#define S second
#define pb push_back
#define mp make_pair
//      loops
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define PER(i,b,a) for(int i=b;i>=a;--i)
#define all(X) (X).begin(), (X).end()
//      I/O
#define sd(n) scanf("%d",&n)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sll(n) scanf("%lld",&n)
#define sll2(x,y) scanf("%lld%lld",&x,&y)
#define sll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
//      debug
#define debug(x) cerr<<"debug->"<<#x<<"::"<<x<<endl
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<"\n"
//      set values
#define mset(n,k) memset(n,k,sizeof(n))
#define MOD 1000000007
ll INV2=500000004;
ll INV6=166666668;
//modular expo
ll power(ll a,ll b, ll c){
    ll x=1,y=a;
    while(b>0){
        if(b&1)
            x=(x*y)%c;
        y=(y*y)%c;
        b/=2;
    }
    return x%c;
}
//perfect numbers till 10^6 6, 28, 496, 8128
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};//clockwise from left
int dr[]={1,1,0,-1,-1,-1, 0, 1};
int dc[]={0,1,1, 1, 0,-1,-1,-1};//anticlockwise from 
const int N = 2e5+5;
int a[N];
int main()
{

  int n;
  sd(n);
  REP(i,1,n) {
    sd(a[i]);
  }
  if(n&1) {
    for(int i=n;i>=1;i-=2) {
      printf("%d ",a[i]);
    }
    for(int i=2;i<=n;i+=2) {
      printf("%d ",a[i]);
    }
  }
  else {
    for(int i=n;i>=1;i-=2) {
      printf("%d ",a[i]);
    }
    for(int i=1;i<=n;i+=2) {
      printf("%d ",a[i]);
    }
  }
  printf("\n");

            


return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        rp(i,b)
        cout << a;
    cout << endl;
    }
    else{
        rp(i,a)
        cout <<b;
    cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

vector<string> s;
vector<vector<int>> sum;
int countwhite(int sx, int tx, int sy, int ty){
    return sum[ty][tx]-sum[ty][sx-1]-sum[sy-1][tx]+sum[sy-1][sx-1];
}

int main(){
    /*ios::sync_with_stdio(false);
    cin.tie(0);*/
    ll h,w,k;cin>>h>>w>>k;
    s=vector<string>(h);
    rep(i,h)cin>>s[i];
    sum = vector<vector<int>>(h+1,vector<int>(w+1,0));
    
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            sum[i][j]=(s[i-1][j-1]=='1')+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
        }
    }
    int ans = h+w;
    for(ll i=0; i<(1<<(h-1)); i++){
        vector<int> ends;
        rep(j,h-1)if((i>>j)&1)ends.push_back(j);
        
        int now = ends.size();
        ends.push_back(h-1);
        

        int l = 1, r = 1;
        bool flag = true;//横1マスでもだめなのがきたらfalseに
        while(r<=w){
            int u = 1;
            bool flag2 = true;//行き過ぎたらfalse
            for(int a: ends){
                //cout<<countwhite(l,r,u,a+1);
                if(countwhite(l,r,u,a+1)>k){
                    if(l==r)flag=false;
                    l=r;
                    now++;
                    flag2 = false;
                    break;
                }
                u=a+2;
            }
            if(!flag)break;
            if(flag2)r++;
        }
        if(!flag)continue;
        ans=min(ans,now);
        //cout<<"now:"<<now<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ans = 1;
  for(int i=0;i<3;i++){
    ans *= N;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
class Node:
    def __init__(self, parent=-1, left=-1, right=-1):
        self.parent = parent
        self.left = left
        self.right = right


n = int(input())
binary_tree = [Node() for i in range(n)]
pre_lst, in_lst, post_lst = [], [], []


def pre_order(u):
    if u == -1:
        return

    pre_lst.append(u)
    pre_order(binary_tree[u].left)
    pre_order(binary_tree[u].right)


def in_order(u):
    if u == -1:
        return

    in_order(binary_tree[u].left)
    in_lst.append(u)
    in_order(binary_tree[u].right)


def post_order(u):
    if u == -1:
        return

    post_order(binary_tree[u].left)
    post_order(binary_tree[u].right)
    post_lst.append(u)


def main():
    for i in range(n):
        idx, left, right = map(int, input().split())
        binary_tree[idx].left = left
        binary_tree[idx].right = right
        if left != -1:
            binary_tree[left].parent = idx
        if right != -1:
            binary_tree[right].parent = idx

    root_idx = 0
    for i in range(n):
        if binary_tree[i].parent == -1:
            root_idx = i
            break

    pre_order(root_idx)
    in_order(root_idx)
    post_order(root_idx)

    print("Preorder")
    print("", " ".join([str(i) for i in pre_lst]))
    print("Inorder")
    print("", " ".join([str(i) for i in in_lst]))
    print("Postorder")
    print("", " ".join([str(i) for i in post_lst]))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5620
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

vector<int> sieve_of_eratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;
  return primes;
}

void solve() {
	int max_n = 100010;
	vector<int> ret_vec = sieve_of_eratosthenes(max_n);
	for (auto it = ret_vec.begin(); it != ret_vec.end();) {
		if (*it == 0) {
			it = ret_vec.erase(it);
		} else {
			++it;
		}
	}
	int x; cin >> x;
	int ans = 0;
	rep (i, ret_vec.size()) {
		if (x > ret_vec[i]) {
			continue;
		} else {
			ans = ret_vec[i];
			break;
		}
	}	
	cout << ans << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val n = jin.readLine().toInt()
    val freq1 = mutableMapOf<Int, Long>()
    val freq2 = mutableMapOf<Int, Long>()
    val tokenizer = StringTokenizer(jin.readLine())
    for (j in 1..n) {
        val h = tokenizer.nextToken().toInt()
        freq1[j - h] = (freq1[j - h] ?: 0L) + 1L
        freq2[j + h] = (freq2[j + h] ?: 0L) + 1L
    }
    var answer = 0L
    for ((k, f) in freq1) {
        answer += f * (freq2[k] ?: 0L)
    }
    println(answer)
}

Measured memory_bytes: 81720
n = int(input())
a = list(map(int, input().split()))

x1 = sum(a) - sum(a[1::2]) * 2

ans = []
ans.append(x1)
for i in range(n-1):
    ans.append(a[i]*2 - ans[i])

print(" ".join(map(str, ans)))

Measured memory_bytes: 84452
#include <bits/stdc++.h>
using namespace std;
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;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, x;
    cin >> a >> b >> x;
    if(a == 0) {
        cout << b / x + 1 << endl;
    } else
        cout << (b / x) - ((a - 1) / x) << endl;
}

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

int main(){
  string str;
  while(getline(cin,str) , str != "0"){
    int sum = 0;
    int cnt = 0;
    for(int i=0;i<str.size();i++){
      if(str[i] == ' '){
      } else if(i+1 != str.size() &&  str[i+1] != ' '){
	sum += (str[i]-'0')*10;
	i++;
      } else {
	if(str[i] == '1') {
	  cnt++;
	  sum += 10;
	}
	sum += str[i]-'0';
      }
    }
    while(sum > 21 && cnt != 0){
      cnt--;
      sum -= 10;
    }
    if(sum > 21) cout << "0" << endl;
    else cout << sum << endl;
  }
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int N;
    cin >> N;
    int l[N], r[N];
    int ans = 0;
    REP(i, N) {
        cin >> l[i] >> r[i];
        ans += (r[i] - l[i]) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 123456789012

int main(){
    ll i,j;
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	for(i=0;i<n;i++){
		ll h;
		cin>>h;
		if(h>=k) ans++;
	}
	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
string str;
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>str;
	int l=str.length(),sum=0;
    for(int i=0;i<l;++i)
		if(str[i]=='g')sum++;
	cout<<min(l/2,sum)-min(l-l/2,l-sum)<<'\n';
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int n, i;
	
	while (1){
		i = 0;
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		while (n != 1){
			if (n % 2 == 0){
				n /= 2;
			}
			else {
				n = n * 3 + 1;
			}
			i++;
		}
		
		printf("%d\n", i);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (auto &v : vec)
    cin >> v;

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

  int vsum = accumulate(vec.begin(), vec.end(), 0);

  int vmin = vsum;
  for (int i = 0; i < n; ++i) {
    if (vec[i] % 10 == 0)
      continue;
    vmin = min(vmin, vec[i]);
  }

  cout << (vsum % 10 == 0 ? vsum - vmin : vsum) << endl;
}


Measured memory_bytes: 3612
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
ll n,m;
bool valid(ll i,ll j)
{
    if(i>=n||j>=m||i<0||j<0)
    {
        return false;
    }
    return true;
}
ll fun(ll n, ll m, vector<string>&v,ll i,ll j)
{
    vector< vector<bool> >visited(n,vector<bool>(m,0));
    queue<p>q;
    q.push({i,j});
    visited[i][j]=true;
    ll ans=0;
    q.push({-1,-1});
    while(!q.empty())
    {
        p cur=q.front();
        q.pop();
        ll x=cur.fi;
        ll y=cur.se;
        if(x==-1)
        {
            if(q.empty())
            {
                break;
            }
            q.push({-1,-1});
            ans++;
            continue;
        }
        if(valid(x+1,y)&&visited[x+1][y]==false&&v[x+1][y]=='.')
        {
            visited[x+1][y]=true;
            q.push({x+1,y});
        }
        if(valid(x-1,y)&&visited[x-1][y]==false&&v[x-1][y]=='.')
        {
            visited[x-1][y]=true;
            q.push({x-1,y});
        }
        if(valid(x,y+1)&&visited[x][y+1]==false&&v[x][y+1]=='.')
        {
            visited[x][y+1]=true;
            q.push({x,y+1});
        }
        if(valid(x,y-1)&&visited[x][y-1]==false&&v[x][y-1]=='.')
        {
            visited[x][y-1]=true;
            q.push({x,y-1});
        }
    }
    return ans;
}
int main()
{
fast;

cin>>n>>m;
vector< string >v(n);
for(ll i=0;i<n;i++)
{
    string s;
    cin>>s;
    v[i]=s;
}
ll ans=0;
for(ll i=0;i<n;i++)
{
    for(ll j=0;j<m;j++)
    {
        if(v[i][j]=='.')
        {
            ll hh=fun(n,m,v,i,j);
            ans=max(ans,hh);
        }
    }
}
cout<<ans<<endl;
return 0;
}


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

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;
		try {
			while ((buffer = reader.readLine())  != null) {
				int a = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ")));
				int b = Integer.valueOf(buffer.substring(buffer.indexOf(" ") + 1));
				System.out.println(a * b + " " + (a + b) * 2 );
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

Measured memory_bytes: 24148
from collections import deque
n,m=map(int,input().split())
if m==0:
  print(-1)
  exit()
edge=[[] for i in range(3*n)]
for i in range(m):
  u,v=map(int,input().split())
  edge[3*(u-1)].append(3*(v-1)+1)
  edge[3*(u-1)+1].append(3*(v-1)+2)
  edge[3*(u-1)+2].append(3*(v-1))
s,t=map(int,input().split())
s-=1
t-=1
visited=[0 for i in range(3*m)]
def bfs(edge,visited,s,t):
  q=deque([3*s])
  visited[3*s]=1
  cnt=0
  while q:
    x=q.popleft()
    if x%3==0 and x//3==t:
      return visited[x]//3
    for i in edge[x]:
      newx=i
      if visited[newx]==0:
        visited[newx]=visited[x]+1
        q.append(newx)
  return -1
print(bfs(edge,visited,s,t))

Measured memory_bytes: 60304
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	double T,A;
	cin>>T>>A;
	vector<double> H;
	for(int i=0;i<N;i++){
		double h;
		cin>>h;
		H.pb(h);
	}
	int ans=-1;
	double near=INF;
	for(int i=0;i<N;i++){
		if(abs((T-H[i]*0.006)-A)<near){
			near=abs((T-H[i]*0.006)-A);
			ans=i;
		}
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  array<string, 4> divide ={"dream", "dreamer", "erase","eraser"};
  for(int i=0;i<4;i++){
    reverse(divide.at(i).begin(), divide.at(i).end());
  }
  
  bool can =true;
  
  for(int i=0; i<s.size(); ){
    bool good= false;
    for(int j=0; j<4; j++){
      string tmp = divide.at(j);
      if( s.substr(i, tmp.size()) == tmp ){
        good =true; i+=tmp.size();
        break;
      }
    }
      if(!good){
        can = false;
        break;
      }
  }
    if(can) cout << "YES" <<endl;
    else cout << "NO"<< endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
#define pii pair<ll int, ll int>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define repi(i, n) for(ll i=0; i<n; i++)
#define rep(i, a, b) for(ll i=a; i<=b; i++)
#define M 1000000007
#define INF 1e10

using namespace std;

int main() {
    ios
    ll h, w;
    cin>>h>>w;
    vector <string> grid(h);
    repi(i, h) cin>>grid[i];
    vector <vector<ll>> dp(h, vector<ll>(w));
    dp[0][0]=1;
    rep(i, 1, w-1) dp[0][i] = (grid[0][i]=='#' ? 0 : dp[0][i-1]%M);
    rep(i, 1, h-1) dp[i][0] = (grid[i][0]=='#' ? 0 : dp[i-1][0]%M);
    rep(i, 1, h-1){
        rep(j, 1, w-1) grid[i][j] == '#' ? 0 : dp[i][j] = (dp[i-1][j] + dp[i][j-1])%M;
    }
    cout<<dp[h-1][w-1];
    return 0;
}

Measured memory_bytes: 12160
H, W = map(int, input().split())
import numpy as np
Grid = np.array([[0 if x == '.' else -1 for x in input()] for _ in range(H)],dtype='int64')

def solveMase(Grid, start, goal): #bfsで迷路を解き、スタート-ゴール間の最低必要白マス数を返す
    seen = {start}
    V = [start]
    while len(V) != 0: #bfs
        v = V.pop(0)
        if v == goal:
            return Grid[goal]
        #移動先nvをリストにまとめる
        y,x = v
        nV = []
        if x > 0: nV.append((y,x-1))
        if y > 0: nV.append((y-1,x))
        if x < W-1: nV.append((y,x+1))
        if y < H-1: nV.append((y+1,x))
        #bfs
        for nv in nV:
            if Grid[nv] == -1 or nv in seen:
                continue
            Grid[nv] = Grid[v] + 1
            V.append(nv)
            seen.add(nv)
    return 0

white = len(Grid[Grid == 0])-1
nes_white = solveMase(Grid, (0,0), (H-1,W-1))
print(white-nes_white if nes_white > 0 else -1)

Measured memory_bytes: 26588
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 100005
#define fi(a, b, c) for(int a = (b); a < (c); a++)
#define FI(a, b, c) for(int a = (b); a <= (c); a++)
using namespace std;

char s[N];
int t;

int main(){
	scanf("%s %d", s, &t);
	
	int n = strlen(s);
	fi(i, 0, n){
		int need = s[i] == 'a' ? 0 : 'z' + 1 - s[i];
		if(t >= need) {
			t -= need;
			s[i] = 'a';
		}
	}
	
	t %= 26;
	int ind = s[n - 1] - 'a';
	ind = (ind + t) % 26;
	s[n - 1] = ind + 'a';
	
	puts(s);
}

Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char *argv[]) {
  int N, M;
  int res = 0;
  cin >> N >> M;
  for(int i = 1; i < N; i++){
    res += i;
  }
  for(int i = 1; i < M; i++){
    res += i;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int n,a[50],k=0;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cout << fixed << setprecision(12);
	cin >> n;
	rep(n) cin >> a[i];
	rep(n) k+=a[i]==i+1;
	print1(k>=n-2?"YES":"NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define F first
#define S second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int M = 1e9 + 7;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;
ll iv[N];
ll powM(ll a, ll b, ll M = M){ll res = 1;for(;b;a=a*a%M,b/=2) if(b&1) res=res*a%M;return res;}
ll nckbig(int n, int k){ll ans = 1;for(int i=1; i<=k; ++i){ans = ans*(n-i+1)%M*iv[i]%M;}return ans;}
ll caliv(){iv[1] = 1;for(int i=2; i<N; i++){iv[i] = M-M/i*iv[M%i]%M;}}
ll f1[N], f2[N];
ll calf(){f1[0] = f2[0] = 1;for(int i=2; i <N; ++i){f1[i] = f1[i-1]*i%M;f2[i] = f2[i-i]*iv[i]%M;}}
ll nck(int n, int k){return f1[n]*f2[n-k]%M*f2[k]%M;}
ll npk(int n, int k){return f1[n]*f2[n-k]%M;}
ll Rnck(int big){if(big){caliv();}else{calf();}}
int parent[N];
vector<int> ran(N, 1);
int find(int x)
{
    if(parent[x]==0)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y]){
        ran[y] += ran[x];
        parent[x]=y;
      }
    else{
        ran[x] += ran[y];
        parent[y]=x;
    }
}
int con[N], em[N];
void solve()
{
  int n,m,k;
  cin>>n>>m>>k;
  rep(i, 0, m){
    int u, v;
    cin>>u>>v;
    con[u]++;
    con[v]++;
    unite(u, v);
  }
  rep(i, 0, k){
    int u, v;
    cin>>u>>v;
    if(find(u) == find(v)){
      em[u]++;
      em[v]++;
    }
  }
  repn(i, 1, n){
    int par = find(i);
    int ans = ran[par] - con[i] - em[i] - 1;
    cout<<ans<<" ";
  }
  cout<<endl;
}


int main()
{
    FAST
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int nAct = 0;
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    /* step 1 */
    bool isEven[3];
    int nEven = 0;
    for(int i = 0; i < 3; i++){
        if((a[i] % 2) == 0){
            isEven[i] = true;
            nEven++;
        }else{
            isEven[i] = false;
        }
    }

    if(nEven == 1){
        nAct++;
        for(int i = 0; i < 3; i++){
            if(!isEven[i]) a[i]++;
        }
    }else if(nEven == 2){
        nAct++;
        for(int i = 0; i < 3; i++){
            if(isEven[i]) a[i]++;
        }
    }

    /* step 2 */

    int maxA = max(a[0], max(a[1], a[2]));
    for(int i = 0; i < 3; i++){
        nAct += (maxA - a[i]) / 2;
    }

    cout << nAct << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
    	Scanner sc= new Scanner(System.in);
 int p=2000,j=2000;
 for(int i=0;i<3;i++)p=Math.min(p, sc.nextInt());
 for(int i=0;i<2;i++)j=Math.min(j, sc.nextInt());
 System.out.println(p+j-50);
    }
}

Measured memory_bytes: 26220
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++) 
#define per(i , n , x)  for(int i = n ; i <= x ; i --) 
using namespace std ;
typedef long long ll ;
typedef pair<int , int> pii ;
const int inf = 0x3f3f3f3f ;
const int maxn = 3e5 + 5 ;
const int maxm = 5005 ;
int x , y , q , w , e ;
int a[maxn] , b[maxn] , c[maxn] ;
queue<int> q1 , q2 , q3 ;
int main()
{
	ll ans = 0 ;
	scanf("%d%d%d%d%d" , &x , &y , &q , &w , &e) ;
	rep(i , 1 , q)  scanf("%d" , &a[i]) ;
	rep(i , 1 , w)  scanf("%d" , &b[i]) ;
	rep(i , 1 , e)  scanf("%d" , &c[i]) ;
	sort(a + 1 , a + q + 1 , greater<int>()) ;
	sort(b + 1 , b + w + 1 , greater<int>()) ;
	sort(c + 1 , c + e + 1 , greater<int>()) ;
	for(int i = x ; i >= 1 ; i --)  q1.push(a[i]) ;
	for(int i = y ; i >= 1 ; i --)  q2.push(b[i]) ;
	for(int i = 1 ; i <= e ; i ++)  q3.push(c[i]) ;
	while(!q1.empty() && !q2.empty() && !q3.empty())
	{
		int r = q1.front() ;
		int t = q2.front() ;
		int u = q3.front() ;
		if(r < t)
		{
			q1.pop() ;
			if(r < u)
			{
				ans += u ;
				q3.pop() ;
			}
			else  ans += r ;
		}
		else
		{
			q2.pop() ;
			if(t < u)
			{
				ans += u ;
				q3.pop() ;
			}
			else  ans += t ;
		}
	}
	while(!q1.empty() && !q3.empty())
	{
		int r = q1.front() ;
		int u = q3.front() ;
		q1.pop() ;
		if(r < u)
		{
			ans += u ;
			q3.pop() ;
		}
		else  ans += r ;
	}
	while(!q2.empty() && !q3.empty())
	{
		int t = q2.front() ;
		int u = q3.front() ;
		q2.pop() ;
		if(t < u)
		{
			ans += u ;
			q3.pop() ;
		}
		else  ans += t ;
	}
	while(!q1.empty())
	{
		int r = q1.front() ;
		q1.pop() ;
		ans += r ;
	}
	while(!q2.empty())
	{
		int t = q2.front() ;
		q2.pop() ;
		ans += t ;
	}
	printf("%lld\n" , ans) ;
	return 0 ;
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(x>=30?"Yes":"No");
        }
            
        
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 27452
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define llong long long
using namespace std;

const int N = 2000;
const int P = 1e9+7;
llong fact[N+N+3],finv[N+N+3];
llong comb[N+3][N+3],sum[N+3][N+3];
int a,b;

void initcomb()
{
	comb[0][0] = 1ll;
	for(int i=1; i<=N; i++)
	{
		comb[i][0] = comb[i][i] = 1ll;
		for(int j=1; j<i; j++)
		{
			comb[i][j] = (comb[i-1][j]+comb[i-1][j-1])%P;
		}
	}
	sum[0][0] = 1ll;
	for(int i=0; i<=N; i++)
	{
		sum[i][0] = 1ll;
		for(int j=1; j<=N; j++) sum[i][j] = (sum[i][j-1]+comb[i][j])%P;
	}
	for(int i=0; i<=N; i++)
	{
		for(int j=1; j<=N; j++) sum[i][j] = (sum[i][j]+sum[i][j-1])%P;
	}
}

int main()
{
	initcomb();
	scanf("%d%d",&a,&b);
	if(a==0 || b==0) {printf("1"); return 0;}
	llong ans = 0ll;
	for(int i=1; i<=a+1; i++)
	{
		llong tmp = 1ll;
		for(int j=1; j<=min(i-1,b-1); j++)
		{
			tmp = (tmp+sum[j-1][i-j-1]*comb[b-1][j])%P;
//			printf("ij%d %d %lld\n",i,j,sum[j-1][i-j-1]*comb[b-1][j]);
		}
//		printf("%d %lld\n",i,tmp);
		ans = (ans+tmp)%P;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 62848
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
  	ll a;cin>>a;
  	cout << 3*a*a<<ednl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int n, m;

vector<vector<bool>> to;

vector<bool> visit;
void dfs(int now) {
	visit[now] = true;
	rep(i, n) {
		if (to[now][i] && !visit[i]) dfs(i);
	}
}

int main() {
	cin >> n >> m;
    to.resize(n,vector<bool>(n));
    visit.resize(n);
	vector<pair<int, int>> e(m);
	rep(i, m) {
		int ai, bi;
		cin >> ai >> bi;
		ai--; bi--;
		to[ai][bi] = true;
		to[bi][ai] = true;
		e[i] = { ai,bi };
	}
	int ans = 0;
	rep(i, m) {
		int ai = e[i].first;
		int bi = e[i].second;
		to[ai][bi] = false;
		to[bi][ai] = false;
		dfs(0);
		bool flag = false;
		rep(i, n) {
			if (!visit[i]) flag = true;
			visit[i] = false;
		}
		if (flag) ans++;
		to[ai][bi] = true;
		to[bi][ai] = true;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
 
int main() {
  double A, B; cin >> A >> B;
  cout << ceil((B-1)/(A-1)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int r,d ,x;
    scanf("%d %d %d",&r,&d,&x);

    for(int i=1;i<=10;i++)
    {
        int ans= (r*x)-d;
        printf("%d\n",ans);
        x=ans;
    }
    return 0;
}


Measured memory_bytes: 1712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int D = scan.nextInt();

		int X = (A + D - 1) / D;
		int Y = (C + B - 1) / B;
		if (X >= Y) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>


int main(){
    int N; cin>>N;
    ll a[N];
    int num_p = 0;
    int num_m = 0;
    ll ans = 0;
    REP(i,N){
        cin>>a[i];
        if(a[i]>=0){ ++num_p;}
        else{ ++num_m; a[i] = -a[i]; }
        ans += a[i];
    }
    if(num_m%2==1){
        ans -= *min_element(a,a+N)*2;
    }
    cout << ans << "\n";
}

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

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  k = min(k, n - 1);
  combination c(n);
  mint ans;
  rep(i, k + 1) ans += c(n, i) * c((n - i - 1) + i, i);
  cout << ans << endl;
}

Measured memory_bytes: 3328