akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(a, b) for(int a = 0; a < b; a++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 100;

ll n, W;
ll DP[105][MAXN];
ll w[105], v[105];

ll rek(int pos, int berat) {
	if (pos == n) return 0;
	ll &ret = DP[pos][berat];
	if (ret != -1) return ret;
	ret = rek(pos + 1, berat);
	if (berat >= w[pos]) ret = max(ret, v[pos] + rek(pos + 1, berat - w[pos]));
	return ret;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> W;
	REP(i, n) cin >> w[i] >> v[i];	
	memset(DP, -1, sizeof DP);
	cout << rek(0, W) << '\n';
}

Measured memory_bytes: 82432
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

long long po(long long a, long long b, long long m){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2,m);
    z = (z*z)%m;
    if(b%2!=0){
        z = (a*z)%m;
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  long long l,a,b,m;
  cin>>l>>a>>b>>m;
  long long c;
  long long power = 1;
  long long ans[3];
  ans[0] = 0;
  ans[1] = a%m;
  ans[2] = 1LL;
  for(long long d = 1; d<=18; d++){
    long long left, right;
    left = ((power - a) + b - 1)/b;
    if(left>=l){
      power *= 10LL;
      continue;
    }
    left = max(left, 0LL);
    right = ((10LL*power - a) + b - 1)/b;
    if(right<=0){
      power *= 10LL;
      continue;
    }
    right = min(right, l);
    if(right<left){
      power *= 10LL;
      continue;
    }
    c = right - left;
    //cout<<c<<endl;
    power *= 10LL;
    long long mat[3][3] = {};
    mat[0][0] = po(10LL, d, m);
    mat[1][0] = mat[1][1] = mat[2][2] = 1LL;
    mat[2][1] = b%m;
    while(c>0){
      if(c & 1){
        long long temp[3] = {};
        REP(i,3){
          REP(j,3){
            temp[i] += (ans[j]*mat[j][i])%m;
            temp[i] %= m;
          }
        }
        REP(i,3){
          ans[i] = temp[i];
        }
      }
      c /= 2;
      
      long long tempMat[3][3] = {};
      REP(i,3){
        REP(j,3){
          REP(k,3){
            tempMat[i][j] += (mat[i][k]*mat[k][j])%m;
            tempMat[i][j] %= m;
          }
        }
      }
      REP(i,3){
        REP(j,3){
          mat[i][j] = tempMat[i][j];
        }
      }
    }
  }
  
  cout<<ans[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }
#define PI 3.14159265358979323846

int main(){
	FASTIO;
	ll n, p; cin >> n >> p;
	string s; cin >> s;
	ll a[n]; for ( int k = 0; k < n; k++ ) a[k] = s[k] - '0';
	if (p == 2 || p == 5) {
		ll ans = 0;
		for ( int k = 0; k < n; k++ )
			if (a[k] % p == 0)
				ans += k + 1;
		return cout << ans << endl, 0;
	}
	ll po = 1;
	for ( int k = n - 1; k >= 0; k--){
		a[k] *= po;
		a[k] %= p;
		po *= 10;
		po %= p;
	}
	ll dp[p]; memset(dp, 0, sizeof dp);
	ll sum = 0;
	ll ans = 0;
	dp[0] = 1;
	for ( int k = 0; k < n; k++ ){
		ans += dp[(sum - (p - a[k]) + p) % p];
		sum = (sum + a[k]) % p;
		dp[sum]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2196
function Main(input) {
    const tmp = input.split(" ");
    const x = tmp[0];
    const y = tmp[1];

    console.log(x * y);
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30336
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

int N, M, H[100010];
vector<int> G[100010];

int main(){
  cin >> N >> M;
  rep(i, N) cin >> H[i];
  rep(i, M){
    int a, b;
    cin >> a >> b;
    // aとbは0インデックスに揃える
    a--;
    b--;
    G[a].push_back(b);
    // 無向グラフなのでbにもaを追加する
    G[b].push_back(a);
  }
  int ans = 0;
  rep(i, N){
    bool check = true;
    for (auto g : G[i]){
      if (H[i] <= H[g]) check = false;
    }
    if (check) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 9064
h,w=map(int,input().split())
a=[]
c=0
for i in range(h):
  a.append(input())
  c+=a[i].count('#')
flg=0
if c != h+w-1:
  flg=1
dh=0
dw=0
for i in range(h+w-2):
  if dh==h-1:
    if a[dh][dw+1]=='#':
      dw+=1
  elif dw==w-1:
    if a[dh+1][dw]=='#':
      dh+=1
  else:
    if a[dh+1][dw]=='#':
      dh+=1
    elif a[dh][dw+1]=='#':
      dw+=1
    else:
      flg=1
if flg==0:
  print('Possible')
else:
  print('Impossible')

Measured memory_bytes: 3064
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong(), a=sc.nextLong(), b=sc.nextLong();
        sc.close();
        if(b<=a) System.out.println("delicious");
        else if(b<=a+x) System.out.println("safe");
        else System.out.println("dangerous");
    }
}

Measured memory_bytes: 23636
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

int L, R, d;
int ans = 0;

int main()
{
	scanf("%d%d%d", &L, &R, &d);
	int base = d;
	while(true)
	{
		if(d >= L && d <= R)
			++ans;
		else if(d > R)
			break;
		d = d + base;
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

int D;
int c[26], s[365][26], t[365], last[26], ans[366];

void calc() {
    for (int i = 0; i < D; ++i) {
        ans[i + 1] = ans[i] + s[i][t[i]];
        last[t[i]] = i + 1;
        for (int j = 0; j < 26; ++j)
            ans[i + 1] -= c[j] * (i + 1 < last[j] ? i + 1 : i + 1 - last[j]);
    }
}

void change(int d, int q) {
    d--, q--;
    int old = t[d];
    if (old == q)
        return;

    t[d] = q, last[old] = 0, last[q] = 0;
    int dif = 0, pos1 = 0, pos2 = 0;
    for (int i = 0; i < D; ++i) {
        last[t[i]] = i + 1;
        if (i < d)
            pos1 = last[q], pos2 = last[old];
        else {
            ans[i + 1] += s[d][q] - s[d][old];
            if (last[q] == d + 1)
                dif += c[q] * (d + 1 - pos1);
            if (last[old] <= d + 1)
                dif -= c[old] * (d + 1 - pos2);
        }
        ans[i + 1] += dif;
    }
}

void greedy() {
    for (int i = 0; i < D; ++i) {
        ans[i + 1] = INT_MIN;
        int maidx = 0;
        for (int k = 0; k < 26; ++k) {
            int res = ans[i] + s[i][k], old = last[k];
            last[k] = i + 1;
            for (int j = 0; j < 26; ++j)
                res -= c[j] * (i + 1 - last[j]);

            if (ans[i + 1] < res) {
                ans[i + 1] = res;
                maidx = k;
            }
            last[k] = old;
        }
        t[i] = maidx;
        last[t[i]] = i + 1;
    }
}

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

    cin >> D;
    for (int i = 0; i < 26; ++i)
        cin >> c[i];
    for (int i = 0; i < D; ++i)
        for (int j = 0; j < 26; ++j)
            cin >> s[i][j];

    for (int i = 0; i < D; ++i) {
        cin >> t[i];
        t[i]--;
    }

    calc();
    int M;
    cin >> M;
    for (int i = 0; i < M; ++i) {
        int d, q;
        cin >> d >> q;
        change(d, q);
        cout << ans[D] << '\n';
    }
    // for (int i = 0; i < D; ++i)
    //     cout << t[i] + 1 << '\n';

    return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R;
    vector<int> tasks(3);
    for(int i = 0; i< 3; i++)
    {
        cin >> tasks.at(i);
    }
    int answer = 500;
    answer = min(answer, abs(tasks.at(1) - tasks.at(0)) + abs(tasks.at(2) - tasks.at(1)));
    answer = min(answer, abs(tasks.at(2) - tasks.at(0)) + abs(tasks.at(1) - tasks.at(2)));
    answer = min(answer, abs(tasks.at(2) - tasks.at(1)) + abs(tasks.at(0) - tasks.at(2)));
    answer = min(answer, abs(tasks.at(0) - tasks.at(1)) + abs(tasks.at(2) - tasks.at(0)));
    answer = min(answer, abs(tasks.at(0) - tasks.at(2)) + abs(tasks.at(1) - tasks.at(0)));
    answer = min(answer, abs(tasks.at(1) - tasks.at(2)) + abs(tasks.at(0) - tasks.at(1)));
    cout << answer <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <list>
using namespace std;



int main(){
    list<int> dlist;
    int n,key,flag = 0;
    char command[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %d",&command,&key);      
        if(command[0] == 'i'){
            dlist.push_front(key);
        }else if(command[0] == 'd'){
            if(command[6] == 'F'){
                dlist.pop_front();
            }else if(command[6] == 'L'){
                dlist.pop_back();
            }else{
                for(list<int>::iterator it = dlist.begin();it != dlist.end();it++){
                    if(*it == key){
                        dlist.erase(it);
                        break;
                    }
                }
            }
        }
    }

    for(list<int>::iterator it = dlist.begin();it != dlist.end();it++){
        if(flag!=0) printf(" ");
        printf("%d", *it);
        flag = 1;  
    }
    printf("\n");
}

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

bool vertical(vector<vector<int>> &board){
  bool flg;

  for (int i = 0; i < 3; i++){
    flg = true;
    for (int j = 0; j < 3; j++){
      if (board.at(i).at(j) != 0) flg = false;
    }
    if (flg){
      return true;
    }
  }
  return false;
}

bool horizontal(vector<vector<int>> &board){
  bool flg;

  for (int i = 0; i < 3; i++){
    flg = true;
    for (int j = 0; j < 3; j++){
      if (board.at(j).at(i) != 0) flg = false;
    }
    if (flg){
      return true;
    }
  }
  return false;
}

bool diagonal(vector<vector<int>> &board){
  if ((board.at(0).at(0) ==  0 && board.at(1).at(1) == 0 && board.at(2).at(2) == 0) 
  || (board.at(2).at(0) == 0 && board.at(1).at(1) == 0 && board.at(0).at(2) == 0)){
    return true;
  }
  else
  {
    return false;
  }
  
}

int main(){
  vector<vector<int>> board(3, vector<int>(3));

  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> board.at(i).at(j);
    }
  }

  int N;
  cin >> N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++) cin >> vec.at(i);

  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      if ( find(vec.begin(), vec.end(),board.at(i).at(j)) != vec.end()){
        board.at(i).at(j) = 0;
      }
    }
  }

  if(vertical(board) || horizontal(board) || diagonal(board)){
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back

int bexp(int a, int b)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a);

        a = (a * a); 
        b >>= 1;
    }
    return res;
}

#define N 200010
#define MOD 1000000007

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


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n;
    cin >> n;

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

    sort(a, a + n);
    int ans = a[n - 1];

    int i = n - 2;
    int cnt = 2;
    while (cnt < n)
    {
        ans += a[i] * 2;
        i--;
        cnt += 2;
    }

    ans -= (cnt == n + 1 ? a[++i] : 0);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  cin>>n;
  double x[n];
  double sum=0;
  string u[n];
  for(i=0;i<n;++i){
    cin>>x[i]>>u[i];
  }
  for(i=0;i<n;++i){
    if(u[i]=="JPY"){
      sum += x[i];
    }
    else{
      sum += x[i]*380000.0;
    }
  }
  cout<<sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

int main() {
    long long A;
    long double B;
    cin >> A >> B;
    cout << (long long)(A * B) << endl;
}

Measured memory_bytes: 3696
/*input
4 1112
1 10 100 1000
*/
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define red(i,r,l) for(int i=r;i>=l;i--)
#define re(i,n) for(int i=0;i<n;i++)
#define db(x) cout<<#x<<"="<<(x)<<" "
#define el cout<<endl
#define PII pair<int, int>
#define PIII pair<PII, int>
#define c0 first
#define c1 second
using namespace std;
const int MXN = 100010;
int n;
int a[MXN], k, ans;

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


Measured memory_bytes: 256
a = int(input())
b = [input() for i in range(a)]
AC = 0
WA = 0
TLE = 0
RE = 0

for bun in b:
    if bun == 'AC':
        AC += 1
    elif bun == 'WA':
        WA += 1
    elif bun =='TLE':
        TLE += 1
    elif bun == 'RE':
        RE += 1

print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))

Measured memory_bytes: 16328
#include<bits/stdc++.h>
using namespace std;
#define int long long
int p,r,t;
int l[333];
int n[333][333];
int P[214514],R[214514];
vector<int> v[333][333];
bool check(int T){
  int x[333][333]={},y[333][333]={},z[333]={};
  for(int j=0;j<r;j++) z[j]=l[j];
  int cnt=0;
  bool used[333]={};
  for(int i=0;i<p;i++){
    bool flg=1;
    for(int j=0;j<r;j++){
      //for(int k:v[i][j]) cout<<"-"<<k;cout<<endl;
      int k=v[i][j].end()-upper_bound(v[i][j].begin(),v[i][j].end(),T);
      //cout<<T<<":"<<*upper_bound(v[i][j].begin(),v[i][j].end(),T)<<endl;
      x[i][j]=v[i][j].size()-k;
      y[i][j]=n[i][j]-x[i][j];
      //cout<<i<<" "<<j<<":"<<x[i][j]<<" "<<y[i][j]<<endl;
      z[j]-=x[i][j];
      flg&=x[i][j]==n[i][j];
    }
    if(flg){
      for(int j=0;j<r;j++)
	z[j]+=x[i][j];
      used[i]=1;
      cnt++;
    }
  }
  //for(int j=0;j<r;j++) cout<<z[j]<<" ";cout<<endl;
  while(1){
    bool flg=0;
    for(int i=0;i<p;i++){
      if(used[i]) continue;
      bool tmp=1;
      for(int j=0;j<r;j++)
	tmp&=y[i][j]<=z[j];
      if(!tmp) continue;
      flg=used[i]=1;cnt++;
      for(int j=0;j<r;j++) z[j]+=x[i][j];
    }
    if(!flg) break;
  }
  //cout<<T<<":"<<cnt<<" "<<p<<endl;
  return cnt==p;
}
signed main(){
  scanf("%lld %lld %lld",&p,&r,&t);
  for(int i=0;i<r;i++) scanf("%lld",l+i);
  for(int i=0;i<p;i++)
    for(int j=0;j<r;j++)
      scanf("%lld",n[i]+j);
  for(int i=0;i<t;i++) scanf("%lld %lld",P+i,R+i);
  for(int i=0;i<t;i++){
    P[i]--;R[i]--;
    v[P[i]][R[i]].push_back(i+1);
  }
  if(check(t+1)){
    puts("-1");
    return 0;
  }
  int X=0,Y=t+1;
  while(X+1<Y){
    int Z=(X+Y)/2;
    if(check(Z)) X=Z;
    else Y=Z;
  }
  printf("%lld\n",Y);
  return 0;
}

Measured memory_bytes: 13844
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int a,b,c,d;
	cin >> a >> b >> c >> d;
	
	(a*b > c*d) ? cout << a * b : cout << c*d;
	
	return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)

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

    ll K, A, B;
    cin >> K >> A >> B;

    ll now = 1;
    if (now < A) {
        if (K < A - now) {
            now += K;
            K = 0;
        } else {
            K -= A - now;
            now = A;
        }
    }

    // cout << "now:" << now << " K:" << K << "\n";

    if (B - A > 2) {
        now += (B - A) * (K / 2);
        K %= 2;
    } else {
        now += K;
        K = 0;
    }
    // cout << "now:" << now << " K:" << K << "\n";
    if (K == 1) {
        now += 1;
        K = 0;
    }

    cout << now << "\n";
    // A枚まで増やす
    // 2回の操作で2枚以上に増やせるならひたすらA→Bをする


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int gate[100006],n,m,l,r;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  int L=-1,R=INF,ll,rr;
  FOR(i,m){
    cin>>l>>r;
    L=max(l,L);
    R=min(r,R);
  }
  int ans=0;
  if(R<L){
    cout<<"0"<<endl;
  }else{
    cout<<R-L+1<<endl;
  }
  return 0;
}


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

int main() {
  int H, W, N, ans;
  cin >> H >> W >> N ;
  if(H < W){
    ans = (N / W) ; 
    if(N % W != 0) ans++ ;
  }  
  else{
    ans = (N / H) ;
    if(N % H != 0) ans++ ;
  }  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
         String[] str=br.readLine().split(" ");
         int a=Integer.parseInt(str[0]);
         int b=Integer.parseInt(str[1]);
         int c=Integer.parseInt(str[2]);
        if((a+b)==c){
              System.out.println("Yes");
        }else if((b+c)==a){
              System.out.println("Yes");
        }else if((c+a)==b){
              System.out.println("Yes");
        }else{
              System.out.println("No");
        }
    }
}

Measured memory_bytes: 21332
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(),b=s.nextInt();
        if(a==b) System.out.println("Draw");
        else if(a==1) System.out.println("Alice");
        else if(b==1) System.out.println("Bob");
        else if(a>b) System.out.println("Alice");
        else System.out.println("Bob");
    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25388
from collections import defaultdict


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())
R = [tuple(map(int, input().split())) for _ in range(M)]

uf = UnionFind(N)
for a, b in R:
    uf.union(a-1, b-1)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)

Measured memory_bytes: 41216
n=gets.to_i
a=gets.split.map(&:to_i)
b=gets.split.map(&:to_i)
aa,bb=0,0
n.times do |i|
  if a[i]<b[i]
    aa+=(b[i]-a[i])/2
  else
    bb+=a[i]-b[i]
  end
end
puts aa>=bb ? "Yes" : "No"


Measured memory_bytes: 2940
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

ll comb(ll n, ll r) {
    ll res = 1;
    for(ll i=1; i<=r; i++) {
        res = res * (n - i + 1) / i;
    }
    return res;
}

int main() {
    int n, p; cin >> n >> p;
    int a[51]; INITA(a, 0, 50, 0);
    int num_odd = 0;
    int num_even = 0;
    REP(i, n) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            num_even++;
        } else {
            num_odd++;
        }
    }
    ll res = 0;
    if (p == 1) {
        if (num_odd > 0) {
            res = pow(2, num_odd-1);
        } else {
            res = 0;
        }
        res *= pow(2, num_even);
    } else {
        if (num_odd > 0) {
            res = pow(2, num_odd-1);
        } else {
            res = 1;
        }
        res *= pow(2, num_even);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string N;
    cin>>N;
    int cnt=N.size();
    bool all9=true;
    rep2(i,1,cnt){
        if(N[i]!='9'){
            all9=false;
        }
    }
    int ans=0;
    if(all9){
        ans=N[0]-'0'+(cnt-1)*9;
    }else{
        ans=N[0]-'0'-1+(cnt-1)*9;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

dp = [[1]*3 for i in range(n)]
ans = 1
for i in range(n-1):
    for j in range(3):
        if a[i] != a[i+1]:
            if dp[i+1][j] < dp[i][j] + 1:
                dp[i+1][j] = dp[i][j] + 1
        if j<2 and a[i] == a[i+1]:
            if dp[i+1][j+1] < dp[i][j] + 1:
                dp[i+1][j+1] = dp[i][j] + 1
for v in dp:
    t = max(v)
    if ans < t:
        ans = t
print(ans)


Measured memory_bytes: 25076
#include "bits/stdc++.h"
using namespace std;

struct edge {
        int to, cap, rev;
};
bool used[101010];
vector<edge> g[101010];
static const int INF = 0x3f3f3f3f;
void add_edge(int from, int to, int cap) {
        g[from].push_back((edge) { to, cap, (int)g[to].size() });
        g[to].push_back((edge) { from, 0, (int)g[from].size() - 1 });
}
int dfs(int v, int t, int f) {
        if (v == t) return f;
        used[v] = true;
        for (int i = 0; i < g[v].size(); i ++) {
                edge& e = g[v][i];
                if (!used[e.to] && e.cap > 0) {
                        int d = dfs(e.to, t, min(f, e.cap));
                        if (d > 0) {
                                e.cap -= d;
                                g[e.to][e.rev].cap += d;
                                return  d;
                        }
                }
        }
        return 0;
}
int MaxFlow(int s, int t) {
        int flow = 0;
        while (true) {
                memset(used, false, sizeof(used));
                int f = dfs(s, t, INF);
                if (f == 0) return flow;
                flow += f;
        }
}

int main() {
        int i, j;
        int h, w;
        cin >> h >> w;
        vector<string> a(h);
        for (i = 0; i < h; i ++) cin >> a[i];
        int s = h + w, t = h + w + 1;
        for (i = 0; i < h; i ++) {
                for (j = 0; j < w; j ++) {
                        if (a[i][j] == 'S') {
                                add_edge(s, i, INF);
                                add_edge(s, h + j, INF);
                        }
                        else if (a[i][j] == 'T') {
                                add_edge(i, t, INF);
                                add_edge(h + j, t, INF);
                        }
                        else if (a[i][j] == 'o') {
                                add_edge(i, j + h, 1);
                                add_edge(j + h, i, 1);
                        }
                }
        }
        int flow = MaxFlow(s, t);
        if (flow >= INF) cout << -1 << endl;
        else cout << flow << endl;
        return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int A,B;
  cin>>A>>B;
  int count=1;
  int P=A;
  for(int i=0;P<B;i++){
    if(A<B){
      P+=A-1;
      count++;
    }
  }
  if(B==1) count=0;
  cout<<count;
    
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef deque<ll> di;
typedef pair<ll,ll> pi;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define pf push_front
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define FOR(i,a,b) for(ll i=a;i<b;i++)


int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    ll n;
    cin>>n;
    ll t=n,count_=0;
    FOR(i,1,t+1)
    {
        for(ll j=1;j<=t;j++)
        {
                if((n-(i*j))>0)
                    count_++;
                else
                    break;

        }
    }

    cout<<count_<<endl;

    return 0;
}


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

long long h, w, m;
vector<long long> cnth, cntw, id;
vector<vector<int>> g;
map<int, int> mp;

long long solve();

int main() {
  cin >> h >> w >> m;
  cnth.resize(h, 0);
  cntw.resize(w, 0);
  g.resize(w);
  id.resize(w);
  for (int i = 0; i < w; ++i) id[i] = i;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    ++cnth[--a];
    ++cntw[--b];
    g[b].push_back(a);
  }
  sort(id.begin(), id.end(), [](int l, int r) { return cntw[l] > cntw[r]; });
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, wcnt = 0;
  for (int i = 0; i < w; ++i)
    if (cntw[id[i]] == cntw[id[0]]) {
      ++wcnt;
      for (auto p : g[id[i]]) ++mp[p];
    }
  for (int i = 0; i < h; ++i) {
    long long now = cnth[i] + cntw[id[0]] - 1;
    if (mp.find(i) == mp.end() || mp[i] != wcnt) ++now;
    res = max(res, now);
  }
  return res;
}

Measured memory_bytes: 40716
K = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[K-1])

Measured memory_bytes: 3060
n,m = map(int, raw_input().split())
def f(a,b): 
	if a == 1 and b == 1:
		return 1
	if a == 1 or b == 1:
		return max(0, max(a,b) - 2)
	return max(0,a - 2) * max(0, b - 2) 
print f(n,m)

Measured memory_bytes: 85440
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n-i-j)
            exit()
print(-1,-1,-1)

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

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

    if (D == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }

    if (D == 23){
        cout << "Christmas Eve Eve" << endl;
    }

    if (D == 24){
        cout << "Christmas Eve" << endl;
    }

    if (D == 25){
        cout << "Christmas" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int x,y,z;

int main() {
    cin >> x >> y >> z;
    int res = (x-z)/(y+z);
    put(res);
    return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1005, mod = (int) 0;
int a[N], b[N];
int main() {
	int n;
	cin >> n;
	vector<int> res;
	for (int j = 0; j < n; ++j) {
		cin >> a[j];
		b[j] = a[j];
		a[j] -= j + 1;
	}
	for (int re = 0; re < n; ++re) {
		int found = 0;
		for (int j = n - 1; j >= 0; --j) {
			if (a[j] == 0) {
				found = 1;
				res.push_back(b[j]);
				for (int i = j; i < n; ++i)
					a[i]++;
				break;
			}
		}
		if (!found) {
			cout << -1 << endl;
			return 0;
		}
	}
	reverse(ALL(res));
	for (int x : res)
		cout << x << '\n';
}



















Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    rep(i, N) {
        char c;
        cin >> c;
        if(c == 'Y') {
            output("Four");
            return 0;
        }
    }
    output("Three");
    return 0;
}


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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

ll X;

int main() {
    cin >> X;
    FOR(A, -200, 200) {
        FOR(B, -200, 200) {
            if (pow(A, 5) - pow(B, 5) == X) {
                printf("%lld %lld\n", A, B);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4072
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 100000
using namespace std;
typedef long long ll;

int main(){
  int n, k; cin >> n >> k;
  int a[MAXNUM], pos;
  REP(i, n) {
    cin >> a[i];
    if(a[i]==1) pos = i;
  }
  cout << ((n-1)+(k-2))/(k-1) << endl;
  return 0;
}

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

vector<int> Zalgorithm(string s) {
  vector<int> res(s.size());
  res[0] = s.size();
  int i = 1, j = 0;
  while (i < s.size()) {
    while (i + j < s.size() && s[j] == s[i + j]) ++j;
    res[i] = j;
    if (j == 0) {
      ++i;
      continue;
    }
    int k = 1;
    while (i + k < s.size() && k + res[k] < j) res[i + k] = res[k], ++k;
    i += k;
    j -= k;
  }

  return res;
}

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

  vector<string> s(N + 1);
  for (int i = 1; i <= N; ++i) {
    cin >> s[i];
  }

  vector<bitset<10101>> reach(N + 1);
  reach.back().set(K);
  for (int i = N; i >= 1; --i) {
    reach[i - 1] = reach[i] | (reach[i] >> s[i].size());
  }

  vector<vector<bool>> dp(N + 1, vector<bool>(K + 10000, false));
  dp[0][0] = true;

  string ans;
  for (int i = 1; i <= N; ++i) {
    dp[i] = dp[i - 1];

    vector<int> d = Zalgorithm(s[i] + ans);
    for (int j = 0; j <= ans.size() && j + s[i].size() <= K; ++j) {
      int t = (j == ans.size() ? 0 : d[s[i].size() + j]);

      if (dp[i][j] && reach[i][j + s[i].size()] && (j == ans.size() || (t < s[i].size()) && (ans[j + t] > s[i][t]))) {
        ans = ans.substr(0, j) + s[i];
        for (int l = j + t + 1; l <= K; ++l) dp[i][l] = false;
        dp[i][j + s[i].size()] = true;
        break;
      }
    }
  }

  cout << ans << endl;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int h, w;
    cin >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, m, a[100010], b[100010], s[100010];
vector<pair<int, int>> vec[100010];
bool bl[100010][2];
ll cnt[100010][2];
bool bo = true;

void dfs(int v, int p, ll x, ll y) {
	bl[v][p] = true;
	if (!p)cnt[v][p] = y - x;
	else cnt[v][p] = x - y;
	for (int i = 0; i < (int)vec[v].size(); i++) {
		if (vec[v][i].first == p)continue;
		if (bl[vec[v][i].first][1 - p]) {
			if (p&&cnt[vec[v][i].first][1 - p] != y + vec[v][i].second - x)bo = false;
			if (!p&&cnt[vec[v][i].first][1 - p] != x + vec[v][i].second - y)bo = false;
			continue;
		}
		if (!p)dfs(vec[v][i].first, 1 - p, x + vec[v][i].second, y);
		else dfs(vec[v][i].first, 1 - p, x, y + vec[v][i].second);
	}
}

signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> s[i];
		vec[a[i]].push_back(make_pair(b[i], s[i]));
		vec[b[i]].push_back(make_pair(a[i], s[i]));
	}
	dfs(1, 0, 0, 0);
	if (!bo) {
		cout << 0 << endl;
		return 0;
	}
	ll mi = 0, ma = 1000000000000000000;
	for (int i = 1; i <= n; i++) {
		int miv = 1000000000, mav = 0;
		for (int j = 0; j < (int)vec[i].size(); j++)miv = min(miv, vec[i][j].second), mav = max(mav, vec[i][j].second);
		if (bl[i][0] && bl[i][1]) {
			if (cnt[i][0] >= cnt[i][1] || (cnt[i][1] - cnt[i][0]) % 2) {
				cout << 0 << endl;
				return 0;
			}
			ll x = (cnt[i][0] + cnt[i][1]) / 2;
			if (!x || miv < x) {
				cout << 0 << endl;
				return 0;
			}
			mi = max(mi, x - cnt[i][0]);
			ma = min(ma, x - cnt[i][0]);
		}
		else if (bl[i][0]) {
			mi = max(mi, 1 - cnt[i][0]);
			ma = min(ma, miv - cnt[i][0]);
		}
		else {
			mi = max(mi, cnt[i][1] - miv);
			ma = min(ma, cnt[i][1] - 1);
		}
	}
	cout << max((ll)0, ma - mi + 1) << endl;
}

Measured memory_bytes: 26872
#include <stdio.h>
#include <string.h>

int main(void)
{
    char str;
    int length;
    int i;

    while(1)
    {
        scanf("%c", &str);  //一文字ずつ読み込む
        if (str == '\n'){   //改行がきたら終了
            break;
        }
        if (str == ' ' || str == '.'){  //空白かピリオドがくるとそのまま出力
            printf("%c", str);
        }else{                          //半角小文字は半角大文字に
            printf("%c", str - 32);
        }
    }
    printf("\n");

    return (0);
}


Measured memory_bytes: 2024
#include <iostream>
 
using namespace std;
 
int main()
{
	int a, b;
  	char ch;
  	cin >> a >> ch >> b;
  	if(ch == '-') {
      b *= (-1);
      cout << a+b << endl;
    }
  	else cout << a+b << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			ans -= a[i];
		} else if (i + 1 == n) {
			ans += a[i];
		} else {
			ans += max(-a[i], a[i]);
		}
	}
	cout << ans << '\n';
	for (int i = 1; i + 1 < n; i++) {
		if (a[i] > 0) {
			cout << a[0] << ' ' << a[i] << '\n';
			a[0] -= a[i]; 
		} else {
			cout << a[n - 1] << ' ' << a[i] << '\n';
			a[n - 1] -= a[i];
		}
	}
	cout << a[n - 1] << ' ' << a[0] << '\n';
}

Measured memory_bytes: 3176
#include<stdio.h>
#include<iostream>
#include<numeric>
#include<algorithm>
#include<vector>
#include<queue>
#include <iostream>
using namespace std;


#define REP(i,a,b) for(long long (i)=(a);(i)<(b);(i)++)
#define REV(i,a,b) for(long long (i)=(a);(i)>(b);(i)--)
typedef long long ll;

int N,W,v[101],w[101],dp[101][10001];

int main(){
  cin>>N>>W;
  REP(i,1,N+1)cin >>v[i]>>w[i];
  REP(j,0,W+1)dp[0][j]=0;
  REP(i,1,N+1) REP(j,1,W+1){
    if(j-w[i]<0)dp[i][j] = dp[i-1][j];
    else dp[i][j] = max(dp[i][j-w[i]]+v[i],max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]));
  }
  cout << dp[N][W] << endl;

  return 0;
}


Measured memory_bytes: 7028
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD1 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int H,W,K; cin>>H; cin>>W;cin>>K;
  vector<vector<char> >  mat (H,vector<char>(W,0));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
       cin>>mat[i][j];
    }
  }
  vector<vector<int> > vv (H,vector<int>(W,0));
  int cnt = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if(mat[i][j] == '#')
      {
        cnt ++;
        vv[i][j] = cnt;
      }
    }
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W-1; j++)
    {
      if(vv[i][j+1] == 0)
      {
        vv[i][j+1] = vv[i][j];
      }
    }
    for (int j = W-1; j >= 1; j--) 
    {
      if(vv[i][j-1] == 0)
      {
        vv[i][j-1] = vv[i][j];
      }
    }
  }

  for (int i = 1; i < H; i++)
  {
    if(vv[i][0] == 0)
    {
      for (int j = 0; j < W; j++)
      {
        vv[i][j] = vv[i-1][j];
      }
      
    }
  }


  for (int i = H-2; i >=0; i--)
  {
    if(vv[i][0] == 0)
    {
      for (int j = 0; j < W; j++)
      {
        vv[i][j] = vv[i+1][j];
      }
      
    }
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if(j != 0)cout<<" ";
      cout<<vv[i][j];
    }
    cout<<endl;
    
  }
  
  return;

}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

using namespace std;

typedef long long ll;
int n;
void sol(int pos, int used, string s){
    if(pos == n){
        cout << s << endl;
        return;
    }
    char c = 'a';
    for(int i=0; i<used; i++){
        sol(pos+1, used, s+c);
        c++;
    }
    sol(pos+1, used+1, s+c);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    sol(1, 1, "a");
    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
double ans;
ll N;
 
 
 
int main(){
    cin >> N;
    ans = M_PI * N * 2;
    cout << ans << endl;
}


Measured memory_bytes: 3788