akhauriyash/Code-Regression huggingface dataset:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

ls = ril()
res = 0
for x in ls:
    if x == 3:
        res += 100000
    elif x == 2:
        res += 200000
    elif x == 1:
        res += 300000
if ls[0] == ls[1] == 1:
    res += 400000
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    string s;
    int k;
    cin>>k;
    cin>>s;
    int n=s.length();
    if(n<=k)
    {
        cout<<s;
    }
    else
    {
        string ans=s.substr(0,k);
        ans+="...";
        cout<<ans;
    }
    
}


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

class Dice{
    public:
    Dice(int t, int s, int e, int w, int n, int b){
        top = t;
        south = s;
        east = e;
        west = w;
        north = n;
        bottom = b;
    };
    
    int getTop(){return top;}
    int getSouth(){return south;}
    int getEast(){return east;}
    int getWest(){return west;}
    int getNorth(){return north;}
    
    void rollNorth();
    void rollWest();
    void rollEast();
    void rollSouth();

    private:
    int top, south, east, west, north, bottom;
};

void Dice::rollNorth(){
    int tmp;
    tmp = top;
    top = south;
    south = bottom;
    bottom = north;
    north = tmp;
}

void Dice::rollSouth(){
    int tmp;
    tmp = top;
    top = north;
    north = bottom;
    bottom = south;
    south = tmp;
}

void Dice::rollEast(){
    int tmp;
    tmp = top;
    top = west;
    west = bottom;
    bottom = east;
    east = tmp;
}

void Dice::rollWest(){
    int tmp;
    tmp = top;
    top = east;
    east = bottom;
    bottom = west;
    west = tmp;
}

int main(void){
    int t, s, e, w, n, b;
    cin >> t >> s >> e >> w >> n >> b;
    Dice dice1(t, s, e, w, n, b);
    char op;
    while(cin.get(op)){
        switch(op){
            case 'N':
            dice1.rollNorth(); break;
            case 'E':
            dice1.rollEast(); break;
            case 'W':
            dice1.rollWest(); break;
            case 'S':
            dice1.rollSouth(); break;
            
            default: break;
        }
    }
    
    cout << dice1.getTop() << endl;
    return 0;
}

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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while(b <= a && k) {
        b *= 2;
        k--;
    }
    while(c <= b && k) {
        c *= 2;
        k--;
    }
    if(b > a && c > b) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
   int a, b, c, d, sum;
   scanf("%d %d %d %d", &a, &b, &c, &d);
   sum = a + b + c + d;
   printf("%d\n%d\n", sum / 60, sum % 60);
   return 0;
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;

  vector<int> vec = {A, B, C};
  sort(vec.begin(),vec.end());

  if(vec.at(0)==5 and vec.at(1)==5 and vec.at(2)==7){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

}

Measured memory_bytes: 256
import sys
import collections


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
s = []
ans = 0
for i in range(N):
    s.append(''.join(sorted(S())))

c = collections.Counter(s)

for i in set(s):
    n = c[i]
    ans += n * (n-1) // 2
print(ans)


Measured memory_bytes: 70876
n = gets.chomp.to_i
s = gets.chomp

min_l = 0
max_l = n/2+1

while min_l+1 < max_l
  l = (min_l + max_l) / 2
  memo = {}
  ok = false
  0.upto(n-l) do |i|
    k = s[i...i+l]
    if memo[k]
      if memo[k]+l-1 < i
        ok = true
        break
      end
    else
      memo[k] = i
    end
  end
  if ok
    min_l = l
  else
    max_l = l
  end
end

puts min_l

Measured memory_bytes: 17020
n,k=map(int,input().split())
cnt=[0]*(n+1)
for _ in range(k):
  tmp=int(input())
  arr=list(map(int,input().split()))
  for val in arr:
    cnt[val]+=1
ans=0
for i in range(1,n+1):
  if cnt[i]==0:
    ans+=1
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <bitset>
#include <cmath>


using namespace std;

const int N = 100000000 + 1;
bitset<N> arr;


void eratosthenes() {
    for (int i = 2; i < N; ++i) {
        arr[i] = 1;
    }

    for (int i = 2; i < sqrt(N); ++i) {
        if (arr[i]) {
            for (int j = 2; i * j < N; ++j) {
                arr[i*j] = 0;
            }
        }
    }
}


bool is_prime(int n) {
    return arr[n];
}


int main() {
    eratosthenes();

    int n;
    cin >> n;

    int count;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        if (is_prime(x)) {
            // cerr << "debug: " <<  x << endl;
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

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

int main()
{
    string S;
    cin >> S;
    int count = 0;
    for (int i = 0; i < S.size() / 2;i++)
    {
        if (S[i] != S[S.size() -1- i])
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please
 
const int mask = (1 << 5) - 1;
const int mod = 1e9 + 7;
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
 
 
	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);
 
	ll dp[1001];
	dp[0] = 1;
	getchar_unlocked();
	getchar_unlocked();
	rep1(w, W - 1) dp[w] = (getchar_unlocked() == '.' ? dp[w - 1] : 0);
	getchar_unlocked();
 
	rep1(h, H - 1) {
		dp[0] = (getchar_unlocked() == '.' ? dp[0] : 0);
		rep1(w, W - 1) {
			dp[w] = (getchar_unlocked() == '.' ? dp[w] + dp[w - 1] : 0);
			if (!(h + w & mask)) dp[w] %= mod;
		}
		getchar_unlocked();
	}
	printf("%d", dp[W - 1] % mod);
 
	Would you please return 0;
}

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

int main () {
	int n ;
  	cin >> n ;
  	string s[n] ;
  	int a = 0, w = 0 , t = 0 , r = 0 ;
  	for (int i = 0 ; i < n ; i++) {
    	cin >> s[i] ; 
      	if (s[i] == "AC") a++ ;
      	else if (s[i] == "WA") w ++ ;
      	else if (s[i] == "TLE") t ++ ;
      	else r++ ;
    }
  	cout << "AC x " << a << endl ;
  	cout << "WA x " << w << endl ;
  	cout << "TLE x " << t << endl ;
  	cout << "RE x " << r << endl ;
  	return 0 ;
}

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

string days[7] =
{
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday",
	"Sunday",
	"Monday",
	"Tuesday"
};

int daysPerMonth[11] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30 };

int main()
{
	int m, d;
	while (cin >> m >> d, m + d)
	{
		int day = 0;
		for (int i = 0; i < m - 1; i++)
		{
			day += daysPerMonth[i];
		}
		day += d;

		cout << days[day % 7] << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=55;
int a[N],w[N],n,m,K,S,T,aim;
ull C[N][N],ans;

int main(){
	read(n),read(K);
	read(S),read(T);
	rep(i,1,n){
		read(a[++m]);
		if((a[m]&S)!=S) m--;
		else if((a[m]|T)!=T) m--;
	}
	n=m,aim=(~S)&T;
	C[0][0]=1;
	rep(i,1,n){
		C[i][0]=1;
		rep(j,1,n){
			C[i][j]=C[i-1][j]+C[i-1][j-1];
		}
	}
	rep(l,1,n){
		rep(r,l+1,n){
			w[r]=(a[l]^a[r])&aim;
		}
		for(int s=aim;;s=(s-1)&aim){
			int tot=0;
			rep(r,l+1,n){
				tot+=((w[r]|s)==s);
			}
			ull sum=0;
			rep(i,0,K-1){
				sum+=C[tot][i];
			}
			if(__builtin_popcount(aim^s)%2==0){
				ans+=sum;
			}
			else{
				ans-=sum;
			}
			if(!s) break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cmath>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int a2[3], b2[3]; // 1 ~ 100 each
    int digita = 0, digitb = 0;
    while (a != 0) {
        a2[digita] = a % 10;
        a /= 10;
        digita++;
    }
    while (b != 0) {
        b2[digitb] = b % 10;
        b /= 10;
        digitb++;
    }
    int c = 0;
    int digitc = 0;
    for (int i = 0; i < digitb; i++) {
        c += b2[i] * pow(10, digitc);
        digitc++;
    }
    for (int i = 0; i < digita; i++) {
        c += a2[i] * pow(10, digitc);
        digitc++;
    }
    //cout << c << endl;
    for (int i = 4; i <= (int)sqrt(c) + 1; i++) { //from 11
        if (c == i * i) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>

using namespace std;

int N, M;
int BIT_J[2000][2000];
int BIT_O[2000][2000];
int BIT_I[2000][2000];

void add_J(int a, int b, int w){
	
	// (a, b)?????????????´????w????¶???? O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		for(int y = b; y <= M; y += y & -y){
			BIT_J[x][y] += w;
		}
	}
}

int sum_J(int a, int b){
	
	// (1, 1)??????(a, b)?????§???????´????????¨?????????? O(log N)
	
	int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		for(int y = b; y > 0; y -= y & -y){
			ret += BIT_J[x][y];
		}
	}
	return ret;
}

void add_O(int a, int b, int w){
	
	// (a, b)?????????????´????w????¶???? O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		for(int y = b; y <= M; y += y & -y){
			BIT_O[x][y] += w;
		}
	}
}

int sum_O(int a, int b){
	
	// (1, 1)??????(a, b)?????§???????´????????¨?????????? O(log N)
	
	int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		for(int y = b; y > 0; y -= y & -y){
			ret += BIT_O[x][y];
		}
	}
	return ret;
}

void add_I(int a, int b, int w){
	
	// (a, b)?????????????´????w????¶???? O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		for(int y = b; y <= M; y += y & -y){
			BIT_I[x][y] += w;
		}
	}
}

int sum_I(int a, int b){
	
	// (1, 1)??????(a, b)?????§???????´????????¨?????????? O(log N)
	
	int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		for(int y = b; y > 0; y -= y & -y){
			ret += BIT_I[x][y];
		}
	}
	return ret;
}

string map[1024];

int main(){
	
	int K;
	
	cin >> M >> N >> K;
	
	for(int i = 0; i < M; i++){
		cin >> map[i];
	}
	
	N = 1024;
	M = 1024;
	
	for(int i = 0; i <= M; i++){
		for(int j = 0; j <= N; j++){
			BIT_J[i][j] = 0;
			BIT_O[i][j] = 0;
			BIT_I[i][j] = 0;
		}
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			if(map[i][j] == 'J'){
				add_J(j + 1, i + 1, 1);
			}else if(map[i][j] == 'O'){
				add_O(j + 1, i + 1, 1);
			}else if(map[i][j] == 'I'){
				add_I(j + 1, i + 1, 1);
			}
		}
	}
	
	M = 4;
	N = 7;
	/*
	for(int i = 1; i <= M; i++){
		for(int j = 1; j <= N; j++){
			printf("%d ", BIT_J[j][i]);
		}
		printf("\n");
	}
	printf("\n");
	
	for(int i = 1; i <= M; i++){
		for(int j = 1; j <= N; j++){
			printf("%d ", BIT_O[j][i]);
		}
		printf("\n");
	}
	printf("\n");
	
	for(int i = 1; i <= M; i++){
		for(int j = 1; j <= N; j++){
			printf("%d ", BIT_I[j][i]);
		}
		printf("\n");
	}
	printf("\n");
	*/
	int a, b, c, d;
	
	for(int loop = 0; loop < K; loop++){
		cin >> b >> a >> d >> c;
		printf("%d ", sum_J(c, d) + sum_J(a - 1, b - 1) - sum_J(a - 1, d) - sum_J(c, b - 1));
		printf("%d ", sum_O(c, d) + sum_O(a - 1, b - 1) - sum_O(a - 1, d) - sum_O(c, b - 1));
		printf("%d\n", sum_I(c, d) + sum_I(a - 1, b - 1) - sum_I(a - 1, d) - sum_I(c, b - 1));
	}
	
	return 0;
}

Measured memory_bytes: 30896
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner console = new Scanner(System.in);
      	int num = console.nextInt();
        console.nextLine();
      
      	int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
      
      	for(int i = 0; i < num; i++){
          String str = console.nextLine();
          switch(str){
            case "AC":
              ac++;
              break;
            case "WA":
              wa++;
              break;
            case "TLE":
              tle++;
              break;
            case "RE":
              re++;
              break;
          }
        }
        
        // 最終出力
        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
     	System.out.println("TLE x " + tle);
      	System.out.println("RE x " + re);
	}
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

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

const ll mod = 1e9 + 7;
const int MAXN = 1e5 + 5;

string S;
ll LA, LQ, RC, RQ;

ll pow3[MAXN];

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    pow3[0] = 1;
    for(int a = 1; a < MAXN; a++){
        pow3[a] = pow3[a - 1] * 3 % mod;
    }

    cin >> S;
    RC = count(allof(S), 'C');
    RQ = count(allof(S), '?');

    ll ans = 0;

    for(char c : S){
        RC -= c == 'C';
        RQ -= c == '?';

        if(c == 'B' || c == '?'){
            ll cntL = pow3[LQ] * LA % mod;
            if(LQ){
                cntL += LQ * pow3[LQ - 1] % mod;
            }

            ll cntR = pow3[RQ] * RC % mod;
            if(RQ){
                cntR += RQ * pow3[RQ - 1] % mod;
            }

            ans += (cntL % mod) * (cntR % mod);
            ans %= mod;
        }

        LA += c == 'A';
        LQ += c == '?';
    }

    cout << ans;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

const int N=2000;
int ab[N+N+1],bc[N+N+1],ac[N+N+1];
int ok(const string&a,const string&b,int i,int j){
    return (i<0||j<0||i>=sz(a)||j>=sz(b)||a[i]=='?'||b[j]=='?'||a[i]==b[j]);
}
int get(int *f,int i){
    if(i<-N||i>N)return 0;
    return f[i+N];
}
int32_t main(){
    string a,b,c;
    cin>>a>>b>>c;
    for(int i=-N;i<=N;++i){
        forn(j,N)
            if(!ok(b,a,j,i+j))
                ab[i+N]=1;
    }
    for(int i=-N;i<=N;++i){
        forn(j,N)
            if(!ok(c,a,j,i+j))
                ac[i+N]=1;
    }
    for(int i=-N;i<=N;++i){
        forn(j,N)
            if(!ok(c,b,j,i+j))
                bc[i+N]=1;
    }
    int ans=sz(a)+sz(b)+sz(c);
    for(int i=-N-N;i<=N+N;++i){
        for(int j=-N-N;j<=N+N;++j){
            int k=j-i;
            int bad=get(ab,i)|get(ac,j)|get(bc,k);
            if(!bad){
                int la=0,lb=i,lc=j;
                int ra=sz(a),rb=lb+sz(b),rc=lc+sz(c);
                int l=min({la,lb,lc});
                int r=max({ra,rb,rc});
                upn(ans,r-l);
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


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

int main() {
  int N;
  cin >>N;
  float x, s=0;
  string u;
  for (int i=0; i<N; i++) {
    cin >> x;
    cin >> u;
    if (u=="BTC") s+=x*380000;
    else s+=x;
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;

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

vector<int> a[11];

int dp[11][2001];

int main() {
  int n, k;
  cin >> n >> k;
  rep (i, n) {
    int c, g;
    cin >> c >> g;
    --g;
    a[g].push_back(c);
  }
  rep (i, 10) sort(a[i].begin(), a[i].end(), greater<int>());
  rep (i, 10) rep (j, a[i].size() - 1) {
    a[i][j + 1] += a[i][j];
  }
  rep (i, 10) rep (j, a[i].size()) {
    a[i][j] += j * (j + 1);
  }
  rep (i, 10) {
    rep (j, n + 1) {
      dp[i + 1][j] = dp[i][j];
      rep (ii, min(j, int(a[i].size()))) {
	//cout << i << " " << j << " " << ii << " " << dp[i][j - ii] << " " << a[i][ii] << endl;
	dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - ii - 1] + a[i][ii]);
	//cout << dp[i + 1][j] << endl;
      }
    }
  }
  cout << dp[10][k] << endl;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
int a[200000];

int main(void){
  int n, i, f=0, low=0;
  long long int c =0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    low--;
    if(a[n-1-i] < low) break;
    if(a[n-1-i] > low){
      low = a[n-1-i];
      c+=a[n-1-i];
    }    
  }
  if(i!=n || low > 0) printf("-1\n");
  else printf("%lld\n",c);
  return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    long long a , b , c;
    cin >> a >> b >> c;
    long long t = (a + b - c);
    if(t > 0){
        cout << "No" << endl;
        return 0;
    }
    unsigned long long x = (unsigned long long)t * (unsigned long long)t, y = 4 * (unsigned long long)a * (unsigned long long)b;
    cout << (x > y? "Yes" : "No") << endl;
    return 0;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    int m = n - n % 2;
    vector<pii> v;
    for (int i = 1; i <= m/2; i++) {
        v.emplace_back(i, m - i + 1);
        // cout << i << " " << m - i + 1 << endl;
    }
    if (n % 2  > 0) v.emplace_back(0, n);

    // cout << v.size() << endl;
    vector<pii> ans;
    for (int i = 1; i < v.size(); i++) {
        auto p1 = v[i - 1];
        auto p2 = v[i];

        ans.emplace_back(p1.first, p2.first);
        ans.emplace_back(p1.first, p2.second);
        ans.emplace_back(p1.second, p2.first);
        ans.emplace_back(p1.second, p2.second);
    }
    if (n >= 5) {
        auto p1 = v.back();
        auto p2 = v[0];

        ans.emplace_back(p1.first, p2.first);
        ans.emplace_back(p1.first, p2.second);
        ans.emplace_back(p1.second, p2.first);
        ans.emplace_back(p1.second, p2.second);
    }

    vector<pii> filtered;
    for(auto& p: ans) {
        if (p.first == 0 or p.second == 0) continue;
        filtered.emplace_back(p);
        // cout << p.first << " " << p.second << endl;
    }

    cout << filtered.size() << endl;
    for(auto& p: filtered) {
        // if (p.first == 0 or p.second == 0) continue;
        cout << p.first << " " << p.second << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int k = sc.nextInt();
    int[] arr = new int[] {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    System.out.println(arr[k - 1]);
  }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int k,s;
    cin >> k >> s;

    int sum=0;

    for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){
                if(s-i-j>=0 && s-i-j<=k){
                    sum++;
                }
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
typedef long long int ll;
using namespace std;
map<ll,ll> mym;
ll res[100005];
int main(){
  ll N;
  cin>>N;
  ll sum=0;
  for(ll i=0; i<N; i++){
    ll t;
    cin>>t;
    sum+=t;
    mym[t]++;
  }
  ll Q;
  cin>>Q;
  for(ll i=0; i<Q; i++){
    ll b,c;
    cin>>b>>c;
    sum-=mym[b]*b;
    sum+=mym[b]*c;
    mym[c]+=mym[b];
    mym[b]=0;
    res[i]=sum;
  }
  for(ll i=0; i<Q; i++) cout<<res[i]<<endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N,K;
vector<P> res;
vector<ll> g[101];
vector<P> cands;

void addedge(ll u,ll v){
  res.push_back(P(u,v));
  g[u].push_back(v);
  g[v].push_back(u);
}

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

  cin>>N>>K;
  ll ub=(N-1)*(N-2)/2;
  if(K>ub){
    cout<<-1<<endl;
    return 0;
  }

  repl(i,1,N){
    addedge(0,i);
  }
  repl(i,1,N)repl(j,i+1,N){
    cands.push_back(P(i,j));
  }

  rep(i,ub-K){
    addedge(cands[i].fi,cands[i].se);
  }

  cout<<res.size()<<endl;
  rep(i,res.size())cout<<res[i].fi+1<<" "<<res[i].se+1<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
int m,a[100005],d[100005],pass[100005];
vector<int> to[100005],from[100005];
//每次将favourite增加1,会产生什么效果? 
int getdist(int t,int fr){
	return (t-fr+m)%m;
} 
int main(){
	int n,fa=1;
	long long ans=0LL,cura=0LL;
	scanf("%d%d",&n,&m);
	rep(k,n)scanf("%d",&a[k]);
	rep1(k,n-1)to[a[k]].push_back(a[k-1]);
	rep(k,n-1)from[a[k]].push_back(a[k+1]);
	rep1(k,n-1)if(a[k]<a[k-1]&&a[k]!=1)pass[1]++;
	for(int k=2;k<=m;k++)pass[k]=pass[k-1]-to[k].size()+from[k-1].size();
	rep(k,n-1)cura+=ll(min(getdist(a[k+1],a[k]),a[k+1]));ans=cura;
	for(int f=1;f<m;f++){
		//after increasing f
		//to[f]:things become worse
		//ones passes f(beg!=f,end!=f):time -1
		cura-=ll(pass[f]);
		rep(k,to[f].size())cura+=ll(getdist(f,to[f][k])-1);
		if(cura<ans){
			ans=cura;
			fa=f+1;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 10368
#include<stdio.h>
    int main(void){
      long long a,b,k;
      scanf("%lld%lld%lld",&a,&b,&k);
      while(a!=0&&k!=0){
        a--;
        k--;
      }
      if(k==0){
        printf("%lld %lld\n",a,b);
        return 0;
      }
          while(b!=0&&k!=0){
        b--;
        k--;
      }
      printf("%lld %lld\n",a,b);
      return 0;
    }
      
      
      

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


int main()
{
	int n;
	cin>>n;
	int arr[100];
	for(int i=1;i<=n;i++)
        cin>>arr[i];
    int sum=0;
	for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            sum+=arr[i]*arr[j];
        }
    }
    cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  string a,b;
  int x=0,y=0;
  while(n--){
    cin>>a>>b;
    if(a==b){
      x++; y++;
    }else if(a>b){
      x+=3;
    }else{
      y+=3;
    }
  }

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

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){    
    int a,b,c;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    if(a == b && b == c) puts("Yes");
    else puts("No");
    return 0;
}

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

int main(){
//freopen("test.in","r",stdin);
int n;
string s;
cin>>n>>s;
if(n%2==1){
    cout<<"No";
    return 0;
}
string a="";
for(int k=0;k<n/2;k++)
    a+=s[k];
a=a+a;
if(a==s)
    cout<<"Yes";
else cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const ll C = 5e8;
const int MAX_N = 2e4 + 5;

ll target [MAX_N];
ll A [MAX_N];
ll B [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    int pi;
    cin >> pi;

    target[pi] = 2 * C + i;
  }

  A[n + 1] = C;
  B[n + 1] = C;
  for (int i = n; i >= 1; i--) {
    ll amax = A[i + 1] - 1;
    ll bmin = B[i + 1] + 1;

    if (target[i] - amax >= bmin) {
      A[i] = amax;
      B[i] = target[i] - amax;
    } else {
      A[i] = target[i] - bmin;
      B[i] = bmin;
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << A[i] << " ";
  }
  cout << endl;
  for (int i = 1; i <= n; i++) {
    cout << B[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long int
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fo1(i, n) for (ll i = 1; i <= n; i++)
#define pi (double)3.14159265359
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define vect vector<ll>
#define pb push_back
#define mod (ll) pow(10, 9) + 7
#define prq priority_queue <int, vector<int>, greater<in1t>>
#define scan(x) scanf("%lld",&x);
#define print(x) printf("%lld\n",x);
using namespace std;

void solve(){
	ll n;
	cin>>n;
	vect v(n);
	fo(i,n){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	ll ans = v[n-1];
	ll z=n/2 -1;
	for(ll i=n-2;i>(n-2-z);i--){
		ans+=2*v[i];
	}
	if(n%2 == 1) ans+=v[n-2-z];
	cout<<ans<<endl;
} 
int main(){
	int t=1;
	//scanf("%d",&t);
	while (t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF 2000'000'000

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);
	ll n, ans = 1000;
	cin >> n;
	vector < ll > v(n);
	for(ll & i : v)
		cin >> i;
	for(int i = 1; i < n; i++){
		if(v[i] > v[i-1])
			ans += (ans / v[i-1]) * (v[i] - v[i-1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

int main(){
    int a, b;
    while(cin >> a >> b, a){
        int n;
        cin >> n;

        long long dp[20][20] = {{0}};
        rep(i,n){
            int x,y;
            cin >> x >> y;
            x--; y--;
            dp[x][y] = -1;
        }

        dp[0][0] = 1;
        rep(i,a){
            rep(j,b){
                if(i == 0 && j == 0) continue;
                if(dp[i][j] == -1) continue;
                long long tmp = 0;
                if(i - 1 >= 0) tmp += (dp[i - 1][j] == -1 ? 0 : dp[i - 1][j]);
                if(j - 1 >= 0) tmp += (dp[i][j - 1] == -1 ? 0 : dp[i][j - 1]);
                dp[i][j] = tmp;
            }
        //rep(i,a){ rep(j,b){ cout << dp[i][j] << ' '; } cout << endl; } cout << endl;
        }
        //cout << endl;
        cout << dp[a - 1][b - 1] << endl;
    }
}

Measured memory_bytes: 2992
#1行目
hoge = gets.chomp.to_i - 1

#2行目読み込み
b = gets.chomp.split(" ").map!{|i| i.to_i}

unchi = 1.0 / b[0]

for i in 1..hoge do
  unchi = unchi + 1.0 / b[i]
end

print 1.0 / unchi

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  vector<vector<int>> a(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> a[i][j];
  Cin(int, n);
  Cins(int, n, b);

  vector<vector<bool>> bingo(3, vector<bool>(3, false));
  rep(i, 3) rep(j, 3) rep(k, n) if (a[i][j] == b[k]) bingo[i][j] = true;

  // yoko
  rep(i, 3) {
    bool ok = true;
    rep(j, 3) ok &= bingo[i][j] == true;
    if (ok) {
      cout << "Yes" << endl;
      return;
    }
  }
  // tate
  rep(j, 3) {
    bool ok = true;
    rep(i, 3) ok &= bingo[i][j] == true;
    if (ok) {
      cout << "Yes" << endl;
      return;
    }
  }
  // naname 11,22,33
  bool ok = true;
  rep(i, 3) ok &= bingo[i][i] == true;
  if (ok) {
    cout << "Yes" << endl;
    return;
  }
  // naname 13,22,31
  ok = true;
  rep(i, 3) ok &= bingo[i][2 - i] == true;
  if (ok) {
    cout << "Yes" << endl;
    return;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int Hours = int.Parse(input[0]);
        int A = int.Parse(input[1]);
        int B = int.Parse(input[2]);
        
        Console.WriteLine((A * Hours <= B) ? A * Hours : B);
    }
}


Measured memory_bytes: 11092
#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>;


int main() {
    int64_t x, k, d;
    cin >> x >> k >> d;

    if (x < 0) x = -x;
    int64_t res = 0;
    if (x / d >= k) {
        res =  x - k * d;
        cout << res << endl;
        return 0;
    }

    //　原点はさんでちょこまかするパタン
    int64_t restK = k - abs(x) / d;
    if (restK % 2 == 0) {
        res = abs(x - d * (k - restK));
    } else {
        res = abs(x - d * (k - restK + 1));
    }
    cout << res << endl;
    return 0;

}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if ((a < b) && (b < c)){
		printf("%d %d %d\n", a, b, c);
	}
	else if ((a < c) && (b > c)){
		printf("%d %d %d\n", a, c, b);
	}
	else if ((b < a) && (a < c)){
		printf("%d %d %d\n", b, a, c);
	}
	else if ((b < c) && (c < a)){
		printf("%d %d %d\n", b, c, a);
	}
	else if ((c < a) && (a < b)){
		printf("%d %d %d\n", c, a, b);
	}
	else if ((c < b) && (b < a)){
		printf("%d %d %d\n", c, b, a);
	}
	else if ((a == b) && (b < c)){
		printf("%d %d %d\n", a, b, c);
	}
	else if ((a == b) && (b > c)){
		printf("%d %d %d\n", c, a, b);
	}
	else if ((a < b) && (b == c)){
		printf("%d %d %d\n", a, b, c);
	}
	else if ((a > b) && (b == c)){
		printf("%d %d %d\n", b, c, a);
	}
	else if ((a == b) && (b == c)){
		printf("%d %d %d\n", a, b, c);
	}
	else if ((a == c) && (c < b)){
		printf("%d %d %d\n", a, c, b);
	}
	else if ((a == c) && (c > b)){
		printf("%d %d %d\n", b, a, c);
	}
	
	return (0);
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String A = sc.next();
    String B = sc.next();
    String C = sc.next();
    int ans = 0;
    for (int i = 0; i < N; i++) {
      char a = A.charAt(i);
      char b = B.charAt(i);
      char c = C.charAt(i);
      if (a == b && b == c) {
        ;
      } else if (a == b || b == c || c == a) {
        ans += 1;
      } else {
        ans += 2;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22736
#ABC-119-A
S = input().split("/")
ans = ""

if int(S[0]) < 2019:
    ans = "Heisei"
elif int(S[0]) > 2019:
    ans = "TBD"
else:
    if int(S[1]) > 4:
        ans = "TBD"
    elif int(S[1]) <= 4:
        ans = "Heisei"
        
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;

ll n, w, W[102], V[102];

ll dp[102][100002]; // dp[i][j] = min weight if we filled the knapsack with some of the first i items, value = j
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

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

	
	cin >> n >> w;
	for(int i = 1; i <= n; ++i)
		cin >> W[i] >> V[i];
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= 1000*n; ++j)
			dp[i][j] = (1<<30);
	dp[0][0] = 0;
	for(int i = 0; i < n; ++i)
		for(int j = 0; j <= 1000*n; ++j)
		{
			if(dp[i][j] + W[i+1] <= w)
				dp[i+1][j + V[i+1]] = min(dp[i+1][j + V[i+1]], dp[i][j] + W[i+1]);
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
		}	
	ll ans = 0;
	for(int j = 0; j <= 1000*n; ++j)
		if(dp[n][j] <= w)
			ans = j;
	cout << ans;
    return 0;
}


Measured memory_bytes: 79232
N = int(input())
text = "MARCH"
d = {a:0 for a in text}
for _ in range(N):
  s = input()[0]
  if s in text:
    d[s] += 1

tot = 0
L = [v for k,v in d.items()]
for i in range(0,5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      #print(i,j,k)
      tot += L[i]*L[k]*L[j]

#print(d)
print(tot)
  

Measured memory_bytes: 9152
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
int c,e,d;
double a,b,result=0;
cin>>a>>b;
c=a/b;
d=fmod(a,b);
result=a/b;
cout<<c<<" "<<d<<" ";
printf("%5f",result);
cout<<endl;
}




Measured memory_bytes: 3292
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n, k;
    cin >> n >> k;
    const int MAX = 100001;
    vi c(MAX);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        c[a] += b;
    }

    rep2(i, 1, MAX) {
        c[i] += c[i - 1];
        if (c[i] >= k) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <list>

using namespace std;

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

const ll mod = 998244353;
const ll inf = (ll) 1e18;

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

  int n, m;
  cin >> n >> m;
  vector<ll> l(m), r(m), c(m);
  for (int i = 0; i < m; i++) cin >> l[i] >> r[i] >> c[i];

  vector<vector<ll> > lrc(m, vector<ll>(3));
  for (int i = 0; i < m; i++) {
    lrc[i][0] = l[i] - 1;
    lrc[i][1] = -r[i];
    lrc[i][2] = c[i];
  }

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

  for (int i = 0; i < m; i++) lrc[i][1] = -lrc[i][1];

  vector<ll> dp(n+2, inf);
  dp[0] = 0;
  for (int k = 0; k < m; k++) {
    ll b = lrc[k][0];
    ll e = lrc[k][1];
    ll cost = dp[b] + lrc[k][2];
    auto it = upper_bound(dp.begin() + b, dp.begin() + e, cost);
    ll d = distance(dp.begin(), it);
    for (int i = d; i < e; i++) {
      dp[i] = cost;
    }
  }

  auto ans = dp[n-1];
  if (ans >= inf) {
    cout << -1 << endl; // impossible
  }
  else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const ll INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n; cin>>n;
  ll ans=1;
  rep(i,n){
    ans*=(ll)(i+1);
    ans%=INF;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int i,j,k,p,n,m,t=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>m>>k>>p;
		if(m<k+p) t=1;
		else{
			if((m-p-k)%2==1) t=1;
		}
	}
	if(t==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
while(<>){
	chomp;
	next if($. == 1);
	@n = split(/ /, $_);
}

for $one (@n){
	$b_cnt{$one}++;
}

$all = 0;
for $one (keys %b_cnt){
	if($b_cnt{$one} <= 1){
		$ptn{$one} = 0;
	}else{
		$ptn{$one} = ($b_cnt{$one} * ($b_cnt{$one} - 1)) / 2;
	}
	$all += $ptn{$one};
}

for $i (0 .. $#n){
	$one = 0;
	$b_cnt{$n[$i]}--;
	if($b_cnt{$n[$i]} <= 1){
		$one = 0;
	}else{
		$one = ($b_cnt{$n[$i]} * ($b_cnt{$n[$i]} - 1)) / 2;
	}
	printf ($all - $ptn{$n[$i]} + $one);
	print "\n";
	$b_cnt{$n[$i]}++;
}



Measured memory_bytes: 51564
n, m, l = gets.split.map(&:to_i)

subjects = Array.new(5).map { [] }
m.times do
    d, a, k, t = gets.split.map(&:to_i)
    subjects[d] << [(2**k-1) << (a-1), t]
end

def f(a, x, i, k)
    return 0 if k == 0
    return 0 if i >= a.size
    b, t = a[i]
    if x & b == 0
        r1 = t + f(a, x | b, i + 1, k - 1)
        r2 = f(a, x, i + 1, k)
        return r1 > r2 ? r1 : r2
    else
        return f(a, x, i + 1, k)
    end
end

m = Array.new(5).map { Array.new(n+1, 0) }
(0..4).each do |i|
    (1..n).each do |j|
        m[i][j] = f(subjects[i], 0, 0, j)
    end
end

ans = 0
(0..n).to_a.repeated_permutation(5) do |s|
    next if s.inject(:+) > l
    x = s.map.with_index {|k, i| m[i][k]}.inject(:+)
    ans = x if ans < x
end
p ans



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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int cnt=0;
		for(int x=0;x<=K;x++) {
			for(int y=0;y<=K; y++) {
				int z= S-x-y;
					if(0<=z && z<=K) {
						cnt++;
					
				}
			}
		}
		System.out.println(cnt);

	}

}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    int sum = 0;
    for(int i=0; i<n; i++)
    {cin>>a[i];;
      sum+=a[i]; }
    int mean1 = sum/n;
    int mean2 = sum/n + 1;
    long long ans1 = 0, ans2=0;
    for(int i=0 ; i<n; i++)
    {
        ans1+= (a[i]-mean1)*(a[i]-mean1);
        ans2+= (a[i]-mean2)*(a[i]-mean2);
    }
    cout<<min(ans1, ans2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-9
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define siz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
#define fir first
#define sec second
#define endl '\n'
typedef pair<int,int> pii;
typedef unsigned long long ull;
const long long linf=1LL<<62;
const int iinf=1000000009;
const double dinf=1e15;
const int Mod=1e9+9;
const int base=228;
typedef long long ll;
typedef long double ld;
struct Solver {
	void solve(){
		iossy;
		int x;
		cin>>x;
		if(x==25) cout<<"Christmas"<<endl;
		else if(x==24) cout<<"Christmas Eve"<<endl;
		else if(x==23) cout<<"Christmas Eve Eve"<<endl;
		else if(x==22) cout<<"Christmas Eve Eve Eve"<<endl;
	}
};
int main(){
//	p[0]=1;
//	For(i,1,500005) p[i]=p[i-1]*base;
//	while(scanf("%d",&n)!=EOF) solve();
	int t=1;
	Solver solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define N_MAX 600

int N, M;
char table[N_MAX][N_MAX];
double memo[N_MAX];

double func(int index)
{
	if (memo[index] > 0.0l){
		return memo[index];
	}

	double ret = 0.0l;

	int cnt = 0;
	for (int i = 0; i < N; i++){
		if (0 == table[index][i]){
			continue;
		}
		cnt++;
	}

	for (int i = 0; i < N; i++){
		if (0 == table[index][i]){
			continue;
		}
		ret += (func(i) + 1.0l) / (double)cnt;
	}

	return memo[index] = ret;
}

void solv()
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++){
		fill(table[i], table[i] + N, 0);
	}
	for (int i = 0; i < M; i++){
		int s, t; scanf("%d%d", &s, &t);
		s--; t--;
		table[s][t] = 1;
	}

	fill(memo, memo + N, -10.0l);

	double def[N_MAX];
	for (int i = 0; i < N; i++){
		def[i] = func(i);
	}

	double ans = (double)(N * 2);
	for (int i = 0; i < N; i++){
		int index, cnt = 0; double val = -10.0l;
		for (int j = 0; j < N; j++){
			if (0 == table[i][j]){
				continue;
			}
			cnt++;
			if (def[j] > val){
				index = j;
				val = def[j];
			}
		}

		if (1 == cnt){
			continue;
		}

		table[i][index] = 0;
		fill(memo, memo + N, -10.0l);
		ans = min(ans, func(0));
		table[i][index] = 1;
	}

	printf("%.10lf", ans);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 512