akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]

    return (s, )


def solve(s):

    if s == 'ARC':
        result = 'ABC'
    else:
        result = 'ARC'
    
    return  result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 62012
while True:
  a , op , b = map(str,input().split())
  a = int(a)
  b = int(b) 
  if op == "?":
    break
  elif op == "+":
    print(a+b)
  elif op == "-":
    print(a-b) 
  elif op == "*":
    print(a*b)
  elif op == "/":
    print(a//b)


Measured memory_bytes: 5596
def main():
    N, D = list(map(int, input().split()))
    points = [list(map(int, input().split())) for _ in range(N)]
    cnt = 0
    for point in points:
        x, y = point
        if x**2 + y**2 <= D**2:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 45452
#include <stdio.h>

int main() {
    int M, N;
    int i;
    int a, b;
    int c[50];
    for( i=0; i<50; i++){
        c[i] = 0;
    }
    scanf("%d %d", &N, &M);
    for( i=0; i<M; i++){
        scanf("%d %d", &a, &b);
        c[a-1]++ ;
        c[b-1]++ ;
    }
    for( i=0; i<N; i++){
        printf("%d\n", c[i]);
    }
    return 0;
}

Measured memory_bytes: 128
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mss map <string,string>
#define msl map <string,ll>
#define mll map <ll,ll>
#define mcl map <char,ll>
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}

int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
  
  ll n;
  string s;
  cin>>n>>s;
  if(n>=3200) cout<<s;
  else cout<<"red";

}

  

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< int, int > Pi;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const long long INF = 5e18;
const int di[4] = { 1,0,-1,0 };
const int dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

ll n,l[51],rui[55];
ll dp[55][50010],ans=INF;

void input(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l[i];
		rui[i+1]=rui[i]+l[i];
	}
	return;
}

void solve(){
	for(int i=0;i<=n;i++){
		for(int j=0;j<50010;j++){
			dp[i][j]=INF;
		}
	}
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<50010;j++){
			for(int k=i+1;k<=n;k++){
				if(dp[i][j]==INF)continue;
				if(k==n&&j==0)continue;
				if(j==0)dp[k][rui[k]]=min(dp[k][rui[k]],rui[k]);
				else{
					if(rui[k]-rui[i]<j)dp[k][rui[k]-rui[i]]=min(dp[k][rui[k]-rui[i]],dp[i][j]);
					else dp[k][j]=min(dp[k][j],max(dp[i][j],rui[k]-rui[i]));
				}
			}
		}
	}
	for(int i=1;i<=50000;i++){
		if(dp[n][i]==INF||dp[n][i]==0)continue;
		ans=min(ans,dp[n][i]-i);
	}
	cout<<ans<<endl;
	return;
}

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



Measured memory_bytes: 23044
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef unsigned long long ull;
typedef pair<ull, ull> p;

bool comp(const p& x, const p& y) {
  return x.first < y.first;
}

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

  vector<p> infos;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    p x = make_pair(a, b);
    infos.push_back(x);
  }
  sort(infos.begin(),
       infos.end(),
       comp);

  ull ans = 0;
  for (int i = 0; i < N; i++) {    
    p x = infos[i];
    if (M <= x.second) {
      ans += x.first * M;
      break;
    }
    else {
      ans += x.first * x.second;
      M -= x.second;
    }
  }
  cout << ans << endl;
} 


Measured memory_bytes: 2420
#include <iostream>
using namespace std;
int ans[200005];
int main(int argc, char** argv) {
	int n;
	cin >> n;
	for(int i=1;i<n;i++)
	{
		int x;
		cin >> x;
		++ans[x];
	}
	for(int i=1;i<=n;i++)
	{
		cout << ans[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
unsigned long long N,A,B;
long long a[100010];
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>N>>A>>B;
    for(int i=1;i<=N;i++)
    {
        cin>>a[i];
    }
    unsigned long long ans=0;
    for(int i=2;i<=N;i++)
    {
        if((a[i]-a[i-1])*A>=B)
        {
            ans+=B;
        }
        else
        {
            ans+=((a[i]-a[i-1])*A);
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

constexpr int MAX_N = 100;
int N, D, X;
int A[MAX_N];

void _main() {
  cin >> N >> D >> X;
  rep(i, 0, N) cin >> A[i];

  int eaten = 0;
  rep(i, 1, D+1) {
    rep(j, 0, N) {
      if ((i - 1) % A[j] == 0) eaten++;
    }
  }
  int ans = X + eaten;

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>

#define pb push_back
#define sz size()
#define rep(i,a) for(int i=0;i<(int)(a);i++)

using namespace std;
typedef long double D;
typedef complex<D> P;
const D EPS = 1e-10;
const D PI = acos(-1);

inline D dot(P x,P y){return real(conj(x)*y);}
inline D cross(P x,P y){return imag(conj(x)*y);}
P rotate(P v,double s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}
/*
inline D arg(P a,P b,P c){
  D res = acos(dot(b-a,c-a)/(abs(b-a)*abs(c-a))); 
  return (cross(b-a,c-a)<0.0)?2*PI-res:res;
}
*/
inline int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

int h,r,n[3];
D d[3],tmp1,tmp2,seta;
P hp[110],up[3][110];
D w[110],a[110];

int main(){
  while(cin >> h >> r,h){
    rep(i,h){
      cin >> tmp1 >> tmp2;
      hp[i] = P(tmp1,tmp2);
    }

    rep(i,3)cin >> n[i]; rep(i,3)cin >> d[i], d[i] *= PI/180/2;

    rep(i,3)rep(j,n[i]){
      cin >> tmp1 >> tmp2;
      up[i][j] = P(tmp1,tmp2);
    }

    rep(i,r)cin >> w[i] >> a[i], w[i] *= PI/180;

    int num[110];
    memset(num,0,sizeof(num));

    rep(x,r)rep(id,h){
      if( !(abs(hp[id]) < a[x] + EPS) )continue;
      /*
      seta = arg(P(0,0),P(100,0),hp[id]);
      if( !(w[x]-d[0] < seta+EPS && seta < w[x]+d[0]+EPS)
	  && !(w[x]-d[0]+2*PI < seta+EPS && seta < w[x]+d[0]+2*PI+EPS) )continue;
      */
      P o = P(0,0), lp = rotate(P(1,0),w[x]+d[0]), rp = rotate(P(1,0),w[x]-d[0]);
      if(ccw(o,lp,hp[id]) != -1 || ccw(o,rp,hp[id]) != 1)continue;

      bool in = 0;
      rep(i,3){
	rep(j,n[i]){
	  if(abs(hp[id]-up[i][j]) < a[x] +EPS){
	    /*
	    P tmp = P(up[i][j].real() + 100.0, up[i][j].imag());
	    seta = arg(up[i][j],tmp,hp[id]);
	    if(w[x]-d[i] < seta+EPS && seta < w[x]+d[i]+EPS){
	      in = 1; break;
	    }
	    seta -= 2*PI;
	    if(w[x]-d[i] < seta+EPS && seta < w[x]+d[i]+EPS){
	      in = 1; break;
	    }
	    */
	    P o = up[i][j], lp = o + rotate(P(1,0),w[x]+d[i]), rp = o + rotate(P(1,0),w[x]-d[i]);
	    if(ccw(o,lp,hp[id]) == -1 && ccw(o,rp,hp[id]) == 1){
	      in = 1; break;
	    }
	  }
	}
	if(in)break;
      }
      if(!in)num[id]++;
    }

    int maxv = *max_element(num,num+h);
    if(maxv==0)cout << "NA\n";
    else{
      vector<int> ans;
      rep(i,h){
	if(num[i] == maxv)ans.pb(i+1);
      }
      rep(i,ans.sz)cout << ans[i] << (i+1==ans.size()?"\n":" ");
    }
  }
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;

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

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

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

mint perm(int n, int k){
    mint res = comb(n,k);
    res *= comb.fact[k];
    return res;
}


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    cin >> K;
    string S;
    cin >> S;
    int n = S.size();
    mint ans = 0;
    for (int i=0;i<=K;i++){
        mint now = mint(26).pow(K-i);
        now *= mint(25).pow(i);
        now *= comb(i+n-1,n-1);
        ans += now;
    }
    cout << ans << "\n";

}

Measured memory_bytes: 35532
#set
n = gets.chomp.to_i
restaurants_arr = Array.new(n) { Array.new(3,0)}

0.upto(n -1) do |i|
  restaurants_arr[i][0] = i + 1
  restaurants_arr[i][1],restaurants_arr[i][2] = gets.chomp.split(" ")
  restaurants_arr[i][2] = restaurants_arr[i][2].to_i
end
i = 0
restaurants_arr.sort_by! {|keys| [keys[2], i += 1]}.reverse!.sort_by! {|keys| [keys[1], i += 1]}
0.upto(n -1) do |i|
 print ("#{restaurants_arr[i][0]}\n")
end

Measured memory_bytes: 1788
=begin
－－－－－－－－－－－－－－
  c = 入力配列
  a = 列の値
  b = 行の値
  ans = 比較配列
－－－－－－－－－－－－－－
1: c を２次元配列で受け取る
2: a[1] の値を 0 と決める
3: b の値に c の (1,1)/(1,2)/(1,3) の値を代入
  → a[1] の値にいくつ足したら c (1,1)/(1,2)/(1,3) になるかを見ています(a1が0なので自ずと c(1,i) = b[i] となる)
4: c(i,1) の値から b[1] の 引く
  4.1: a[i] + b[j] = c[i,j] となるため a[i] = c[i,1] - b[1]
5: a[i] と b[j] を足して ans(配列)を作成
6: ans[i,j] と c[i,j] を比較
  6.1: 全て一致していれば "Yes"
  6,2: 一つでも一致していなければ "No"  を出力する
=end

c = 3.times.map{gets.split.map(&:to_i)}
a = []
b = []
ans = []
a[0] = 0

3.times do |j|
  b[j] = c[0][j].to_i
end

(1..2).each{|i|
  a[i] = c[i][0].to_i - b[0].to_i
}

a.each{|i|
  num = []
  b.each{|j|
    num << i + j
  }
  ans << num
}

puts (ans == c) ? "Yes" : "No"

Measured memory_bytes: 1916
#include<cstdio>
#include<cmath>
int main() {
	double a, b, C;
	scanf("%lf%lf%lf", &a, &b, &C);
	C = C*3.14159265 / 180;
	printf("%f\n%f\n%f\n", 0.5*a*b*std::sin(C), a+b+std::sqrt(a*a + b*b - 2 * a*b*std::cos(C)), b*std::sin(C));
	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll x,y;cin >>x>>y;
    bool flg=false;
    for (int a = 0; a <=x; ++a) {
        ll b=x-a;
        if(2*a+4*b==y)flg=true;
    }
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
class Main {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int k = scanner.nextInt();
    int n = scanner.nextInt();
    int[] a = new int[n];
    for(int i = 0;i < n;i++){
      a[i] = scanner.nextInt();
    }
    int difference = 0;
    for(int i = 0;i < n - 1;i++){
      if(a[i+1] - a[i] > difference)difference = a[i+1] - a[i];
    }
    if(a[0] - a[n-1] + k > difference)difference = a[0] - a[n-1] + k;
    System.out.println(k - difference);
  }
}

Measured memory_bytes: 67176
import java.util.*;

class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int[] path = new int[3];
        path[0] = sc.nextInt();
        path[1] = sc.nextInt();
        path[2] = sc.nextInt();
        Arrays.sort(path);
        System.out.println(path[0]+path[1]);
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define lint long long int 
#define mm 1000000007
using namespace std;

int main()
{
     int n;
     cin>>n;
     vector<int >arr(n);
     int i;
     for(i=0;i<n;i++)
     {
     cin>>arr[i];
     arr[i]--;
     }
     int count[100]={0};
     for(i=0;i<n;i++)
     {
           count[arr[i]]++;
     }
     int ans=0;
     for(i=0;i<100;i++)
     {
           if(count[i]>0)
           ans++;
     }cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N  4

int main(){
  const char abc[N] = "ABC";
  const char arc[N] = "ARC";
	char s[N];
  int abc_cnt = 0;
  int arc_cnt = 0;

  scanf("%s", s);

  for (int ii = 0; ii < N - 1; ii++) {
    if(s[ii] == abc[ii]){
      abc_cnt++;
    }
    if(s[ii] == arc[ii]) {
      arc_cnt++;
    }
  }

  if(abc_cnt == 3){
    puts("ARC");
  }else if(arc_cnt == 3){
    puts("ABC");
  }

  return 0;
}

Measured memory_bytes: 2036
#include<stdio.h>
int main(){
  int i,j,count=0,n,q,key;
  int a[10000],b[10000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&a[i]);
}
scanf("%d",&q);
for(i=0;i<q;i++){
scanf("%d",&b[i]);
}
for(j=0;j<q;j++){
  i=0;
  key=b[j];
  a[n]=key;
while(1){
  if(a[i]==b[j]){
    count++;
    break;
  }
  i++;
  if(i==n){
    break;
  }
}
}
printf("%d\n",count);
return 0;
}



Measured memory_bytes: 2144
#include <stdio.h>

int main(void)
{

int a,b;
int count=0;

scanf("%d %d",&a,&b);

for(int i=0;i<2;i++){
    if(a>=b){
        count+=a;
        a--;    
    }else{
        count+=b;
        b--;
    }
}
printf("%d\n",count);

return 0;
}

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

int main(){

  int numN=0, numT=0, ans;
  string S, N, T;
  cin >> S;
  N=S;
  T=S;

  for(int i=0; i<S.size(); i++){
    if(i%2){
      N[i]='0';
    }else{
      N[i]='1';
    }
  }
  for(int i=0; i<S.size(); i++){
    if(!(i%2)){
      T[i]='0';
    }else{
      T[i]='1';
    }
  }

  for(int i=0; i<S.size(); i++){
    if(S[i]!=N[i]) numN++;
    if(S[i]!=T[i]) numT++;
  }

  ans = min(numN, numT);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=998244353;
const ll inf=1e16;
const ll ms=(1e5) +5;



int main()
{
    idfc;

    int n,m;
    cin>>n>>m;
    int aa=(n*(n-1))/2;
    int bb=(m*(m-1))/2;
    cout<<aa+bb;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

vector <int> conn[2050];
vector <int> son[2050];
bool dchk[2050];
int N, K;
int dp[2050][2050];
int sz[2050];

int tdp1[2050];
int tdp2[2050];
void DFS(int n) {
	dchk[n] = true;
	sz[n] = 1;
	for (auto it : conn[n]) {
		if (dchk[it]) continue;
		son[n].push_back(it);
		DFS(it);
		sz[n] += sz[it];
	}

	for (int i = 0; i <= K; i++) tdp1[i] = 0;
	for (auto it : son[n]) {
		for (int i = 0; i <= K; i++) tdp2[i] = tdp1[i] + sz[it];
		for (int i = 1; i <= K; i++) {
			// max(a, b+1) = i
			
			int a, b;
			a = i, b = min(i - 1, K - 1 - a);
			if (b >= 0) tdp2[i] = min(tdp2[i], tdp1[a] + dp[it][b]);
			
			b = i - 1, a = min(i, K - 1 - b);
			tdp2[i] = min(tdp2[i], tdp1[a] + dp[it][b]);
		}
		for (int i = 1; i <= K; i++) tdp2[i] = min(tdp2[i - 1], tdp2[i]);
		for (int i = 0; i <= K; i++) tdp1[i] = tdp2[i];
	}
	for (int i = 0; i <= K; i++) dp[n][i] = tdp1[i];
}
int main() {
	int i;
	scanf("%d %d", &N, &K);
	for (i = 1; i < N; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		conn[t1].push_back(t2);
		conn[t2].push_back(t1);
	}
	DFS(1);

	int ans = N;
	for (i = 1; i <= N; i++) ans = min(ans, N - sz[i] + dp[i][K]);
	return !printf("%d\n", ans);
}


Measured memory_bytes: 16896
N, M = map(int, input().split())
ans = 1
for i in range(N, min(M+1, 100000)):
    q, m = divmod(M, i)
    if m==0:
        ans = q
        break
else:
    for i in range(100000, 0, -1):
        q, m = divmod(M, i)
        if q < N: continue
        if m==0:
            ans = i
            break
print(ans)


Measured memory_bytes: 3060
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <string>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
struct edge { int to, cost; };
typedef vector<vector<edge>> AdjList;
AdjList graph;
typedef pair<int, int> P;
const int INF = 10000000;
vector<int> dist;
vector<int> prever;
int idx[100][100];
void dijkstra(int n, int s) {
	dist = vector<int>(n, INF);
	prever = vector<int>(n, -1);
	dist[s] = 0;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (dist[v] < p.first) {
			continue;
		}
		for (int i = 0; i < graph[v].size(); i++) {
			edge e = graph[v][i];
			if (dist[e.to] > dist[v] + e.cost) {
				dist[e.to] = dist[v] + e.cost;
				prever[e.to] = v;
				que.push(P(dist[e.to], e.to));
			}
		}
	}
}
vector<int> get_path(int t) {
	vector<int> path;
	for (; t != -1; t = prever[t]) {
		path.push_back(t);
	}
	reverse(path.begin(), path.end());
	return path;
}
int main(void) {
	int N, M;
	cin >> N >> M;
	graph = AdjList(N);
	bool used[1000];
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		graph[a].push_back({ b, c });
		graph[b].push_back({ a, c });
		used[i] = false;
		idx[a][b] = i;
		idx[b][a] = i;
	}
	for (int i = 0; i < N; i++) {
		dijkstra(N, i);
		for (int j = 0; j < N; j++) {
			vector<int> ans = get_path(j);
			for (int k = 0; k < ans.size() - 1; k++) {
				used[idx[ans[k]][ans[k + 1]]] = true;
				
			}
		}
	}
	int result = 0;
	for (int i = 0; i < M; i++) {
		if (!used[i]) {
			result++;
		}
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int main() {
  int n,x,sum,count;
  cin >> n >> x;
  vector<int> dif(n);
  rep(i,n){
    cin >> dif[i];
  }
  rep(i,n){
    if(sum <= x){
      count++;
    }else if(sum > x){
      break;
    }
    sum += dif[i];
  }
  if(sum <= x){
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
   int n;
   cin>>n;
   string s="eve";
   string ans="Christmas";
   rep(i,25-n)
   {
       ans+=" ";
       ans+="Eve";
   }
   cout<<ans;
}

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

using u32 = uint32_t;

int main()
{
	u32 a;
	u32 b;
	
	std::cin >> a >> b;
	
	u32 n = std::ceil(float(b-1)/float(a-1));
	
	std::cout << n << "\n";
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
'''
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_3_A&lang=jp
???????¨???????
?????§????????¢
??£?????¢??????????§£????????????????????????????????°????????§?§£???????????????
'''

H, W = map(int, input().split())
C = list()
maxArea = 0

for h in range(H):
    C.append(list(map(int, input().split())))

#buf = [[-1 for w in range(W)] for h in range(H)]
T = [[float('inf') for w in range(W)] for h in range(H)]
for h in range(H):
    for w in range(W):
        if C[h][w] == 1:
            T[h][w] = 0
        else:
            if h==0:
                T[h][w] = 1
                continue
            T[h][w] = T[h-1][w] + 1

class Rectangle():
    def __init__(self, height, pos):
        self.height = height
        self.pos = pos

def getLargestRectangle(size, buff):
    S = list()
    maxv = 0
    buff.append(0)
    for w in range(size+1):
        rect = Rectangle(buff[w], w)
        if len(S) ==0:
            S.append(rect)
            #print("len(S)=0,w=",w)
        else:
            if S[-1].height < rect.height:
                S.append(rect)
                #print("S[-1].height < rect.height,w=",w)
            elif S[-1].height > rect.height:
                target = w
                while len(S) > 0 and S[-1].height >= rect.height:
                    #print("S[-1].height > rect.height,w=",w,",target=",target)
                    pre = S.pop()
                    area = pre.height * (w - pre.pos)
                    maxv = max(maxv, area)
                    target = pre.pos
                rect.pos = target
                S.append(rect)
    return maxv

#print(T)

ans = 0
for h in range(H):
    ans = max(ans, getLargestRectangle(W, T[h]))


print(ans)

Measured memory_bytes: 84728
a,b,c = map(int,input().split())
k = int(input())

cnt = 0
while not(a<b<c):
    if a >= b:
        b = 2*b
    else:
        if b >= c:
            c = 2*c
    
    cnt += 1

if cnt <= k:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
// ---------- begin chmin, chmax ----------
trait ChangeMinMax {
    fn chmin(&mut self, x: Self) -> bool;
    fn chmax(&mut self, x: Self) -> bool;
}

impl<T: PartialOrd> ChangeMinMax for T {
    fn chmin(&mut self, x: Self) -> bool {
        *self > x && {
            *self = x;
            true
        }
    }
    fn chmax(&mut self, x: Self) -> bool {
        *self < x && {
            *self = x;
            true
        }
    }
}
// ---------- end chmin, chmax ----------

use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        n: usize,
        a: [Usize1; 3 * n],
    }
    let mut dp = vec![vec![-5000; n]; n];
    let mut max = vec![-5000; n];
    dp[a[0]][a[1]] = 0;
    dp[a[1]][a[0]] = 0;
    max[a[0]] = 0;
    max[a[1]] = 0;
    let mut add = 0;
    let mut change = vec![];
    for a in a[2..].chunks_exact(3) {
        let (a, b, c) = (a[0], a[1], a[2]);
        if a == b && b == c {
            add += 1;
            continue;
        }
        change.clear();
        let v = *max.iter().max().unwrap();
        if a == b || b == c || c == a {
            let q = a ^ b ^ c;
            let p = (a + b + c - q) / 2;
            for i in 0..n {
                change.push((i, q, dp[i][p] + 1));
                change.push((i, p, max[i]));
                change.push((i, q, max[i]));
            }
            change.push((p, p, v));
            change.push((p, q, v));
            change.push((p, p, dp[q][q] + 1));
        } else {
            change.push((b, c, dp[a][a] + 1));
            change.push((c, a, dp[b][b] + 1));
            change.push((a, b, dp[c][c] + 1));
            change.push((a, b, v));
            change.push((b, c, v));
            change.push((c, a, v));
            for &x in [a, b, c].iter() {
                for i in 0..n {
                    change.push((x, i, max[i]));
                }
            }
        }
        for &(x, y, v) in change.iter() {
            dp[x][y].chmax(v);
            dp[y][x].chmax(v);
            max[x].chmax(v);
            max[y].chmax(v);
        }
    }
    let last = *a.last().unwrap();
    let ans = add + std::cmp::max(*dp.iter().flatten().max().unwrap(), dp[last][last] + 1);
    println!("{}", ans);
}

fn main() {
    run();
}


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

using namespace std;

int main()
{
    int H, W, p, k, M=0;
    cin >> H >> W;
    char C[H+1][W+1];
    int A[H+1][W+1], B[H+1][W+1];
    for (int i = 0; i < H+1; i++)
    {
        for (int y = 0; y < W+1; y++)
        {
            if (i == H || y == W)
            {
                C[i][y] = '#';
            }
            else
            {
                cin >> C[i][y];
            }
        }
    }
    for (int i = 0; i < H; i++)
    {
        p = 0;
        k = 0;
        for (int y = 0; y <= W; y++)
        {
            if (C[i][y] == '#')
            {
                for (int u = p; u < y; u++)
                {
                    A[i][u] = k;
                }
                A[i][y] = 0;
                p = y+1;
                k = 0;
            }
            else
            {
                k++;
            }
        }
    }
    for (int y = 0; y < W; y++)
    {
        p = 0;
        k = 0;
        for (int i = 0; i <= H; i++)
        {
            if (C[i][y] == '#')
            {
                for (int u = p; u < i; u++)
                {
                    B[u][y] = k;
                }
                B[i][y] = 0;
                p = i+1;
                k = 0;
            }
            else
            {
                k++;
            }
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int y = 0; y < W; y++)
        {
            if (C[i][y] == '.')
            {
                M = max(M, A[i][y] + B[i][y] - 1);
            }
        }
    }
    cout << M;
    return 0;
}


Measured memory_bytes: 35456
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

struct edge {
    ll to, cost, num;
};

int V;
vector<edge> G[1000000];
ll d[1000000];

void addedge(int st, int ed, ll co, ll num) {
    edge e;
    e.to = ed;
    e.cost = co;
    e.num = num;
    G[st].push_back(e);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    plglg D[N];
    ll minnum = inf;
    ll dbase[N];
    REP(i, 0, N) {
        ll d;
        cin >> d;
        dbase[i] = d;
        D[i] = plglg(d, i);
        minnum = min(minnum, d);
    }
    V = N;
    bool ok = false;
    REP(i, 0, M) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        addedge(u, v, 1, i);
        addedge(v, u, 1, i);
        if (D[u].first == minnum && D[v].first == minnum) {
            ok = true;
        }
    }
    ll mark[N];
    fill(mark, mark + N, -1);
    ll wt[M];
    sort(D, D + N);
    REP(i, 0, N) {
        bool subok = false;
        ll from = D[i].second;
        REP(j, 0, G[from].size()) {
            edge e = G[from][j];
            if (dbase[e.to] <= D[i].first) {
                subok = true;
                if (mark[from] == -1) {
                    if (mark[e.to] == -1) {
                        mark[from] = 0;
                        mark[e.to] = 1;
                    } else {
                        mark[from] = 1 - mark[e.to];
                    }
                }
                wt[e.num] = D[i].first;
            }
        }
        if (!subok) {
            ok = false;
            break;
        }
    }
    if (!ok) {
        cout << -1 << endl;
    } else {
        string S = "";
        REP(i, 0, N) {
            if (mark[i] == 0) {
                S += "B";
            } else {
                S += "W";
            }
        }
        cout << S << endl;
        REP(i, 0, M) {
            cout << wt[i] << endl;
        }
    }
}


Measured memory_bytes: 45824
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 100000

int main(int argc,char const* argv[])
{
  string s;
  int n,i,ans=0,gtimes=0,ptimes=0;
  cin >> s;
  n=s.size();
  for(i=0;i<n;i++)
    {
      if(s[i]=='g' && ptimes+1<=gtimes)
	{
	  ans++;
	  ptimes++;
	}
      else if(s[i]=='g' && ptimes+1>gtimes)
	{
	  gtimes++;
	}
      else if(s[i]=='p' && ptimes+1<=gtimes)
	{
	  ptimes++;
	}
      else if(s[i]=='p' && ptimes+1>gtimes)
	{
	  gtimes++;
	  ans--;
	}
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <numeric>
#include <iostream>
#include <array>
#include<vector>
#include<algorithm>
#include<math.h>
#include <iomanip>
#define lli long long int
using namespace std;

const int MAX = 2010000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int x,y,n;
    cin>>x>>y;
    n=x+y;
    if(n%3!=0){
        
        //cout<<"[1]"<<endl;        
        cout<<"0"<<endl;
        
        return 0;
    }
    n/=3;
    if(x<n || y<n){
        
        //cout<<"[2]"<<endl;
        cout<<"0"<<endl;
        
        return 0;
    }
        // 前処理
        COMinit();
        // 計算例
        x-=n;
        y-=n;
        /*
        cout<<x<<" "<<y<<endl;
        cout<<"[3]"<<endl;
        */      
        cout << COM(x+y,x) << endl;
    
    return 0;
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 and i % 5 != 0) sum += i;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3604
#ifdef _WIN32
#include "XOR.h"
#endif

#include <stdio.h>

#include <iostream>
#include <vector>
#include <array>

constexpr int64_t MOD = 1'000'000'007;
constexpr int64_t help = 1;

#define ll long long int

#define o(X) ll bits##X = 0
#define ok(X) bits##X += !!(d & (help << X))

#define oke(X) ans += (bits##X * (n - bits##X) % MOD) *((help << X) % MOD); ans %= MOD;
//ll p = (help << b) % MOD;
//ans += (bits[b] * (n - bits[b]) % MOD) * p;
//ans %= MOD;

char buf[1 << 17], *bp = buf, *bend = buf;
char gc() {
    if (bp == bend) {
        int x = fread_unlocked(buf, 1, sizeof buf, stdin);
        bend = buf + x;
        bp = buf;
    }
    return *bp++;
}
void fastscan(ll &n) {
    char c;
    n = 0;
    c = gc();
    for (; '0' <= c && c <= '9'; c = gc())
        n = 10 * n + c - '0';
}

#ifdef _WIN32
namespace XOR
{
#endif 

	int main() {
		ll n;

		fastscan(n);

		o(0);
		o(1);
		o(2);
		o(3);
		o(4);
		o(5);
		o(6);
		o(7);
		o(8);
		o(9);
		o(10);
		o(11);
		o(12);
		o(13);
		o(14);
		o(15);
		o(16);
		o(17);
		o(18);
		o(19);
		o(20);
		o(21);
		o(22);
		o(23);
		o(24);
		o(25);
		o(26);
		o(27);
		o(28);
		o(29);
		o(30);
		o(31);
		o(32);
		o(33);
		o(34);
		o(35);
		o(36);
		o(37);
		o(38);
		o(39);
		o(40);
		o(41);
		o(42);
		o(43);
		o(44);
		o(45);
		o(46);
		o(47);
		o(48);
		o(49);
		o(50);
		o(51);
		o(52);
		o(53);
		o(54);
		o(55);
		o(56);
		o(57);
		o(58);
		o(59);
		o(60);
		o(61);
		o(62);

		std::array<ll, 62> bits{};
		for (ll i = 0; i < n; i++) {
			ll d;
			fastscan(d);
			ok(0);
			ok(1);
			ok(2);
			ok(3);
			ok(4);
			ok(5);
			ok(6);
			ok(7);
			ok(8);
			ok(9);
			ok(10);
			ok(11);
			ok(12);
			ok(13);
			ok(14);
			ok(15);
			ok(16);
			ok(17);
			ok(18);
			ok(19);
			ok(20);
			ok(21);
			ok(22);
			ok(23);
			ok(24);
			ok(25);
			ok(26);
			ok(27);
			ok(28);
			ok(29);
			ok(30);
			ok(31);
			ok(32);
			ok(33);
			ok(34);
			ok(35);
			ok(36);
			ok(37);
			ok(38);
			ok(39);
			ok(40);
			ok(41);
			ok(42);
			ok(43);
			ok(44);
			ok(45);
			ok(46);
			ok(47);
			ok(48);
			ok(49);
			ok(50);
			ok(51);
			ok(52);
			ok(53);
			ok(54);
			ok(55);
			ok(56);
			ok(57);
			ok(58);
			ok(59);
			ok(60);
			ok(61);
			ok(62);
		}

		ll ans = 0;

		oke(0);
		oke(1);
		oke(2);
		oke(3);
		oke(4);
		oke(5);
		oke(6);
		oke(7);
		oke(8);
		oke(9);
		oke(10);
		oke(11);
		oke(12);
		oke(13);
		oke(14);
		oke(15);
		oke(16);
		oke(17);
		oke(18);
		oke(19);
		oke(20);
		oke(21);
		oke(22);
		oke(23);
		oke(24);
		oke(25);
		oke(26);
		oke(27);
		oke(28);
		oke(29);
		oke(30);
		oke(31);
		oke(32);
		oke(33);
		oke(34);
		oke(35);
		oke(36);
		oke(37);
		oke(38);
		oke(39);
		oke(40);
		oke(41);
		oke(42);
		oke(43);
		oke(44);
		oke(45);
		oke(46);
		oke(47);
		oke(48);
		oke(49);
		oke(50);
		oke(51);
		oke(52);
		oke(53);
		oke(54);
		oke(55);
		oke(56);
		oke(57);
		oke(58);
		oke(59);
		oke(60);
		oke(61);
		oke(62);
		//for (ll b = 0; b < 62; b++) {
		//	ll p = (help << b) % MOD;
		//	ans += (bits[b] * (n - bits[b]) % MOD) * p;
		//	ans %= MOD;
		//}

		std::cout << ans;
		return 0;
	}
#ifdef _WIN32
}
#endif 


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

int main() {
	int n,k;
	cin>>n>>k;
	int a[n];
	int ans=0;
	for(int i=0;i<n;i++)
	{cin>>a[i];
		if(a[i]>=k)
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n, k = nm()
    p = nl()
    c = nl()
    seen = [0] * n
    ans = max(c)
    for i in range(n):
        if seen[i]:
            continue
        g = list()
        v = i
        while not seen[v]:
            g.append(c[v])
            seen[v] = 1
            v = p[v] - 1
        m = len(g)
        for i in range(1, m):
            g[i] += g[i-1]
        if k <= m:
            for i in range(m):
                for j in range(i+1, i+k+1):
                    cur = 0
                    if j >= m:
                        cur += g[-1]
                        j -= m
                    cur += g[j] - g[i]
                    if ans < cur:
                        ans = cur
        else:
            for i in range(m):
                for j in range(i+1, i+m+1):
                    cur = 0
                    if g[-1] > 0:
                        cur += g[-1] * ((k - (j-i))//m)
                    if j >= m:
                        cur += g[-1]
                        j -= m
                    cur += g[j] - g[i]
                    if ans < cur:
                        ans = cur
    print(ans)
    return

solve()


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


int main()
{
	int N,Y;
	cin>>N>>Y;
	for(ll i=0;i<=N;i++)
	{
		for(ll j=0;j<=N;j++)
		{
			if(i+j<=N&&i*10000+j*5000+(N-i-j)*1000==Y)
			{
				cout<<i<<" "<<j<<" "<<(N-i-j)<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    W,H,N=map(int,input().split())
    c=[[1]*W for _ in range(H)]
    for _ in range(N):
        x,y,a=map(int,input().split())
        if a==1:
            for i in range(x):
                for j in range(H):
                    c[j][i]=0
        if a==2:
            for i in range(x,W):
                for j in range(H):
                    c[j][i]=0
        if a==3:
            for i in range(W):
                for j in range(y):
                    c[j][i]=0
        if a==4:
            for i in range(W):
                for j in range(y,H):
                    c[j][i]=0
    print(sum(sum(c,[])))

if __name__ == '__main__':
    main()


Measured memory_bytes: 41200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,i;
	ll ans;
	vector<bool> v;
	string s[2];
	cin >> n;
	cin >> s[0];
	cin >> s[1];
	for(i=0; i<n; ++i){
		if(s[0][i] == s[1][i]){
			v.push_back(true);
		}else{
			v.push_back(false);
			++i;
		}
	}
	n = v.l_ength();
	ans = (v[0])?3ll:6ll;
	for(i=1; i<n; ++i){
		if(v[i-1]){
			mul_mod(ans,2ll);
		}else if(!v[i]){
			mul_mod(ans,3ll);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	string s;
	cin >> s;
	
	string ans = "";
	rep(i,0,s.size()){
		if(s[i] == '0')ans.append("0");
		else if(s[i] == '1')ans.append("1");
		else if(ans.size() == 0 and s[i] == 'B')continue;
		else ans.erase(ans.size()-1,1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<Long> list = new ArrayList<>();
        int n = sc.nextInt();
        list.add(2L);
        list.add(1L);
        for(int i = 2;i <= n;i++){
            list.add(list.get(i-2)+list.get(i-1));
        }
        System.out.println(list.get(n));
    }
}


Measured memory_bytes: 21844
#include<iostream>
    using namespace std;
     
    int main()
      {
      int n, i, max, alice, bob, del, j;
      alice = 0;
      bob = 0;
      cin >> n;
      int a[n];
      for(i = 0; i < n; i++)
      {
        cin >> a[i];
      }
      for(j = 0; j < (n/2)+1; j++)
      {
        max = 0;
        for(i = 0; i < n; i++)
        {
          if(a[i] > max)
          {
            max = a[i];
            del = i;
          }
        }
        alice += max;
        a[del] = 0;
        max = 0;
        for(i = 0; i < n; i++)
        {
          if(a[i] >= max)
          {
            max = a[i];
            del = i;
          }
        }
        bob += max;
        a[del] = 0;
      }
      cout << alice - bob << endl;
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < 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 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

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

  vector<int> R(N);
  vector<int> G(N);
  vector<int> B(N);
  int r=0;
  int g=0;
  int b=0;
  REPR(i,N-1){
    if(S.at(i)=='R'){
      r++;
      R[i]=r;
      G[i]=g;
      B[i]=b;
    }else if(S.at(i)=='G'){
      g++;
      R[i]=r;
      G[i]=g;
      B[i]=b;
    }else{
      b++;
      R[i]=r;
      G[i]=g;
      B[i]=b;
    }
  }

  ll ans = 0;
  REP(i,N-2){
    FOR(j,i+1,N-1){
      if((S.at(i)=='R'&&S.at(j)=='G')||(S.at(i)=='G'&&S.at(j)=='R')){
        if(2*j-i<N-1){
          ans+=B[j+1]-B[2*j-i]+B[2*j-i+1];
        }else if(2*j-i==N-1){
          ans+=B[j+1]-B[2*j-i];
        }else{
          ans+=B[j+1];
        }
      }else if((S.at(i)=='B'&&S.at(j)=='G')||(S.at(i)=='G'&&S.at(j)=='B')){
        if(2*j-i<N-1){
          ans+=R[j+1]-R[2*j-i]+R[2*j-i+1];
        }else if(2*j-i==N-1){
          ans+=R[j+1]-R[2*j-i];
        }else{
          ans+=R[j+1];
        }
      }else if((S.at(i)=='R'&&S.at(j)=='B')||(S.at(i)=='B'&&S.at(j)=='R')){
        if(2*j-i<N-1){
          ans+=G[j+1]-G[2*j-i]+G[2*j-i+1];
        }else if(2*j-i==N-1){
          ans+=G[j+1]-G[2*j-i];
        }else{
          ans+=G[j+1];
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3644
import math
import sys

sys.setrecursionlimit(10**9)

MOD = 10**9+7

n, k = map(int, input().split())
k = min(k, n-1)

fact = [1]
for i in range(1, 10**6):
    fact.append((fact[i-1]*i)%MOD)

inv = [None]*10**6
def inv_fact(n):
    if inv[n] == None:
        inv[n] = pow(fact[n], MOD-2, MOD)
    return inv[n]

def comb(n, r):
    return (fact[n]*inv_fact(n-r)*inv_fact(r))%MOD

ans = 0
for i in range(k+1):
    ans = (ans + comb(n-1, i)*comb(n, i))%MOD
print(ans)

Measured memory_bytes: 93804
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long n, m, x,cnt , ans;
const ll N = 1e5 + 7;
    vector<ll>d(N);
    string s , s1;
int main(){
    ll T;
    cin >> T;
    while( T -- ){
        cin >> n >> m;
        if( n == m )
            cnt ++;
            else
                cnt = 0;
        if( cnt == 3 )
            ans = 1;
    }
    if( ans )
        cout << "Yes";
    else
        cout << "No";
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>n; int s=0; ans=INF;
    int a[n]; rep(i,0,n-1) cin>>a[i];
    rep(i,0,n-1){
        
        ans=min(ans,a[i]);
        if(ans>=a[i]) s++;
    }
    cout<<s;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 1792
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n,k;
	cin>>n>>k;
	int num[n];
	for(int i=0;i<n;i++)
		cin>>num[i];
	int ans=0;
	sort(num,num+n);
	for(int i=0;i<k;i++)
		ans+=num[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3628