akhauriyash/Code-Regression huggingface dataset:
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 103000;

    void solve() {
      ll n, r = 0 , t = 0;
      cin >> n;
      for(; (1<<r)<=n; r++ ) if(n&(1<<r)) t++;
      cout << r << " " << 2*r+t-3 << endl;
      repA(i, 1, r-1){
        cout << i << " " << i+1 << " " << 0 << endl;
        cout << i << " " << i+1 << " " << (1<<i-1) << endl;
        if(n&(1<<(i-1))) cout << i << " " << r << " " << (n-=n&-n) << endl;
      }
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N;
  cin >> N;
  vector<vector<int>> testimony(N, vector<int>(N, -1));
  int to_x, to_y;
  for(int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    for(int j = 0; j < A; ++j) {
      int x, x_is;
      cin >> x >> x_is;
      testimony[i][x - 1] = x_is;
    }
  }

  int ans = 0;
  for(int i = 0; i < (1 << N); ++i) {
    vector<int> pattern(N);
    for(int j = 0; j < N; ++j) {
      if(i >> j & 1) {
        pattern[j] = 1;
      }
    }

    bool testimony_of_all = true;
    for(int j = 0; j < N; ++j) {
      if(pattern[j]) {
        for(int k = 0; k < N; ++k) {
          if(testimony[j][k] == -1) continue;
          if(testimony[j][k] != pattern[k]) testimony_of_all = false;
        }
      }
    }
    if(testimony_of_all) ans = max(ans, __builtin_popcount(i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main()
{int i,j=1;
while(1)
{
    scanf("%d",&i);
    if(i==0)
    {
        break;
    }
    else
    {
        printf("Case %d: %d\n",j,i);
        j++;
    }
}
    return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    const int LIMIT = 1015;
    vector <int> perfect_power(LIMIT, false);

    perfect_power[1] = true;
    for(int n = 2; n*n < LIMIT; n++)
    {
        int current_power = n*n;

        while(current_power < LIMIT)
        {
            perfect_power[current_power] = true;
            current_power *= n;
        }
    }

    int X;
    cin >> X;

    while(!perfect_power[X])
        X--;

    cout << X;
    return 0;
}


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

namespace ConsoleApp1
{
    public class Person
    {
        public string firstName;
        public string lastName;
        public void Introduce()
        {
            Console.WriteLine("My name is " + firstName + " " + lastName);
        }
        public Person(string a = "HAHAa", string b =  "VCCAVA")
        {
            this.firstName = a;
            this.lastName = b;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int N, R;
            var a = Console.ReadLine().Split(' ');
            Int32.TryParse(a[0], out N);
            Int32.TryParse(a[1], out R);
            if (N < 10)
            {
                int ans;
                ans = 100 * (10 - N) + R;
                Console.WriteLine(ans);
            }
            else Console.WriteLine(R);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int A,B; cin >> A >> B;
	if(B%A==0) cout << A + B << endl;
	else cout << B - A << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
long long ans[510][510];
int p[21000];
vector<int>v;
long long gcd(long long a,long long b){
	while(a){b%=a;swap(a,b);}return b;
}
int main(){
	int a;scanf("%d",&a);
	if(a==2){
		printf("4 7\n23 10\n");return 0;
	}
	p[0]=p[1]=-1;
	for(int i=2;i<21000;i++){
		if(p[i]!=-1){
			if(i>2)v.push_back(i);
			p[i]=1;
			for(int j=i+i;j<21000;j+=i)p[j]=-1;
		}
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if((i+j)%2)continue;
			int X=(i+j)/2;
			int Y=(i-j+500)/2+500;
			long long ks=1;
			ks*=v[X];
			ks*=v[Y];
			ans[i][j]=ks;
		}
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if((i+j)%2){
				long long cur=1;
				if(i)cur=cur/gcd(cur,ans[i-1][j])*ans[i-1][j];
				if(j)cur=cur/gcd(cur,ans[i][j-1])*ans[i][j-1];
				if(i<a-1)cur=cur/gcd(cur,ans[i+1][j])*ans[i+1][j];
				if(j<a-1)cur=cur/gcd(cur,ans[i][j+1])*ans[i][j+1];

				cur++;
				ans[i][j]=cur;
			}
		}
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(j)printf(" ");
			printf("%lld",ans[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 7296
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        string A, B;
        cin >> A >> B;

        string n;
        n += A;
        n += B;
        int num = 0;
        for (int i = 0; i < n.size(); i++)
        {
                num = num * 10 + (n[i] - '0');
        }
        int s = sqrt(num) + 0.5;
        if (num == s * s)
        {
                cout << "Yes" << endl;
        }
        else
        {
                cout << "No" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
import collections
N ,K = map(int,input().split())
lsA = list(map(int,input().split()))
counterA = collections.Counter(lsA)
valu = list(counterA.values())
valu.sort()
kind = len(set(lsA))
if kind <= K:
    ans = 0
else:
    ans = sum(valu[:kind - K])
print(ans)

Measured memory_bytes: 45800
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
#include<set>

typedef long long ll;

const int maxn=1e5+5;

using namespace std;

ll n,a,b;
ll ans,s;

int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    s=n/(a+b);
    if(s*(a+b)+a>n)
        ans=n-s*b;
    else
        ans=(s+1)*a;
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    ll h,w;
    cin >> h >> w;

    if(h==1||w==1) {
        print(1);
        return 0;
    }
    ll ans = 0;
    ll dp[MAX];
    dp[0] = (h+h%2)/2;
    dp[1] = (h-h%2)/2;

    rep(i, w) {
        ll t = i % 2;
        ans += dp[t];
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int X = stdIn.nextInt();
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		
		X -= A;
		
		while(X >= B)
		{
			X -= B;
		}
		
		System.out.println(X);

	}

}


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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
map <string, int> xcj;
int n;
int main(){
    n = read();
    for (int i = 1; i <= n; i++){
        string s;
        cin >> s;
        xcj[s] = 1;
    }
    cout << xcj.size() << endl;
    return 0;
}
//g++ C.cpp -o C.exe -lm -Wall

Measured memory_bytes: 19176
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n||m){
    vector<pair<int,char> > shop(5);
    shop[0] = make_pair(n+m,'A');
    cin >>n>>m; shop[1] = make_pair(n+m,'B');
    cin >>n>>m; shop[2] = make_pair(n+m,'C');
    cin >>n>>m; shop[3] = make_pair(n+m,'D');
    cin >>n>>m; shop[4] = make_pair(n+m,'E');
    sort(shop.begin(),shop.end());
    cout <<shop[4].second<<" "<<shop[4].first<<endl;
  }
  return 0;
}

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

using namespace std;

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

using ll = long long;

int N,M;
priority_queue<int, vector<int>, greater<int>> q;
pair<int,int> p[100010];

int main() {
  cin >> N >> M;
  REP(i,N) {
    int x;
    scanf("%d", &x);
    q.push(x);
  }
  REP(i,M) {
    int b,c;
    scanf("%d %d", &b, &c);
    p[i] = make_pair(b, c);
  }

  sort(p, p + M, [](const pair<int,int>& a, const pair<int,int>& b){
    return a.second > b.second;
  });

  // REP(i,M) cout << p[i].first << ' ' << p[i].second << endl;

  REP(i,M) {
    int b = p[i].first;
    int c = p[i].second;
    int t = q.top();
    if (t < c) {
      while (b--) {
        q.pop();
        q.push(c);
      }
    }
  }

  ll res = 0L;
  while (!q.empty()) {
    res += q.top();
    q.pop();
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1528
#include "stdio.h"
long count(long n)
{
	long c=0;
	while(n/=2)
	{
			c++;
	}
	return c;
}
int main()
{
	long x;
	while(~scanf("%ld",&x))
	{
		long i,max=0,t=1;
		for(i=1;i<=x;i++)
			if(count(i)>max)
			{
				max=count(i);
				t=i;
			}
		printf("%d\n",t);
	}
	return 0;
}


Measured memory_bytes: 128
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl read >>= print

solve :: Int -> Int
solve x = f [a .. b]
  where
    a = ceiling (sqrt (2 * fromIntegral x) - 1)
    b = floor (sqrt (2 * fromIntegral x) + 1)
    f (h:ts)
      | h * (h + 1) `div` 2 >= x = h
      | otherwise = f ts

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

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

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int field[22][22];
int H, W;
int ans;

void dfs(int x, int y, int n){
  if(n > 10 || n > ans) return;
  if(field[y][x] == 3){
    ans = min(ans, n);
    return;
  }

  rep(i, 4){
    int nx, ny;
    nx = x+dx[i], ny = y+dy[i];
    if(field[ny][nx] == 1) continue;
    else if(nx < 0 || nx >= W ||ny < 0 || ny >= H) continue;
    else if(field[ny][nx] == 3) dfs(nx, ny, n+1);
    
    while(true){
      nx += dx[i], ny += dy[i];
      if(nx < 0 || nx >= W || ny < 0 || ny >= H) break;
      else if(field[ny][nx] != 0) break;
    }
    if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
    if(field[ny][nx] == 1){
      field[ny][nx] = 0;
      dfs(nx-dx[i], ny-dy[i], n+1);
      field[ny][nx] = 1;
    }
    else if(field[ny][nx] == 3) dfs(nx, ny, n+1);
  }
}

int main(){
  int sx, sy;
  while(cin >> W >> H, H|W){
    ans = (1<<29);

    rep(i, H){
      rep(j, W){
	cin >> field[i][j];
	if(field[i][j] == 2) sx = j, sy = i, field[i][j] = 0;
      }
    }
    dfs(sx, sy, 0);
    if(ans == (1<<29)) cout << "-1" << endl;
    else cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    long long int n,i,k=0,maxi=0;
    cin>>n;
    long long int a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=0;i<n-1;i++)
    {
    	if(a[i]>=a[i+1])
    	k++;
    	else
    	{
    		maxi=max(maxi,k);
    		k=0;
		}
	}
	maxi=max(maxi,k);
	cout<<maxi;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace ABC94_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int x = int.Parse(s[2]);
            string[] s2 = ReadLine().Split(' ');
            int[] a = new int[m];
            int rs = 0;
            int ls = 0;
            for (int i = 0; i < m; i++)
            {
                a[i] = int.Parse(s2[i]);
                if (a[i] > x) { rs++; }
                else { ls++; }
            }
            WriteLine(ls < rs ? ls : rs);
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		if(n.equals("Sunny")){
      		System.out.println("Cloudy");
    	}else if (n.equals("Cloudy")){
      System.out.println("Rainy");
    }else{
      System.out.println("Sunny");
    }
    }
}


Measured memory_bytes: 23380
#include <stdio.h>
#include <math.h>

typedef struct {
    double x;
    double y;
} point;

point roll(point p1, point p2){
    point p3;
    p3.x = p1.x + (p2.x - p1.x) * cos(M_PI / 3) - (p2.y - p1.y) * sin(M_PI / 3);
    p3.y = p1.y + (p2.x - p1.x) * sin(M_PI / 3) + (p2.y - p1.y) * cos(M_PI/3);

    return p3;
}

void kock(int n, point p1, point p2)
{
    if (n==0)
        return;
    
    point s = {(2*p1.x+p2.x)/3 , (2*p1.y+p2.y)/3};
    point t = {(p1.x+2*p2.x)/3 , (p1.y+2*p2.y)/3};
    point u = roll(s, t);

    kock(n-1, p1, s);
    printf("%f %f\n", s.x, s.y);
    kock(n - 1, s, u);
    printf("%f %f\n", u.x, u.y);
    kock(n - 1, u, t);
    printf("%f %f\n", t.x, t.y);
    kock(n - 1, t, p2);
}

int main(void){

    int i, j, n;
    point p1 = {0.0, 0.0};
    point p2 = {100.0, 0.0};

    scanf("%d", &n);

    printf("%f %f\n", p1.x, p1.y);

    kock(n, p1, p2);

    printf("%f %f\n", p2.x, p2.y);

    return 0;
}


Measured memory_bytes: 2036
#include <cstdio>

#define fin stdin
#define fout stdout

char s[100];

int main()
{
    int n = 0;
    char ch = fgetc(fin);
    while(ch != '\n'){
        if(ch == 'B'){
            if(n > 0) n --;
        }else s[++ n] = ch;
        ch = fgetc(fin);
    }

    for(int i = 1; i <= n; i ++)
        fputc(s[i], fout);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,ans=0,count=1;
  cin>>n>>m;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    ans = ans + a[i];
    if(ans<=m){
      count++;
    }
  }
  cout<<count<<endl;
} 

Measured memory_bytes: 3596
d,g=map(int,input().split())
pc_=[list(map(int,input().split())) for _ in range(d)]
pc=[[(i+1)*100,pc[0],pc[1]] for i,pc in enumerate(pc_)]
n=d
ans=1000
for i in range(2**n):
  all_ac=[]
  no_ac=[]
  for j in range(n):
    if ((i>>j) & 1):#立っているビットのところで処理が走る
      all_ac.append(j)
    else:
      no_ac.append(j)
  score=sum([pc[j][2]+pc[j][0]*pc[j][1] for j in all_ac])
  n_ac=sum([pc[j][1] for j in all_ac])
  tmp=g-score
  while no_ac and tmp>0:
    a=no_ac.pop()
    i,p,c=pc[a]
    if tmp<=i*(p-1):
      n_ac+=(tmp+i-1)//i
      tmp=0
    else:
      n_ac+=p-1
      tmp-=i*(p-1)
  if tmp<=0:
    ans=min(n_ac,ans)
print(ans)

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

#define x first
#define y second
#define pb push_back
#define Set(i, v) memset(i, v, sizeof i)
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

typedef long long LL;

using namespace std;

const int N = 1e5 + 10;

int n, m;
int X[N];
bool vis[N];
vector<int> G[N], w[N];

void DFS(int o){
	vis[o] = true;
	For(i, 0, (int)G[o].size() - 1){
		int v = G[o][i], d = w[o][i];
		if(vis[v] && X[v] != X[o] + d){
			puts("No");
			exit(0);
		}
		else if(!vis[v]){
			X[v] = X[o] + d;
			DFS(v);
		}
	}
}

int main(){

	scanf("%d%d", &n, &m);
	For(i, 1, m){
		int u, v, d;
		scanf("%d%d%d", &u, &v, &d);
		G[u].pb(v), G[v].pb(u);
		w[u].pb(d), w[v].pb(-d);
	}

	For(i, 1, n) if(!vis[i]) DFS(i);
	puts("Yes");

	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int gcd(int a, int b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

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

  int A, B;
  std::cin >> A >> B;

  ll res = 1ll * A * (B / gcd(A, B));
  std::cout << res << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n+m==0)break;
			int[] t = new int[n+1];
			int sumt = 0;
			for(int i=1;i<=n;i++) {
				t[i] = sc.nextInt();
				sumt += t[i];
			}
			
			int[] h = new int[m+1];
			int sumh = 0;
			for(int i=1;i<=m;i++) {
				h[i]  = sc.nextInt();
				sumh += h[i];
			}
			
			int Git=101;int Gih=101;
			for(int i=1;i<=n;i++){
				for(int j=1;j<=m;j++) {
					if(sumt-t[i]+h[j] == sumh-h[j]+t[i] && Git+Gih > t[i]+h[j]) {
						Git=t[i];
						Gih=h[j];
					}
				}
			}
			if(Git + Gih == 202)
				System.out.println("-1");
			else System.out.println(Git + " " + Gih);
			
		}
		
	}
}


Measured memory_bytes: 29376
r, c = map(int, input().split(' '))
table = [list(map(int, input().split(' '))) for i in range(r)]

for i in range(r):
    tmp = sum(table[i])
    table[i].append(tmp)

lst = []
for i in range(c+1):
    tmp = 0
    for j in range(r):
        tmp += table[j][i]
    lst.append(tmp)
table.append(lst)

for i in range(len(table)):
    for j in range(len(table[0])):
        if j != c:
            print(f"{table[i][j]} ", end='')
        else:
            print(table[i][j])



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

using namespace std;

string s;
string c[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main()
{
	cin >> s;
	for (int i = 0; i < 7; i++)
		if (s == c[i])
			cout << 7 - i << endl;
	return 0;
}


Measured memory_bytes: 256
#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(){

    int N,M, A;
    int cunt = 0;
    cin >> N >> M;
    rep(i, M){
        cin >> A;
        cunt += A;
    }
    int vaca = N - cunt;
    if(vaca < 0){
        cout << -1 << endl;
    }else{
        cout << vaca << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int S = Integer.parseInt(s.next());
        List<Integer> list = new ArrayList<>();
        list.add(S);
        for (int i = 1;; i++) {
            int n = f(list.get(i - 1));
            if (list.contains(n)) {
                System.out.println(i + 1);
                return;
            }
            list.add(n);
            if (i > 10000) {
                System.out.println(i);
                return;
            }
        }
    }

    static int f(int n) {
        if (n % 2 == 0) {
            return n / 2;
        }
        return 3 * n + 1;
    }
}

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

int main()
{
    std::string s;
    std::cin >> s;
    int ans = 0;

    for (int i = 0; i < s.length()/2; i++) {
        if (s[i] != s[s.length()-1-i])
            ans++;
    }

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


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int n;
	int a[10000];
	int c = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		for (int j = 0; j > -1; j++) {
			if (a[i] % 2 == 0) {
				c++;
				a[i] = a[i] / 2;
			}
			else {
				break;
			}
		}
	}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {

		int n = sc.nextInt();
		
		
		int sum = sum(1,n-1);
		for(int i = 1; i < n/2 ; i++){
			int a=  i;
			int b = n-a;
			sum = Math.min(sum(a,b), sum);
			
		}
		System.out.println(sum);
	}
	
	int sum(int a, int b){
		return d(a)+d(b);
	}
	
	int d(int i){
		int res = 0;
		for(char ch:(""+i).toCharArray()){
			res += ch - '0';
		};
		return res;
		
	}
}


Measured memory_bytes: 29908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
    double n;
    cin>>n;
    int ans=ceil(n/1.08);
    int res=floor(ans*1.08);
    if(res==n) cout<<ans<<endl;
    else cout<<":("<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pa;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second

int N,M,H,W,K,A,B,S;
const int INF = 10000000;


int main() {
    cin >> H >> W;
    vector<vector<int>> cellnum(H,vector<int>(W,INF));
    //vector<vector<char>> cellchar(H,vector<char>(W,'x'));
    queue<pa> que;
    char c;
    rep(i,H) {
        rep(j,W) {
            cin >>c;
            if(c == '#'){
                cellnum.at(i).at(j) = 0;
                que.push(pa(i,j));
            }
        }
    }

    pa next;
    int dh[4] = {1,0,-1,0}, dw[4] = {0,1,0,-1};
    int nwh, nww, nxh, nxw, ans = 0;
    while(que.size()){
        pa now = que.front(); que.pop();
        nwh = now.fi; nww = now.se;
        rep(i,4){
            next.fi = now.fi + dh[i];
            next.se = now.se + dw[i];
            nxh = next.fi; nxw = next.se;
            if(nxh >= 0 && nxh < H  && nxw >= 0 && nxw < W && cellnum.at(nxh).at(nxw) == INF){
                cellnum.at(nxh).at(nxw) = cellnum.at(nwh).at(nww) + 1;
                que.push(next);
                ans = cellnum.at(nxh).at(nxw);
            }
            //cout << nwh << ' ' << nww << ' ' << nxh << ' ' << nxw << endl;
        }
    }
    //cout << ans << endl;
    //rep(i,H) rep(j,W) cout << cellnum.at(i).at(j) << ' ';
    cout << ans << endl;
}

Measured memory_bytes: 12432
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N,M;
vector<int> H;
Graph G;

int main() {
  cin >>N >>M;
  H.assign(N, 0); rep(i, N) cin >>H[i];
  G.assign(N, vector<int>());
  rep(i, M){
    int a,b; cin >>a >>b; a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int res = 0;
  rep(i, N){
    bool ok = true;
    for (int v : G[i]){
      if (H[i] <= H[v]){
        ok = false; break;
      }
    }
    if (ok) res++;
  }
  cout <<res <<endl;
}

Measured memory_bytes: 8716
N =int(input())
list ={"AC":0, "WA":0, "TLE":0, "RE":0 }
 
for i in range(N):
  words = input()
  list[words]+=1
 
print("AC x "+str(list["AC"]))
print("WA x "+str(list["WA"]))
print("TLE x "+str(list["TLE"]))
print("RE x "+str(list["RE"]))

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

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

  vector<long long> a(n), b(n), c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  long long ans = 0;
  rep(i,n) {
    long long k = 0;
    k = lower_bound(a.begin(), a.end(),b[i]) - a.begin();

    long long j = 0;
    j = c.end() -upper_bound(c.begin(), c.end(), b[i]);

    ans += k * j;
  }

  cout << ans << endl;

}

Measured memory_bytes: 5568
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      vector<int>arr={31,28,31,30,31,30,31,31,30,31,30,31};
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      if(arr[a-1]==b)cout<<1;
      else cout<<0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
a = []

if s[0] == "0":
    a.append(0)

zero_cnt = 0
one_cnt = 0
for i in range(n):
    if s[i] == "0":
        zero_cnt += 1
        if one_cnt > 0:
            a.append(one_cnt)
            one_cnt = 0
    else:
        one_cnt += 1
        if zero_cnt > 0:
            a.append(-1 * zero_cnt)
            zero_cnt = 0

if zero_cnt > 0:
    a.append(-1 * zero_cnt)
elif one_cnt > 0:
    a.append(one_cnt)

if s[-1] == "0":
    a.append(0)

a_len = len(a)

cum = [0] * (a_len + 1)
for i in range(1, a_len + 1):
    cum[i] = cum[i - 1] + abs(a[i - 1])

ans = 0

for left in range(0, a_len + 1, 2):
    right = left + k * 2 + 1
    if right > a_len:
        right = a_len

    ans = max(ans, cum[right] - cum[left])

print(ans)



Measured memory_bytes: 75928
import java.io.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int c1x = sc.nextInt();
    int c1y = sc.nextInt();
    int c1r = sc.nextInt();
    int c2x = sc.nextInt();
    int c2y = sc.nextInt();
    int c2r = sc.nextInt();

    int diffX = Math.abs(c1x - c2x);
    int diffY = Math.abs(c1y - c2y);
    int xyR = c1r + c2r;
    int right1X = c1x + c1r;
    int left1X = c1x - c1r;
    int right2X = c2x + c2r;
    int left2X = c2x - c2r;
    int top1Y = c1y + c1r;
    int bottom1Y = c1y - c1r;
    int top2Y = c2y + c2r;
    int bottom2Y = c2y - c2r;

    if(c1x == c2x) {
      if(diffY == xyR) { //外接
        System.out.println(3);
      } else if(diffY > xyR) { // 離れ
        System.out.println(4);
      } else {
        if(((top1Y < top2Y) && (bottom1Y > bottom2Y)) ||
        ((top1Y > top2Y) && (bottom1Y < bottom2Y))) { // 内包
          System.out.println(0);
        } else if(((top1Y == top2Y) || (bottom1Y == bottom2Y)) || (top1Y == top2Y) || (bottom1Y == bottom2Y)) { // 内接
          System.out.println(1);
        } else System.out.println(2); // 交わる
      }
    } else if(c1y == c2y) {
      if(diffX == xyR) { //外接
        System.out.println(3);
      } else if(diffX > xyR) { // 離れ
        System.out.println(4);
      } else {
        if(((right1X < right2X) && (left1X > left2X)) ||
        ((right1X > right2X) && (left1X < left2X))) { // 内包
          System.out.println(0);
        } else if(((right1X <= right2X) || (left1X <= left2X)) &&
        ((right1X >= right2X) || (left1X >= left2X))) { // 内接
          System.out.println(1);
        } else System.out.println(2); // 交わる
      }
    } else {
      double d = Math.sqrt(diffX*diffX + diffY*diffY);
      if(d > xyR) { //離れ
        System.out.println(4);
      } else if(d == xyR) {
        System.out.println(3);
      } else {
        if((((right1X < right2X) && (left1X > left2X) && (!(d+c1r > c2r))) && ((top1Y < top2Y) && (bottom1Y > bottom2Y) && (!(d+c1r > c2r)))) ||
        (((right1X > right2X) && (left1X < left2X) && (!(d+c2r > c1r))) && ((top1Y > top2Y) && (bottom1Y < bottom2Y)) && (!(d+c2r > c1r)))) { // 内包
          System.out.println(0);
        } else if(((right1X == right2X) || (left1X == left2X) || (top1Y == top2Y) || (bottom1Y == bottom2Y)) && (!(d+c1r > c2r))) { // 内接
          System.out.println(1);
        } else System.out.println(2); // 交わる
      }
    }
  }
}


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

typedef pair<int, int> pi; 

void sortbypair(long long  x[], long long   y[],long long  n){
	
    pair <long long,long long> pairs[n];
    for(long long  i = 0; i < n; ++i){
        pairs[i].first = y[i];
	pairs[i].second = x[i];}
	
    sort(pairs, pairs + n);
    for(long long i = 0; i < n; ++i){
        y[i] = pairs[i].first;
      x[i] = pairs[i].second;}}

int main(){

ios_base::sync_with_stdio(false);

long long n,i,k,s=0;

cin>>n;

long long b[n],ans[n],p[n];


for(i=0;i<n-1;i++){
	cin>>b[i];
p[i]=i;
ans[i]=1e9;}

ans[n-1]=1e9;

sortbypair(p,b,n-1);

for(i=0;i<n-1;i++){
	
	k=p[i];
	

	ans[k]=min(ans[k],b[i]);
ans[k+1]=min(ans[k+1],b[i]);}

for(i=0;i<n;i++)
	s+=ans[i];

cout<<s<<endl;

return 0;}

Measured memory_bytes: 256
def solve():
    dp = [0] * N
    for i in range(N):
        dp[A[i]-1] = i+1
    for i in range(N):
        print(dp[i], end=" ")


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    solve()  


Measured memory_bytes: 20560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.IOException;
import java.util.stream.Stream;
import java.util.Arrays;
import java.util.function.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        String line = getContents().get(1);
        System.out.println(line);
        int[] xs = Arrays.stream(line.split(" ")).mapToInt(Integer::parseInt).toArray();
        int v;
        for(int i = 1, len = xs.length; i < len; ++i){
            v = xs[i];
            int j = i - 1;
            while(j >= 0 && xs[j] > v){
                xs[j + 1] = xs[j];
                --j;
            }
            xs[j + 1] = v;
            System.out.println(String.join(" ", Arrays.stream(xs).mapToObj(String::valueOf).toArray(String[]::new)));
        }
    }
    
    public static ArrayList<String> getContents() throws IOException{
        String line;
        ArrayList<String> list = new ArrayList<String>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while((line = br.readLine()) != null) list.add(line);
        
        return list;
    }
}


Measured memory_bytes: 32136
import numpy as np

n = int(input())
s = np.array([list(map(ord, input())) for _ in range(n)])
s = np.hstack((s, s))
s = np.vstack((s, s))
ans = 0
for i in range(n):
    p = s[0:n, i:i + n]
    if (p == p.T).all():
        ans += n

print(ans)


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

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}

int main() {
    int n = read(), m = read();
    int l = 1, r = n;
    while (m--) {
        int u = read(), v = read();
        l = max(l, u); r = min(r, v);
    }
    int ans;
    if (l > r) ans = 0;
    else ans = r - l + 1;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        n: usize,
        x: i32,
        l: [i32; n],
    }

    let mut bound = vec![0; n + 1];
    for i in 1..n + 1{
        bound[i] = bound[i - 1] + l[i - 1];
    }

    println!("{}", bound.into_iter().filter(|y|y <= &x).collect::<Vec<i32>>().len());
}



Measured memory_bytes: 4352
M, K = map(int, input().split())

if K >= 2 ** M:
    print(-1)
elif M == 1:
    print("1 0 0 1" if K == 0 else -1)
else:
    A = [str(i) for i in range(2 ** M) if i != K]
    print(" ".join(A), K, " ".join(reversed(A)), K)

Measured memory_bytes: 16020
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, T;
	cin >> n >> T;
	vector<int> c(n);
	vector<int> t(n);
	for (int i = 0; i < n; i++) {
		cin >> c.at(i);
		cin >> t.at(i);
	}
	int ans = 1000;
	for (int i = 0; i < n; i++) {
		if (t.at(i) <= T) {
			ans = min(ans, c.at(i));
		}
		else if (i + 1 == n && ans == 1000) {
			cout << "TLE" << endl;
			return 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i, j;
	char n[100000] = { 0 };
	int  x[1001] = { 0 };

	i = 0;
	j = 0;

	while (1) {
		scanf("%c", &n[i]);
		if (n[i] == '0' && n[i - 1] == '\n' || n[0] == '0') {
			break; 
		}

		if (n[i] >= '1' && '9' >= n[i] && n[i] != '\n') {
			x[j] += n[i] - 48;
		}

		if (n[i] == '\n') {
			j = j + 1;
		}
		i = i + 1;
	}

	for (i = 0; i < j; i++) {
		printf("%d", x[i]);
		printf("\n");
	}

	return(0);
}


Measured memory_bytes: 2140
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  double s=0;
  for(int i=0; i<N; i++){
    double x;
    string u;
    cin >> x >> u;
    if(u=="BTC") x*=380000.0;
    s+=x;
  }
  cout << setprecision(18) << s << endl; 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<vector<bool>> M(n, vector<bool>(n));
	for (int i = 0; i < n; i++) {
		int v, k;
		cin >> v >> k;

		for (int j = 0; j < k; j++) {
			int x;
			cin >> x;
			M.at(v - 1).at(x - 1) = true;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) cout << ' ';
			cout << M.at(i).at(j);
		}
		cout << endl;
	}
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

	ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

	ModInt inv()const{return pow(mod-2);}                                              
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<1000000007>;

int N,A,B;

mint dp[5010][3][5010];
signed main(){
	cin>>N>>A>>B;
	if(A>B)swap(A,B);

	dp[0][1][0]=1;
	mint ans=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<B;j++){
			dp[i+1][0][j+1]+=dp[i][0][j];
			dp[i+1][1][j+1]+=dp[i][0][j];
		}

		for(int j=0;j<B;j++){
			dp[i+1][1][j+1]+=dp[i][1][j];
			if(i+A<=N)dp[i+A][0][min(j+A,B)]+=dp[i][1][j];
			dp[i+1][2][1]+=dp[i][1][j];
		}
		for(int j=0;j<A;j++){
			dp[i+1][1][1]+=dp[i][2][j];
			dp[i+1][2][j+1]+=dp[i][2][j];
		}
		ans*=2;
		ans+=dp[i+1][0][B]+dp[i+1][1][B];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 297740
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

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


// 68 11 55 - rank 3
// 69 12 19

int gcd(int a, int b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << "\n";

}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
   string S;
   cin >> S;
   string ans;
   for(int i=0;i<S.size();i++){
       if(S[i] == '0'){
           ans.push_back('0');
       }
       if(S[i] == '1'){
           ans.push_back('1');
       }
       if(S[i] == 'B'){
           if(!ans.empty()){
               ans.pop_back();
           }
       }
   }
   cout << ans << endl;
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
ll n;
ll Binary_search(ll kyori,vector<pair<ll,ll>> &vp){
    ll ok = -1,ng = n; 
    while(ng-ok>1){
        ll mid = (ng+ok)/2;
        if(vp[mid].first<=kyori)ok = mid;
        else ng = mid;
    }
    return ng;
}

int main() {
    ll m, i, j, k,d,a;
    cin >> n >> d >> a;
    vector<pair<ll,ll>> vp(n);
    for(i=0;i<n;i++){
        ll x,h;
        cin >> x >> h;
        vp[i] = {x,h};
    }
    sort(vp.begin(),vp.end());
    ll cnt=0;
    ll ret = 0;
    ll damege[n+1]={};
    for(i=0;i<n;i++){
        damege[i+1] += damege[i];
        if(damege[i+1]>=vp[i].second)continue;
        else{
            cnt = (vp[i].second - damege[i+1]+a-1)/a;
            ret+=cnt;
            ll p = Binary_search(vp[i].first+2*d,vp);
            damege[i+1]+=cnt*a;
            if(p!=n)damege[p+1]-=cnt*a;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 4992