akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N = 3e5, M = N;
//=======================

vi g[N];

void solve() {
	int i, j, n, m;
	int k;
	cin >> n >> k;
	int a[n];
	fo(i, n) cin >> a[i];
	int dp[2][k + 1];
	//dp[studenet][candies]
	int cur = 0;
	int prev = 1;
	fo(i, k + 1) {
		dp[cur][i] = 0;
	}
	fo(j, 2) {
		dp[j][0] = 1;
	}
	std::vector<int> prefix(k + 1);
	Fo(i, 1, n + 1) {
		cur = 1 ^ cur;
		prev = 1 ^ prev;
		Fo(j, 0, k + 1) {
			prefix[j] = dp[prev][j] % mod;
			if (j) prefix[j] = (prefix[j] % mod + prefix[j - 1] % mod) % mod;
		}
		Fo(j, 1, k + 1) {
			if (j <= a[i - 1]) {
				dp[cur][j] = prefix[j] % mod;
			}
			else {
				int non_cnting = j - a[i - 1] - 1;
				dp[cur][j] = ( prefix[j] % mod - prefix[non_cnting] % mod + mod) % mod;
			}
		}
		prefix.clear();
	}

	cout << dp[cur][k];
}

int32_t main()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
	return 0;
}



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

long long Plus(long long x)
    {
     long long tx=x;
     long long top10=1;
     int cnt=0,las;
     while(x)
         {
          las=x;
          x/=10;
          top10*=10;
          cnt++;
         }
     if(top10==1000000000000000 and tx<110000000000000) return top10/1000;
     if(las<=cnt-3) return top10/100;
     else return top10/10;
    }

int main()
{
int k;
cin>>k;
long long ans=2;
while(k--)
    {
     cout<<ans-1<<endl;
     ans+=Plus(ans);
    }

return 0;
}

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

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

  int A, B, C;
  cin >> A >> B >> C;
  if(C >= A && C <= B) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
use bigint;
($Q,$H,$S,$D)=glob<>;
$N=<>;
$S=4*$Q if(4*$Q<$S);
$S=2*$H if(2*$H<$S);
$D=2*$S if(2*$S<$D);
print+$N%2?$S+$D*($N>>1):$D*$N/2

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
const int maxi = 3010;
long long grid[maxi][maxi], dp[maxi][maxi][4], n, m, k;
long long solve(int r, int c, int tak){
    if (r>n || c>m)
        return LLONG_MIN;
    if (r==n && c==m){
        if (tak!=3) return grid[r][c];
        return 0;
    }
    if (dp[r][c][tak]!=-1)
        return dp[r][c][tak];
    long long cur = 0;
    if (tak!=3){
        cur = max(cur, solve(r, c+1, tak+1)+grid[r][c]);
        cur= max(cur, solve(r+1, c, 0)+grid[r][c]);
    }
    cur = max(cur, solve(r, c+1, tak));
    cur = max(cur, solve(r+1, c, 0));
    return dp[r][c][tak] = cur;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    memset(dp, -1, sizeof(dp));
    cin >> n >> m >> k;
    int r, c, cval;
    for (int i=1; i<=k; i++){
        cin >> r >> c >> cval;
        grid[r][c] = cval;
    }
    cout << solve(1, 1, 0) <<"\n";
}

Measured memory_bytes: 357744
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	string S;
	cin >> S;
	ll N = S.size();
	ll tower[N] = {-1};
	ll red = 0;
	ll blue = 0;
	REP(i,N){
		if (S[i]=='0') red++;
		else blue++;
	}
	ll ans = red + blue - max(red-blue, blue-red);
	cout << ans << endl;
	
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  rep(i,a,b) for(i=a;i<b;i++)
#define ll long long int
#define ld long double
using namespace std;
int main()
{
IOS;
ll n,i;
cin>>n;
if(n<10)
cout<<n;
else
if(n>=10 && n<100)
cout<<'9';
else
if(n>=100 && n<1000)
cout<<9+(n-100)+1;
else
if(n>=1000 && n<10000)
cout<<"909";
else
if(n==100000)
cout<<909+(n-10000);
else
cout<<910+(n-10000);
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p){ return Point(x + p.x, y + p.y); }
    Point operator - (Point p){ return Point(x - p.x, y - p.y); }
    Point operator * (Point p){ return Point(x * p.x, y * p.y); }
    Point operator / (Point p){ return Point(x / p.x, y / p.y); }

    Point operator * (double k){ return Point(x*k, y*k);}

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
};

typedef Point Vector;

struct Segment {
    Point p1, p2;
};

typedef Segment Line;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
};

Point projection(Segment s, Point p) {
    Vector a = s.p2 - s.p1;
    Vector b = p - s.p1;
    double k = dot(a, b)/a.norm();
    a.x = k*a.x, a.y = k*a.y;
    return s.p1 + a;
};

int main() {
    Segment s;
    int q;
    Point p, P;
    double x0, y0, x1, y1;

    scanf("%lf %lf %lf %lf", &x0, &y0, &x1, &y1);
    scanf("%d", &q);
    s.p1.x = x0; s.p1.y = y0; s.p2.x = x1; s.p2.y = y1;

    for (int i=0; i<q; i++) {
        scanf("%lf %lf", &p.x, &p.y);
        P = projection(s, p);
        printf("%.8lf %.8lf\n", P.x, P.y);
    }

    return 0;
}


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

template<int mod>
struct ModInt{
	int x;

	ModInt() : x(0){}
	ModInt(long long y) : x(y>=0 ? y%mod : (mod-(-y)%mod)){}

	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}

	ModInt operator-() const{return ModInt(-x);}
	ModInt operator+(const ModInt &p) const{return ModInt (*this)+=p;}
	ModInt operator-(const ModInt &p) const{return ModInt (*this)-=p;}
	ModInt operator*(const ModInt &p) const{return ModInt (*this)*=p;}
	ModInt operator/(const ModInt &p) const{return ModInt (*this)/=p;}
	bool operator==(const ModInt &p) const{return x==p.x;}
	bool operator!=(const ModInt &p) const{return x!=p.x;}
	friend ostream &operator<<(ostream &os, const ModInt &p){return os<<p.x;}
	friend istream &operator>>(istream &is,ModInt &a){
		int t;
		is>>t;
		a=ModInt<mod>(t);
		return (is);
	}

	ModInt inverse() const{
		int a=x, b=mod, u=1, v=0, t;
		while(b>0){
			t=a/b;
			a-=t*b;
			swap(a,b);
			u-=t*v;
			swap(u,v);
		}
		return ModInt(u);
	}
	
	ModInt pow(int e) const{
		long long a=1,p=x;
		while(e>0){
			if(e%2==0){p=(p*p)%mod; e/=2;}
			else {a=(a*p)%mod; e--;}
		}
		return ModInt(a);
	}

};

const int p=1000000007;
using modint=ModInt<p>;

modint fact[200010];

modint nCr(int n,int r){
	return fact[n]/(fact[n-r]*fact[r]);
}

signed main(){
	int H,W,A,B;
	cin>>H>>W>>A>>B;
	fact[0]=1;
	for(int i=1;i<200000;i++)fact[i]=fact[i-1]*i;

	modint ans=0;
	for(int i=B;i<W;i++){
		modint tmp=nCr(H-A+i-1,i)*nCr(A+W-i-2,A-1);
		ans+=tmp;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

const int inf = 1 << 30;
int N;
int M;
int a[1010];
int b[1010];
int dp[5000];
vector<int> cs[1010];

int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
        for(int j = 0; j < b[i]; j++){
            int c;
            cin >> c;
            cs[i].push_back(c - 1);
        }
    }
    for(int i = 1; i < (1 << N); i++){
        dp[i] = inf;
    }

    for(int i = 0; i < (1 << N); i++){
        for(int j = 0; j < M; j++){
            int cost = dp[i] + a[j];
            int to = i;
            for(auto u : cs[j]){
            to |= 1 << u;
            }
            chmin(dp[to], cost);
        }
    }
    cout << (dp[(1 << N) - 1] == inf ? -1 : dp[(1 << N) - 1]) << endl;
    return 0;
}

Measured memory_bytes: 384
<?php 
  list($a,$b)=explode(" ",trim(fgets(STDIN)));
  $c=explode(" ",trim(fgets(STDIN)));
$total=0;
for($i=0;$i<$b;$i++){
    $total+=$c[$i];
}
if($a>=$total){
    echo $a-$total;
}elseif ($a<$total) {
    echo "-1";
}

Measured memory_bytes: 16708
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int main()
{
	IOS;
	int c;
	cin>>n>>k>>c;
	string str;
	cin>>str;
	v32 a(n+1);
	forsn(i,1,n+1){
		if(str[i-1]=='o') a[i]=1;
		else a[i]=0;
	}
	v32 l,r;
	int prev=-1;
	forsn(i,1,n+1){
		if(a[i]){
			if(prev==-1 || i-prev-1>=c)
				l.pb(i),prev=i;
		}
	}
	prev=-1;
	for(int i=n;i>=1;i--){
		if(a[i]){
			if(prev==-1 || prev-i-1>=c)
				r.pb(i),prev=i;
		}
	}
	// reverse(r.begin(),r.end());
	v32 rn;
	for(int i=k-1;i>=0;i--){
		rn.pb(r[i]);
	}
	forn(i,k){
		if(l[i]==rn[i]) cout<<l[i]<<ln;
	}
}


Measured memory_bytes: 5004
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < int(n); i++)
using namespace std;
 
int main() {
    int b,k,x;
    cin >> k >> x;
    
    vector<int> a(2*k - 1);
    b = x - (k-1);
    a.at(0) = b;

    for(int i = 1; i < 2*k - 1; i++){
        a.at(i) = a.at(i-1) + 1;
        
    }
    rep(i,2*k-1) cout << a.at(i) << endl;
    
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}

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

template <typename T>
void greater_sort(vector<T>& vec) {
	sort(all(vec), greater<T>());
	return;
}

signed main() {
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
	else cout << "Good" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		sc.close();

		int result = 0;

		if (a < b) {
			result += a;
		} else {
			result += b;
		}

		if (c < d) {
			result += c;
		} else {
			result += d;
		}

		System.out.println(result);
	}
}

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) (x).begin(),(x).end()

const int MOD = 998244353;

int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

const int MAXN = 3010;
int n, s;
int a[MAXN];
int pows[MAXN];
int dp[MAXN];

void solve() {
	cin >> n >> s;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = 0;
	for (int i = 0; i < MAXN; i++)
		dp[i] = 0;
	for (int i = 1; i <= n; i++) {
		for (int w = s - a[i]; w >= 1; w--) {
			int nxt = w + a[i];
			dp[nxt] = add(dp[nxt], dp[w]);
		}
		int nxt = a[i];
		if (nxt <= s) dp[nxt] = add(dp[nxt], i);
		ans = add(ans, dp[s]);
	}
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout.precision(20);
	int t;
	//cin >> t;
	t = 1;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int v[6],k;
int main()
{
    for(int i=1;i<=5;i++)
    {
        cin>>v[i];
    }
    cin>>k;
    for(int i=1;i<=4;i++)
    {
        for(int j=i;j<=5;j++)
        {
            if(abs(v[i]-v[j])>k)
            {
                cout<<":(";
                return 0;
            }
        }
    }
    cout<<"Yay!";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rall(x) x.rbegin(),x.rend()
#define mu(x) x.resize(unique(all(x))-x.begin());
#define srt(x) sort(all(x));
#define rev(x) reverse(all(x));
#define each(x,a) for(auto& x:a)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define PER(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cerr<<#x<<" "<<x<<"\n";
#define debug_v(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y<<" "; cerr<<'\n';}
#define debug_vp(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y.ff<<" "<<y.ss<<'\n'; cerr<<'\n';}
#ifndef BTW
	#define cerr if(false)cerr
#endif
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int main(){
	fastio;
	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+(m-1)*m/2;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    var lst = Array(N, {0})
    repeat(M){
        val (a, b)=readLine()!!.split(" ").map{str -> str.toInt()-1}
        lst[a]++
        lst[b]++
    }
    for(l in lst){
        println(l)
    }
}

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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        long[] a=new long[n+1];
        a[0]=0;
        for(int i=1;i<=n;i++){
            a[i]=fsc.nextLong()+a[i-1];
        }
        fsc.close();
        long min=Long.MAX_VALUE;
        long sum=a[n];
        for(int i=1;i<n;i++){
            long x=a[i];
            long y=sum-x;
            min=Math.min(min, Math.abs(x-y));
        }
        System.out.println(min);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 24572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] a = new int[5];
		for (int i = 0; i < 5; i++) {
			a[i] = scan.nextInt();
		}
		int num = 0;
		for (int i = 0; i < 5; i++) {
			if (a[i] == 0) {
				num = i;
			}
		}
		System.out.println(num + 1);
	}
}


Measured memory_bytes: 26968
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;

const int N = 1010000;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, x; cin >> n >> x;
  vector<int> v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  int jumps = 1;
  int cur_sum = 0;
  for(int i = 0;i < n; ++i) {
    cur_sum += v[i];
    if(cur_sum <= x) ++jumps;
    else break;
  }
  cout << jumps << endl;
}


Measured memory_bytes: 888
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; cin  >>n;
  map<string,int> MAP;
  vector<string> s(n);
  rep(i,n) {
  string a;
  cin >>a;
  s[i]=a;
  MAP[a]++;
  }
  int count=0;
  for(string S:s)  count =max(count,MAP[S]);
  for (auto it = MAP.begin(); it != MAP.end(); it++) {
      if (it->second == count) {
      cout << it->first << endl;
      }
  //for(auto it=MAP.begin();it!=MAP.end();it++) if(MAP[it]==count) cout <<it<<endl;
  }
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    unsigned long long x,y;
    cin >> x >> y;
    
    unsigned long long n=0;
    while(x <= y){
        x *= 2;
        n++;
    }

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S,T;
    cin>>S>>T;
    int ans=0;
    rep(i,S.size()){
        if(S[i]!=T[i])ans++;
    }
    cout << ans << endl;

    



}


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

int main(){
	string input;
	while(cin && getline(cin, input)){
		string ans = "";
		for(int n=0; n<input.size(); n++){
			if('a'<=input[n]&&input[n]<='z'){
				ans += input[n]-'a'+'A';
			} else {
				ans += input[n];
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
main :: IO ()
main = getLine >>= print . solve . map read . words
solve :: [Int] -> Int
solve (m:d:_) = length . filter isSekisu $ candidates
  where
    isSekisu (month, day) = month == d1 * d10
      where
        d1 = day `mod` 10
        d10 = day `div` 10
    candidates = filter (\(_, day) -> (day `mod` 10) > 1) $ do
      month <- [1..m]
      day <- [22..d]
      return (month, day)

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,m;
    cin >> a >> b >> m;
    int ary[a];
    int bary[b];
    rep(i,a) cin >> ary[i];
    rep(i,b) cin >> bary[i];
    int x[m];
    int y[m];
    int c[m];
    rep(i,m) cin >> x[i] >> y[i] >> c[i];

    int ans = INT_MAX;
    rep(i,m)
    {
        ans = min(ans, ary[--x[i]]+bary[--y[i]]-c[i]);
    }
    sort(ary, ary+a);
    sort(bary, bary+a);
    ans = min(ans, ary[0]+bary[0]);
    cout << ans << endl;
    
    
}




Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int h,w,k;
    cin >> h >> w >> k;
    char a[h][w];
    int answer[h][w];
    int color = 1;
    set <int>empty_rows,filled_lows;
    REP(i,h)REP(j,w)cin >> a[i][j];

    REP(i,h){
        bool empty = true;
        REP(j,w){
            if(a[i][j]=='#')empty = false;
        }
        if(empty){
            empty_rows.insert(i);
        }
    }
    REP(i,h){
        int stberry=0;
        REP(j,w){
            if(i!=0 && empty_rows.find(i)!=empty_rows.end()){
                answer[i][j] = answer[i-1][j];
                filled_lows.insert(i);
            }else{
                if(a[i][j]=='#'){
                    stberry++;
                    if(stberry >= 2){
                        color++;
                    }
                }
                answer[i][j]=color;
            }
        }
        if(empty_rows.find(i)==empty_rows.end())
            color++;
    }

    FORR(i,h-2,0){
        REP(j,w){
            if(empty_rows.find(i)!=empty_rows.end()){
                answer[i][j]=answer[i+1][j];
            }
        }
    }

    REP(i,h){
        REP(j,w){
            
            printf("%3d ",answer[i][j]);
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4172
<?php
    ini_set('memory_limit', '-1');
    fscanf(STDIN,"%d %d",$N,$W);
    for($i=0;$i<$N;++$i){
        fscanf(STDIN,"%d %d",$v[],$w[]);
    }    
    $dp =array();
    for($x=0;$x<=$N;$x++){
        for($y=0;$y<=$W;$y++){
            $dp[$x][$y]=0;
        }
    }
    for($i=0;$i<$N;++$i){
        for($j=0;$j<=$W;++$j){
            if($j-$w[$i]>=0){
                $dp[$i+1][$j] = max(  ($dp[$i+1][$j-$w[$i]]+$v[$i]) ,  $dp[$i][$j]  );
            }else{
                $dp[$i+1][$j] = $dp[$i][$j];
            }
        }
    }
    echo $dp[$N][$W]."\n";
?>


Measured memory_bytes: 158540
#!/usr/bin/env python
# coding: utf-8
#

import copy

def check_w(in_l):
    l = copy.deepcopy(in_l)
    for i in range(len(l)):
        line = list(l[i])
        # print(line)
        if '#' not in line:
            # print('del')
            del l[i]
            return l, True
    return l, False


def check_h(in_l):
    l = copy.deepcopy(in_l)
    # 文字数確認
    
    for i in range(len(l[0])):
        line = [ l[j][i:i+1] for j in range(len(l))]
        # print(line)
        if '#' not in line:
            ret = []
            # print(line)
            for j in range(len(l)):
                ret.append(l[j][:i] + l[j][i+1:])
            return ret, True
    return l, False
            
    
def main(in_l):
    l = copy.deepcopy(in_l)
    flg = True
    # print(l)
    
    while flg:
        # print(l)
        ret_l, ret_f = check_w(l)
        if ret_f:
            l = ret_l
            flg = True
            continue
        else:
            flg = False

        ret_l, ret_f = check_h(l)
        if ret_f:
            l = ret_l
            flg = True
            continue
        else:
            flg = False

    # 出力
    for line in l:
        print('{}'.format(line))
    
    
if __name__ == '__main__':
    try:
        h, w = list(map(int,input().strip().split(" ")))
        l = []
        for _ in range(h):
            l.append(input().strip())
        main(l)
    except EOFError:
        pass


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    ll N,M;
    cin >> N  >> M;

    ll ans = 0;
    for (ll x = M / N; x >= 1; x--) {
        if (M % x == 0) {
            ans = x;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3644
##未完成

N = int(input())
K = str(N)
l = len(str(N))

ans = 0

def tp(i,j,p):
    tmp = 0
    if p >= 2:
        if l == p:
            if i == int(K[0]):
                if j > int(K[l-1]):
                    tmp = (N-int(K[0])*10**(l-1)-int(K[l-1]))//10
                else:
                    tmp = (N-int(K[0])*10**(l-1)-int(K[l-1]))//10+1
            elif i >= int(K[0]):
                tmp = 0
            else:
                tmp = 10**(p-2)
        elif l > p:
            tmp = 10**(p-2)
        return tmp
    else:
        if i == j and i <= N:
            return 1
        else:
            return 0


for i in range(1,10):
    for j in range(1,10):
        for p in range(1,l+1):
            for q in range(1,l+1):
                ans += tp(i,j,p)*tp(j,i,q)

print(ans)

Measured memory_bytes: 73760
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>

using ll = long long;
using ull = unsigned long long;

using namespace std;
int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> x(n);
  ll res = 10000000000;
  for (auto i = 0; i < n; i++) cin >> x[i];
  for (auto b = 0; b < n; b++) {
    auto e = b + k-1;
    if (e >= n) continue;
    ll reslocal;
    if (x[b] >= 0) reslocal = x[e];
    else if (x[e] <= 0) reslocal = -x[b];
    else {
      reslocal = -x[b] + x[e] + min(-x[b], x[e]);
    }
    res = min(res, reslocal);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int times = 1;
		while(true) {
			String str = br.readLine();
			int n = Integer.parseInt(str);
			if (n == 0) {
				break;
			}
			System.out.println("Case " + times + ": " + n);
			times++;
		}
	}
}

Measured memory_bytes: 31764
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

const int64_t kMOD = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }

    int64_t inner = 0;
    for(int i=0; i<N-1; ++i) {
        for(int j=i+1; j<N; ++j) {
            if(A[i] > A[j]) {
                inner++;
            }
        }
    }

    int64_t outer = 0;
    sort(A.rbegin(), A.rend());
    for(int i=0; i<N-1; ++i) {
        for(int j=i+1; j<N; ++j) {
            if(A[i] > A[j]) {
                outer++;
            }
        }
    }

    inner *= K;
    inner %= kMOD;


#if 1
    if(K % 2 == 0) {
        outer *= K / 2;
        outer %= kMOD;
        outer *= K - 1;
        outer %= kMOD;
    } else {
        outer *= (K-1) / 2;
        outer %= kMOD;
        outer *= K;
        outer %= kMOD;
    }
#else
    inner = inner * K;
    inner %= kMOD;

    outer *= K-1;
    outer %= kMOD;
    outer *= K;
    outer %= kMOD;
    outer /= 2;
#endif
//    cout << inner << " " << outer << endl;

    cout << (inner + outer) % kMOD << endl;

    return 0;
}



Measured memory_bytes: 3204
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
     cin>>n;
     string s;
     cin>>s;
     Ff(i,0,min((ll)s.size(),n))
     cout<<s[i];
     if(s.size()>n)
     cout<<"...";
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10668
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int dc=100000;
#define MAX 100010


int main(){
  if(df)printf("*** debug mode ***\n");
  int n,i;
  scanf("%d",&n);
  int a=1,b=10,sum=0;
  while(b<=n){
    sum+=b-a;
    a*=100;
    b*=100;
  }
  if(a<=n)sum+=n-a+1;

  printf("%d",sum);
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	if b < a {
		fmt.Println(0)
		return
	}
	if (b / a) <= c {
		fmt.Println(b / a)
	} else {
		fmt.Println(c)
	}
}

Measured memory_bytes: 512
_ = STDIN.gets.split.map(&:to_i)
v = STDIN.gets.split.map(&:to_i)
c = STDIN.gets.split.map(&:to_i)

vc = v.map.with_index {|v1, i| v1 - c[i] }

puts vc.select {|i| i > 0 }.inject(:+) || 0


Measured memory_bytes: 1788
def myAnswer(N:int,A:list) -> int:
   accum = [A[0]]
   total = sum(A)
   ans = []
   for i in range(1,N):
      accum.append(accum[i-1] + A[i])
   accum.pop()
   # print(accum)
   for x in accum:
      y = total - x
      ans.append(abs(x - y))
      # print(ans)

   return min(ans)

def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A))
if __name__ == '__main__':
   main()

Measured memory_bytes: 28724
import bisect
def main():
    N = int(input())
    L = [int(n) for n in input().split()]
    # L = list(range(int(2 * 1e3)))
    L.sort()
    res = 0
    for i in range(N):
        for j in range(i+1, N):
            c = L[i]
            b = L[j]
            targ = b - c
            #targ <
            insert_index = bisect.bisect_right(L, targ)
            if insert_index >= i:
                continue
            # print(b, c)
            # print(insert_index)
            # print("---")
            res += i - insert_index
    print(res)
main()


Measured memory_bytes: 43932
//ABC 051-A
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	string S;

	cin >> S;
	S[5] = ' ';
	S[13] = ' ';

	cout << S << endl;;
}


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

using namespace std;

typedef struct 
{
    unsigned int left;
    unsigned int area;
}AreaInfo_t;

#define CalcArea(x,y) ((x) - (y))

stack<unsigned int> ArealeftIdxStack;
stack<AreaInfo_t> AreaInfoStack;
stack<unsigned int> PrintStack;

bool Decision(char, unsigned int);
void Fusion(AreaInfo_t);
void PrintArea(void);

int main(void){
    char ch;
    unsigned int idx = 0;
    
    while(cin >> ch)
    {
        Decision(ch, idx);
        idx++;
    }

    PrintArea();
    
    return 0;
    
}

bool Decision(char ch, unsigned int idx)
{
    switch(ch)
    {
        case '\\':
            ArealeftIdxStack.push(idx);
            break;
        case '/':
            if(ArealeftIdxStack.empty())
            {
                break;
                
            }
            AreaInfo_t area;
            area.left = ArealeftIdxStack.top();
            area.area = CalcArea(idx, ArealeftIdxStack.top());
            Fusion(area);
            ArealeftIdxStack.pop();
            break;
        case '_':
            // pass
            break;
        default:
            return false;
    }

    return true;
}

void Fusion(AreaInfo_t tInfo)
{
    
    while(1)
    {
        if(AreaInfoStack.empty())
        {
            AreaInfoStack.push(tInfo);
            break;
        }
        
        AreaInfo_t tmp = AreaInfoStack.top();
        if(tmp.left > tInfo.left)
        {
            tInfo.area += tmp.area;
            AreaInfoStack.pop();
        }
        else
        {
            AreaInfoStack.push(tInfo);
            break;
        }
    }
    return;
}

void PrintArea()
{
    unsigned int total = 0;
    unsigned int num = 0;
    
    num = AreaInfoStack.size();
    
    while(1)
    {
        if(AreaInfoStack.empty())
        {
            break;
        }
        unsigned int tmp = AreaInfoStack.top().area;
        total += tmp;
        PrintStack.push(tmp);
        AreaInfoStack.pop();
    }

    cout << total << endl;
    cout << num;
    while(1)
    {
        if(PrintStack.empty())
        {
            cout << endl; 
            break;
        }
        else
        {
            cout << " ";
        }
        cout << PrintStack.top();
        PrintStack.pop();
    }
    
    return;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[100004],b,cnt=0;
	vector <int> v;
	long long sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
		scanf("%d",&a[i]);
	for(int i=0;i<n;++i){
		scanf("%d",&b);
		if(a[i]<b){
			cnt++;
			sum+=(b-a[i]);
		}
		else if(a[i]>b)
			v.push_back(a[i]-b);
	}
	sort(v.begin(),v.end());
	for(int i=v.size()-1;i>=0;--i){
		if(!sum)
			break;
		sum-=v[i];
		cnt++;
		if(sum<0)
			sum=0;
	}
	if(sum>0)
		printf("-1\n");
	else
		printf("%d\n",cnt);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  sort(a.rbegin(), a.rend());
  int A=0, B=0;
  for(int i=0; i<N; i++) {
    if (i % 2 == 0) A+=a[i];
    else B+=a[i];
  }
  cout << A-B << endl;
}

Measured memory_bytes: 3620
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader(); 
        int MOD = 1000000007;
        int N = r.i();
        
        long[][] num = new long[N+1][10];
        num[0][0] = 1;
        
        int[][] p = {{2,0,2,2,0,2,0,1,1,1},
                     {1,1,0,1,0,1,1,1,0,0},
                     {1,0,1,0,0,0,0,1,1,1},
                     {0,1,0,0,0,0,0,0,0,0},
                     {0,1,0,0,0,0,1,0,0,0},
                     {0,1,0,0,0,0,1,0,0,0},
                     {0,0,1,0,1,0,0,0,1,1},
                     {0,0,0,0,1,0,0,0,0,0},
                     {0,0,0,0,1,0,0,0,0,0},
                     {0,0,0,0,0,1,0,0,0,0}};

        for(int i = 1; i <= N; i++){
            for(int j = 0; j < 10; j++){
                long temp = 0;
                long[] prev = num[i-1];
                int[] pj = p[j];
                for(int k = 0; k < 10; k++)
                    temp = (temp+ prev[k]*pj[k])%MOD;
                num[i][j] = temp;
            }
        }

        long ans = 0;
        for(long i : num[N])
            ans = (ans+i)%MOD;
        println(ans);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}


Measured memory_bytes: 20692
s=input()
a=[]
b=1
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        b+=1
    elif s[i]!=s[i+1]:
        a.append(b)
        b=1
    if i==len(s)-2:
        a.append(b)

if len(a)%2==0:
    if s[0]=="<":
        for i in range(0,len(a),2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1
    else :
        for i in range(1,len(a)-1,2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1

else:
    if s[0]=="<":
        for i in range(0,len(a)-1,2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1
    else :
        for i in range(1,len(a),2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1   
#print(a)
def wa(n):
    return (n+1)*n//2
d=[]
if a==[]:
  print(1)
else:
  for i in range(len(a)):
    d.append(wa(a[i]))
  print(sum(d))

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int k, x, y;
std::pair<int, int> ans[1000005];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> k;
    std::cin >> x >> y;

    int sx = 1, sy = 1;
    bool change = false;
    if (x < 0) {
        sx = -1;
        x *= -1;
    }
    if (y < 0) {
        sy = -1;
        y *= -1;
    }
    if (x < y) {
        change = true;
        std::swap(x, y);
    }

    if (x + y == k) {
        if (change)
            std::swap(x, y);
        std::cout << 1 << std::endl << sx * x << " " << sy * y << std::endl;
        return 0;
    }

    auto d = x + y;
    auto div = (d + k - 1) / k;
    auto n = std::max(2, div);
    if ((n * k - d) % 2 != 0) {
        if (k % 2 == 0) {
            std::cout << -1 << std::endl;
            return 0;
        }
        else {
            ++n;
        }
    }

    auto r = (n * k - d) / 2;
    if (n == 3&&div==1) {
        auto a = r / 2;
        auto b = r - a;
        for (int i = 0; i < n; ++i) {
            auto l = k * (i + 1);
            int px = 0, py = 0;

            if (l <= y + a) {
                px = 0;
                py = l;
            }
            else if (l <= y + a + x + b) {
                px = l - (y + a);
                py = y + a;
            }
            else if (l <= y + a + x + b + a) {
                px = x + b;
                py = y + a - (l - (y + a + x + b));
            }
            else {
                px = x + b - (l - (y + a + x + b + a));
                py = y;
            }

            ans[i].first = px;
            ans[i].second = py;
        }
    }
    else {
        auto a = r;
        for (int i = 0; i < n; ++i) {
            auto l = k * (i + 1);
            int px = 0, py = 0;

            if (l <= y + a) {
                px = 0;
                py = l;
            }
            else if (l <= y + a + x) {
                px = l - (a + y);
                py = a + y;
            }
            else {
                px = x;
                py = a + y - (l - (y + a + x));
            }

            ans[i].first = px;
            ans[i].second = py;
        }
    }

    std::cout << n << std::endl;
    for (int i = 0; i < n; ++i) {
        auto ax = ans[i].first, ay = ans[i].second;

        if (change)
            std::swap(ax, ay);
        std::cout << sx * ax << " " << sy * ay << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int N = sc.nextInt();

        if (D == 0) {
            if (N == 100) {
                System.out.println(101);
            } else {
                System.out.println(N);
            }
        } else if (D == 1) {
            if (N == 100) {
                System.out.println(10100);
            } else {
                System.out.println(N * 100);
            }
        } else {
            if (N == 100) {  
                System.out.println(1010000);
            } else {
                System.out.println(N * 10000);
            }
        }
    }
}


Measured memory_bytes: 21844