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

using namespace std;

int main()
{
	string s;
	cin >> s;

	int count = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '1') {
			count++;
		}
	}

	cout << count << endl;

	
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double pi = 3.141592653589793;

int main()
{
    ll n, ans = 1, tmp;
    bool flag = false, zero = false;

    cin >> n;
    rep(i, n)
    {
        cin >> tmp;
        if (tmp == 0)
        {
            zero = true;
        }
        if (tmp != 0 && (ans > tmp * ans || tmp * ans > 1000000000000000000))
        {
            flag = true;
        }
        ans *= tmp;
    }
    cout << ((flag && !zero) ? -1 : ans) << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    while(cin >> N >> M, N | M) {
        vector<ll> P(N);
        rep(i, N) { cin >> P[i]; }
        P.pb(0);
        vector<ll> P2;
        rep(i, N + 1) {
            FOR(j, i, N + 1) { P2.pb(P[i] + P[j]); }
        }
        sort(All(P2));
        ll res = 0;
        for(int i = 0; i < P2.size(); i++) {
            if(P2[i] > M)
                continue;
            auto it = lower_bound(All(P2), M - P2[i]);
            if(it != P2.begin())
                it--;
            res = max(res, P2[i] + *it);
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 10768
import sys

readline = sys.stdin.readline
read = sys.stdin.read

N, Q = map(int, readline().split())
graph = [[] for _ in range(N + 1)]
cnt = [0] * (N + 1)

for _ in range(N - 1):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)

px = map(int, read().split())
for p, x in zip(*[px] * 2):
    cnt[p] += x

stack = [1]
checked = [False] * (N + 1)
checked[1] = True
while stack:
    V = stack.pop()
    for i in graph[V]:
        if checked[i]:
            continue
        checked[i] = True
        stack.append(i)
        cnt[i] += cnt[V]

print(' '.join(map(str, cnt[1:])))


Measured memory_bytes: 76216
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
#include <numeric>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define PB push_back
#define INF 100000000000000000

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

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

  // 素数である
  return true;
}

/*********************************************************/
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************/
ll gcd( ll m, ll n )
{
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;

  // ユークリッドの方法
  while( m != n )
  {
    if ( m > n ) m = m - n;
    else         n = n - m;
  }
  return m;
}//gcd

//*********************************************************
// 最小公倍数（Least Common Multiple）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll lcm( ll m, ll n )
{
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

/********************************************************/

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

  if(A==0 && B==0 && C == 0){
    cout << 0 << endl;
    return 0;
  }
  if(A==0 && B==0){
    cout << 1 << endl;
    return 0;
  }
  if((A+B)>=C){
    ans = C + B;
    cout << ans << endl;
    return 0;
  }

  if(C>(A+B)){
    ans = A + B + 1 + B;
    cout << ans << endl;
    return 0;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <stack>
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

/*Xを前から見ていって、Sの１個以上の連続箇所があれば、それ以降の部分で
Tが何個連続しているかを見る
各連続箇所で、連続回数の少ない方*2をカウント
*/
int main(){
  string x;
  cin >> x;
  int n=x.size();
  stack<char> s;
  for(int i=0;i<n;i++){
    if(x[i]=='S'){
      s.push(x[i]);
    }else if(x[i]=='T'){
      if(s.empty()){
        s.push(x[i]);
      }else if(s.top()=='S'){
        s.pop();
      }else if(s.top()=='T'){
        s.push(x[i]);
      }
    }
  }
 
  cout << s.size() << endl;

}


Measured memory_bytes: 644
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll K, A, B;

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

  cin >> K >> A >> B;

  if (K <= A-1) {
    cout << K+1 << endl;
  } else {
    K -= A-1;

    if (K%2 == 0) {
      if (B-A > 2) {
        cout << A + K*(B-A)/2 << endl;
      } else {
        cout << K + A << endl;
      }
    } else {
      if (B-A > 2) {
        cout << A + (K-1)*(B-A)/2 + 1 << endl;
      } else {
        cout << K+A << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
module AOJ_Volume0093;

import std.stdio,std.string,std.conv;

int main()
{
	bool first = true;
	while(true)
	{
		string[] s = readln.chomp.split(" ");
		int a = s[0].to!int;
		int b = s[1].to!int;

		if(a == 0 && b == 0) break;

		if(first)
		{
			first = false;
		}
		else
		{
			writeln;
		}

		bool flag = true;
		foreach(i;a..b+1)
		{
			if(i%400 == 0)
			{
				flag = false;
				i.writeln;
			}
			else if(i%100 != 0 && i%4 == 0)
			{
				flag = false;
				i.writeln;
			}
		}

		if(flag) "NA".writeln;
	}
	return 0;
}

Measured memory_bytes: 1080
#include <iostream>
#include<string>
using namespace std;
int main()
{
	long long a, b, k;
	cin >> a >> b >> k;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			if (a % 2 == 1) a = a - 1;
			a = a / 2;
			b = b + a;
		}
		else {
			if (b % 2 == 1) b = b - 1;
			b = b / 2;
			a = a + b;
		}
	}
	cout << a << " " << b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    ll n, ans, i;
    cin>>n;
    for(i=sqrt(n);i>=1;i--){
        if(n%i==0){
         
            break;
        }
    }

    cout<<i + n/i - 2<<endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pa;
const int maxn=305;

inline ll rd(){
    ll x=0;char c=getchar();int neg=1;
    while(c<'0'||c>'9'){if(c=='-') neg=-1;c=getchar();}
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*neg;
}

int N,M,a[maxn][maxn],cnt[maxn],flag[maxn];
bool del[maxn];

int main(){
    //freopen("","r",stdin);
	N=rd(),M=rd();
	for(int i=1;i<=N;i++) for(int j=1;j<=M;j++) a[i][j]=rd();
	for(int i=1;i<=N;i++) cnt[a[i][1]]++,flag[i]=1;
	int ans=1e9;
	for(int i=1;i<=M;i++){
		int ma=0;
		for(int j=1;j<=M;j++) if(cnt[j]>cnt[ma]) ma=j;
		ans=min(ans,cnt[ma]);
		CLR(cnt,0);
		del[ma]=1;
		for(int j=1;j<=N;j++){
			for(;del[a[j][flag[j]]];flag[j]++);
			cnt[a[j][flag[j]]]++;
		}
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

typedef long long ll;

int main() {
	int N;
	ll A[100];
	cin >> N;
	for (int i = 0; i < N - 1; i++)cin >> A[i];
	ll ans[100];
	ans[0] = A[0], ans[1] = A[0];

	for (int i = 1; i < N - 1; i++) {
		if (A[i] >= A[i - 1]) {
			ans[i + 1] = A[i];
		}
		else {
			ans[i] = A[i], ans[i + 1] = A[i];
		}
	}
	ll total = 0;
	for (int i = 0; i < N; i++)total += ans[i];
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

sum_A = sum(A)
X = []
X.append(sum_A - 2*(sum(A[1:N-1:2])))
for i in range(1, N):
    X.append(2*A[i-1] - X[i-1])

print(*X)

Measured memory_bytes: 14028
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
#define N 200020
const int mod=998244353;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,dep[N],root,f[N],L,dp[N][3][3];
vector<int> G[N],D;
void init(int u,int fa){
	dep[u]=dep[fa]+1;
	f[u]=fa;
	if(dep[u]>L){
		L=dep[u],root=u;
	}
	for(auto v:G[u]){
		if(v==fa)continue;
		init(v,u);
	}
}
void dfs(int u,int fa,int dep){
	if(dep==(D.size()-1)/2){
		dp[u][1][1]=1;
	}
	else{
		dp[u][0][0]=1;
	}
	for(auto v:G[u]){
		if(v==fa)continue;
		dfs(v,u,dep+1);
		static int g[3][3];
		memset(g,0,sizeof(g));
		for(int i=0;i<3;++i){
			for(int j=0;j<3;++j){
				for(int x=0;x<3;++x){
					for(int y=0;y<3;++y){
						for(int k=0;k<3;++k){
							int a=min(2,i+x*(k==1));
							int b=min(2,j+y*(k==2));
							g[a][b]=(g[a][b]+1LL*dp[u][i][j]*dp[v][x][y])%mod;
						}
					}
				}
			}
		}
		memcpy(dp[u],g,sizeof(dp[u]));
	}
}
int main(){
	n=read();
	for(int i=1;i<n;++i){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	init(1,0);
	L=0;
	init(root,0);
	for(int u=root;u;u=f[u]){
		D.push_back(u);
	}
	if(D.size()&1){
		int x=D[D.size()>>1];
		dfs(x,0,0);
		printf("%lld\n",1LL*dp[x][1][1]*((mod+1)/2)%mod);
	}
	else{
		int x=D[(D.size()>>1)-1],y=D[D.size()>>1];
		dfs(x,y,0),dfs(y,x,0);
		printf("%lld\n",(1LL*dp[x][1][0]+dp[x][1][1]+dp[x][1][2])*(1LL*dp[y][0][1]+dp[y][1][1]+dp[y][2][1])%mod);
	}
	return 0;
}



Measured memory_bytes: 30452
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int a[]=new int[N];
		int i,j=0;
		for( i=0;i<N;++i) {
		 a[i]=sc.nextInt(); 
		}
		outside:while(true) {
			for( i=0;i<N;++i) {
				if(a[i]%2==0) {
				a[i]=a[i]/2;	
				}else {
				break outside;
				}
			}
			++j;
		}
			System.out.println(j);
		
		}
			
	}

Measured memory_bytes: 36140
# 入力値の取得
n, a, b = gets.chomp.split(" ").map(&:to_i)

# 制約のチェック
raise "Nは1以上、10^4以下" unless n.between?(1, 10**4)
raise "Aは1以上、36以下" unless a.between?(1, 36)
raise "Bは1以上、36以下" unless b.between?(1, 36)

# 計算
puts (1..n).select { |num| num.to_s.split("").map(&:to_i).inject(:+).between?(a, b) }.inject(:+)


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n,ans[100005];char a[100005];int len[100005];
void walk(int x,int p){
    if(len[x]) return;
    int w=a[x],cur=0;if(p==-1) cur=-1;
    while(a[x]==w){
        cur++;
        len[x]=cur;
        x+=p;
    }
}
int main()
{
    scanf("%s",a+1);
    n=strlen(a+1);
    rep(i,2,n)
    if(a[i-1]=='R'&&a[i]=='L') walk(i-1,-1),walk(i,1);
    rep(i,1,n) {
        int nxt=(a[i]=='L'?i-len[i]:i+len[i]),nxt2=nxt+1;
        if(len[i]%2==0) ans[nxt]++;
        else ans[nxt2]++;
    }
    rep(i,1,n) printf("%d ",ans[i]);
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(){
    string text , test1 , test2 , test3;
    int n , num = 0;
    cin >> n >> text;
    for (int i = 0 ; i < n ; i++) {
        string test1(1, text[i]);
        string test2(1, text[i + 1]);
        string test3(1, text[i + 2]);
        if (test1 + test2 + test3 == "ABC") num++;
    }
    cout << num;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
using namespace std;

int n;
void CountingSort(int a[], int b[], int k);

int main(void)
{
	cin >> n;
	int *a = new int[n + 1];
	int *b = new int[n + 1];

	for (int i = 1; i <= n; i++) cin >> a[i];

	CountingSort(a, b, 10000);

	cout << b[1];
	for (int i = 2; i <= n; i++) cout << " " << b[i];
	cout << endl;

	return 0;
}

void CountingSort(int a[], int b[], int k)
{
	int c[10000 + 1] = { 0 };

	for (int j = 1; j <= n; j++) c[a[j]]++;

	for (int i = 1; i <= k; i++) c[i] += c[i - 1];

	for (int j = n; j >= 1; j--) {
		b[c[a[j]]] = a[j];
		c[a[j]]--;
	}
}

Measured memory_bytes: 18772
#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	
	int m = 1000, result,k;
	if(n<1000){
		printf("%d", 1000-n);
	} else if(n>1000 && n%1000!=0){
		k = n/1000;
		k += 1;
		result = k*1000;
		printf("%d", result-n);
	} else {
		k = n/1000;
		result = k*1000;
		printf("%d", result-n);
	}
	
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;

const int max_n = 1e3 + 5;


int main() {
	make(n);
	VI v;
	if (n == 3) {
		v = {2, 5, 63};
		
	} else if (n==4) {
		v = {2, 5,  20, 63};
	} else {
		v.pb(2); v.pb(4);
		v.pb(3); v.pb(9);
		int x = 21;
		while (v.size() + 2 <= n && x < 30000 ) {
			v.pb(x); v.pb(x-6);
			x += 12;
		}
		x = 10;
		while (v.size() + 2 <= n && x < 30000) {
			v.pb(x); v.pb(x-2);
			x+=6;
		}
		x = 6;
		while (v.size() !=n) {
			v.pb(x);
			x+=6;
		}
	}
	FORE(i, v) {
		printf("%d ", *i);
	}
	printf("\n");
}



Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c,d,x;
    string s,s1;
    cin >> x >> a >> b;
    c = x - a;
    while(c>=b){
        c -= b ;
    }
    cout << c << endl;
    return 0;
} 

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x,long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }

        public static long C(long n,long k)
        {
            long x=1;
            for (long i = 1; i <=k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = new long[n];
            var b = new long[n];
            for (int i = 0; i < n; i++)
            {
                var q = Reads();
                a[i] = q[0];
                b[i] = q[1];
            }
            Array.Sort(b, a);
            long sum = 0;
            var f = false;
            for (int i = 0; i < n; i++)
            {
                sum += a[i];
                if (sum > b[i]) f = true;
            }
            WriteLine(f ? "No" : "Yes");
            

            Console.Out.Flush();
        }
    }
}


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

void solve(long long N, std::vector<long long> L)
{
    sort(L.begin(), L.end());
    int res = 0;
    for (int i = 0; i < 2 * N; i += 2)
    {
        res += min(L[i], L[i + 1]);
    }
    cout << res << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> L(2 * N);
    for (int i = 0; i < 2 * N; i++)
    {
        scanf("%lld", &L[i]);
    }
    solve(N, std::move(L));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<int>
using namespace std;
using ll = long long;


int main() {
    ll a,b;
    cin>>a>>b;
    if(a!=1&&b!=1)cout<<(a*b+1)/2<<endl;
    else cout<<1<<endl;
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let k: usize = itr.next().unwrap().parse().unwrap();

    let mut q: std::collections::VecDeque<u64> = (1..10).collect();
    let mut count = 0;
    while let Some(x) = q.pop_front() {
        count += 1;
        if count == k {
            println!("{}", x);
            return;
        }
        let y = x % 10;
        if y > 0 {
            q.push_back(x * 10 + y - 1);
        }
        q.push_back(x * 10 + y);
        if y < 9 {
            q.push_back(x * 10 + y + 1);
        }
    }
}


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

int main(){
  using namespace std;
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1;i <= n;i++){
    if(static_cast<int>(log10(i) + 1) % 2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
    using namespace atcoder;
#endif
using namespace std;
namespace defines{
    typedef long long ll;
    typedef pair<ll,ll> P;
    #define FOR(i,a,b) for(ll i = a ; i < b ; i++) // for i in range(a,b)
    #define REP(i,n) for(ll i = 0 ; i < n ; i++) // for i in range(b)
    #define FORD(i,a,b) for(ll i = a ; i > b ; i--) // for i in range(a,b,-1)
    #define ALL(x) x.begin(),x.end()
    template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
    template<class T, class... Ts> auto make_vec(size_t a, Ts... ts){ return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

    /* for debug print */
    #define DEBUG(x) cerr << #x << ": " << x << '\n'
    #define DEBUGP(x) cerr << #x << ": (" << x.first << ", " << x.second << ")" << '\n' 
    #define DEBUGL(xl) dbgl_f(#xl,xl)
    #define DEBUGLP(xl) dbglp_f(#xl,xl)
    #define DEBUGLL(xll) dbgll_f(#xll,xll)
    #define DEBUGM(xl) dbgm_f(#xl,xl)
    template<class T> void dbgl_f(string name, vector<T> xl){cerr<<name<<": "; for(T x: xl) cerr<<x<<" "; cerr << '\n';}
    template<class T, class U> void dbgm_f(string name, map<T,U> xl){cerr<<name<<": ";for(auto x: xl)cerr<<"("<<x.first<<": "<<x.second<<") ";cerr<<'\n';}
    template<class T> void dbglp_f(string name, vector<T> xl){cerr<<name<<": ";for(T x: xl)cerr<<"("<<x.first<<", "<< x.second<<") ";cerr<<'\n';}
    template<class T> void dbgll_f(string name, vector<vector<T>> xll){
        cerr<< name << ": " << '\n'; 
        for(vector<T> xl: xll){
            for(T x : xl) cerr << x << " ";
            cerr << '\n';
        }
    }
}
using namespace defines;

const int IINF = 1'001'001'001;
const ll INF = 1'001'001'001'001'001'001ll;
const int MOD = 1'000'000'007;


void solve(){
    int n,C; cin >> n >> C;
    vector<vector<P>> c_stl(C, vector<P>(0));
    REP(i,n){
        int s,t,c; cin >> s >> t >> c;
        c-=1;
        c_stl[c].push_back(P(s,t));
    }

    vector<vector<bool>> c_exist(C, vector<bool>(pow(10,5)+1, false));
    REP(c,C){
        for( P st : c_stl[c] ){
            int s = st.first;
            int t = st.second;
            FOR(i,s,t+1){
                c_exist[c][i] = true;
            }
        }
    }
    int max_c = 0;
    REP(t,pow(10,5)+1){
        int cnt = 0;
        REP(c,C){
            if(c_exist[c][t]) cnt++;
        }
        max_c = max(max_c,cnt);
    }
    cout << max_c << endl;
}

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

Measured memory_bytes: 5856
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 998244353;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),* $(,)*) => {
        #[cfg(debug_assertions)]
        eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        lr: [(usize, usize); k],
    }
    let mut c = 0;
    let mut insert = BinaryHeap::new();
    let mut remove = BinaryHeap::new();
    let mut dp = vec![0; n + 1];
    dp[1] = 1;
    for i in 0..k {
        let (li, ri) = lr[i];
        insert.push(Reverse((1 + li, 1)));
        remove.push(Reverse((1 + ri, 1)));
    }
    for t in 2..=n {
        while let Some(&Reverse((t2, s))) = insert.peek() {
            if t2 > t {
                break;
            }
            c = (c + s) % M;
            insert.pop();
        }
        debug!(t, c);
        dp[t] = c;
        while let Some(&Reverse((t2, s))) = remove.peek() {
            if t2 > t {
                break;
            }
            c = (c + M - s) % M;
            remove.pop();
        }
        for i in 0..k {
            let (li, ri) = lr[i];
            insert.push(Reverse((t + li, dp[t])));
            remove.push(Reverse((t + ri, dp[t])));
        }
    }
    debug!(dp);
    println!("{}", dp[n]);
}


Measured memory_bytes: 61956
import numpy as np


# 解がマイナスのとき
def solve1(k, ml, pl):
    left, right = -(10 ** 18) - 1, 0
    while right - left > 1:
        x = (left + right) // 2
        n = (len(pl) - np.searchsorted(pl, x // ml + (x % ml != 0))).sum()
        if k <= n:
            right = x
        else:
            left = x
    return right


# 解がプラスのとき
def solve2(k, ml, pl):
    left, right = 0, 10 ** 18
    while right - left > 1:
        x = (left + right) // 2
        n = 0
        n += (len(ml) - np.searchsorted(ml, x // ml + (x % ml != 0))).sum()
        n -= np.count_nonzero(ml ** 2 <= x)
        n += (np.searchsorted(pl, x // pl, side="right")).sum()
        n -= np.count_nonzero(pl ** 2 <= x)
        assert n % 2 == 0
        n //= 2
        if k <= n:
            right = x
        else:
            left = x
    return right


def main():
    N, K = list(map(int, input().split()))
    A = np.array(input().split(), dtype=int)
    A.sort()
    ml = A[A < 0]
    pl = A[A > 0]
    zl = A[A == 0]
    mn = len(ml) * len(pl)
    zn = sum([N - i - 1 for i in range(len(zl))])
    if K <= mn:
        ans = solve1(K, ml, pl)
    elif K <= mn + zn:
        ans = 0
    else:
        ans = solve2(K - mn - zn, ml, pl)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 34588
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        s: String
    }

    let mut sum = 0;

    for i in 0..2u32.pow(s.len() as u32 - 1) {
        let pattern = format!("{:0>1$b}", i, s.len() - 1);
        let mut formula = s.clone();
        for (num, j) in pattern.chars().rev().enumerate() {
            if j == '1' {
                formula.insert((s.len() - 1) - num, '+')
            }
        }
        sum += formula
            .split('+')
            .map(|x| -> i64 { x.parse().unwrap() })
            .fold(0, |sum, a| sum + a)
    }
    println!("{}", sum);
}


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

#define maxn 100100
int a[maxn];
int n,c,k;

int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>c>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	sort(a+1,a+1+n);
	
	int ans=0;
	
	for(int i=1;i<=n;i++)
	{
		int j=i;
		while (j+1<=n && j+1<=i+c-1 && a[j+1]<=a[i]+k) j++;
		ans++;
		i=j;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
double P,E,T,ans;
int K,R,L;

void dfs(double r,double l,double pro,int night){
    if(r>T+E||l<T-E)return;
    if(r>=T-E&&l<=T+E)
    {
        ans+=pro;
        return;
    }
    double h=(r+l)/2.0;
    if(night>K){
        if(h>=T-E&&h<=T+E)
            ans+=pro;
        return;
    }
    if(h>=T){
        dfs(r,h,pro*(1-P),night+1);
        dfs(h,l,pro*P,night+1);
    }
    else{
        dfs(r,h,pro*P,night+1);
        dfs(h,l,pro*(1-P),night+1);
    }
}
int main()
{
    scanf("%d%d%d%lf%lf%lf",&K,&R,&L,&P,&E,&T);
    dfs(double(R),double(L),1,1);
    printf("%lf\n",ans);
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define MAX_N (10010)
int parent[MAX_N];
int n;
int q;

int search_root(int x)
{
    if ( x == parent[x] ) return x;
    else return parent[x] = search_root(parent[x]);
}

void unite(int x, int y)
{
    int root_x = search_root(x);
    int root_y = search_root(y);
    
    parent[root_y] = root_x;
}

bool same(int x, int y)
{
    int root_x = search_root(x);
    int root_y = search_root(y);

    return (root_x == root_y);
}

int main() 
{
    scanf("%d %d", &n, &q);
    
    for ( int i = 0; i < n; i++ ) parent[i] = i;

    for ( int i = 0; i < q; i++ ) {
	int com, x, y;
	scanf("%d %d %d", &com, &x, &y);
	if ( com == 0 ) {	// unite
	    unite(x, y);
	}
	else {			// same
	    if ( same(x, y) ) {
		printf("1\n");
	    }
	    else {
		printf("0\n");
	    }
	}
    }

    return 0;
}

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

int main() {

  long long N, M;
  cin >> N >> M;

  long long answer = 0;
  
  if (M <= N * 2) {
    answer = M / 2;
  } else {
    answer = N + (M - N * 2) / 4;
  }

  cout << answer <<  endl;

  return 0;

}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt (string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS=1e-10;
const double PI=acos(-1.0);

int main(){
	int N;
	cin>>N;
	REP(z,N){
		vvi map(5,vi(5,0));
		REP(i,5){
			REP(j,5){
				cin>>map[i][j];
			}
		}
		int maxCount=0;
		REP(i,5){
			REP(j,5){
				if(map[i][j]==0)	continue;
				else{
					REP(k,5){
						REP(l,5){
							if(k<i||l<j)	continue;
							else{
								int count=0;
								FOR(m,i,k+1){
									FOR(n,j,l+1){
										if(map[m][n]==1)	count++;
										else goto ng;
									}
								}
								maxCount=max(maxCount,count);
								ng:;
							}
						}
					}
				}
			}
		}
		cout<<maxCount<<endl;
	}
}

Measured memory_bytes: 0
n,k,s=map(int,input().split())
a=[]
if s!=10**9:
  for i in range(k):
    a.append(s)
  for i in range(n-k):
    a.append(s+1)
  print(*a)
else:
  for i in range(k):
    a.append(s)
  for i in range(n-k):
    a.append(s-1)
  print(*a)

Measured memory_bytes: 9692
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    
    string s;
    cin >> s;
    int n = s.size();
    ll K;
    cin >> K;
    {
        bool ok = true;
        for (int i = 1; i < n; ++i) ok &= s[i] == s[0];
        if (ok)
        {
            cout << (K * n) / 2;
            return 0;
        }
    }
    int f = 0;
    while (f + 1 < n && s[f + 1] == s[f]) ++f;
    int b = n - 1;
    while (b - 1 >= 0 && s[b - 1] == s[b]) --b;

    ll ans = 0;
    int ptr = f + 1;
    while (ptr < b)
    {
        int i = ptr;
        int j = i;
        while (j + 1 < b && s[j + 1] == s[i])
            ++j;
        ans += (j - i + 1) / 2 * K;
        ptr = j + 1;
    }

    if (s[f] != s[b])
    {
        ans += (f + 1) / 2 * K;
        ans += (n - b) / 2 * K;
    }
    else
    {
        ans += (f + 1) / 2;
        ans += (n - b) / 2;
        ans += (n - b + f + 1) / 2 * (K - 1);
    }

    cout << ans;

    return 0;
}

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

string a[12];
void dfs(int y,int x){
	if(y<0||12<=y||x<0||12<=x||a[y][x]=='0')return;
	a[y][x]='0';
	for(int i=-1;i<=1;i++)for(int j=-1;j<=1;j++)
		if(!i||!j)dfs(y+i,x+j);
}
int main(){
	string s;
	while(cin>>a[0]){
		for(int i=1;i<12;i++)cin>>a[i];
		int ans=0;
		for(int y=0;y<12;y++)for(int x=0;x<12;x++)
			if(a[y][x]=='1')ans++,dfs(y,x);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

#define NUM 4000000
#define NIL -1
int A[NUM];
int heap_n = 0;

void init(){
    for(int i = 0; i < NUM; i++){
        A[i] = NIL;
    }
}

void upHeapify(int num){
    if(num == 1){
        return;
    }
    
    if(A[num] > A[num / 2]){
        int tmp = A[num];
        A[num] = A[num / 2];
        A[num / 2] = tmp;
        upHeapify(num / 2);
    }
}

void downHeapify(int num){
    int m = max(A[num], max(A[num * 2], A[num * 2 + 1]));

    if(m == A[num * 2]){
        swap(A[num * 2], A[num]);
        downHeapify(num * 2);
        return;
    }
    if(m == A[num * 2 + 1]){
        swap(A[num * 2 + 1], A[num]);
        downHeapify(num * 2 + 1);
        return;
    }
}


void insert_(int num){
    A[heap_n + 1] = num;
    heap_n++;
    upHeapify(heap_n);
}

void pop_(){
    A[1] = A[heap_n];
    A[heap_n] = NIL;
    heap_n--;
    downHeapify(1);
}

int main(void){
    init();
    char buf[100];
    int num;
    
    while(1){
        scanf("%s", buf);
        if(!strcmp(buf, "end")){
            break;
        }

        if(!strcmp(buf, "insert")){
            scanf("%d", &num);
            insert_(num);
        }

        if(!strcmp(buf, "extract")){
            printf("%d\n", A[1]);
            pop_();
        }

        if(!strcmp(buf, "print")){
            for(int i = 1; i <= heap_n; i++){
                printf("%d ", A[i]);
            }
        }
    }
}



Measured memory_bytes: 18820
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = ((n) - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, M;
    cin >> N >> M;

    vll A(M), C(M, 0);

    REP(i, M) {
        int b; cin >> A[i] >> b;
        REP(j, b) {
            int c;
            cin >> c;
            --c;
            C[i] |= (1LL << c);
        }
    }

    ll SMAX = (1 << N) + 5;
    ll dp[M + 1][SMAX];
    REP(i, M + 1) REP(j, SMAX) dp[i][j] = INF;
    dp[0][0] = 0;

    REP(i, M) {
        REP(j, 1 << N) {
            REP(k, N) {
                if (!(C[i] >> k & 1) || j >> k & 1) continue;

                // i-1 -> i
                dp[i + 1][j | 1 << k] = min(dp[i + 1][j | 1 << k], dp[i][j] + A[i]);

                // i -> i
                dp[i + 1][j | 1 << k] = min(dp[i + 1][j | 1 << k], dp[i + 1][j]);

            }

            dp[i + 1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    print(dp[M][(1 << N) - 1] == INF ? -1 : dp[M][(1 << N) - 1]);
}


Measured memory_bytes: 35700
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int R,C,K;cin>>R>>C>>K;
    vector<ll> rpos,cpos,V;
    vector<vector<int>> grid(R, vector<int>(C, -1));
    for(int i = 0;i < K;i++){
        ll _a,_b,_c;cin>>_a>>_b>>_c;_a--;_b--;
        grid[_a][_b] = i;
        V.push_back(_c);
    }
    vector<vector<vector<ll>>> dp(R, vector<vector<ll>>(C, vector<ll>(4, 0)));
    for(int r = 0;r < R;r++){
        for(int c = 0;c < C;c++){
            for(int i = 0;i <= 3;i++){
                // cout<<r<<c<<i<<endl;
                //とらない
                dp[r][c][i] = 0;
                dp[r][c][i] = c != 0 ? dp[r][c-1][i] : 0;
                if (r != 0){
                    for(int j = 0;j <= 3;j++)
                        dp[r][c][i] = max(dp[r][c][i], dp[r-1][c][j]);}
                if(i != 0 && grid[r][c] != -1){
                    //とる
                    if(c == r && r == 0){
                        // cout<<c<<r<<i<<endl<<"!";
                        dp[r][c][i] = max(dp[r][c][i], V[grid[r][c]]);
                    }
                    if(c != 0)
                        dp[r][c][i] = max(dp[r][c-1][i-1] + V[grid[r][c]], dp[r][c][i]);
                    if(r != 0)
                        for(int j  = 0;j <= 3;j++)
                            dp[r][c][i] = max(dp[r-1][c][j] + V[grid[r][c]], dp[r][c][i]);
                }
            }
        }
    }
    // for(int i = 0; i < R;i++){
    //     for(int j = 0;j < C;j++){
    //         for(int k = 0;k < 4;k++){
    //             cout<<dp[i][j][k]<<" ";
    //         }cout<<" | ";
    //     }cout<<endl;
    // }cout<<endl;
    ll res = 0;
    for(int i = 0;i <= 3;i++){
        res = max(res, dp[R-1][C-1][i]);
    }
    cout<<res<<endl;

}

Measured memory_bytes: 673172
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10005;
const int MAXD = 105;
const int64_t MOD = 1000000007;
int64_t dp[MAXN][MAXD][2]; // Kより小さい

int main()
{
  string S;
  int D;
  cin >> S >> D;
  int N = S.size();
  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < D; j++)
    {
      for (int k = 0; k < 2; k++)
      {
        int d = S[i] - '0';
        if (k == 0)
        {
          (dp[i + 1][(j + d) % D][0] = dp[i][j][k]) %= MOD;
          for (int l = 0; l < d; l++)
          {
            (dp[i + 1][(j + l) % D][1] += dp[i][j][k]) %= MOD;
          }
        }
        else
        {
          for (int l = 0; l <= 9; l++)
          {
            (dp[i + 1][(j + l) % D][k] += dp[i][j][k]) %= MOD;
          }
        }
      }
    }
  }
  cout << (dp[N][0][0] + dp[N][0][1] + MOD - 1) % MOD << endl;
}


Measured memory_bytes: 19980
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
        int n = 3;
        int a[n][n], b[n][n];
        for(int i = 0; i  < n; i++) {
            for(int  j= 0;j < n; j++) {
                cin >> a[i][j];
            }
        }

        int q;
        cin >> q;
        while(q--) {
            int x;
            cin >> x;
            for(int i = 0; i < n; i++){
                for(int j = 0 ; j< n; j++) {
                    if(a[i][j] == x)
                        a[i][j] = 0;
                }
            }
        }

        int c = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[i][i] == 0)
                c++;
        }

        if(c==3){
            cout << "Yes";
            return 0;
        }

        c = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[i][2 - i] == 0)
                c++;
        }

        if(c==3){
            cout << "Yes";
            return 0;
        }

        c = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[i][0] == 0)
                c++;
        }

        if(c==3){
            cout << "Yes";
            return 0;
        }

        c = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[i][2] == 0)
                c++;
        }

        if(c==3){
            cout << "Yes";
            return 0;
        }

        c = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[i][1] == 0)
                c++;
        }

        if(c==3){
            cout << "Yes";
            return 0;
        }

        c = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[0][i] == 0)
                c++;
        }

        if(c==3){
            cout << "Yes";
            return 0;
        }

        c = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[2][i] == 0)
                c++;
        }

        if(c==3){
            cout << "Yes";
            return 0;
        }

        c = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[1][i] == 0)
                c++;
        }

        if(c==3){
            cout << "Yes";
            return 0;
        }


        cout << "No";
        
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int x,a,b,i;
  	scanf("%d",&x);
  	scanf("%d",&a);
  	scanf("%d",&b);
  	x-=a;
	for(i=0;x>=b;i++){
    	x-=b;
    }
	printf("%d",x);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main(){
  int i,j,k,n,m,ans=0,now;
  cin >> n >> m;
  now=0;
  vector<pair<int,int> > v(m);
  for(i=0;i<m;i++){
    cin >> v[i].second >> v[i].first;
  }
  sort(v.begin(),v.end());
  for(i=0;i<m;i++){
    if(v[i].second>=now){
      ans++;
      now=v[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define    int               long long int
 #define    bp(x)         __builtin_popcount(x)
#define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
#define  mod  1000000007
#define  endl  "\n"
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int32_t main()
{
    fast
    int n,x,y;  cin>>n;
    int a[n+5];
    f(i,0,n+3)  a[i]=0;
    f(i,1,n){
        cin>>x>>y;
        if(x==y)    a[i]=1;
        else    a[i]=0;
    }
    f(i,1,n)
        if(a[i]+a[i+1]+a[i+2]==3)
        {
            cout<<"Yes";
            exit(0);
        }
    cout<<"No";
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp;
    string S;
    cin >> V[0] >>V[1] >>V[2];
    sort(V.begin(), V.end());
    
    // if(A%3==0 || B%3==0 || (A+B)%3==0)
    // 	puts("Possible");
    // else
    // 	puts("Impossible");
    ans = V[0]+V[1];
    
    cout <<ans<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>


#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

using ll = unsigned long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

namespace mp = boost::multiprecision;
using BigInt = mp::cpp_int;


int main() {
	int n;

	cin >> n;
	vector<ll> as;
	int prev = -1;

	rep(i ,n) {
		int cur;
		cin >> cur;

		if (prev == cur) continue;

		as.push_back(cur);
		prev = cur;
	}
	vector<ll> bs;

	if (as[0] < as[1]) {
		bs.push_back(as[0]);
	}
	/*
	for (int a: as) {
		cout << a << endl;
	}
	*/

	for(int i = 1; i < as.size() - 1; i++) {
		if (as[i - 1] < as[i] && as[i] > as[i + 1]) {
			bs.push_back(as[i]);
		} else 
		if (as[i - 1] > as[i] && as[i] < as[i + 1]) {
			bs.push_back(as[i]);
		}
	}

	if (as[as.size() - 2] < as[as.size() - 1]) {
		bs.push_back(as[as.size() - 1]);
	} 
	/*
	cout << "-----" << endl;
	for (int b: bs) {
		cout << b << endl;
	}
	*/
	BigInt money = 1000;
	for(int i = 0; i < (bs.size() / 2) * 2 ; i += 2) {
		BigInt stock = money / bs[i];
		money -= (BigInt) bs[i] * (BigInt) stock;
		money += (BigInt) bs[i + 1] * (BigInt) stock;
	}
	cout << money << endl;

	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;
typedef long double ldb;
long double qpow(long double x,int y){
	long double res = 1.00;
	while (y){
		if (y & 1) res *= x;
		x *= x;y >>= 1;
	}
	return res;
}
int n , k;
long double res;
int main(){
	cin >> n >> k;
	for (int i = 1;i <= n;i++){
		int t = 0 , n = i;
		while (n < k) {
			n <<= 1;
			
			t++;
		}
		res += qpow(0.5 , t);
	}
	res /= n;
	printf("%.12Lf",res);
	return 0;
}

Measured memory_bytes: 256