akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}


graph g;
lli dp[100100][2];

void dfs(int nn,int pp){
	dp[nn][0]=1;
	dp[nn][1]=1;
	for(auto v:g[nn]){
		if(v!=pp){
			dfs(v,nn);
			dp[nn][0]=(dp[nn][0]*(dp[v][0]+dp[v][1]))%MOD;
			dp[nn][1]=(dp[nn][1]*dp[v][0])%MOD;
		}
	}
}

void solve(){
	lli n;cin>>n;
	g.resize(n+1);
	fr(i,n-1){
		int a,b;
		cin>>a>>b;
		g[a].EB(b);
		g[b].EB(a);
	}
	dfs(1,0);
	cout<<(dp[1][0]+dp[1][1])%MOD<<endl;

}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	pre();lli t=1;//cin>>t;
	for(lli i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, q;
    cin >> n >> k >> q;
    vector <int> a(n);
    vector <int> b(n);
    for (int i=0; i<n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    int v;
    int ans = 1000000000;
    sort(b.begin(), b.end());
    for (int i=0; i<n-k+1; i++){
        v = b[i];
        vector <vector <int> > g;
        vector <int> r;
        int f = 0;
        for (int j=0; j<n; j++){
            if (a[j] >= v){
                r.push_back(a[j]);
            }
            else{
                if (r.size()!=0){
                    g.push_back(r);
                    r.clear();
                }
            }
        }
        if (r.size()!=0){
            g.push_back(r);
            r.clear();
        }
        for (int j=0; j<g.size(); j++){
            sort(g[j].begin(),g[j].end());
        }
        vector <int> tr;
        for (int j=0; j<g.size();j++){
            if (g[j].size()>=k){
                for (int jj=0; jj<g[j].size()-k+1; jj++){
                    tr.push_back(g[j][jj]);
                }
            }
        }
        if(tr.size()>=q){
            sort(tr.begin(),tr.end());
            if (tr[q-1] - tr[0] < ans){
                ans = tr[q-1] - tr[0];
            }
        }
    }
    cout << ans;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    ll x, y;
    cin >> x >> y;

    ll ans = 0;
    while(x <= y){
        x *= 2;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		long ans=0,m=s[0]+s[1];
		long[][] a=new long[s[0]+s[1]][];
		for(int i=0;i<s[0];i++){a[i]=new long[]{int.Parse(Console.ReadLine()),0};}
		for(int i=s[0];i<m;i++){a[i]=new long[]{int.Parse(Console.ReadLine()),1};}
		Array.Sort(a,ca);
		s[0]++;
		s[1]++;
		for(int i=0;i<m;i++){
			ans+=a[i][0]*s[a[i][1]^1];
			s[a[i][1]]--;
		}
		Console.WriteLine(ans);
	}
	static int ca(long[] a,long[] b){
		if(a[0]>b[0]){return 1;}
		else if(a[0]<b[0]){return -1;}
		else{return 0;}
	}
}

Measured memory_bytes: 29520
n=int(input())
ans_list=[[0]*10 for i in range(10)]
for i in range(1,n+1):
  sn=str(i)
  x=int(sn[0])
  y=int(sn[-1])
  ans_list[x][y]+=1
ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=ans_list[i][j]*ans_list[j][i]
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        int[][] board = new int[8][8];
        
        for(int i = 0; i < 8 ; i++){
        	Arrays.fill(board[i], 0);
        }
        
        for(int i = 0; i < n; i++){
        	String[] tmpArray = br.readLine().split(" ");
        	int r = Integer.parseInt(tmpArray[0]);
        	int c = Integer.parseInt(tmpArray[1]);
        	board[r][c] = 1;
        }
        
        int nextC = getAvailableColumn(board, 8);
        if(nextC >= 0){
        	for(int i = 0; i < 8; i++){
        		boolean result = putQueen(board, 8, i, nextC);
        		if(result == true){
        			break;
        		}
        	}
        }
        //print
        for(int i = 0; i < 8; i++){
        	for(int j = 0; j < 8 ; j++){
        		if(board[i][j] == 1){
        			System.out.print("Q");
        		}
        		else{
        			System.out.print(".");
        		}
        	}
        	System.out.println();
        }
	}
	
	static int getAvailableColumn(int[][] board, int n){
		int j;
		for(j = 0; j < n ; j++){
			int queen = 0;
			for(int i = 0; i < n; i++){
				if(board[i][j] == 1){
					queen++;
					break;
				}
			}
			if(queen == 0){
				break;
			}
		}
		
		if(j >= n){
			return -1;
		}
		
		else {
			return j;
		}
	}
	
	static boolean putQueen(int[][] board, int n, int r, int c){
		//System.out.println("n "+n + " r "+r+" c "+c);
		//????????????????????????????????????????????????????????¨??????????????£??????
		for(int i = 0; i < n ; i++){
			if(board[i][c] == 1 && i != r){
				//System.out.println("error 1");
				return false;
			}
			if(board[r][i] == 1 && i != c){
				//System.out.println("error 2");
				return false;
			}
		}
		for(int i = 0; i < n; i++){
			if(  r+i < n && c+i < n && board[r+i][c+i] ==1){
				//System.out.println("error 3");
				return false;
			}
			if( r+i < n && c-i >= 0 && board[r+i][c-i] ==1 ){
				//System.out.println("error 4");
				return false;
			}
			if(  r-i >= 0 && c+i < n && board[r-i][c+i] ==1){
				//System.out.println("error 5");
				return false;
			}
			if( r-i >= 0 && c-i >= 0 && board[r-i][c-i] ==1 ){
				//System.out.println("error 6");
				return false;
			}
		}
		//System.out.println("("+r+","+c+") is OK");
		board[r][c] = 1;
		
		int nextColumn = getAvailableColumn(board, 8);
		if(nextColumn < 0){
			return true;
		}
		for(int i = 0; i < n ; i++){
			boolean result = putQueen(board, n, i, nextColumn);
			if(result == true){
				return true;
			}
		}
		board[r][c] = 0;
		return false;
	}

}



Measured memory_bytes: 24468
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




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

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

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


int main() {
  ll A,N;
  cin >> A>>N;
  ll ans=0;
  if(A>12){
    ans=N;
  }else if(A>5){
    ans=N/2;
  }


  cout<<ans<<endl;

}


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

struct Edge { int to; ll cost; };
vector<Edge> G[2010];
ll INF = 1e18;

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

  int V, E; cin >> V >> E;
  vector<ll> d(V, INF);

  for (int i = 0; i < E; i++) {
    int a, b; cin >> a >> b; a--; b--;
    ll c; cin >> c;
    G[a].emplace_back(Edge({b, -c}));
    // G[b].emplace_back(Edge({a, -c}));
  }

  d[0] = 0;
  for (int t = 0; t < V * 2; t++) {
    for (int i = 0; i < V; i++) {
      if (d[i] == INF) continue;
      for (auto e: G[i]) {
        if (d[e.to] > d[i] + e.cost) {
          d[e.to] = d[i] + e.cost;
          if (t == V - 1) {
            d[e.to] = -INF;
          }
        }
      }
    }
  }

  if (d[V - 1] <= -INF) cout << "inf\n";
  else cout << -d[V - 1] << '\n';

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
void bfs(void);

void enqueue(int);
int dequeue(void);
int G[N][N],d[N],f[N],n,Q[N],tail,head,color[N],time;
int main(){

  int i,j,y,b,k;

  for(i=1;i<=100;i++){
    for(j=1;j<=100;j++){
      G[i][j]=0;
    }
  }
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&y,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&b);
      G[y][b]=1;
      
    }
  }

  bfs();

  for(i=1;i<=n;i++){
    if(d[i]==2000000)
      d[i]=-1;
    printf("%d %d\n",i,d[i]);
  }
  return 0;
}

void bfs(){
  int i,u;
  for(i=1;i<=n;i++){
    color[i]=WHITE;
    d[i]=2000000;
  }
  color[1]=GRAY;
  d[1]=0;
  
  enqueue(1);

  while(head!=tail){
    u=dequeue();
    for(i=1;i<=n;i++){
      if(G[u][i]!=0){
      if(color[i]==WHITE){
	color[i]=GRAY;
	d[i]=d[u]+1;
	enqueue(i);
      }}
    }
    color[u]=BLACK;
   
  }
}

void enqueue(int x){
  
  Q[tail]=x;
  if(tail+1==N)
    tail=0;
  else
    tail++;
}

int dequeue(){
  int x;
  x=Q[head];
  if(head+1==N){
    head=0;
  }
  else
    head++;
  return x;
}
 

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  if(N==3) cout<<2<<" "<<3<<" "<<25<<endl;
  else{
    vi A,B,C;
    REP(i,1,30000){
      if(i%6==0) A.pb(i);
      else if(i%2==0) B.pb(i);
      else if(i%3==0) C.pb(i);
    }
    cout<<B[0]<<" "<<B[1]<<" "<<C[0]<<" "<<C[1];
    N-=4;
    rep(i,1,B.size()/2){
      if(N>=2){
        N-=2;
        cout<<" "<<B[i*2]<<" "<<B[i*2+1];
      }
    }
    rep(i,1,C.size()/2){
      if(N>=2){
        N-=2;
        cout<<" "<<C[i*2]<<" "<<C[i*2+1];
      }
    }
    rep(i,0,N) cout<<" "<<A[i];
    cout<<endl;
  }
  }


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int maxn=105;
const int inf=0x3f3f3f3f;
int n,m;
int mp[maxn][maxn];
struct edge{
    int a,b,c;
}e[1005];
void floyd (){
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                mp[i][j]= min ( mp[i][k]+mp[k][j], mp[i][j] );
            }
        }
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) mp[i][j]=0;
            else mp[i][j]=inf;
        }
    }
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&e[i].a,&e[i].b,&e[i].c);
        mp[e[i].a][e[i].b]=mp[e[i].b][e[i].a]=e[i].c;
    }
    floyd();
    int ans=m;
    for(int i=0;i<m;i++){
        int u=e[i].a,v=e[i].b,w=e[i].c;
        bool flag=false;
        for(int s=1;s<=n;s++){
            if(mp[s][v]==mp[s][u]+w) flag=true;
        }
        if(flag) ans--;
    }
    cout<<ans<<endl;
   
    return 0;
}

Measured memory_bytes: 256
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();
  
// ここから
function main(){
  var i = 1;
  for(var len = input[0] - 0;len--;){
    var x = input[i++].split('').reverse().join('').trim();
    var y = input[i++].split('').reverse().join('').trim();

    var loop = x.length > y.length ? x.length : y.length;
    var results = new Int8Array(loop + 1);
    for(var j = 0; j < loop; j++){
      var xj = x.length > j ? x[j] - 0 : 0;
      var yj = y.length > j ? y[j] - 0 : 0;
      var rj = results[j] - 0;
      var sum = xj + yj + rj;
      if(sum >= 10){
        sum -= 10;
        results[j + 1]++;
      }
      results[j] = sum;
    }

    var result = "";
    for(loop++;loop--;){
      result += results[loop];
    }
    result=result.replace(/^0/g, "");


    console.log(result.length > 80 ? 'overflow' : result);
  }
}

Measured memory_bytes: 7904
#include <stdio.h>

int main(void) {
	int n,m,a;
	scanf("%d%d\n", &n,&m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &a);
		n -= a;
	}

	printf("%d\n", n >= 0 ? n : -1);
	
	return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int N, H, D;
ll DP[1000000], S[1000000], t;

ll s(int x) {
	if (x - D - 1 >= 0)
		return (S[x - 1] + mod - S[x - D - 1]) % mod;
	else
		return S[x - 1];
}

int main() {
	cin >> N >> H >> D;
	ll tmp = 1;
	for (ll i = 1; i <= N; i++) {
		tmp *= i;
		tmp %= mod;
		t += tmp;
		t %= mod;
	}
	DP[0] = S[0] = tmp;
	for (int i = 1; i < H; i++) {
		DP[i] = s(i)*t%mod;
		S[i] = (S[i - 1] + DP[i]) % mod;
	}
	cout << s(H) << endl;
}

Measured memory_bytes: 15872
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X, A = list(map(int, sys.stdin.buffer.readline().split()))
    print(0 if X < A else 10)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    if (s != 1000000000) {
        for (int i = 0; i < n; i++) {
            if (i < k) cout << s <<' ';
            else cout << "1000000000 ";
        }
    }
    else {
        for (int i = 0; i < n; i++) {
            if (i < k) cout << s <<' ';
            else cout << "1 ";
        }
    }
}

Measured memory_bytes: 1280
local n=io.read("n")
local verte={}
local flag=true
for i=1,n do
    local x=io.read("n")
    if (i==1 and x>0) or (i>1 and x==0) then
        flag=false
    end
    verte[x]=(verte[x] or 0)+1
end

if not flag then
    print(0)
else
    local tree=1
    local mod=998244353
    for x,_ in pairs(verte) do
        if x+1<=#verte then
            if not verte[x] or not verte[x+1] then
                print(0)
                return
            end
            for i=1,verte[x+1] do
                tree=tree*verte[x]%mod
            end
        end
    end
    print(string.format("%d",tree))
end

Measured memory_bytes: 4964
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>

using namespace std;

int main() {
	int i, j, k;
	vector<int>a(3);

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

	sort(a.begin(), a.end());

	int sum = 0;

	sum += a[1] - a[0];

	sum += a[2] - a[1];

	cout << sum << endl;










	getchar();
	getchar();
	return 0;
}

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if(s.size() <= k) {
    cout << s << endl;
    return 0;
  }
  else {
    // int dif = s.size() - k;
    cout << s.erase(k) + "..." << endl;
    return 0;
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
	int N;cin>>N;
	for(int i = N;i > 0;--i){
		if(ceil(pow(i,0.5)) == floor(pow(i,0.5))){
			cout<<i;
			break;
    }
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1000100,P=1e9+7;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,a[N],h[N],ne[N],to[N],du[N],L,flag=1;
inline void addl(int x,int y){
	ne[++L]=h[x];h[x]=L;to[L]=y;du[x]++;
	ne[++L]=h[y];h[y]=L;to[L]=x;du[y]++;
}
int dfs(int x,int fa){
	if(du[x]==1)return a[x];
	int re=a[x]+a[x],k,s;
	for(k=h[x];k;k=ne[k])
	if(to[k]!=fa){
		s=dfs(to[k],x);
		if(s>a[x])flag=0;
		re-=s;
	}if(re>a[x]||re<0)flag=0;
	return re;
}
int main(){
	//freopen("1.out","w",stdout);
	int i;
	n=read();
	for(i=1;i<=n;i++)a[i]=read();
	if(n==2){flag=(a[1]==a[2]);}
	for(i=1;i<n;i++)addl(read(),read());
	for(i=1;i<=n;i++)if(du[i]>1)
	{if(dfs(i,0)>0)flag=0;break;}
	puts(flag?"YES":"NO");
	return 0;
}

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

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

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif
    int n,m;
    int arr[100010];
    int fr, to;
    sc(n);sc(m);
    FOR(i,n){
        arr[i] = 1;
    }

    bool mungkin[100010];
    reset(mungkin, false);
    mungkin[0] = true;

    FOR(i,m){
        sc(fr);sc(to);
        fr--;to--;
        if(mungkin[fr])mungkin[to] = true;
        arr[fr]--;
        if(arr[fr] == 0)mungkin[fr] = false;
        arr[to]++;
    }
    int tot = 0;
    FOR(i,n){
        if(arr[i] && mungkin[i])tot++;
    }

    cout << tot;



    return 0;
}





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

using namespace std; 

int main(){ 
  int k,a,b;
  cin>>k>>a>>b;
  if(b/k-a/k>0) cout<<"OK";
  else if(b/k-a/k==0&&a%k==0) {
    cout<<"OK";
  }
  else if(b/k-a/k==0&&b%k==0) {
    cout<<"OK";
  }
  else cout<<"NG";
}
    

Measured memory_bytes: 3624
N,L = map(int,input().rstrip().split(' '))
WORDS=["" for i in range(N)]
for i in range(N):
    WORDS[i] = input().rstrip()

WORDS.sort(key=str,reverse=False)

#print(WORDS)

for i in range(N):
    print(WORDS[i],end="")

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

int main()
{
     int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
    return 0;
}



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

int main()
{
    int n,k;
    cin>>n>>k;
    vector <double> p(n);
    rep(i,n)
    {
        cin>>p[i];
    }

    vector <double> e(n);
    rep(i,n)
    {
        e[i]=(p[i]+1)/2;
    }

    queue <double> q;
    double mx = 0.0;
    double temp=0.0;

    rep(i,n)
    {
        temp+=e[i];
        q.push(e[i]);
        if(q.size()>k)
        {
            temp-=q.front();
            q.pop();
        }
        if(q.size()==k)
        {
            mx = max(mx,temp);
        }
        
    }

     cout << fixed << setprecision(15) << mx << endl;
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;

    ll ans = (n*(n+1))/2;

    ll a = n/3;
    ll b = n/5;
    ll c = n/15;

    ans -= 3 * (a * (a+1))/2;
    ans -= 5 * (b * (b+1))/2;
    ans += 15* (c * (c+1))/2;

    cout<<ans;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,t,a,b;
    string s;
    while(cin>>a>>b>>s)
    {
         int  ok=0,cnt=0;
        for(i=0;i<s.size();i++)
        {

            if(s[i]=='-')
            {
                cnt++;
                if(i==a)
                {
                    ok=1;

                }

            }
        }
        if(cnt==1&&ok)printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}



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

#define N 51
#define mod 1000000007
#define ll long long

ll n, k;
vector<vector<ll> > adj(N, vector<ll> (N));

vector<vector<ll> > multiply(vector<vector<ll> > &a, vector<vector<ll> > &b) {
	vector<vector<ll> > prod(n, vector<ll> (n, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (ll k = 0; k < n; k++) {
				prod[i][j] += (a[i][k] * b[k][j]) % mod;
				prod[i][j] %= mod;
			}
		}
	}
	return prod;
}

vector<vector<ll> > matrix_expo(vector<vector<ll> > adj, ll p) {
	vector<vector<ll> > res(n, vector<ll> (n));
	// form identity matrix
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) res[i][j] = 1;
			//cout << res[i][j] << " ";
		}
	}
	while (p) {
		if (p & 1) {
			//res = res * adj
			res = multiply(res, adj);
		}
		adj = multiply(adj, adj);
		p >>= 1;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> adj[i][j];
		}
	}

	vector<vector<ll> > dist;
	dist = matrix_expo(adj, k);

	// print matrix
	/*for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << dist[i][j] << " ";
		}
		cout << "\n";
	}*/
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans += dist[i][j];
			ans %= mod;
		}
	}

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


Measured memory_bytes: 3700
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
  using namespace std;
   using namespace std::chrono;      
  using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e12
 #define sm         -2e18
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;
#define MEM(x,val) memset(x,val,sizeof(x))

 typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
            tree_order_statistics_node_update>  odst; 



void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   
    #endif
}



void solve()
{
  int n;
  cin >> n;
  string s = "ACL" , an;
  

  forf(i,0,n)
  {
    an+=s;
  }

  cout<<an;

}

int32_t main()
{
  pr_init();
  //fastio;
  auto start = high_resolution_clock::now(); 
  solve(); 
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

  return 0;
}

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

int main(){
  long long N,P;
  cin >> N >> P;

  long long ans=1;
  for(long long i=2;i*i<=P;i++){
    long long cnt=0;
    while(P%i==0){
      P/=i;
      cnt++;
    }
    ans*=pow(i,cnt/N);
  }
  if(N==1)  ans*=P;
  cout << ans << endl;

  return 0;
}

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

using ll = long long;
//typedef long long ll;

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll n, a, b;

int main() {
  cin >> n;

  int sq = sqrt(n), ans = 100000;

  for (int i = 1; i <= sq; ++i) {
    a = i; b = n / a;
    if (n % a != 0) continue;
    ans = min(ans, max((int)to_string(a).size(), (int)to_string(b).size()));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::collections::BinaryHeap;

fn main() {
    let (N, M) = get!(usize, usize);
    let mut AB = get!(usize, i64; N);

    // 後ろから（M-1日後から）貪欲に詰める
    AB.sort_by_key(|&(a, b)| (a, -b));
    let mut i = 0;
    let mut q = BinaryHeap::new();
    let mut ans = 0;
    for k in 1..(M + 1) {
        while i < N && AB[i].0 <= k {
            q.push(AB[i].1);
            i += 1;
        }
        ans += match q.pop() {
            Some(b) => b,
            _ => 0
        }
    }

    println!("{}", ans);
}



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

const long mod=1000000007;

using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  
  if(n-m>1||m-n>1) {
    cout << 0 << endl;
   return 0;
  }
  
   long res;
   if(n==m) res=2;
   else res=1; 
  
  while(n>0){
   res*=n;
   res%=mod;
   n--;
  }
   while(m>0){
   res*=m;
   res%=mod;  
   m--;
  }
  
  cout << res << endl;
  
}

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <=b; i++) {
        if (i%k==0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3612
#
import sys
import math
import numpy as np
import itertools

def lcm(m,n):
    p=max(m,n)
    q=min(m,n)
    if p % q == 0:
        return q
    else:
        return lcm(q,p%q)



# いくつか入力
a,b,c,d = (int(i) for i in input().split())  

x = b // c - (a-1) // c
y = b // d - (a-1) // d
e = c * d // lcm(c,d)
z = b // e - (a-1) // e

print(b-a+1-x-y+z)



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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c =='i' || c =='u' || c =='e' || c =='o'){
    cout << "vowel";
  }
  else{ 
    cout << "consonant";
  }
  
}

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

int cost[101][101],t[101][101];
bool tf,cf;

int wf(int p,int q,int r,int m){
	if(r){
		if(tf){
		for(int k=1 ; k <= m ; ++k){
			for(int i=1 ; i <= m ; ++i){
				for(int j=1 ; j <= m ; ++j){
					if(t[i][j] > t[i][k] + t[k][j]) t[i][j] = t[i][k] + t[k][j];
				}
			}
		}
		tf = false;
			return t[p][q];
		}
		else return t[p][q];
		}
		else if(cf){
		for(int k=1 ; k <= m ; ++k){
			for(int i=1 ; i <= m ; ++i){
				for(int j=1 ; j <= m ; ++j){
					if(cost[i][j] > cost[i][k] + cost[k][j]) cost[i][j] = cost[i][k] + cost[k][j];
				}
			}
		}
		cf = false;
		return cost[p][q];
	}
	else return cost[p][q];
}

int main(){
	int a,b,c,d,n,m,k,p,q,r;
	
	while(cin >> n >> m && n && m){
		for(int i=1 ; i <= m ; ++i){
			for(int j=1 ; j <= m ; ++j){
				cost[i][j] = 10000;
				t[i][j] = 10000;
			}
		}
		cf = true;
		tf = true;
		for(int i=0 ; i < n ; ++i){
			cin >> a >> b >> c >> d;
			cost[a][b] = c;
			cost[b][a] = c;
			t[a][b] = d;
			t[b][a] = d;
		}
		cin >> k;
		for(int i=0 ; i < k ; ++i){
			cin >> p >> q >> r;
			cout << wf(p,q,r,m) << endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 944
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int ma = 0,mi = 1000;
        for(int i = 0;i < n; i++){
            int x,sum=0;
            for(int j = 0;j < 5; j++){
                scanf("%d",&x);
                sum += x;
            }
            ma = max(ma,sum);
            mi = min(mi,sum);
        }
        printf("%d %d\n",ma,mi);
    }
    return 0;
}

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

int main(){
  int n,l;
  cin >> n >> l;
  string s[n];
  for(int i=0;i<n;i++) cin >> s[i];
  sort(s,s+n);
  for(int i=0;i<n;i++) cout << s[i];
  cout << endl;
}  


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val A = Array.fill(3)(sc.nextInt)

    (A.max - A.min).toString
  }
}


Measured memory_bytes: 27424
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	if (N == 1) {
		if (A != B) {
			cout << 0 << endl;
			return 0;
		}
		else {
			cout << 1 << endl;
			return 0;
		}
	}
	else {
		if (A > B) cout << 0 << endl;
		else {
			N -= 2;
			cout << N * B - N * A + 1 << endl;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	if(x==y)
	{
		cin>>x;
		cout<<x;
		return 0;
	}
	int z;
	cin>>z;
	if(x==z)
	{
		cout<<y;
		return 0;
	}
	cout<<x;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define min(a, b) ((a) < (b)? (a) : (b))

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N * A, B) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    vector <string> data(n);
    rep(i, n) {
        cin >> data[i];
    }

    vvi ch(n, vi(30, 0));

    rep(i, n) {
        rep(j, data[i].size()) {
            ch[i][data[i][j] - 'a']++;
        }
    }

    bool hhh = false;
    rep(j, 29) {
        int ret = ch[0][j];
        Rep(i, n) {
            ret = min(ch[i][j], ret);
        }
        rep(i, ret) {
            hhh = true;
            printf("%c", 'a'+j );
        }
    }
    if (hhh) 
    cout << endl;
    return 0;

    

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>arr(n),brr(m);
    for(int i=0;i<n;++i){
        cin>>arr[i];
        if(i) arr[i]+=arr[i-1];
    }
    for(int i=0;i<m;++i){
        cin>>brr[i];
        if(i) brr[i]+=brr[i-1];
    }
    int book=0;
    int a=upper_bound(brr.begin(),brr.end(),k)-brr.begin();
    int b=upper_bound(arr.begin(),arr.end(),k)-arr.begin();
    book =max(a, b);

    for(int i=0;i<n;++i){
        if(arr[i]>k){
            int st2=upper_bound(brr.begin(),brr.end(),k)-brr.begin();
            book=max(book,st2);
            break;
        }
        else{
            int rem=k-arr[i];
            int st2= upper_bound(brr.begin(),brr.end(),rem)-brr.begin();
            book=max(book,i+st2+1);
        }
    }
    cout<<book<<endl;
}

int main()
{
    fast;
    int t;
    solve();
}





Measured memory_bytes: 6348
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll a, b, c;
	cin >> a >> b >> c;

	if (c - a - b > 0 && 4 * a*b < (c - a - b)*(c - a - b)) { cout << "Yes"; }
	else { cout << "No"; }
	

	system("PAUSE");

}





Measured memory_bytes: 504
n,k=map(int, input().split())
lr=[list(map(int,input().split())) for _ in range(k)]
mod=998244353
dp2=[0]*n
dp2[0]=1
for i in range(1,n):
    dp2[i]+=dp2[i-1]
    for l,r in lr:
        if i-l>=0:
            dp2[i]+=dp2[i-l]
        elif i-l<0 and i-r>=0:
            dp2[i]+=dp2[0]
        if i-r-1>=0:
            dp2[i]-=dp2[i-r-1]
    dp2[i]%=mod
print((dp2[-1]-dp2[-2])%mod)

Measured memory_bytes: 16920
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int N;
    cin >> N;
    cout << N*N << endl;
    return;
}



// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
use std::collections::HashMap;

fn main() {
    let n = read();
    let mut log: HashMap<String, i64> = HashMap::new();

    let mut max_count = 0;
    for _ in 0..n {
        let s = read();
        let count = log.entry(s).or_insert(0);
        *count += 1;
        if *count > max_count {
            max_count = *count;
        }
    }
    let mut words = Vec::new();
    for (s, c) in log.iter() {
        if max_count == *c {
            words.push(s);
        }
    }
    words.sort();

    for s in words.iter() {
        println!("{}", s);
    }

}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}



Measured memory_bytes: 20408
#include<bits/stdc++.h>
using namespace std;
long long int f(int* h,int i){
	if(i<=0) return 0;
	if(i==1) return abs(h[i]-h[0]);
	long long int ans1 = f(h,i-2)+abs(h[i]-h[i-2]);
	long long int ans2 = f(h,i-1)+abs(h[i]-h[i-1]);
	return min(ans1,ans2);
}
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	//cout<<f(a,n-1);
	long long int dp[n];
	dp[0]=0;
	dp[1] = abs(a[1]-a[0]);
	for(int i=2;i<n;i++) dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	cout<<dp[n-1];
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, five = 0, seven = 0;
    cin >> a >> b >> c;
    switch(a){
        case 5:five++;break;
        case 7:seven++;break;
        default:break;
    }
    switch(b){
        case 5:five++;break;
        case 7:seven++;break;
        default:break;
    }
    switch(c){
        case 5:five++;break;
        case 7:seven++;break;
        default:break;
    }
    /*if(a==5){
        five++;
    }
    if(b==5){
        five++;
    }
    if(c==5){
        five++;
    }
    else if(a==7 || b==7 || c==7){
        seven++;
    }*/

    if(five==2 && seven==1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

int memo[100010];
int func(int x)
{
    if (x==0) return 0;
    auto& res=memo[x];
    if (~res) return res;
    res=x;
    for(int i=1; i<=x; i*=6) res=min(res, func(x-i)+1);
    for(int i=1; i<=x; i*=9) res=min(res, func(x-i)+1);
    return res;
}

int main()
{
    memset(memo, -1, sizeof(memo));
    int n; cin>>n;
    cout<<func(n)<<endl;
}


Measured memory_bytes: 3712
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x = 0;
	cin >> x;
	if (x >= 400 && x < 600)
		cout << "8";
	else if (x >= 600 && x < 800)
		cout << "7";
	else if (x >= 800 && x < 1000)
		cout << "6";
	else if (x >= 1000 && x < 1200)
		cout << "5";
	else if (x >= 1200 && x < 1400)
		cout << "4";
	else if (x >= 1400 && x < 1600)
		cout << "3";
	else if (x >= 1600 && x < 1800)
		cout << "2";
	else
		cout << "1";
	cout << endl;
}

Measured memory_bytes: 3556
#include <cstdio>
#include <algorithm>
using namespace std;
int a[2000],b[2000],c[2000];
int d[101][101];
int N,M;
int main(){
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++){
      d[i][j]=1000000000;
      if(i==j)d[i][j]=0;
    }
  }
  scanf("%d %d",&N,&M);
  int ans=0;
  for(int i=0;i<M;i++){
    scanf("%d %d %d",&a[i],&b[i],&c[i]);
    a[i]--;b[i]--;
  }
  for(int i=0;i<M;i++){
    d[a[i]][b[i]]=min(d[a[i]][b[i]],c[i]);
    d[b[i]][a[i]]=min(d[b[i]][a[i]],c[i]);
  }
  for(int k=0;k<N;k++){
    for(int j=0;j<N;j++){
      for(int i=0;i<N;i++){
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	}
      }
    }
  
  for(int i=0;i<M;i++){
    if(d[a[i]][b[i]]<c[i])ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        string str = Console.ReadLine();
        double a = double.Parse(str.Split(' ')[0]);
        double b = double.Parse(str.Split(' ')[1]);
        double c = double.Parse(str.Split(' ')[2]);
        double d = double.Parse(str.Split(' ')[3]);
        double ans = Math.Sqrt((c - a) * (c - a) + (d - b) * (d - b));
        Console.WriteLine(ans);
    }    
}

Measured memory_bytes: 5748
import math


def main():
    n = int(input())
    ans = 0
    for i in range(n):
        x = int(input())
        if x == 2:
            ans += 1
        elif x % 2 == 0:
            pass
        else:
            flag = True
            j = 3
            while j <= math.sqrt(x):
                if x % j == 0:
                    flag = False
                    break
                j += 2
            if flag:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int N,H,W;
  cin >> N >> H >> W;
  int count =0;
  vector<int> A(N);
  vector<int> B(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    cin >> B.at(i);
    if(A.at(i)>=H && B.at(i)>=W){
      count ++;
    }
  }
  cout << count << endl;

  
 


}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------
ll a[201010], b[201010];
ll N, M, K;

int main() {
  cin >> N >> M >> K;
  rep(i, 0, N) {
    ll A;
    cin >> A;
    a[i + 1] = a[i] + A;
  }
  rep(i, 0, M) {
    ll B;
    cin >> B;
    b[i + 1] = b[i] + B;
  }

  ll bcur = 0;
  for (ll i = M; i >= 0; --i) {
    if (b[i] <= K) {
      bcur = i;
      break;
    }
  }

  ll ans = bcur;
  repe(i, 1, N) {
    ll rest = K - a[i];
    if (rest < 0) {
      break;
    }

    for (ll j = bcur; j >= 0; --j) {
      if (b[j] <= rest) {
        bcur = j;
        break;
      }
    }

    chmax(ans, i + bcur);
  }

  cout << ans;
}


Measured memory_bytes: 6712