akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
inline void solve(void){
  string S;
  in(S);
  ll N=S.size();
  map<ll,ll>cnt;
  ll tmp=0,T=1;
  cnt[0]=1;
  ll ans=0;
  dw(i,N-1,0){
    tmp+=(S[i]-'0')*T;
    ans+=cnt[tmp%2019]++;
    T*=10;
    T%=2019;
  }
  out(ans);
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3788
N, M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

tmp = []
for a in A:
  for b in B:
    if(tmp != B):
      if(b in a):
        tmp.append(b)
    else:
      break
if(tmp == B):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int a[5001];
int b[5001];
int A, B;

bool check(int al, int ar, int bl, int br){
	if(br > B) return false;
	int idx = bl;
	for(int i = al; i < ar; i++){
		if(a[i] == b[idx]){
			idx++;
			if(idx >= br) return true;
		}
	}
	return false;
}

int main(){
	cin >> A >> B;
	rep(i, A) cin >> a[i];
	rep(i, B) cin >> b[i];

	int left = 0, right = 1;
	int ans = 0;
	while(1){
		while(right < B && left == right || check(0, A, left, right)) right++;
		if(left > right) break;
		ans = max(ans, right-left-1);
		left++;
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    int coa=0, cob=0, coc=0;
    for(int i = 0; i < 3; i++)
    {
        if (s[i] == 'a') {
            coa++;
        }
        else if (s[i] == 'b') {
            cob++;
        }
        else if (s[i] == 'c') {
            coc++;
        }
    }
    if (coa==1 && cob==1 && coc==1) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

int main() {
  string s;
  cin>>s;
  map<char, int> m;
  for(int i = 97; i <= 122; i++) m[i] = 0;
  rep(i, s.length()) {
    m[s[i]]++;
  }
  for(auto i : m) {
    if (i.second == 0) {
      cout << i.first;
      return 0;
    }
  }
  cout << "None";
}


Measured memory_bytes: 512
n, t = map(int, input().split())
ct = [list(map(int, list(input().split()))) for i in range(n)]

ct.sort(key=lambda x: x[0])

for i in range(n):
    if ct[i][1] <= t:
        print(ct[i][0])
        exit()
    if i == n - 1:
        print("TLE")

Measured memory_bytes: 3060
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        
        while(true){
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int vertical = nums[0];
            int side = nums[1];
            
            if(vertical==0 && side==0){
                break;
            }
            
            for(int i = 0; i < vertical; i++){
                for(int l = 0; l < side; l++){
                    
                    if(i == 0 || i == (vertical - 1)){
                        Console.Write("#");
                    }else if(l == 0 || l == (side - 1)){
                        Console.Write("#");
                    }else{
                        Console.Write(".");
                    }
                    
                }
                
                Console.WriteLine();
            
                
            }
            Console.WriteLine();
        }
    }
}



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

int r, g, b, n;
int res = 0;

int main(void){
    cin >> r >> g >> b >> n;
    
    for (int i = 0; i <= n / r; i++) {
        for (int j = 0; j <= n / g; j++) {
            if ((n - i*r - j*g) >= 0 && (n - i*r - j*g) % b == 0) res++;
        }
    }

    cout << res << endl;
}

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

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

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b; cin >> a >> b;

  if (b % a) cout << b - a << endl;
  else cout << a + b << endl;

  return (0);
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

string str;
int to[200001];

pi sub(int st, int en) {
    vector<pi> ands;
    pi now = pi(0, MOD);
    for (int i = st; i < en; i++) {
        if (str[i] == '(') {
            pi rec = sub(i+1, to[i]);
            now.second = min(now.second, now.first + rec.second);
            now.first += rec.first;
            if (now.second == MOD) now.second = rec.second;
            i = to[i];
        } else if (str[i] == '?') {
            now.second = min(now.second, now.first+1);
            now.first++;
        } else if (str[i] == '&') {
        }
        if (str[i] == '|' || i == en-1) {
            ands.push_back(now);
            now = pi(0,MOD);
        }
    }
    /*
    if (st == 0) {
        rep(i,ands.size()) {
            cout << ands[i].first << " " << ands[i].second << endl;
        }
    }
    */

    int one = ands[0].first;
    int tmp = 0;
    rep(i,ands.size()) {
        one = min(one, tmp + ands[i].first);
        tmp += ands[i].second;
    }
    int two = 0;
    rep(i,ands.size()) {
        two += ands[i].second;
    }
    return pi(one, two);
}

int main() {
    cin >> str;
    stack<int> par;
    rep(i,str.size()) {
        if (str[i] == '(') par.push(i);
        if (str[i] == ')') {
            to[par.top()] = i;
            par.pop();
        }
    }
    pi ans = sub(0, str.size());
    cout << ans.second << " " << ans.first << endl;
}



Measured memory_bytes: 4084
def actual(N):
    # 0 <= ケーキの数   <= N/4
    # 0 <= ドーナツの数 <= N/7
    # その範囲で (ケーキの数A, ドーナツの数B) を全探索する
    # N = 4A + 7B を満たす組があれば Yes
    n_max_cakes = N // 4
    n_max_donuts = N // 7

    for n_cakes in range(n_max_cakes + 1):
        for n_donuts in range(n_max_donuts + 1):
            price = (4 * n_cakes) + (7 * n_donuts)

            if price == N:
                return 'Yes'

    return 'No'

N = int(input())
print(actual(N))

Measured memory_bytes: 9184
#include <stdio.h>
#include <stdlib.h>//atoi 文字列の数字をint型の数値する
#include <string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}


int pop() {
	top--;
	return S[top+1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	while( scanf("%s", s) != EOF ) {
		if ( s[0] == '+' ) {
			a = pop();
			b = pop();
			push(a + b);
		} else if ( s[0] == '-' ) {
			b = pop();
			a = pop();
			push(a - b);
		} else if ( s[0] == '*' ) {
			a = pop();
			b = pop();
			push(a * b);
		} else { 
			push(atoi(s));
		}
	}
	
	printf("%d\n", pop());
	
	return 0;
	
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

vector<string> split(const string &s,char c){
	vector<string> ret;
	stringstream ss(s);
	string t;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}

int main(){
	string s;
	getline(cin,s);
	vector<string> s1=split(s,' ');
	bool f=0;
	rep(i,0,s1.size()){
		vector<string> s2=split(s1[i],',');
		rep(j,0,s2.size()){
			vector<string> s3=split(s2[j],'.');
			rep(k,0,s3.size()){
				if(s3[k].size()>=3 && s3[k].size()<=6){
					if(f) cout<<" "; 
					cout<<s3[k]; f=1;
				}
			}
		}
	}
	cout<<endl;
}

Measured memory_bytes: 1192
#include <iostream>

using namespace std;

int main(){
    int ans_dic[4][13] = {};
    int n;
    cin >> n;
    char t;
    int num; 
    while(cin >> t){
        cin >> num;
        if(t == 'S')ans_dic[0][num - 1] = 1;
        if(t == 'H')ans_dic[1][num - 1] = 1;
        if(t == 'C')ans_dic[2][num - 1] = 1;
        if(t == 'D')ans_dic[3][num - 1] = 1;
    }
    for(int i = 0;i < 4;i++){
        for(int j = 0;j < 13;j++){
           if(ans_dic[i][j] == 0){
               if(i == 0)cout << "S " << j+1 << endl;
               if(i == 1)cout << "H " << j+1 << endl;
               if(i == 2)cout << "C " << j+1 << endl;
               if(i == 3)cout << "D " << j+1 << endl;
           }
        }
    }
    return 0;
}


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		int n = sc.nextInt();
		int count=0;
		//int[] array = new int[n];

		/*for(int i=0;i<n;i++) {
			array[i] = sc.nextInt();
		}*/
		for(int i=1;i<=n;i++) {
			if(String.valueOf(i).length() %2!=0)count++;
		}
		System.out.println(count);
	}


	public static int sample() {
		return 1;
	}

}


Measured memory_bytes: 27348
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    ld ans = (ld)W * (ld)H / (ld)2.0;
    cout << ans << ' ' << (int)(W == 2 * x && H == 2 * y) << endl;
}

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



int main() 
{
  int N,M; cin>>N>>M;
  vector<vector<int>> graph(N+1,vector<int>(0));
  rep(i,M)
  {
    int A,B; cin>>A>>B;
    graph.at(A).push_back(B);
    graph.at(B).push_back(A);
  }
  vector<int> sirube(N+1,0);
  queue<int> hoge;
  hoge.push(1);
  while(!(hoge.empty()))
  {
    int par=hoge.front();
    hoge.pop();
    auto children=graph.at(par);
    for(auto child:children)
    {
      if(sirube.at(child)==0)
      {
        sirube.at(child)=par;
        hoge.push(child);
      }
    }
  }
  cout<<"Yes"<<endl;
  rep(i,N)
  {
    if(i==0) {continue;}
    cout<<sirube.at(i+1)<<endl;
  }  
  return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int A = 0;
    vector<int> a(3);
    for (int i = 0; i < 3;i++)
    {
        cin >> A;
        a[i] = A;
    }
    sort(all(a));
    if(a[0] == 5 && a[1] == 5 && a[2] == 7){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

type magic struct {
	a int
	b int
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	h := nextInt()
	n := nextInt()
	m := make([]magic, n)

	for i := range m {
		m[i].a = nextInt()
		m[i].b = nextInt()
	}

	dp := make([]int, h+1)
	for i := 1; i <= h; i++ {
		minCost := -1
		for j := range m {
			cost := m[j].b
			if i-m[j].a >= 0 {
				cost += dp[i-m[j].a]
			}
			if minCost == -1 || minCost > cost {
				minCost = cost
			}
		}
		dp[i] = minCost
	}

	_, _ = fmt.Fprintf(writer, "%d", dp[h])
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
int H[200005];
int  comp(const void*a,const void*b)//用来做比较的函数。

{    return *(int*)a-*(int*)b;}
int main()
{
    int N,K;

    scanf("%d%d",&N,&K);
    long long i;
    for(i=0;i<N;i++)
    {
        scanf("%d",&H[i]);
    }
    qsort(H,N,sizeof(int),comp);
    long long sum;
    if(K>=N)
    {
        printf("0");
    }
    else
    {
        sum=0;
        for(i=0;i<N-K;i++)
        {
            sum=sum+(long long)H[i];
        }
        printf("%lld",sum);
    }

    return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

string vow = "aeiou";

void solve ( int test_case )
{
    int n ; cin >> n ;

    ld fav = n/2 + n % 2 ;
    ld tot = n ;

    ld ans = fav / tot ;
    pp ( ans ) ;
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


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

using namespace std;

int a[1010][1010];

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

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin >> a[i][j];
            a[i][j] %= 2;
        }
    }

    vector <vector <int> > v;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(a[i][j] == 1)
            {
                swap(a[i][j],a[i][j+1]);

                vector <int> p;
                p.push_back(i);
                p.push_back(j);
                p.push_back(i);
                p.push_back(j+1);

                if(a[i][j] == 1)
                    a[i][j+1] = 0;

                v.push_back(p);
            }
        }
    }

    for(int i=1;i<n;i++)
    {
        if(a[i][m] == 1)
        {
            swap(a[i][m],a[i+1][m]);

            vector <int> p;
            p.push_back(i);
            p.push_back(m);
            p.push_back(i+1);
            p.push_back(m);

            if(a[i][m] == 1)
                a[i+1][m] = 0;

            v.push_back(p);
        }
    }

    cout << v.size() << endl;

    for(int i=0;i<v.size();i++)
        cout << v[i][0] << " " << v[i][1] << " " << v[i][2] << " " << v[i][3] << endl;
}

Measured memory_bytes: 11312
#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(){
    string s;
    cin >> s;
    int l;
    l=s.size();
    vector <int> ss(l);
    string c;
    rep(i,l){
        c=s[i];
        ss[i]=atoi(c.c_str());
    }

    /*rep(i,l){
        cout << ss[i] << endl;
    }*/

    int k=0;
    vector <int> b(l-1),b2(l-1,0);
    ll ans=0,ans2;
    ans2=ss[l-1];

    rep(i,pow(2,l-1)){
        b=b2;
        ans2=ss[l-1];
        k=1;
        rep(j,l-1){
            if((i>>j)&1==1){
                //b[j]=1;
                ans2+=pow(10,k)*ss[l-j-2];
                ++k;
            }
            else{
                ans+=ans2;
                ans2=0;
                k=0;
                ans2+=pow(10,k)*ss[l-j-2];
                k=1;
                //cout << "t" << endl;
            }
        }
        //ans2+=pow(10,k)*ss[0];
        ans+=ans2;
        //cout << ans << endl;
    }


    cout << ans << endl;
    

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  while (true) {
    int n, m;
    vector<PII> a;
    cin >> n >> m;
    if (!n && !m)
      break;
    REP(i, n) {
      int d, p;
      cin >> d >> p;
      a.push_back(make_pair(p, d));
    }
    sort(ALL(a), greater<PII>());

    int cost = 0;
    REP(i, n) {
      if (a[i].second <= m)
        m -= a[i].second;
      else if (m > 0) {
        cost += a[i].first * (a[i].second - m);
        m = 0;
      } else {
        cost += a[i].first * a[i].second;
      }
    }

    cout << cost << endl;
  }
  return 0;
}

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

 int main() {
   string s, ans;
   int K;
   cin >> s >> K;

   vector<vector<int>> alpha(26);

   rep(i, 0, s.length()) alpha.at((int)(s.at(i) - 'a')).push_back(i);

   bool done = false;
   map<string, int> exist;

   while (!done) {
     rep(i, 0, 26) {
       if (alpha.at(i).size() == 0) continue;
       else {
         vector<string> S;
         for (int j : alpha.at(i)) {
           S.push_back(s.substr(j, s.length() - j));
         }
         sort(S.begin(), S.end());
         for (string k : S) {
           rep(m, 1, k.length() + 1) {
             if (exist[k.substr(0, m)] != 0) continue;
             else {
               K--;
               if (K == 0) {
                 done = true;
                 ans = k.substr(0, m);
                 break;
               }
               exist[k.substr(0, m)]++;
             }
           }
           if (done) break;
         }
       }
       if (done) break;
     }
   }

   cout << ans << endl;
 }


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

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

    int left = max(x - (k - 1), -1000000);
    int right = min(x + (k - 1), 1000000);

    for(int i = left; i <= right; ++i) 
    {
        cout << i << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
int main()
{
       int n;
       cin>>n;
       cout<<(n^1)<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

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

const ll MOD = 1000000007;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 2e5 + 5;

ll n, m, k;
ll a[N], b[N];

void Solve(){
    cin >> n >> m;
    cout << Lcm(n, m);
}

int main(){
    Speed;
    int query = 1; //cin >> query;
    while(query--){
        Solve();
    }
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    double L;
    while(cin>>L){
        L/=3;
        double vol = L*L*L;
        printf("%.8lf\n",vol);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[15],t[15],a[15];
int main() {
	int x,y;
	scanf("%s%s%d%d%s",s,t,&x,&y,a);
	if(strcmp(s,a)==0) x--;
	else y--;
	printf("%d %d\n",x,y);
	return 0;
}

Measured memory_bytes: 256
W, H, N = gets.chomp.split(" ").map(&:to_i)
ans = [[0, 0], [W, H]]
N.times{
  x, y, a = gets.chomp.split(" ").map(&:to_i)
  case a
  when 1
    ans[0][0] = x if ans[0][0] < x
  when 2
    ans[1][0] = x if ans[1][0] > x
  when 3
    ans[0][1] = y if ans[0][1] < y
  when 4
    ans[1][1] = y if ans[1][1] > y
  end
}

if (ans[1][0] - ans[0][0]) < 0 || (ans[1][1] - ans[0][1]) < 0 then
  puts 0
else
  puts (ans[1][0] - ans[0][0]) * (ans[1][1] - ans[0][1])
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
  int n, q;
  int m[100500];

int main(){
  cin >> n >> q;
  for(int i=1;i<=q;i++){
    int x, y;
    cin >> x >> y;
    m[x]++;
    m[y]++;
  }
  for(int i=1;i<=n;i++){
    if(m[i] % 2 != 0){
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}

Measured memory_bytes: 640
import sys
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())

def func(n):
    cnt=0
    while n%2==0:
        cnt+=1
        n/=2
    return cnt

ans=float("inf")
for x in A:
    ans=min(ans,func(x))
if ans==float("inf"):
    print 0
else:
    print ans


Measured memory_bytes: 28780
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll N, t;
  string S;
  cin >> S;
  N = S.length();

  t = 0;
  rep(i,N){
    t += (ll)S[i] - 48;
    //cout << t << endl;
  }

  //cout << t << endl;
  if(t%9 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3740
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second


int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

bool app[50][50][50][50];

main(){
  int w,h;
  while(cin>>w>>h,w|h){
    memset(app,0,sizeof(app));
    string lr[h],rr[h];
    rep(i,h){
      cin>>lr[i]>>rr[i];
    }

    string ans="No";
    int rsx,rsy,lsx,lsy;
    rep(i,h)rep(j,w){
      if(lr[i][j]=='L')lsx=i,lsy=j;
      if(rr[i][j]=='R')rsx=i,rsy=j;
    }

    queue<pair<PI,PI> > Q;
    Q.push(mp(mp(lsx,lsy),mp(rsx,rsy)));

    while(!Q.empty()){
      PI tp=Q.front().F;
      int clx,cly,crx,cry;
      clx=tp.F,cly=tp.S;
      tp=Q.front().S;Q.pop();
      crx=tp.F,cry=tp.S;
      if(lr[clx][cly]=='%' && rr[crx][cry]=='%'){
        ans="Yes";
        break;
      }
      if(lr[clx][cly]=='%' || rr[crx][cry]=='%')continue;
      
      app[clx][cly][crx][cry]=true;

      rep(i,4){
        int nrx=crx+dx[i],nlx=clx+dx[i],nry=cry+dy[i],nly=cly-dy[i];
        if(nrx<0 || nry<0 || nrx>=h || nry>=w)nrx=crx,nry=cry;
        if(nlx<0 || nly<0 || nlx>=h || nly>=w)nlx=clx,nly=cly;
        if(lr[nlx][nly]=='#'){
          nlx=clx;
          nly=cly;
        }
        if(rr[nrx][nry]=='#'){
          nrx=crx;
          nry=cry;
        }
        if(app[nlx][nly][nrx][nry])continue;
        app[nlx][nly][nrx][nry]=true;
        Q.push(mp(mp(nlx,nly),mp(nrx,nry)));
      }
/*      
      rep(i,h){
        rep(j,w){
          if(clx==i && cly==j)cout<<'L';
          else if(lr[i][j]=='L')cout<<'.';
          else cout<<lr[i][j];
        }
        cout<<" ";
        rep(j,w){
          if(crx==i && cry==j)cout<<'R';
          else if(rr[i][j]=='R')cout<<'.';
          else cout<<rr[i][j];
        }
        cout<<endl;
      }
      cout<<endl;
*/
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 7928
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
import std.bigint, std.functional;

const MOD = 1000000000 + 7;

class FermetCalculator {
	long[] factrial; //階乗を保持
	long[] inverse;  //逆元を保持
	
	this(long size) {
		factrial = new long[size + 1];
		inverse = new long[size + 1];
		factrial[0] = 1;
		inverse[0] = 1;
		
		for (long i = 1; i <= size; i++) {
			factrial[i] = (factrial[i - 1] * i) % MOD;  //階乗を求める
			inverse[i] = pow(factrial[i], MOD - 2) % MOD; // フェルマーの小定理で逆元を求める
		}
	}
	
	long combine(long n, long k) {
		return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
	}
	
	long combine_naive(long n, long k) {
		auto bunshi = reduce!((x, i) => (x * (n - i + 1)) % MOD)(1L, iota(1, k+1));
		auto bumbo = reduce!((x, i) => (x * i) % MOD)(1L, iota(1, k+1));
    return bunshi * pow(bumbo, MOD - 2) % MOD;
	}
	
	long pow(long x, long n) { //x^n 計算量O(logn)
		long ans = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				ans = ans * x % MOD;
			}
			x = x * x % MOD; //一周する度にx, x^2, x^4, x^8となる
			n >>= 1; //桁をずらす n = n >> 1
		}
		return ans;
	}
}

void main() {
  auto INPUT = readln.split.to!(long[]);
  auto N = INPUT[0];
  auto A = INPUT[1];
  auto B = INPUT[2];

  auto fermetCalculator = new FermetCalculator(1);

  ulong solve() {
    auto answer = fermetCalculator.pow(2, N) - 1;
    auto a = fermetCalculator.combine_naive(N, A);
    auto b = fermetCalculator.combine_naive(N, B);

    answer = answer >= a ? answer - a : MOD - a + answer;
    answer = answer >= b ? answer - b : MOD - b + answer;

    return answer;
  }

  solve().writeln;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
from numpy.fft import rfft,irfft

N = int(readline())
L = np.array(read().split(),np.int32)

fft_len = 2048

counter = np.bincount(L,minlength=1001)
add = (irfft(rfft(counter,fft_len)**2)+.5).astype(int)

# 同じものを2回使うパターンを除外
add[:2002:2] -= counter
add //= 2

# a+b <= c となる(a,b,c)を除外する

cum = counter.cumsum()
remove = ((N-cum+counter) * add[:1001]).sum()

answer = N*(N-1)*(N-2)//6 - remove
print(answer)

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

int main() {
	int a,b,c,x;
	int total=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				int sum=500*i+100*j+50*k;
				if(sum==x) total++;
			}
		}
	}
	cout << total << endl;
	return 0;
}

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

int main(){	
	long long N;
	long long H;
	scanf("%lld",&N);
	vector<long long> b(N-1+1);
	vector<long long> a(N-1+1);
	scanf("%lld",&H);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
		scanf("%lld",&b[i]);
	}
	
	ll maxa = 0;
	for(int i = 0 ; i <= N-1 ; i++){
		if (maxa <= a[i]) {
			maxa = a[i];
		}
	}

	sort(b.begin(), b.end(), greater<ll>());

	ll res = 0;
	for(int i = 0 ; i <= N-1 ; i++){
		if (maxa < b[i]) {
			H -= b[i];
			res++;
			// cout << b[i] << endl;
		}
		if (H <= 0) break;
	}
	// cout << res << endl;
	if (H > 0) res += (H + (maxa - 1)) / maxa;
	cout << res << endl;

	return 0;
}



Measured memory_bytes: 1792
N, M = map(int, input().split())
data = []

for i in range(N):
  tmp_a, tmp_b = map(int, input().split())
  data.append((tmp_a, tmp_b))

sorted_data = sorted(data, key=lambda x: x[0])
  
buy_count = 0
money_count = 0

while buy_count < M:
  tmp_a = sorted_data[0][0]
  tmp_b = sorted_data[0][1]

  if buy_count + tmp_b < M:
    buy_count += tmp_b
    money_count += tmp_b * tmp_a
    sorted_data.pop(0)
  else:
    while buy_count < M:
      buy_count += 1
      money_count += tmp_a
      
print(money_count)

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

int main(){
	double a, b, c, d, e, f;
	double x, y;

	while (cin >> a >> b >> c >> d >> e >> f){
		y = (f*a - c*d) / (e*a - b*d);
		x = (c - b*y) / a;
		printf("%.3lf %.3lf\n", x, y);
	}
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll ans = 0;
    ll max_number = 1e7;
    vector<ll> era(max_number+1, 2);
    era[0] = 1;  era[1] = 1;
    for(i = 2;i <= max_number;++i){
        for(j = 2*i;j <= max_number;j += i){
            ++era[j];
        }
    }
    for(i = 1;i <= n;++i){
        ans += i*era[i];   
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 81380
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var rgb = new long[3];
            var len = int.Parse(Console.ReadLine());
            var chars = Console.ReadLine().ToCharArray();
            /* 全探索アルゴリズム(時間が足りない)
            for(int i = 0; i < len - 2; i++)
            {
                for(int j = i + 1;j<len - 1; j++)
                {
                    if(chars[j] != chars[i])
                    {
                        for(int k = j+1;k<len; k++)
                        {
                            if(chars[i] != chars[k] && chars[j] != chars[k] && k - j != j - i)
                            {
                                count++;
                            }
                        }
                    }
                }
            }*/
            foreach(char c in chars)
            {
                if (c == 'R') rgb[0]++;
                else if (c == 'G') rgb[1]++;
                else rgb[2]++;
            }
            //考えられる組み合わせの総数
            Int64 allC = rgb[0] * rgb[1] * rgb[2];
            for (int i = 0; i < len; i++)
            {
                for(int j = i + 1; j < len; j++)
                {
                    if (2 * j - i < len)//k-j=j-iの時、k=2j-i,kが範囲外のときは考えない
                    {
                        if (chars[i] != chars[j] && chars[j] != chars[2 * j - i] && chars[i] != chars[2 * j - i])
                        {
                            allC--;
                        }
                    }
                }
            }
            Console.WriteLine(allC);
        }
    }
}


Measured memory_bytes: 27540
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	ll n;
	cin >> n;
	ll t = 1e6+1;
	ll res = LLONG_MAX;
	FOR(i, 1, t) {
		if (n % i == 0) {
			chmin(res, i + n / i - 2);
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, m, k, c[200], i, j, a[200], b[200];
	cin >> n;
	for (i = 0; i < 2*n; i++)
		c[i] = i+1;
	cin >> m;
	for (i = 0; i < m; i++)
	{
		cin >> k;
		if (k == 0)
		{
			for (j = 0; j < n; j++)
				a[j] = c[j];
			for (j = n; j < 2*n; j++)
				b[j-n] = c[j];
			for (j = 0; j < 2*n; j+=2)
			{
				c[j] = a[j/2];
				c[j+1] = b[j/2];
			}
		}
		else
		{
			for (j = 0; j < k; j++)
				a[j] = c[j];
			for (j = k; j < 2*n; j++)
				b[j-k] = c[j];
			for (j = 0; j < 2*n-k; j++)
				c[j] = b[j];
			for (j = 2*n-k; j < 2*n; j++)
				c[j] = a[j-2*n+k];
		}
	}
	for (i = 0; i < 2*n; i++)
		cout << c[i] << endl;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  
  cout << (int)(k*pow(k-1,n-1)) << endl;
  
  return 0;
}

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

typedef long long ll;

using namespace std;

void solve() {
    int n, w;

    cin >> n >> w;
    vector<int> weight(n);
    vector<int> value(n);
    for (int i = 0; i < n; i++) {
        cin >> weight[i] >> value[i];
    }

    vector< vector<ll> > dp(n+1, vector<ll>(w+1, 0));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= w; j++) {
            dp[i][j] = dp[i-1][j];
            if (weight[i-1] <= j) {
                dp[i][j] = max(dp[i][j], value[i-1] + dp[i-1][j-weight[i-1]]);
            }
        }
    }

    cout << dp[n][w] << endl;
}


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


Measured memory_bytes: 80256
unittest
{
	assert( [ "3", "2 2 4" ].parse.expand.solve == "4 0 4" );
	assert( [ "5", "3 8 7 5 5" ].parse.expand.solve == "2 4 12 2 8" );
	assert( [ "3", "1000000000 1000000000 0" ].parse.expand.solve == "0 2000000000 0" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	// 最初の山の降雨量を計算
	auto anss = new long[ as.length ];
	anss[ 0 ] = as[ 0 ];
	for( auto i = 1L; i < as.length; i += 2 )
	{
		anss[ 0 ] = anss[ 0 ] - as[ i ] + as[ i + 1 ];
	}
	
	// 最後から2番目までの山の降雨量を計算
	anss[ $ - 1 ] = as[ $ - 1 ] * 2 - anss[ 0 ];
	for( auto i = as.length.signed - 2; 0 < i; i-- )
	{
		anss[ i ] = as[ i ] * 2 - anss[ i + 1 ];
	}
	
	return anss.to!( string[] ).join( " " );
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            abc088_a();
        }

        static void abc088_a()
        {
            // A - Infinite Coins
            int N = int.Parse(Console.ReadLine());
            int A = int.Parse(Console.ReadLine());
            string ans;
            if (N % 500 <= A) ans = "Yes";
            else ans = "No";
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define R cin>>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    string S;
    R S;
    int len, h;
    int ans = 0;
    len = S.size();
    for(int i=0; i < len; i++) {
        h = 0;
        FOR(j, i, len) {
            if (S.at(j) == 'A') h += 1;
            else if (S.at(j) == 'T') h += 1;
            else if (S.at(j) == 'G') h += 1;
            else if (S.at(j) == 'C') h += 1;
            else break;
        }
        if (h > ans) ans = h;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  vi x(5);
  for (ll i = 0; i < 5; i++) {
    cin >> x[i];
    if (x[i] == 0) cout << i + 1 << endl;
  }
}


Measured memory_bytes: 3496