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

using namespace std;

vector<string> buf;
int row;
int column;
string rem;

void printbuf(){
  cout << row << ' ' << column << " \"" << rem << "\"" << endl;
  for(int i=0;i<buf.size();i++){
    cout << buf[i];
  }
}

main(){
  string in;
  while(getline(cin, in)){
    if(in == "END_OF_TEXT") break;
    //if(in == "END_OF_TEXT" || in == "1") break;
    in += '\n';
    buf.push_back(in);
  }
  char c;
  row = 0;
  column = 0;
  while(cin >> c){
    if(c == '-') break;
    switch(c){
      case 'a':
        column = 0;
        break;
      case 'e':
        column = (int)buf[row].size()-1;
        break;
      case 'p':
        column = 0;
        if(row > 0) --row;
        break;
      case 'n':
        column = 0;
        if(row+1 < buf.size()) ++row;
        break;
      case 'f':
        if(column+1 >= buf[row].size()){
          if(row+1 < buf.size()){
            column = 0;
            ++row;
          }
        }else{
          ++column;
        }
        break;
      case 'b':
        if(column == 0){
          if(row > 0){
            --row;
            column = (int)buf[row].size()-1;
          }
        }else{
          --column;
        }
        break;
      case 'd':
        if(column+1 == buf[row].size()){
          if(row+1 != buf.size()){
            buf[row].erase((int)buf[row].size()-1);
            buf[row] += buf[row+1];
            vector<string>::iterator ite = buf.begin();
            for(int i=0;i<row+1;i++) ++ite;
            buf.erase(ite);
          }
        }else{
          buf[row].erase(column, 1);
        }
        break;
      case 'k':
        rem = "";
        if(column+1 == buf[row].size()){
          if(row+1 != buf.size()){
            buf[row].erase((int)buf[row].size()-1);
            buf[row] += buf[row+1];
            vector<string>::iterator ite = buf.begin();
            for(int i=0;i<row+1;i++) ++ite;
            buf.erase(ite);
            rem += '\n';
          }
        }else{
          for(int i=column;i+1<buf[row].size();++i){
            rem += buf[row][i];
          }
          string::iterator ite = buf[row].begin();
          for(int i=0;i<column;i++) ++ite;
          buf[row].erase(ite, buf[row].end());
          buf[row] += '\n';
        }
        break;
      case 'y':
        if(rem.size() != 0){
          int irem;
          string back = buf[row].substr(column);
          buf[row] = buf[row].substr(0, column);
          for(irem = 0;irem<rem.size();irem++){
            buf[row] += rem[irem];
            ++column;
            if(rem[irem] == '\n'){
              vector<string>::iterator ite = buf.begin();
              for(int i=0;i<row+1;i++) ++ite;
              buf.insert(ite, "");
              column = 0;
              ++row;
            }
          }
          buf[row] += back;
        }
        break;
    }
    //printbuf();
  }
  for(int i=0;i<buf.size();i++){
    cout << buf[i];
  }
  //cout << endl;

  return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  long long ans;
  long long numr=0, numg=0, numb=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R')numr++;
    else if(s[i]=='G')numg++;
    else if(s[i]=='B')numb++;
  }
  ans = numr*numg*numb;
  
  for(int i=0;i<n-1;i++){
    for(int j=1;j<=n/2;j++){
      if(i+j+j>n-1)continue;
      if(s[i]!=s[i+j]&&s[i]!=s[i+j+j]&&s[i+j]!=s[i+j+j])ans--;
    }
  }

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


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int K = 1000;
int wh[K][K], bl[K][K];
signed main() {
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    for (int i=0; i < k; i++){
        for (int j=0; j < k; j++){
            wh[i][j] = 0;
            bl[i][j] = 0;
        }
    }
    for (int i=0; i < n; i++){
        int x, y;
        cin >> x >> y;
        char c;
        cin >> c;
        if (c == 'B') x += k;
        x %= (2*k);
        y %= (2*k);
        if (x >= k){
            x -= k;
            if (y >= k) y -= k;
            else y += k;
        }
        if (y < k){
            wh[x][y]++;
        }
        else bl[x][y-k]++;
    }
    for (int i=1; i < k; i++){
        wh[0][i] += wh[0][i-1];
        bl[0][i] += bl[0][i-1];
        wh[i][0] += wh[i-1][0];
        bl[i][0] += bl[i-1][0];
    }
    for (int i=1; i < k; i++){
        for (int j=1; j < k; j++){
            wh[i][j] += (wh[i-1][j] + wh[i][j-1] - wh[i-1][j-1]);
            bl[i][j] += (bl[i-1][j] + bl[i][j-1] - bl[i-1][j-1]);
        }
    }
    int ans = 0;
    int B = bl[k-1][k-1], W = wh[k-1][k-1];
   // cout << bl[0][0] << endl;
    //cout << W << " " << B << endl;
    for (int i=0; i < k; i++){
        for (int j=0; j < k; j++){
            int A = bl[i][j];
            A += B - (bl[i][k-1] + bl[k-1][j] - bl[i][j]);
            int C = wh[i][j];
            C += W - (wh[i][k-1] + wh[k-1][j] - wh[i][j]);
            ans = max(ans, A + W - C);
            ans = max(ans, C+B-A);
        }
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 15872
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<string>
using namespace std;

int main() {
  string a, b, c; cin >> a >> b >> c;
  // ASCIIの文字コードで大文字や小文字が連続して配置されていることを利用して文字コードの差を足し算して求めることもできる。
  char dif = 'A' - 'a';
  printf("%c%c%c\n", a[0] + dif, b[0] + dif, c[0] + dif);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
template<class T, class U> bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(auto& i : s) cin >> i;
    vector cost(h, vector(w, INF));
    vector<pair<int, int>> q;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(s[i][j] == '#'){
        cost[i][j] = 0;
        q.emplace_back(i, j);
    }
    int ans = 0;
    for(int i = 0; i < q.size(); i++){
        auto [x, y] = q[i];
        ans = cost[x][y];
        for(int d = 0; d < 4; d++){
            const int x2 = x + dx[d], y2 = y + dy[d];
            if(x2 < 0 || x2 >= h || y2 < 0 || y2 >= w) continue;
            if(chmin(cost[x2][y2], cost[x][y] + 1)) q.emplace_back(x2, y2);
        }
    }
    cout << ans << endl;
}


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

int main(){
    string N;
    cin >> N;
    //各桁の和を求める
    int num=0;
    int sum=0;
    rep(i,N.size()){
        num = N[i];
        num -= '0';
        sum += num;
    }
    int ans = stoi(N);
    if(ans % sum == 0){
        cout<<"Yes"<<endl;
    } else {
        cout<< "No" << endl;
    }
}

Measured memory_bytes: 256
a, b, c, d, e, f = gets.split.map(&:to_i)
a *= 100
b *= 100

ans = [-1, 0, 0]
(0..).each do |i|
    (0..).each do |j|
        w = a * i + b * j
        break if w > f
        ms = [e * w / 100, f - w].min

        (0..).each do |k|
            s = c * k
            break if s > ms
            s += d while s + d <= ms

            r = s.fdiv(w + s)

            if r > ans[0]
                ans[0] = r
                ans[1] = w + s
                ans[2] = s
            end
        end
    end

    break if a + i > f
end

puts ans[1,2].join(" ")

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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())

int main() {
    string s;
    cin >> s;
    if(s[s.size() - 1] == '2' || s[s.size() - 1] == '4' ||
       s[s.size() - 1] == '5' || s[s.size() - 1] == '7' ||
       s[s.size() - 1] == '9') {
        cout << "hon" << endl;
    } else if(s[s.size() - 1] == '0' || s[s.size() - 1] == '1' ||
              s[s.size() - 1] == '6' || s[s.size() - 1] == '8') {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}

Measured memory_bytes: 3628
#include<stdio.h>
using namespace std;

int main()
{
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	set<int> mochi_array;
	int width; 
	for (int i = 0; i < N; i++) {
		cin >> width;
		mochi_array.insert(width);
	}

	cout << mochi_array.size() << endl;
	return 0;
}


Measured memory_bytes: 256
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;
#define DumpPairs(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i].fi <<"," << cont[__i].se<<")";} cout<<endl;
/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;

int main() {
    cout.precision(15);
    cout << fixed;
    ll X,N;
    vector<ll> V;
    cin >> X >> N;
    V.resize(N);
    REP(i,N) {
        cin >> V[i];
    }
    sort(ALL(V));
    int pt=N-1;
    int bv=1000;
    int ans=101;
    for(int i=101;i>=0;--i) {
        if (pt>=0&&i==V[pt]) {
            pt--;
        } else {
            if (bv>=abs(X-i)) {
                ans=i;
                bv=abs(X-i);
            }
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <array>
#include <list>
#include <vector>
 
int main(){
    int N;
    std::cin >> N;
     
    //std::array<int, 20> ans;
    std::list<int> ans; //change
    //std::vector<int> ans;
     
    for(int i=0; i<N; ++i){
        double xa, ya, ra, xb, yb, rb;
        std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
         
        double d = pow((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb), 0.5);
        
        /*
        if(ra > rb && d < ra-rb) ans[i] = 2;
        else if(rb > ra && d < rb-ra) ans[i] = -2;
        else if(d <= ra+rb) ans[i] = 1;
        else if(d > ra+rb) ans[i] = 0;
        */
        
        if(ra > rb && d < ra-rb) ans.push_back(2);
        else if(rb > ra && d < rb-ra) ans.push_back(-2);
        else if(d <= ra+rb) ans.push_back(1);
        else if(d > ra+rb) ans.push_back(0);
    }
    
    /*
    for(int i=0; i<N; ++i)
        std::cout << ans[i] << std::endl;
    */
    
    for(std::list<int>::iterator it = ans.begin(); it != ans.end(); ++it){
    	std::cout << *it << std::endl;
	}
	
    return 0;
}

Measured memory_bytes: 1292
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0184

"""
import sys
from sys import stdin
from collections import defaultdict
input = stdin.readline


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        visitors = defaultdict(int)

        for _ in range(n):
            age = int(input())
            if age < 10:
                visitors['under10'] += 1
            elif age < 20:
                visitors['10s'] += 1
            elif age < 30:
                visitors['20s'] += 1
            elif age < 40:
                visitors['30s'] += 1
            elif age < 50:
                visitors['40s'] += 1
            elif age < 60:
                visitors['50s'] += 1
            else:
                visitors['60s+'] += 1

        print(visitors['under10'])
        print(visitors['10s'])
        print(visitors['20s'])
        print(visitors['30s'])
        print(visitors['40s'])
        print(visitors['50s'])
        print(visitors['60s+'])


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7980
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
  ll p[4]={0,300000,200000,100000};
  ll ans=0;
  if(x<4)
    ans+=p[x];
  if(y<4)
    ans+=p[y];
  if(x==1 && y==1)
    ans+=400000;
  cout<<ans;
  return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using ll = long long;

vector<int> v;
int n, k;

bool solve(int a) {
    ll cnt = 0;
    for (int x : v) cnt += (x-1)/a;
    return (cnt <= k);
}

int main() {
    FAST;

    int i, l, r, m, ans = 0;
    cin >> n >> k;

    v.resize(n);
    for (i = 0; i < n; ++i) cin >> v[i];

    l = 1;
    r = 1e9;

    while (l <= r) {
        m = (l+r) >> 1;

        if (solve(m)) {
            ans = m;
            r = m-1;
        } else {
            l = m+1;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3956
import sys 

stdin = lambda : sys.stdin.readline()
stdout = lambda *args: sys.stdout.write(' '.join(map(str, args))+'\n')


def main():
    n = int(stdin())
    h = list(map(int, stdin().split()))

    dp = [float('inf')] * n

    dp[0] = 0
    dp[1] = abs(h[1] - h[0])

    for i in range(2, n):
        chmin(dp, i, dp[i-1] + abs(h[i] - h[i-1]))
        chmin(dp, i, dp[i-2] + abs(h[i] - h[i-2]))
    stdout(dp[n-1])


def chmin(array, idx, value):
    if array[idx] > value:
        array[idx] = value

main()



Measured memory_bytes: 13716
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    int n, k; cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        double p = 1;
        int x = i;
        while (x < k) {
            p *= 0.5;
            x *= 2;
        }
        ans += p / n;
    }
    printf("%.10f\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

char s[10004];

int main(){
    int k;
    cin>>k;
    cin>>s;
    for(int i=0;i<strlen(s);i++){
        s[i]='A'+(s[i]-'A'+k)%26;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
  using namespace std;
  int GCD(int a,int b)
  {
      if(b>a) return GCD(b,a);
      if(b==0 )return a;
      else return GCD(b,a%b);
  }
  int main()
  {
      int a,b;
      cin>>a>>b;
      int res = GCD(a,b);
      cout<<res<<endl;
      
  }

Measured memory_bytes: 3100
#include<cstdio>

typedef long long ll;

const ll mod=1e9+7;
ll jc[3000010]={1,1};
ll in[3000010]={1,1};

ll pow(ll a,ll b)
{
	ll ans = 1;
	while(b > 0){
		if(b & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		b>>=1;
	}
	return ans;
}
inline ll inv(ll x){return pow(x,mod-2);}
ll C(ll r,ll c){return jc[r+c]*in[r]%mod*in[c]%mod;}

int main()
{
	ll r1,c1,r2,c2;
	scanf("%lld%lld%lld%lld",&r1,&c1,&r2,&c2);
	for(ll i=1;i<=3000000;i++) jc[i]=jc[i-1]*i%mod,in[i]=inv(jc[i]);
	ll ans=0;
	for(ll r=r1;r<=r2;r++)
	{
		ans+=((C(r+1,c2)-C(r+1,c1-1))%mod+mod)%mod;
		ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 46976
import java.util.*;

public class Main {
    public static void main(String[] args) {
        for(int i = 1; i <= 9; ++i) {
            for(int j = 1; j <= 9; ++j) {
                System.out.println(i + "x" + j + "=" + i*j);
            }
        }
    }
}

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

long long calc(long long n) {
	return (n + 1) * n / 2;
}

int main() {
	string str;
	long long  len;
	long long table[26] = { 0 };
	long long cnt = 0;

	cin >> str;
	len = str.length();

	for (int i = 0; i < len; i++) {
		table[str[i] - 'a']++;
	}

	for (int i = 0; i < 26; i++) {
		if (table[i] > 1) {
			cnt += calc(table[i] - 1);
		}
	}

	cout << calc(len - 1) + 1 - cnt << endl;
	return 0;
}

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

using namespace std;

int a[100050];
int dp[100050];

int ghadr(int a, int b) {
	return max((a - b) , (b - a));
}

int main() {
	long long int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	dp[0] = 0;
	dp[1] = ghadr(a[0] , a[1]);
	for (int i = 2; i < n; i++) {
		dp[i] = min ((dp[i - 1] + ghadr(a[i] , a[i - 1])) , (dp[i - 2] + ghadr(a[i] , a[i - 2])));
			}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
 
constexpr int64_t mod = 1000000007;

int64_t gcd(int64_t a, int64_t b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
 
int64_t power(int64_t n, int64_t k) {
    if(k==0) return 1;
    int64_t ans = power(n*n%mod,k/2);
    if(k%2){
        ans = ans*n%mod;
    }
    return ans;
}
 
int main() {
    int n;
    cin>>n;
    map<pair<int64_t,int64_t>,int64_t> count;
    
    for(int i=0; i<n; i++){
        int64_t a, b;
        cin>>a>>b;
        
        if(a==0 && b==0){
            count[make_pair(0, 0)] ++;
            continue;
        }
        
        int64_t e = gcd(abs(a),abs(b));
        a/=e;
        b/=e;
        if(a<0 || (a==0 && b<0)){
            a = -a;
            b = -b;
        }
        count[make_pair(a, b)]++;
        
        if(b<0 || (b==0 && a>0)){
            b = -b;
            a = -a;
        }
        auto f = make_pair(b, -a);
        
        count[f]+=0;
        
    }
    
    int64_t ans = 1;
    for(auto e: count){
        auto p = make_pair(e.first.second, -e.first.first);
        if(p.first<0 || (p.first==0 && p.second<0)){
            p.first = -p.first;
            p.second = -p.second;
        }
        
        if(e.first>=p) continue;
        ans *= (power(2, e.second)+power(2, count[p])+mod-1)%mod;
        ans%=mod;
    }
    cout<<(ans+mod-1+count[make_pair(0, 0)])%mod<<endl;
    return 0;
}

Measured memory_bytes: 28588
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
	
	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int index;
			int index2;
			int a;
			int b;
			int result;
			Map <Integer,Integer> map= new HashMap<Integer,Integer> ();
			for(index=0;index<5;index++) {
				a = sc.nextInt();
				map.put(index,a);
			}
			int k = sc.nextInt();
			sc.close();
			// 
			result=0;
			for(index=0;index<4;index++) {
				a = map.get(index);
				for(index2=index+1;index2<5;index2++) {
					b = map.get(index2);
					if(b-a>k) {
						result=1;
						break;
					}
				}
			}
			// 出力

			if(result==1) {
				System.out.println(":(");
			}
			else {
				System.out.println("Yay!");
			}
	}
}

Measured memory_bytes: 24020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		for (String str; (str = br.readLine()) != null; ) {
			String[] data = str.split(",");
			int[] hand = new int[5];
			for (int i=0; i < 5; i++) {
				hand[i] = Integer.parseInt(data[i]); // 0, 1, 2, 3, 4
			}
			Arrays.sort(hand);

			if (fourCard(hand)) System.out.println("four card");
			else if (fullHouse(hand)) System.out.println("full house");
			else if (straight(hand)) System.out.println("straight");
			else if (threeCard(hand)) System.out.println("three card");
			else if (twoPair(hand)) System.out.println("two pair");
			else if (onePair(hand)) System.out.println("one pair");
			else System.out.println("null");
		}
	}

	public static boolean fourCard(int[] hand) {
		if (hand[1] != hand[3]) return false;
		if (hand[2] == hand[0] || hand[2] == hand[4]) return true;
		return false;
	}

	public static boolean fullHouse(int[] hand) {
		if (hand[0] == hand[1] && hand[2] == hand[4]) return true;
		if (hand[0] == hand[2] && hand[3] == hand[4]) return true;
		return false;
	}

	public static boolean straight(int[] hand) {
		if (hand[0] == 1
				&& hand[1] == 10
				&& hand[2] == 11
				&& hand[3] == 12
				&& hand[4] == 13) {
			return true;
		}
		if (hand[0] + 1 == hand[1]
				&& hand[1] + 1 == hand[2]
				&& hand[2] + 1 == hand[3]
				&& hand[3] + 1 == hand[4]) {
			return true;
		}
		return false;
	}

	public static boolean threeCard(int[] hand) {
		if (hand[0] == hand[2]) return true;
		if (hand[1] == hand[3]) return true;
		if (hand[2] == hand[4]) return true;
		return false;
	}

	public static boolean twoPair(int[] hand) {
		if (hand[0] == hand[1]
				&& hand[2] == hand[3]) {
			return true;
		}
		if (hand[0] == hand[1]
				&& hand[3] == hand[4]) {
			return true;
		}
		if (hand[1] == hand[2]
				&& hand[3] == hand[4]) {
			return true;
		}
		return false;
	}

	public static boolean onePair(int[] hand) {
		for (int i=0; i <= 3; i++) {
			if (hand[i] == hand[i+1]) return true;
		}
		return false;
	}
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define all(v,a,b) v.begin(a),v.end(b)
#define in cin>>
#define out cout<<
#define endl <<endl
#define INF 100000000000

int main()
{
	int N;
	in N;
	string S;
	in S;
	if (N % 2 == 1)
	{
		out "No" endl;
	}
	else
	{
		rep(i, N / 2)
		{
			if (S.at(i) != S.at(i + N / 2))
			{
				out "No" endl;
				break;
			}
			if (i == N / 2 - 1)
			{
				out "Yes" endl;
			}
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>  
#include<iostream>  
#include<sstream>  
#include<cstring>  
#include<string>  
#include<cmath>  
#include<cstdlib>  
#include<algorithm>  
#include<set>
#include<map>
#include<queue>
using namespace std;
int a[60];
long long jiecheng(int n,int m) {
	long long res = 1;
	for (int i = 1;i <= m;++i) {
		res = (res*(n-m+i))/i;
	}
	return res;
}

int main() {
	long long N,P,res;
	scanf("%lld%lld",&N,&P);
	int num = 0;
	//偶数个奇数or奇数个奇数
	for (int i = 0;i < N;++i) {
		scanf("%d",a+i);
		if(a[i]%2==1)num++;
	}
	if (P % 2 == 0) {
		res = pow(2,(N-num));
		long long o = 1;
		for (int i = 2;i <= num;i += 2) {
			o += jiecheng(num,i);
		}
		res = res*o;
	}
	if (P % 2 == 1) {
		res = pow(2,(N-num));
		long long o = 0;
		for (int i = 1;i <= num;i += 2) {
			o += jiecheng(num, i);
		}
		res = res * o;
	}
	printf("%lld",res);
}

Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main(void) {
	int n, m;
	int a[10003];
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i];
	}
	bool can = true;
	rep(i, m) {
		n -= a[i];
		if (n < 0) {
			can = false;
			break;
		}
	}

	if (can) cout << n << endl;
	else cout << "-1" << endl;
}


Measured memory_bytes: 3208
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int y[100],i=0,x=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      y[i-2] = y[i-2] + y[i-1];
      i--;
     }
 
    else if ( s[0] == '-' ){
      y[i-2] = y[i-2] - y[i-1];
      i--;
    }
 
    else if ( s[0] == '*' ){
      y[i-2] = y[i-2] * y[i-1];
      i--;
    }
 
    else {
      x = atoi(s);
      y[i] = x;
      i++;
    }  
  } 
  printf("%d\n",y[i-1]);
  return 0;
}

Measured memory_bytes: 548
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S):
    idx = defaultdict(list)
    for i, s in enumerate(S):
        idx[int(s)].append(i)

    ans = 0
    for i in range(0, 10):
        if not idx[i]:
            continue
        l = idx[i][0]
        for j in range(0, 10):
            if not idx[j]:
                continue
            ll = bisect.bisect_right(idx[j], l)
            if ll == len(idx[j]):
                continue
            ll = idx[j][ll]
            for k in range(0, 10):
                if not idx[k]:
                    continue
                lll = bisect.bisect_right(idx[k], ll)
                if lll != len(idx[k]):
                    ans += 1

    return ans


def main():
    N = read_int()
    S = read_str()
    print(slv(N, S))

    # N = 300000
    # S = '0123456789' * (N //10)
    # print(slv(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6716
#include <stdio.h>
int a[10000000];
int main(){
	int n,i,x,flag=0,m;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]==2)flag=1;
	}
	
	x=a[1];
	a[1]=0;
	for(i=1;;i++){
		if(flag=0){
			printf("-1");break;
		}
			if(x==2){
				printf("%d",i);break;
			}
			m=x;
		x=a[x];
		a[m]=0;
		if(x==0){
			printf("-1");break;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
inline int read(){
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    write(a); puts("");
}
string s;
int main(){
    cin>>s;
    if(s.length()<4||s[0]!='Y'||s[1]!='A'||s[2]!='K'||s[3]!='I'){
    	puts("No");
	}else puts("Yes");
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,k;
    while(scanf("%d %d",&n,&m)!=0)
    {
        if(n==0&&m==0)
            break;
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
            {
                if(i%2==0)
                {
                    if(j%2!=0)
                        printf(".");
                    else printf("#");
                }
                else
                    {
                    if(j%2!=0)
                        printf("#");
                    else printf(".");
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3164
#include <cstdio>
using namespace std;
const int NN = 1e5 + 5, NM = 1e5 + 5;
int N, M;
struct E {
	int v, nxt, fx;
	E(int _v=0, int _nxt=0, int _fx=0) : v(_v), nxt(_nxt), fx(_fx) {}
};
struct Graph {
	int head[NN], totE;
	E edge[NM<<1];
	void AddE(int u, int v, int fx) {
		edge[++totE] = E(v, head[u], fx);
		head[u] = totE;
	}
} G;
int col[NN];
bool vis[NN];
int ys[] = {1, 2, 0};
int fanys[] = {2, 0, 1};
//0->1
//1->2
//2->0
int cnt[3], egnum = 0, cc;
bool Dfs(int u) {
	vis[u] = 1;
	cnt[col[u]] += 1;
	int hoho = 0;
	bool ret = 1;
	for (int p = G.head[u]; p; p = G.edge[p].nxt) {
		int v = G.edge[p].v;
		++hoho;
		if (vis[v]) {
			if (G.edge[p].fx == 1 && col[v] != ys[col[u]]) {
				ret = 0;
			}
			if (G.edge[p].fx == -1 && col[v] != fanys[col[u]]) {
				//注意第一个 G.edge[p].fx == -1的条件
				//以后限制能多写就多写 
				ret = 0;
			}
			continue ;
		}
		if (G.edge[p].fx == 1)
			col[v] = ys[col[u]];
		else col[v] = fanys[col[u]];
		if (!Dfs(v)) //记得这句话 
			ret = 0;
	}
	egnum += hoho;
	return ret;
}
int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= M; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		G.AddE(u, v, 1);
		G.AddE(v, u, -1);
	}
	long long ans = 0;
	for (int i = 1; i <= N; ++i) {
		if (!vis[i]) {
			cnt[0] = cnt[1] = cnt[2] = 0;
			egnum = 0; //初始化！ 
			bool jd = Dfs(i);
			int sum = cnt[0] + cnt[1] + cnt[2];
			//这里得 dfs完 cnt[0] cnt[1] cnt[2]才准确 
			if (!jd) ans += (long long)sum * sum;
			else if (!cnt[0] || !cnt[1] || !cnt[2]) ans += egnum / 2;
			else ans += (long long)cnt[0] * cnt[1] +
						(long long)cnt[1] * cnt[2] +
						(long long)cnt[2] * cnt[0];
		}
	}
	printf("%lld\n", ans);
	return 0;
}
/*
5 4
1 2
2 3
4 5
5 5
*/

Measured memory_bytes: 12652
S = input()
prev = ""
cut = [0]
inds = []
rs = []
r = 0
for i in range(len(S)):
    if prev == "L" and S[i] == "R":
        cut.append(i)
    if prev == "R" and S[i] == "L":
        inds.append(i)
        rs.append(r)
        r = 0
    if S[i] == "R":
        r += 1
    prev = S[i]
cut.append(len(S))
diff = [cut[i]-cut[i-1] for i in range(1,len(cut))]
ans = [0] * len(S)
# print(rs)
# print(diff)
# print(inds)
for d, i, r in zip(diff, inds, rs):
    ans[i-1] = d//2 
    ans[i] = d//2
    if d%2 == 1 and r%2==1:
        ans[i-1] += 1
    elif d%2 == 1 and r%2 == 0:
        ans[i] += 1
print(*ans)

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amin(T& a,T b){ a=min(a,b);}
template <class T> void amax(T& a,T b){ a=max(a,b);}

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int t,x, ans=0;
	cin >>t >>x;
	double tt=t;
	
	printf("%.10f\n", tt/x);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "YES" : "NO";
}

int main(){

    int n; cin >> n;
    vi a(n),b(n),c(n);
    
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    
    Sort(a);Sort(b);Sort(c);
    
    ll ans = 0;
    rep(i, n){
        ll numa = lower_bound(ALL(a),b[i])-a.begin();
        ll numc = c.end()-upper_bound( ALL(c), b[i]);
        
        ans += numa*numc;
    }

    cout << ans << endl;
    

}






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

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);	
	if(a[0] == 5 && a[1] == 5 && a[2] == 7)
	cout << "YES";
	else
	cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define vi vector <int>
#define si set <int>
#define mii map <int,int>
#define pii pair <int,int>
#define endl "\n"
#define FOR(P,Q) for(int P=0;P<(Q);P++)
#define FORR(P,Q) for(int P=1;P<=(Q);P++)
#define rep(P,R,Q) for(int P=(R);P<=(Q);P++)
#define repb(P,R,Q) for(int P=(R);P>=(Q);P--)
#define pb push_back
#define eb emplace_back
#define bug(j) cerr<<j<<" "
#define NL cerr<<endl
#define D1(arr,a) rep(i,1,a) bug(arr[i]) 
typedef long long ll;
typedef long double ld;
using namespace std;

const int mod = 1e9+7;
    
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("error.txt","w",stderr);
	#endif
	//change ll to int before using string builtin operations
	int tces=1;
	// cin>>tces;
	while(tces--){
		int m,n;
		cin>>m>>n;
		char a[1003][1003];
		int dp[1003][1003];
		FOR(i,m){
			cin>>a[i];
		}
		dp[0][0]=1;
		rep(i,1,m-1){
			if(a[i][0]=='.')
				dp[i][0]=dp[i-1][0];
			else 
				dp[i][0]=0;
		}
		rep(i,1,n-1){
			if(a[0][i]=='.')
				dp[0][i]=dp[0][i-1];
			else 
				dp[0][i]=0;
		}
		rep(i,1,m-1){
			rep(j,1,n-1){
				if(a[i][j]=='.')
					dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
				else 
					dp[i][j]=0;
			}
		}
		cout<<dp[m-1][n-1];
	}
	
return 0;
}

Measured memory_bytes: 12464
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] a = new int[n][2];
        for (int i = 0; i < n; i++) {
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();
        }
        Arrays.sort(a, (x, y) -> x[0] - y[0]);
        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        int idx = 0;
        long ans = 0L;
        for(int i = 1; i <= m; i++){
            while(idx < n && a[idx][0] <= i){
                pq.add(a[idx][1]);
                idx++;
            }
            if(!pq.isEmpty()){
                ans += pq.poll();
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 93196
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back
#define inf (1<<29)

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

        int m,n; cin >> n >> m;
        string A[n];
        string B[m];
        rep(i,n)cin >> A[i];
        rep(i,m)cin >> B[i];
        bool ans = false;
        rep(i,n-m+1){
            rep(j,n-m+1){
                bool chek = true;
                rep(x,m){
                    rep(y,m){
                        if(A[i+x][j+y] !=B[x][y])chek = false;
                    }
                }
                if(chek) ans = true;
            }
        }
        if(ans)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;


return 0;
}



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

int main(){
  
  int k;
  string s;
  
  cin >> k >> s;
  
  if(s.length()<=k){
    cout << s << endl;
  }
  else{
    for(int i=0; i<k; i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }
    
  return 0;
}

Measured memory_bytes: 3624
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second

int main()
{

// #ifndef ONLINE_JUDGE
// 	// for getting input from input.txt
// 	freopen("input1.txt", "r", stdin);
// 	// for writing output to output.txt
// 	freopen("output1.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll x, y , a , b, c;
	cin >> x >> y >> a >> b >> c;
	vector<pair<int, int>> red(a, mp(0, 1));
	vector<pair<int, int>> green(b, mp(0, 2));
	vector<pair<int, int>> colorless(c, mp(0, 3));
	for (int i = 0; i < a; i++)
		cin >> red[i].F;
	for (int i = 0; i < b; i++)
		cin >> green[i].F;
	for (int i = 0; i < c; i++)
		cin >> colorless[i].F;
	vector<pair<int, int>> all;
	all.reserve(a + b + c);
	all.insert( all.end(), red.begin(), red.end());
	all.insert( all.end(), green.begin(), green.end());
	all.insert( all.end(), colorless.begin(), colorless.end());
	sort(all.begin(), all.end());
	ll delec = 0;
	ll tot = x + y;
	ll i = all.size() - 1;
	while (i >= 0 and tot)
	{
		int cand = all[i].F;
		int sign = all[i].S;
		//cout << cand << "\n";
		if (sign == 1 and x > 0)
		{
			delec += cand;
			x--;
			tot--;
		}
		else if (sign == 2 and y > 0)
		{
			delec += cand;
			y--;
			tot--;
		}
		else if (sign == 3)
		{
			delec += cand;
			tot--;
		}
		i--;
	}
	cout << delec << "\n";
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
int main(){
  char a[4];
  scanf("%s",a);
  for(int i=0;i<3;i++){
    if(a[i]=='a')for(int j=0;j<3;j++){
      if(a[j]=='b')for(int k=0;k<3;k++){
        if(a[k]=='c'){
          puts("Yes");
          return 0;
        }
      }
    }
  }
  puts("No");
  return 0;
}

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

namespace debug
{
    public static partial class Program
    {
        public static void Main()
        {
            var nab = Console.ReadLine().ArrayLongs();
            Console.WriteLine(Math.Min(nab[1] * nab[0], nab[2]));
        }
    }

    public static partial class Program
    {
        //テンプレここから
        public static long a, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s, t, u, v, w;
        public static long GCD(long aaa, long bbb) => bbb == 0 ? aaa : GCD(bbb, aaa % bbb);
        public static long LCM(long aaa, long bbb) => aaa * bbb / GCD(aaa, bbb);
        public static long ToLong(this double ddd) => (long) ddd;
        public static long ToLong(this string str) => long.Parse(str);
        public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
        public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
        public static long Diff(long aaa, long bbb) => Math.Abs(Math.Max(aaa, bbb) - Math.Min(aaa, bbb));
        public static long Sign(this long iii) => Math.Sign(iii);
        public static bool IsEven(this long iii) => iii % 2 == 0;
        public static readonly int[] Dx = {0, -1, 0, 1};
        public static readonly int[] Dy = {-1, 0, 1, 0};
        public const int MOD = 1000000007;
        public const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const string alphabet = "abcdefghijklmnopqrstuvwxyz";
        public static long ToLong(this char ccc) => ccc.ToString().ToLong();
        public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
        public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

        public static string JoinToStr(this IEnumerable<long> array, string sep = "")
            => array.Select(xxx => xxx.ToString()).Join(sep);

        //テンプレここまで
    }
}

Measured memory_bytes: 13396
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data)

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = I()
xs = Is()
mod = 1000000007

acc = xs[0]
ans = 0
for x in xs[1:]:
    ans += acc * x
    ans %= mod
    acc += x

print(ans)

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

int main()
{
	stack<int> s;
	deque<int> ans;
	int n;

	while (cin >> n)
	{
		if (cin.eof()) return 0;
		if (n == 0)
		{
			ans.push_front(s.top());
			s.pop();
			//if (s.empty()) break;
		}
		else
		{
			s.push(n);
		}
	}

	while (1)
	{
		if (!ans.empty())
		{
			cout << ans.back() << endl;
			ans.pop_back();
		}
		else break;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
N,M =map(int,input().split())
A =[int(i)for i in input().split()]
A.sort()
bc = [[int(i)for i in input().split()]for _ in range(M)]
bc = sorted(bc,key=lambda x:-x[1])
n = 0
s =False
while True:
    if len(bc)==0:
        break
    BC = bc.pop(0)
    for i in range(BC[0]):
        if A[n] < BC[1]:
            A[n] = BC[1]
            n += 1
            if n > N-1:
                s =True
                break
        else:
            s = True
            break
    if s:
        break
print(sum(A))

Measured memory_bytes: 30988
import itertools

while True:
	n,x = map(int,input().split(" "))

	if n == 0 and x == 0:
		break

	#データリスト作成
	data = [m for m in range(1,n+1)]
	data_cmb = list(itertools.combinations(data,3))

	#検証
	res = [ret for ret in data_cmb if sum(ret) == x]
	print(len(res))



Measured memory_bytes: 31296
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int kans(int a){
    if(a%2==0){
        return a/2;
    }else{
        return 3*a+1;
    }
}
using namespace std;
int main(){
    int A,B,K;
    cin >> A >> B >> K;

    if(A>B) swap(A,B);

    vector<bool> vec(A+5);
    REP(i,A+5) vec[i] = false;
    
    for(int i=1;i<=A;i++) if((A%i==0)&&(B%i==0)) vec[i] = true;
    
    int n = 0;
    for(int i=A;0<=i;i--){
        if(vec[i]) n++;
        if(n == K){
            cout << i << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
import java.util.Scanner;
 

public class Main {

	

	public static void main(String[] args) {

		int N , sum = 0;
		Scanner input = new Scanner(System.in);
		N=input.nextInt();
		for (int j = 1; j <= N; j++) {
			sum += j;
		}
		System.out.println(sum);

		
	}

}

Measured memory_bytes: 26940
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int n;
int main(){
	map<char,string>in;
	in[' ']="101";
	in['\'']="000000";
	in[',']="000011";
	in['-']="10010001";
	in['.']="010001";
	in['?']="000001";
	in['A']="100101";
	in['B']="10011010";
	in['C']="0101";
	in['D']="0001";
	in['E']="110";
	in['F']="01001";
	in['G']="10011011";
	in['H']="010000";
	in['I']="0111";
	in['J']="10011000";
	in['K']="0110";
	in['L']="00100";
	in['M']="10011001";
	in['N']="10011110";
	in['O']="00101";
	in['P']="111";
	in['Q']="10011111";
	in['R']="1000";
	in['S']="00110";
	in['T']="00111";
	in['U']="10011100";
	in['V']="10011101";
	in['W']="000010";
	in['X']="10010010";
	in['Y']="10010011";
	in['Z']="10010000";
	map<string,char>out;
	out["00000"]='A';
	out["00001"]='B';
	out["00010"]='C';
	out["00011"]='D';
	out["00100"]='E';
	out["00101"]='F';
	out["00110"]='G';
	out["00111"]='H';
	out["01000"]='I';
	out["01001"]='J';
	out["01010"]='K';
	out["01011"]='L';
	out["01100"]='M';
	out["01101"]='N';
	out["01110"]='O';
	out["01111"]='P';
	out["10000"]='Q';
	out["10001"]='R';
	out["10010"]='S';
	out["10011"]='T';
	out["10100"]='U';
	out["10101"]='V';
	out["10110"]='W';
	out["10111"]='X';
	out["11000"]='Y';
	out["11001"]='Z';
	out["11010"]=' ';
	out["11011"]='.';
	out["11100"]=',';
	out["11101"]='-';
	out["11110"]='\'';
	out["11111"]='?';
	string s;
	while(getline(cin,s)){
		string a="";
		rep(i,s.size())a+=in[s[i]];
		while(a.size()%5)a+='0';
		rep(i,a.size()/5)cout<<out[a.substr(i*5,5)];
		cout<<endl;
	}
}

Measured memory_bytes: 1200
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    int main(){
      ll n;cin>>n;
      ll mn = 1e15+5;
      rep(i,6){
          ll a;cin>>a;
          mn = min(a,mn);
      }
      ll r;
      if(n%mn == 0)r = n/mn;
      else r = n/mn+1;
      ll res = 4+r;
      cout<<res;
    }
    


Measured memory_bytes: 256