akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int D,G; cin>>D>>G;
    int p[D],c[D]; REP(i,D) cin>>p[i]>>c[i];
    int ans = INF;
    for(int bit = 0; bit < 1<<D; bit++) {
        int score = 0;
        int tmp = 0;
        bool flag = false;
        REP(i,D) {
            if (bit&(1<<i)) {
                score += c[i]+p[i]*(i+1)*100;
                tmp += p[i];
            }
        }
        if (score>=G) {
            ans = min(tmp,ans);
            continue;
        }
        PER(i,D) {
            if (!(bit&(1<<i))) {
                REP(j,p[i]-1) {
                    score += 100*(i+1);
                    tmp++;
                    if (score>=G) {
                        flag = true;
                        break;
                    }
                }
            if (flag) break;
            }
        }
        if (flag) ans = min(tmp,ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
result = [input() for i in range(n)]
a=0
w=0
t =0
r=0

for i in range(n):
    if result[i]=="AC":
        a += 1
    elif result[i]=="WA":
        w += 1
    elif result[i]=="TLE":
        t += 1
    else:
        r += 1

print("AC x " + str(a))
print("WA x " + str(w))
print("TLE x "+ str(t))
print("RE x "+ str(r))
    

Measured memory_bytes: 16208
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N,M;
int a[100010];
int main(){
  cin>>N>>M;
  rep(i,M) cin>>a[i];
  ll d[100010];
  d[0]=1;
  int j=0;
  rep1(i,N){
    if(i==a[j]){
      d[i]=0;
      j++;
    }
    else{
      if(i==1){
	d[i]=1;
      }
      else{
	d[i]=(d[i-1]+d[i-2])%MOD;
      }
    }
  }
  prin(d[N]);
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int h, w;
char grid[2000][2000];
int memo[2000][2000][4];


int search(int a, int b){
	int light = 1;
	for (int i = 0; i < 4; i++){
		light += memo[a][b][i] - 1;
	}
	return light;
}


int main(){
 	int ans = 0;
	cin >> h >> w;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin >> grid[i][j];
		}
	}
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (grid[i][j] == '.'){
				if (j == 0) memo[i][j][0] = 1;
				else memo[i][j][0] = memo[i][j-1][0] + 1;
			}
		}
	}
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (grid[i][j] == '.'){
				if (i == 0) memo[i][j][1] = 1;
				else memo[i][j][1] = memo[i-1][j][1] + 1;
			}
		}
	}
	for (int i = 0; i < h; i++){
		for (int j = w-1; j >= 0; j--){
			if (grid[i][j] == '.'){
				if (j == w-1) memo[i][j][2] = 1;
				else memo[i][j][2] = memo[i][j+1][2] + 1;
			}
		}
	}
	for (int i = h-1; i >= 0; i--){
		for (int j = 0; j < w; j++){
			if (grid[i][j] == '.'){
				if (i == h-1) memo[i][j][3] = 1;
				else memo[i][j][3] = memo[i+1][j][3] + 1;
			}
		}
	}

	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (grid[i][j] == '.'){
				ans = max(ans, search(i, j));
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 66688
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct List {
	struct Node {
		int key;
		Node *next, *prev;
		Node() {}
	};
	Node *p;
	List() {
		p = (Node*)malloc(sizeof(Node));
		p->next = p->prev = p;
	}
	void insert(int x) {
		Node *n = (Node*)malloc(sizeof(Node));
		n->key = x;
		n->next = p->next;
		n->next->prev = n;
		p->next = n;
		n->prev = p;
	}
	Node* findkey(int x) {
		for (Node *f = p->next; f != p; f = f->next)
			if (f->key == x)return f;
		return nullptr;
	}
	void Delete_ptr(Node *f) {
		if (f == nullptr)return;
		f->prev->next = f->next;
		f->next->prev = f->prev;
		free(f);
	}
	void Delete_x(int x) {
		Delete_ptr(findkey(x));
	}
	void Deletefirst() {
		Delete_ptr(p->next);
	}
	void Deletelast() {
		Delete_ptr(p->prev);
	}
	void print() {
		for (Node *z = p->next; z != p; z = z->next) {
			if (z != p->next)putchar(' ');
			printf("%d", z->key);
		}
		puts("");
	}
};
signed main() {

	int N; scanf("%d", &N);
	char c[256];
	List ls;
	rep(i, 0, N) {
		scanf("%s", c);
		if (c[0] == 'i') {
			int x; cin >> x;
			ls.insert(x);
		}
		else if (strcmp(c, "delete") == 0) {
			int x; cin >> x;
			ls.Delete_x(x);
		}
		else if (c[6] == 'F') {
			ls.Deletefirst();
		}
		else ls.Deletelast();
	}
	ls.print();
	return 0;
}

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

int main() {
   char s[11], t[12];
   int cnt = 0;
   scanf("%s",s);
   scanf("%s",t);

   if(1 <= strlen(s) && strlen(s) <= 10 && strlen(t) == strlen(s) + 1) {
      for(int i = 0; s[i] != '\0'; i++) {
         if(s[i] == t[i]) {
            cnt++;
         }
      }
      if(cnt == strlen(s) && t[strlen(t)-1] >= 'a' && t[strlen(t) - 1] <= 'z') {
         printf("Yes\n");
      } else {
         printf("No\n");
      }
   }
   return 0;
}

Measured memory_bytes: 1600
package main

import "fmt"


func main() {
	var a, b, c int
  	fmt.Scan(&a, &b, &c)
  
    if a == b {
      fmt.Println(c)
    } else if b == c {
      fmt.Println(a)
    }else if c == a {
      fmt.Println(b)
    }
}

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

int main(){
    int n;
    cin>>n;
    int t[n+1];
    int x[n+1],y[n+1];
    t[0]=0;
    x[0]=0;
    y[0]=0;
    for(int k=1;k<=n;k++){
        cin>>t[k]>>x[k]>>y[k];
    }
    bool jud=true;
    for(int i=0;i<n;i++){
        if((t[i+1]-t[i]-abs(x[i+1]-x[i])-abs(y[i+1]-y[i]))%2!=0 || t[i+1]-t[i]<(abs(x[i+1]-x[i])+abs(y[i+1]-y[i]))){
            jud = false;
            break;
            }
        }
    if(jud==true){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string.h>
using namespace std;

int main(){
    string s,a="peach",b="apple";
    getline(cin,s);
    for(int i=0,j;i<s.length();i++){
        for(j=0;j<5&&j+i<s.length();j++){
            if(s[i+j]!=a[j])
                break;
        }
        if(j==5){cout<<b;i+=4;}
        else{
            for(j=0;j<5&&j+i<s.length();j++){
                if(s[i+j]!=b[j])
                    break;
            }
            if(j==5){cout<<a;i+=4;}
            else cout<<s[i];
        }
    }
    cout<<endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

int main(){
  int K,N;
  cin >> K>>N;
  for(int i =N-K+1; i<N+K ;i++){
    cout << i <<endl;
  }
}


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

int main(){
    string S;
    cin>>S;
    int A=0;
    for(int i=0;i<4;i++){
        if(S.at(i)=='+'){
            A++;
        }
        if(S.at(i)=='-'){
            A--;
        }
    }
    cout<<A<<endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = "";

            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == '0')
                    ans += s[i].ToString();
                else if (s[i] == '1')
                    ans += s[i].ToString();
                else if (!string.IsNullOrEmpty(ans))
                    ans = ans.Substring(0, ans.Length - 1);
            }

            Console.WriteLine(ans);
        }
    }
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll mode = 0;
    ll N;
    ll count = 1;
    ll prev;
    cin >> N;
    cin >> prev;
    for(ll i = 1;i < N;i++) {
        ll temp;
        ll nm = 0;
        cin >> temp;
        if(temp > prev) nm = 1;
        else if(temp < prev) nm = -1;
        if(mode == 0) {
            mode = nm;
        } else if(nm != 0 && mode != nm) {
            count++;
            mode = 0;
        }
        prev = temp;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IL inline
#define RG register
#define LL long long
#define Upd(a) (a)>=mod?(a)-=mod:1
using namespace std;
int n, k;
const int _ =2001, mod = 924844033;
bool Use[_<<1];
LL dp[_<<1][_][2], pre=0, pg=0;
LL jc[_], g[_];
IL int Add (RG int now) {
	if (now<=n) {
		if (now+k>n) return -1;
		return now+k+n;
	}
	else {
		if (now+k-n>n) return -1;
		return now+k-n;
	}
}
IL void work (RG int now) {
	for (RG int i=0; i<=n; ++i) dp[pre+1][i][0]=dp[pre][i][0]+dp[pre][i][1], Upd(dp[pre+1][i][0]);
	++pre;
	Use[now]=1;
	for (RG int i=Add(now); ~i; i=Add(i)) {
		Use[i]=1;
		for (RG int j=1; j<=n; ++j) {
			dp[pre+1][j][1]=dp[pre][j-1][0];
		}
		for (RG int j=0; j<=n; ++j) {
			dp[pre+1][j][0]=dp[pre][j][1]+dp[pre][j][0];
			Upd(dp[pre+1][j][0]);
		}
		++pre;
	}
}
int main () {
	cin>>n>>k;
	dp[0][0][0]=1;
	for (RG int i=1; i<=n; ++i) {
		if (!Use[i]) work (i);
		if (!Use[i+n]) work (i+n);
	}
	jc[0]=1;
	for (RG int i=1; i<=n; ++i) jc[i]=1LL*jc[i-1]*i%mod;
	for (RG int i=0; i<=n; ++i) g[i]=1LL*(dp[n*2][i][0]+dp[n*2][i][1])%mod*jc[n-i]%mod;
	for (RG int i=1, j=1; i<=n; ++i, j=-j) g[0]-=1LL*g[i]*j%mod, g[0]=(g[0]+mod)%mod;
	cout<<g[0];
}


Measured memory_bytes: 125312
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  int K;
  string S;
  cin >> K >> S;

  if(S.size() > K){
    for (int i = 0; i < K; i++) {
      cout << S[i];
    }
      cout << "..." << endl;
  } else {
    cout << S << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

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

	if (100 <= N, N <= 111) {
		cout << "111" << endl;
	}
	else if (112 <= N, N <= 222) {
		cout << "222" << endl;
	}
	else if (212 <= N, N <= 333) {
		cout << "333" << endl;
	}
	else if (312 <= N, N <= 444) {
		cout << "444" << endl;
	}
	else if (412 <= N, N <= 555) {
		cout << "555" << endl;
	}
	else if (512 <= N, N <= 666) {
		cout << "666" << endl;
	}
	else if (612 <= N, N <= 777) {
		cout << "777" << endl;
	}
	else if (712 <= N, N <= 888) {
		cout << "888" << endl;
	}
	else if (812 <= N, N <= 999) {
		cout << "999" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    cout << (n/1000 + (n%1000 != 0))*1000 - n << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int


 int main()
 {

   ll a[2000],n,k=1;
   cin>>n;
   for(ll i=0;i<n ;i++)
    cin>>a[i];
   for(ll i=0;i<n;i++)
    {
        if(a[i]%2==0)
           {
               if(a[i]%3==0||a[i]%5==0)
                k=1;
               else
               {k=0;   break;}
           }


    }

   if(k==1)
    cout<<"APPROVED"<<endl;
   else
    cout<<"DENIED"<<endl;

     return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=max(a*b,c*d);
	cout<<ans<<endl;
	return 0;
} 

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int n;string s;cin>>n>>s;
  int ans=0;
  rep(i,s.size()-2){
    if(s[i]=='A'){
      if(s[i+1]=='B'){
        if(s[i+2]=='C'){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,x,y,ans;
  
  scanf("%d %d",&a,&b);
  
  x=(a*3)+b;
  
  y=x%2;
  
  if(y==1){
    ans = (x-1)/2;
  }else{
    ans = x/2;
  }
  
  printf("%d",ans);
  
  return 0;
  
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <set>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<vector<int>> children;
  vector<int> hukasa;
  vector<int> kazu;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    kazu = vector<int>(n,1);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
      kazu.at(rx) += kazu.at(ry);
    }
    else{
      par.at(rx) = ry;
      kazu.at(ry) += kazu.at(rx);
    }
  }
  void newkazu(){
    int n = kazu.size();
    for(int i=0;i<n;i++){
      kazu.at(i) = kazu.at(root(i));
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
void hukasa(vector<vector<int>> s,vector<vector<int>> table,int &ans,pii frm,int n,int m){
  int x,y;
  tie(x,y) = frm;
  set<pii> se;
  if(x-1 >= 0)se.insert(pii(x-1,y));
  if(x+1 < n)se.insert(pii(x+1,y));
  if(y-1 >= 0)se.insert(pii(x,y-1));
  if(y+1 < m)se.insert(pii(x,y+1));
  for(auto t:se){
    int tx,ty;
    tie(tx,ty) = t;
    if(s.at(tx).at(ty) && table.at(tx).at(ty) == -1){
      table.at(tx).at(ty) = table.at(x).at(y) + 1;
      ans = max(ans,table.at(tx).at(ty));
      hukasa(s,table,ans,t,n,m);
      table.at(tx).at(ty) = -1;
    }
  }
}
void daiku(int frm,vector<vector<pii>> g,vector<int> &cost,int n){
  priority_queue<pii,vector<pii>,greater<pii>> q;
  q.push(pii(cost.at(frm),frm));
  vector<bool> kakutei(n,false);
  while(!q.empty()){
    pii now = q.top();
    q.pop();
    int n1,n2;
    tie(n1,n2) = now;
    if(kakutei.at(n2))continue;
    kakutei.at(n2) = true;
    for(auto t:g.at(n2)){
      int tx,ty;
      tie(tx,ty) = t;
      if(cost.at(tx) > n1 + ty){
        cost.at(tx) = n1 + ty;
        q.push(pii(cost.at(tx),tx));
      }
    }
  }
}

int main(){
  int n;
  cin >> n;
  vector<vector<int>> table(n);
  for(int i=0;i<n;i++){
    if(i==0)continue;
    int tmp;
    cin >> tmp;
    table.at(tmp-1).push_back(i);
  }
  for(int i=0;i<n;i++){
    cout << table.at(i).size() << endl;
  }
}

Measured memory_bytes: 13924
a = list(map(int, input().split()))
ans = float("INF")

for i in range(3):
  n1 = (a[i]//2)*a[(i+1)%3]*a[(i+2)%3]
  n2 = (a[i]-a[i]//2)*a[(i+1)%3]*a[(i+2)%3]
  ans = min(ans, abs(n1-n2))
print(ans)

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

string s, t;

int main(){
	cin >> s >> t;
	if(s[0]==t[2]&&(s[1]==t[1]&&s[2]==t[0])){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//----------------------------------------------
ll n,cl[N],dp[N][2]; vector<ll> vc[N];
ll dfs(ll i,ll p,ll flg){
	if(dp[i][flg]!=-1){
		return dp[i][flg];
	}
	if(flg){
		ll a=1,b=1;	
		for(auto it:vc[i]){
			if(it==p) continue;
			a=(a*dfs(it,i,1))%mod;
			b=(b*dfs(it,i,0))%mod;
		}
		return dp[i][flg]=(a+b)%mod;
	}
	else{
		ll a=1;
		for(auto it:vc[i]){
			if(it==p) continue;
			a=(a*dfs(it,i,1))%mod;
		}
		return dp[i][flg]=a%mod;
	}
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,k,l;
	cin>>n;
	for(i=1;i<n;i++){
		cin>>k>>l;
		vc[k].ps(l);
		vc[l].ps(k);
	}
	memset(dp,-1,sizeof(dp));
	ll an=dfs(1,1,1);
	cout<<an<<endl;
	return 0;	
}

Measured memory_bytes: 134980
#include<iostream>
using namespace std;
int main(){

  int N,K,blood_sum[100],blood_num[100],blood;
  bool flag;

  while(1){
    cin >>N>>K;
    if(N == 0 && K == 0)break;
    
    flag=0;

    for(int i=0 ; i < 100 ; i++)blood_sum[i]=0;

    for(int i=0 ; i < K ; i++)cin >>blood_num[i];

    for(int i=0 ; i < N ; i++){
      for(int j=0 ; j < K ; j++){
	cin >>blood;
	blood_sum[j]+=blood;
      }
    }
    
    for(int i=0 ; i < K ; i++){
      if(blood_sum[i] > blood_num[i]){
	flag=1;
	break;
      }
    }
    
    if(flag == 1){
      cout <<"No"<<endl;
    }else{
      cout <<"Yes"<<endl;
    }
    
  }
  return 0;
  
}

Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
    public static void main(String[] args)throws Exception{
        BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
        String s=b.readLine();
        int a=Integer.parseInt(s);
        System.out.println(a*a*a);
    }
}

Measured memory_bytes: 24236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  int N;
  cin >> N;
  vector<string> S(N);
  rep(i, 0, N) {
    cin >> S[i];
  }
  map<string, long> cnt{};
  rep(i, 0, N) {
    sort_(S[i]);
    cnt[S[i]] += 1;
  }
  long ans = 0;
  for (auto s : cnt) {
      ans += (s.second * (s.second - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16640
def valid?(a, b, c)
  a <= b + c && b <= c + a + 1 && c <= a + b + 1
end
 
def calc(rear, front, west, east, north, south, best)
  path = ''
  loop do
    a = rear + front
    b = west + east
    c = north + south
 
    return path if a + b + c == 0
 
    if east > 0 && valid?(b - 1, c, a)
      rear, front, west, east = east - 1, west, rear, front
      y = 'E'
    elsif north > 0 && valid?(c - 1, a, b)
      rear, front, north, south = north - 1, south, front, rear
      y = 'N'
    elsif south > 0 && valid?(c - 1, a, b)
      rear, front, north, south = south - 1, north, rear, front
      y = 'S'
    elsif west > 0 && valid?(b - 1, c, a)
      rear, front, west, east = west - 1, east, front, rear
      y = 'W'
    else
      throw 'error'
    end
     
    if best
      x = best[path.size]
      return best if x < y
      best = nil if x > y
    end
    path << y  
  end
end
 
def find(target)
  best = nil
  target.permutation(6).to_a.uniq.each do |rear, front, west, east, north, south|
    a = rear + front
    b = west + east
    c = north + south
    if valid?(a, b, c)
      best = calc(rear, front, west, east, north, south, best)
    end
  end
  best
end
 
loop do
  target = STDIN.gets.split.map!(&:to_i)
  break if target.max == 0
  p, q = STDIN.gets.split.map!(&:to_i)
  result = find(target)
  puts result ? result[p-1...q] : 'impossible'
end

Measured memory_bytes: 10032
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum = 0
for i in range(0,N):#0,1,,,,N-1
    if A[i] >= B[i]:
        sum += B[i]
    else:
        sum +=A[i]
        if A[i+1] >= B[i] -A[i]:
            A[i+1] -= B[i]-A[i]
            sum += B[i]-A[i]
        else:
            sum += A[i+1]
            A[i+1] = 0
print(sum)

Measured memory_bytes: 18476
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
using namespace std;

typedef set<string> set_t;
set_t A;

int organize(string str1,string str2){
  A.insert(str1+str2);
  A.insert(str2+str1);
}


int main(){
  int k;
  cin >> k;
  string train;
  for(int i=0;i<k;i++){
    cin >>train;
    int len = train.length();
    for(int j =0;j<len-1;j++){
      string str1;
      string str2;
      for(int l=0;l<=j;l++){
	str1+=train[l];
      }
      for(int l=j+1;l<len;l++){
	str2+=train[l];
      }
      organize(str1,str2);
      reverse(str1.begin(),str1.end());
      organize(str1,str2);
      reverse(str2.begin(),str2.end());
      organize(str1,str2);
      reverse(str1.begin(),str1.end());
      organize(str1,str2);
    }
    cout << A.size() << endl;
    A.clear();
  }
}

Measured memory_bytes: 3252
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
s=s0()

c=Counter(s)
d=list(c.values())
MOD=10**9+7

def prod(line):
    r=1
    for i in line:
        r*=i
        r%=MOD
    return r


ans=prod([i+1 for i in d])
print((ans-1)%MOD)

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

int main() {
    long long n;
    cin >> n;
    long long ans;
    if(n%11==0)ans=(n/11)*2;
    else if(n%11>0&&n%11<=6) ans=(n/11)*2+1;
    else ans=(n/11)*2+2;
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
inf = 10 ** 9 + 7
N , M = map(int,input().split())
if abs(N - M) > 1:
    print(0)
elif abs(N - M) == 1:
    print(math.factorial(N) * math.factorial(M) % inf)
else:
    print(math.factorial(N) * math.factorial(M) * 2 % inf)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    V<int> a(n), b(n), c(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

    V<V<int> > dp(n + 1, V<int>(3, 0));
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for(int i = 1; i <= n; i++){
        dp[i][0] = max(dp[i - 1][1] + a[i - 1], dp[i - 1][2] + a[i - 1]);
        dp[i][1] = max(dp[i - 1][0] + b[i - 1], dp[i - 1][2] + b[i - 1]);
        dp[i][2] = max(dp[i - 1][0] + c[i - 1], dp[i - 1][1] + c[i - 1]);
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}


Measured memory_bytes: 6912
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** ベルの種類数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			System.out.println(IntStream.range(0, N).map(i -> scanner.nextInt()).sorted().limit(2).sum());
		}
	}
}


Measured memory_bytes: 26964
def resolve():
    a, b, c = map(int, input().split())
    k = int(input())
    n = 0
    while a >= b:
        b *= 2
        n += 1
    while b >= c:
        c *= 2
        n += 1
    print("Yes" if n <= k else "No")


if __name__ == '__main__':
    resolve()


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

int main()
{
    bool flag = true;
    std::string s;
    std::cin >> s;
    while(s.empty() == false && flag == true){
        if(s.size() < 5){
            flag = false;
            break;
        }
        if(s.substr(s.size() - 5, 5) == "dream"){
            s.erase(s.end() - 5, s.end());
        }
        else if(s.substr(s.size() - 5, 5) == "erase"){
            s.erase(s.end() - 5, s.end());
        }
        else if(s.size() < 6){
            flag = false;
            break;
        }
        else if(s.substr(s.size() - 6, 6) == "eraser"){
            s.erase(s.end() - 6, s.end());
        }
        else if(s.size() < 7){
            flag = false;
            break;
        }
        else if(s.substr(s.size() - 7, 7) == "dreamer"){
            s.erase(s.end() - 7, s.end());
        }
        else{
            flag = false;
        }
    }
    if(flag == true){
        std::cout << "YES" << std::endl;
    }
    else{
        std::cout << "NO" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int cont = 0;
	if(b >= a*c)
		printf("%d\n", c);
	else
		if(a > b)
			printf("0\n");
		else{
			while(b >= a){
				b = b - a;
				cont++;
			}
			printf("%d\n", cont);
		}

	return 0;
}

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

using namespace std;

int main(int argc, char* argv[]) {
  string a, b, c;
  cin >> a >> b >> c;

  char turn = 'a';
  int cursor_a = 0;
  int cursor_b = 0;
  int cursor_c = 0;
  while (true) {
    if (turn == 'a') {
      if (cursor_a == a.size()) {
        cout << "A" << endl;
        return 0;
      }
      turn = a[cursor_a++];
    } else if (turn == 'b') {
      if (cursor_b == b.size()) {
        cout << "B" << endl;
        return 0;
      }
      turn = b[cursor_b++];
    } else if (turn == 'c') {
      if (cursor_c == c.size()) {
        cout << "C" << endl;
        return 0;
      }
      turn = c[cursor_c++];
    }
  }

  return 0;
}

Measured memory_bytes: 256
/*
 * SmallLargeEqual.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
using namespace std;

int main(void) {
	int a, b = 0;
	cin >> a >> b;

	if (a < b) {
		cout << "a < b" << endl;
	} else if (a > b) {
		cout << "a > b" << endl;
	} else {
		cout << "a == b" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=(a);i<(b);++i)
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795;
/*
int main()
{
	int a = 0, b = 0, c = 0;
	string s;
	cin >> s;
	if (s[0] == 'a')
	{
		a++;
	}else{
		if(s[0] == 'b'){
			b++;
		}else{
			c++;
		}
	}
	if (s[1] == 'a')
	{
		a++;
	}else{
		if(s[1] == 'b'){
			b++;
		}else{
			c++;
		}
	}
	if (s[2] == 'a')
	{
		a++;
	}else{
		if(s[2] == 'b'){
			b++;
		}else{
			c++;
		}
	}
	if(a == 1 && b==1 && c==1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}
*/
int main(){
	string s;
	cin >> s;
	if(s[0] != s[1] && s[1] != s[2] && s[0] != s[2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
string s[8];
vector<vector<int> > rot;
void do_rotate(vector<int>& v, int a, int b, int c, int d){
  int t = v[a];
  v[a] = v[b]; v[b] = v[c]; v[c] = v[d]; v[d] = t;
}
void make_rot(){
  vector<int> v(6);
  REP(i, 6) v[i] = i;
  for(int k = 0; k < 6; k++){
    if(k % 2 == 0) do_rotate(v, 0, 2, 5, 3);
    else do_rotate(v, 0, 1, 5, 4);
    for(int l = 0; l < 4; l++){
      do_rotate(v, 1, 2, 4, 3);
      rot.push_back(v);
    }
  }
}
bool used[8];
int d_id[8];
int r_id[8];
// {id1, id2, r1, r2}
int role[12][4] = {
  {0, 1, 2, 3},
  {0, 2, 1, 4},
  {0, 4, 5, 0},
  {1, 3, 1, 4},
  {1, 5, 5, 0},
  {2, 3, 2, 3},
  {2, 6, 5, 0},
  {3, 7, 5, 0},
  {4, 5, 2, 3},
  {4, 6, 1, 4},
  {5, 7, 1, 4},
  {6, 7, 2, 3}
};
bool match(char c, char d){
  if(c > d) swap(c, d);
  return c - 'A' + 'a' == d;
}
bool dfs(int k){
  for(int i = 0; i < 12; i++) if(role[i][1] < k){
    int id1 = role[i][0], id2 = role[i][1];
    int r1 = role[i][2], r2 = role[i][3];
    char c1 = s[d_id[id1]][rot[r_id[id1]][r1]];
    char c2 = s[d_id[id2]][rot[r_id[id2]][r2]];
    if(!match(c1, c2)) return false;
  }
  if(k == 8) return true;
  for(int i = 0; i < 8; i++) if(!used[i]){
    used[i] = true;
    d_id[k] = i;
    for(int j = 0; j < 24; j++){
      r_id[k] = j;
      if(dfs(k + 1)) return true;
    }
    used[i] = false;
  }
  return false;
}
int main(){
  make_rot();
  while(true){
    REP(i, 8) cin >> s[i];
    if(cin.eof()) break;
    memset(used, 0, sizeof used);
    memset(d_id, 0, sizeof d_id);
    memset(r_id, 0, sizeof r_id);
    if(dfs(0)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const int MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int main() {
    while(true){
        int a,b;
        char op;
        cin >> a >> op >> b;
        if(op == '?') return 0;
        switch (op)
        {
        case '+':
            cout << a+b << endl;
            break;
        case '-':
            cout << a-b << endl;
            break;
        case '*':
            cout << a*b << endl;
            break;
        case '/':
            cout << a/b << endl;
            break;
        }

    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
 
int main (){
  int N;
  cin>>N;
  vector<int>D(N);
  rep(i,N){
    int x,y;
    cin>>x>>y;
    if(x==y) D[i]=1;
    else D[i]=0;
  }
  rep(i,N-2){
    if(D[i]+D[i+1]+D[i+2]==3){
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
}

Measured memory_bytes: 3624
/*
    I was lying to myself
*/




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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int>pii;
typedef unsigned long long ull;

#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF          0x3f3f3f3f
#define inputfile    freopen("input.txt", "r", stdin)
#define outputfile   freopen("output.txt", "w", stdout)
#define appendfile   freopen("output.txt", "a", stdout)


struct hash_pair
{
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);auto hash2 = hash<T2> {}(p.second);return hash1 ^ hash2;
    }
};

ll t;
ll mod=N;
ll BigMod(ll base,ll pow,ll mod)
{
    if(pow==0||base==1)return 1;
    else if(pow==1)return base;
    else if(pow%2)return BigMod(base,pow-1,mod)*base%mod;
    else {ll x=(BigMod(base,pow/2,mod)%mod);x=(x*x)%mod;return x;}
}



string s;
ll arr[1002][1002],dp[1002][1002];

ll solve(ll n,ll m)
{
    if(dp[n][m]!=-1)return dp[n][m];
    if(arr[n][m]==1)return 0;
    if(n==0||m==0)return 0;
    return dp[n][m]=(solve(n-1,m)+solve(n,m-1))%mod;
}


int main()
{
    //fast;
    ll a,b,c,d,e,f,g,i,j;
    ll n,m,k;
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        cin>>s;
        for(j=0;j<m;j++)
        {
            if(s[j]=='#')arr[i][j+1]=1;
        }
    }
    memset(dp,-1,sizeof(dp));
    dp[1][1]=1;
    cout<<solve(n,m)%mod<<endl;
    return 0;
}



Measured memory_bytes: 19392
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)

using namespace std;
ll n;
int main(){
    cin>>n;
    if(n%2==1){
        puts(0);
    }else{
        n/=2;
        ll ans=0;
        ll e=1;
        ll c=1;
        while(c!=0){
            ans+=n/ll(pow(5,e));
            c=n/ll(pow(5,e));
            e++;
        }
        puts(ans);
    }
}


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

co = sum(a)

temp = a[0]
ans = 0
for i in range(n):
    temp = a[i] - b[i]
    a[i] = max([0,temp])
    if a[i] == 0:
        a[i+1] = max([0,a[i+1] + temp])

print(co - sum(a))

Measured memory_bytes: 18624
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int ans = 8 - (X - 400) / 200;

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

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

		int n = sc.nextInt();
		int k = sc.nextInt();

		int max = (n - 1) * (n - 2) / 2;

		if (max < k) {
			System.out.println(-1);
			return;
		}

		int m = (n - 1) + (max - k);
		System.out.println(m);
		for (int i = 0; i < n - 1; i++) {
			System.out.print(1);
			System.out.print(" ");
			System.out.println(i + 2);
		}

		int i = 0;
		int s = 2;
		int t = 3;
		while (i < max - k) {
			System.out.print(s);
			System.out.print(" ");
			System.out.println(t);
			i++;
			t++;
			if (t > n) {
				s++;
				t = s + 1;
			}
		}
	}
}


Measured memory_bytes: 23636
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	vector<int> a(3);
	while (cin >> a[0] >> a[1] >> a[2]) {
		sort(a.begin(), a.end());
		ll ans = 8e18;
		do {
			ans = min(ans, 1LL * a[1] * a[2] * abs(a[0] / 2 - (a[0] - a[0] / 2)));
		} while (next_permutation(a.begin(), a.end()));
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n; cin >> n;
   V<int> a(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }

   V<P<int,int>> p(n);
   for (int i = 0; i < n; i++) {
      p[i] = make_pair(a[i], i);
   }
   sort(p.begin(), p.end());

   int ans = 0;
   for (int i = 0; i < n; i++) {
      if (i % 2 == 0 && p[i].second % 2 == 1) {
         ans++;
      }
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 2688
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
cnt = 0
memo = 0
for aa in a:
    if aa % 4 == 0:
        cnt += 1
    elif aa % 2 == 1:
        memo += 1
print('Yes' if (cnt >= memo - 1 and cnt + memo == n) or cnt >= memo else 'No')


Measured memory_bytes: 12496
/*
Author : N_o_o_B
Created : May 30 2020 17:35:21 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    string s;
    cin >> s;
    for(char& c:s){
        if(c=='?') c = 'D';
    }
    cout << s << endl;
    // int ans = 0;
    // fori(i,sz(s)-1){
    //     if(s[i]=='P' and s[i+1]=='D') ans++;
    //     ans += (s[i]=='D');
    // }
    // ans += (s.back()=='D');

    // cout << ans << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define INF 2e9
#define ll long long


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

    double v[n];
    for(int i=0; i<n; i++){
        cin>>v[i];
    }

    sort(v, v+n);

    for(int i=0; i<n-1; i++){
        v[i+1] = (v[i]+v[i+1])/2;
    }

    printf("%.6f\n", v[n-1]);
}

Measured memory_bytes: 256
import heapq
N,M = map(int,input().split())
AB = [[] for i in range(M+1)]
for i in range(N):
    a,b = list(map(int,input().split()))
    if a <= M:
        AB[a].append(-b)
work = 0
AB2 = []
heapq.heapify(AB2)
for i in range(1,M+1):
    for j in AB[i]:
        heapq.heappush(AB2,j)
    if not AB2:
        continue
    b = heapq.heappop(AB2)
    work += -b
print(work)

Measured memory_bytes: 23752