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

using namespace std;

int gcd(int n, int m) {
    if (n == 0)
        return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    i = (i + (i >> 4)) & 0x0f0f0f0f;
    i = i + (i >> 8);
    i = i + (i >> 16);
    return i & 0x3f;
}

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

string S;
string T;
long int num=0;
int main(){
    cin>>S>>T;
    for(int i=0;i<S.size();++i){
        if(S[i]!=T[i])num++;
    }
    cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+2;

int main()
{
    fastio;
    ll i, j, k, n, m, t;
    vll a;
    cin>>n>>k;
    for ( i = 0; i < n; i++)
    {
        cin>>j;
        a.pb(j);
    }
    sort(all(a));
    m=0;
    for ( i = 0; i < n-k; i++)
    {
        m+=a[i];
    }
    cout<<m<<endl;


        
    return 0;
}

Measured memory_bytes: 5272
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define lli long long int

const lli MOD = 1e9 + 7;
const lli INF = 1e15;

const lli MAX_N = 200010;
vector<pair<lli, lli> > G[MAX_N];
vector<lli> dijkstra(lli start){
    vector<lli> dist(MAX_N, INF);
    dist[start] = 0;//dist[i] :=　start->iまでの最短距離
    priority_queue<pair<lli, lli>, vector<pair<lli, lli> >, greater<pair<lli, lli> > >  que;
    que.push(make_pair(0, start));
    while(!que.empty()){
        lli cost, w;//今までにかかった時間 現在の頂点
        cost = que.top().first, w = que.top().second;
        que.pop();
        if(dist[w] < cost) continue;
        for (auto tmp : G[w]){
            lli v = tmp.first, time = tmp.second;//隣接する頂点 その頂点まで行く時間
            if(dist[v] > dist[w] + time){//u->v
                dist[v] = dist[w] + time;
                que.push(make_pair(dist[v], v));
            }
        }
    }
    return dist;
}

lli n, m, s,t;
lli u[100010], v[100010], a[100010],b[100010];

signed main(void){

    cin >> n >> m >> s>> t;
    s--;t--;
    rep(i, m){
        cin >> u[i]>>v[i]>>a[i]>>b[i];
        u[i]--, v[i]--;
        G[u[i]].pb(mp(v[i], a[i]));
        G[v[i]].pb(mp(u[i], a[i]));
    }
    auto dist1 = dijkstra(s);
    rep(i, MAX_N){
        G[i].clear();
    }
    rep(i, m){
        G[u[i]].pb(mp(v[i], b[i]));
        G[v[i]].pb(mp(u[i], b[i]));
    }
    auto dist2 = dijkstra(t);

    /*s->i->tと経由する場合のコストを出す*/

    vector<lli> o;
    rep(i, n)o.push_back(dist1[i]+dist2[i]);

    for(lli i=n-2;i>=0;i--){
    	o[i] = min(o[i],o[i+1]);
    }
    for(lli i=0;i<n;i++){
    	lli ans = 1e15 - o[i];
    	cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 20288
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

set <int> S;
vector <int> g[N];
int n, m, k, mod;
int a[N], dp1[N], dp2[N];
string ss;

void dfs1(int v, int p){
	int list = 1;
	for (auto to: g[v]){
		if (to != p){
			dfs1(to, v);
			list = 0;
		}
	}
	if (list){
		dp1[v] = 1;
		return;
	}
	dp1[v] = 1;
	for (auto to: g[v]){
		if (to != p){
			(dp1[v] *= dp1[to] + 1) %= mod; 
		}
	}
}

void dfs2(int v, int p){
	if (p == -1){
		dp2[v] = 1;
	}
		int pp = 1;
		for (auto to: g[v]){
			if (to != p){
				dp2[to] = pp;				
				(pp *= (dp1[to] + 1)) %= mod;
			}
		}
		reverse(all(g[v]));
		pp = 1;
		for (auto to: g[v]){
			if (to != p){
				(dp2[to] *= pp) %= mod;				
				(pp *= (dp1[to] + 1)) %= mod;
				(dp2[to] *= dp2[v]) %= mod;
				dp2[to]++;
				dp2[to] %= mod;
			}
		}
	for (auto to: g[v]){
		if (to != p){
			dfs2(to, v);
		}
	}
}

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> mod;
//	mod = 1e9;
	for (int i = 0; i < n - 1; i++){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs1(1, -1);
	dfs2(1, -1);
	int ans = 0;
	for (int i = 1; i <= n; i++){
		cout << (dp2[i] * dp1[i]) % mod << endl;
		//cout << i << " >> " << dp2[i]  << " " <<  dp1[i] << "\n";
	}
	//cout << ans;
	return 0;
}












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

#include <algorithm>

#include <iomanip>

using namespace std;

int A, B, H, M;

int main()
{
	cin >> A;
	cin >> B;
	cin >> H;
	cin >> M;

	double ans;

	double l = H * 30.0 + M*0.5;
	double s = M * 6.0;

	double r = abs(l - s)/ 180.0 * M_PI;

	if (r == 0.0) {
		ans = abs(A-B);
	}
	else {
		double a = A*sin( r);
		double b = A * cos(r) - B;

		ans = sqrt(a*a + b*b);
	}

	cout << fixed << setprecision(20) << ans << endl;

	return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int x;
    cin >> x;
    if(x==7||x==5||x==3) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int K, S, count;
  cin >> K >> S;
  for(int x = 0; x <= K; x++){
   for(int y = 0; y <= K; y++){
     int z = S - x - y;
     if(0 <= z && z <= K){
      count++; 
     }
       
       
     
   }
  }
  cout << count << endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b;
	cin >> a >> b;
	cout << (a * b % 2 == 0 ? "Even" : "Odd") << endl;
	return 0;
}
 

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
dic = {}
dic["a"] = list(input().rstrip())
dic["b"] = list(input().rstrip())
dic["c"] = list(input().rstrip())
next_ = dic["a"].pop(0)
while len(dic["a"]) >= 0 and len(dic["b"]) >= 0 and len(dic["c"]) >= 0:
    if len(dic[next_]) == 0:
        print(next_.upper())
        sys.exit()
    next_ = dic[next_].pop(0)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    long long a,b,ans;
    char s[15];
    cin>>a>>s;
    b=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0'); 
    ans=a*b/100;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3184
import Control.Applicative ((<$>))
import Control.Monad (forM_)
import Data.List (sort)
import Data.IntMap.Strict
import Data.Vector.Unboxed (Vector)
import Data.Vector.Unboxed.Mutable (IOVector, unsafeRead, unsafeWrite)
import qualified Data.List as L
import qualified Data.IntMap.Strict as M
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV

type Cost   = Int
type Costs  = Vector Cost
type Sorted = IntMap Int
type Flags  = IOVector Bool

main :: IO ()
main = do
    getLine
    inputs <- L.map read . words <$> getLine :: IO [Int]
    flags  <- MV.replicate 10000 True
    forM_ inputs (write False flags)
    cycles <- getCycles inputs flags
    print . sum . L.map (getCost (minimum inputs)) $ cycles
  where
    write v vs i = MV.unsafeWrite vs i v

getCycles :: [Int] -> Flags -> IO [[Int]]
getCycles inputs flags =
    mapM (getCycle costs sorted flags []) inputs
  where
    costs  = V.fromList inputs
    sorted = M.fromList $ zip (sort inputs) [0..]

getCycle :: Costs -> Sorted -> Flags -> [Int] -> Int -> IO [Int]
getCycle costs sorted flags cycle c = do
    isValid <- unsafeRead flags c
    if isValid then
        return cycle
    else do
        unsafeWrite flags c True
        getCycle costs sorted flags (c:cycle) (costs V.! (sorted M.! c))

getCost :: Int -> [Int] -> Int
getCost _ []      = 0
getCost _ (c:[])  = 0
getCost min costs =
    if min `elem` costs then
        sum1
    else
        minimum [sum1, sum2]
  where
    sum1 = sum costs + (n - 2) * mc
    sum2 = sum costs + mc + (n + 1) * min
    n  = length costs
    mc = minimum costs



Measured memory_bytes: 5644
n = gets.to_i
data = n.times.map {gets.strip.split.map(&:to_i)}
#二次元配列を作成する

def is_reachable(current, next_data)
  tc,xc,yc = current
  tn,xn,yn = next_data
  dist = (xc - xn).abs + (yc - yn).abs
  return false if dist > tn - tc
  (dist - (tn - tc)).even?
end

current = [0,0,0]
data.each do |d|
  unless is_reachable(current,d)
    puts 'No'
    exit 0
  end
 current = d
end

puts 'Yes'

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

int main(){
  int M,D;
  cin >> M >> D;
  int ans=0;
  for(int i = 22;i<=D;i++){
    if(M>=(i/10)*(i%10)&&(i/10)>=2&&(i%10)>=2){
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll x; cin >> x;
    string S = to_string(x+1);
    
    int ans = S[0] - '1';
    ans += (S.size()-1) * 9;
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
n,a,b,c = map(int, input().split())
l = [int(input()) for i in range(n)]
y=[0]*n
x=[]
def dfs(n,y,now):
    if now==n:
        z=y.copy()
        x.append(z)
        return
    for i in range(4):
        y[now]=i
        dfs(n,y,now+1)
dfs(n,y,0)
mi=1000000
for i in range(len(x)):
    al,bl,cl=0,0,0
    ac,bc,cc=0,0,0
    for j in range(n):
        if x[i][j]==1:
            al+=l[j]
            ac+=1
        if x[i][j]==2:
            bl+=l[j]
            bc+=1
        if x[i][j]==3:
            cl+=l[j]
            cc+=1
    if ac!=0 and bc!=0 and cc!=0:
        ans=abs(a-al)+abs(b-bl)+abs(c-cl)+10*(ac+bc+cc-3)
        mi=min(mi,ans)
print(mi)


Measured memory_bytes: 12788
n = int(input())
h = list(map(int, input().split()))
a = [-1 for _ in range(n)]
a[0] = h[0]
a[n-1] = h[n-2]
for i in range(1,n-1):
	a[i] = min(h[i-1], h[i])

print(sum(a))

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

using namespace std;

#define endl "\n"
#define pb push_back
#define ar array

typedef long long ll;
typedef string str;

void setIO(string filename = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if ((int)filename.size()) {
        freopen((filename+".in").c_str(), "r", stdin);
        freopen((filename+".out").c_str(), "w", stdout);
    }
}

ll N,W;
ll w[101],v[101];
/* weight/value */
ll dp[101][100001];

int main() {
    setIO();
    cin >> N >> W;
    for(int i=1;i<=N;++i){
        cin >> w[i] >> v[i];
    }
    for(int i=1;i<=N;++i){
        ll weight=w[i], val=v[i];
        for(int j=1;j<=W;++j){
            dp[i][j]=dp[i-1][j];
            if(j>=weight && dp[i-1][j-weight]+val > dp[i][j]){
                dp[i][j] = dp[i-1][j-weight] + val;
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}



Measured memory_bytes: 81700
#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 repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define nil -1
#define mp make_pair
typedef long long ll;
using namespace std;

template <typename T>
inline void output(T a, int p) {
    if(p){
        cout << fixed << setprecision(p)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}
// end of template

class scc_decomposition{
public:
    int V;
    vector<vector<int>> E, rE;
    vector<int> pos, used, cmp;
    scc_decomposition(int v){
        V = v;
        E.resize(v);
        rE.resize(v);
        cmp.resize(v);
        used.resize(v, 0);
    }
    
    void add(int from, int to){
        E[from].push_back(to);
        rE[to].push_back(from);
    }
    
    void dfs(int v){
        used[v] = 1;
        rep(i, E[v].size()){
            if (!used[E[v][i]]) dfs(E[v][i]);
        }
        pos.push_back(v);
    }
    
    void rdfs(int v, int k){
        used[v] = 1;
        cmp[v] = k;
        rep(i, rE[v].size()){
            if (!used[rE[v][i]]) rdfs(rE[v][i], k);
        }
    }
    
    int scc(){
        rep(v, V){
            if (!used[v]) dfs(v);
        }
        used.assign(V, 0);
        int k = 0;
        for (int i = (int)pos.size() - 1; i >= 0; i--) {
            if (!used[pos[i]]) rdfs(pos[i], k++);
        }
        return k; // return the number of sccs
    }
    
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int V, E;
    cin >> V >> E;
    scc_decomposition S(V);
    rep(i, E){
        int s, t;
        cin >> s >> t;
        S.add(s, t);
    }
    int cmp = S.scc();
    int Q;
    cin >> Q;
    rep(i, Q){
        int a, b;
        cin >> a >> b;
        if (S.cmp[a] == S.cmp[b]) {
            cout << 1 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4436
import java.util.*;
class Main{
        final static int MAX = 123456*2;
        static boolean[] prime = new boolean[MAX+1];
        public static void make_prime(){
                for(int i=0;i<=MAX;i++){
                        prime[i] = true;
                }
                prime[1] = false;
                for(int i=2;i*i<=MAX;i++){
                        if(prime[i]){
                                for(int j=i+i;j<=MAX;j+=i){
                                        prime[j] = false;
                                }
                        }
                }
        }

        static Scanner sc = new Scanner(System.in);
        public static void doIt(){
                make_prime();
                while(true){
                        int n = sc.nextInt();
                        if(n==0)break;
                        int ans=0;
                        for(int i=n+1;i<=2*n;i++){
                                if(prime[i])ans++;
                        }
                        System.out.println(ans);
                }
        }
        public static void main(String[] args){
                Main obj = new Main();
                obj.doIt();
        }

}

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

int main(){
 while(true){
  int M, T, P, R;
  cin >> M >> T >> P >> R;

  if(M==0 && T==0 && P==0 && R==0) break;

  int CP[T],  TT[T],  PT[T][P]; //正解数、時間計、ペナルティ
  for(int i=0; i<T; i++){
   CP[i] = TT[i] = 0;
   for(int j=0; j<P; j++){
    PT[i][j] = 0;
   }
  }

  for(int i=0; i<R; i++){ //各チームの正解数、時間計を求める
   int m, t, p, j;
   cin >> m >> t >> p >> j;
   
   if(j==0){ //正解
    CP[t-1]++;
    TT[t-1] += (m+PT[t-1][p-1]);
   }else{ //不正解
    PT[t-1][p-1] += 20;
   }
  }

   int t_now, t_pre = -1; //今のチーム、1つ前のチーム
   bool flag[50]; //処理済みフラグ
   for(int i=0; i<T; i++){
    flag[i] = false;
   }
   
   for(int i=0; i<T; i++){
    t_now = -1;
    for(int j=0; j<T; j++){ //今のチームを求める
     if(flag[j]) continue;
     if(t_now==-1){
      t_now = j;
     }else{
      if(CP[j]>CP[t_now] || (CP[j]==CP[t_now] && TT[j]<=TT[t_now])){
       t_now = j;
      }
     }
    }

    if(t_pre!=-1){
     if(CP[t_now]==CP[t_pre] && TT[t_now]==TT[t_pre]){
      cout << '=';
     }else{
      cout << ',';
     }
    }
    cout<<t_now+1;

    flag[t_now] = true;
    t_pre = t_now;
   }
   cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;

string s, a;
int res, t;

int main() {
	a = "AGCT";
	cin >> s;
	for (int i = 0; i < s.size(); ++i) {
		bool f = false;
		for (int j = 0; j < 4; ++j) {
			if (s[i] == a[j]) {
				f = true;
				++t;
			}
		}
		if (f) {
			res = max(res, t);
		}
		else {
			t = 0;
		}
	}
	cout << res << endl;
	return 0;
}

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

int main() {

  int N ;
  string S ; 
  cin >> N ; 
  cin >> S ; 
  int T = S.size() ; 


  
  for( int i = 0 ; i < T ; i++  ){
    char A = S.at(i) ; 
    int X =  A - 'A' ; 
    X = (N+X)%26 ; 
    
    cout <<(char)('A' + X ) ; //int からcharへ
  }
 
}



Measured memory_bytes: 3588
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  // 1行目がinput[0], 2行目がinput[1], …に入る
  var inputs = input[0].split(" ");
  var n = Number(inputs[0]);
  var r = Number(inputs[1]);
  if (n >= 10) {
    console.log(r);
  } else {
    console.log(r + 100 * (10 - n));
  }
}
// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(`2 2919`);
// Main(['22 3051']);


Measured memory_bytes: 7372
/*
	created by scarlyw
*/
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cmath>
#include <cctype>
#include <vector>
#include <set>
#include <queue>
#include <ctime>
#include <deque>
#include <iomanip> 
#include <iterator>
#include <map>

inline char read() {
	static const int IN_LEN = 1024 * 1024;
	static char buf[IN_LEN], *s, *t;
	if (s == t) {
		t = (s = buf) + fread(buf, 1, IN_LEN, stdin);
		if (s == t) return -1;
	}
	return *s++;
}

// /*
template<class T>
inline void R(T &x) {
	static char c;
	static bool iosig;
	for (c = read(), iosig = false; !isdigit(c); c = read()) {
		if (c == -1) return ;
		if (c == '-') iosig = true;	
	}
	for (x = 0; isdigit(c); c = read()) 
		x = ((x << 2) + x << 1) + (c ^ '0');
	if (iosig) x = -x;
}
//*/

const int OUT_LEN = 1024 * 1024;
char obuf[OUT_LEN], *oh = obuf;
inline void write_char(char c) {
	if (oh == obuf + OUT_LEN) fwrite(obuf, 1, OUT_LEN, stdout), oh = obuf;
	*oh++ = c;
}

template<class T>
inline void W(T x) {
	static int buf[30], cnt;
	if (x == 0) write_char('0');
	else {
		if (x < 0) write_char('-'), x = -x;
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 + 48;
		while (cnt) write_char(buf[cnt--]);
	}
}

inline void flush() {
	fwrite(obuf, 1, oh - obuf, stdout);
}

/*
template<class T>
inline void R(T &x) {
 	static char c;
	static bool iosig;
	for (c = getchar(), iosig = false; !isdigit(c); c = getchar()) {
		if (c == -1) return ;
		if (c == '-') iosig = true;	
	}
	for (x = 0; isdigit(c); c = getchar()) 
		x = ((x << 2) + x << 1) + (c ^ '0');
	if (iosig) x = -x;
}
// */

const int MAXM = 8000 + 33;
const int MAXN = 4000 + 33;
const int MAXX = 2000 + 5;
const int mod = 1000000000 + 7;
const int MAXC = 200000 + 11;

int n;
int start[MAXN][MAXN], fac[MAXM], inv_fac[MAXM], a[MAXC], b[MAXC];
int dp[MAXN][MAXN];

inline int mod_pow(int a, int b) {
	int ans = 1;
	for (; b; b >>= 1, a = (long long)a * a % mod)
		if (b & 1) ans = (long long)ans * a % mod;
	return ans;
}

inline int c(int n, int m) {
	return (n < m) ? (0) : ((long long)fac[n]
		 * inv_fac[m] % mod * inv_fac[n - m] % mod);
}

inline void add(int &x, int t) {
	x += t, (x >= mod) ? (x -= mod) : x;
}

inline void solve() {
	R(n), fac[0] = 1;
	for (int i = 1; i <= n; ++i) 
		R(a[i]), R(b[i]), start[MAXX - a[i]][MAXX - b[i]]++;
	
	for (int i = 1; i < MAXM; ++i) fac[i] = (long long)fac[i - 1] * i % mod;
	inv_fac[MAXM - 1] = mod_pow(fac[MAXM - 1], mod - 2);
	for (int i = MAXM - 2; i >= 0; --i) 
		inv_fac[i] = (long long)inv_fac[i + 1] * (i + 1) % mod; 
	for (int i = 1; i < MAXN; ++i)
		for (int j = 1; j < MAXN; ++j)
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] + start[i][j]) % mod;
	int ans = 0;
	for (int i = 1; i <= n; ++i) add(ans, dp[MAXX + a[i]][MAXX + b[i]]);
	for (int i = 1; i <= n; ++i) 
		add(ans, mod - c(a[i] + a[i] + b[i] + b[i], a[i] + a[i]));
	std::cout << ((long long)ans * (mod + 1) / 2) % mod;
}

int main() {
//	freopen("in.in", "r", stdin);
	solve();
	return 0;
}

Measured memory_bytes: 101632
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
long long n,i,k,ans;
struct nyh{
	long long x,y,z;
}o[105];
double ans2;
long long read(){
	long long xx=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
		ch=getchar();
	while(ch>='0'&&ch<='9'){
		xx=xx*10+ch-'0';
		ch=getchar();
	}
	return xx;
}
long long pus(long long xx,int flagg){
	if(xx>=10)
		pus(xx/10,0);
	putchar(xx%10+'0');
	if(flagg==1)
		putchar(' ');
	if(flagg==2)
		putchar('\n');
}
int ss(long long j,long long u,long long v){
	if(j>n){
		ans=max(ans,u*u+v*v);
		return 0;
	}
	if(j<=10||u*u+v*v<=(u+o[j].x)*(u+o[j].x)+(v+o[j].y)*(v+o[j].y))
		ss(j+1,u+o[j].x,v+o[j].y);
	if(j<=10||u*u+v*v>(u+o[j].x)*(u+o[j].x)+(v+o[j].y)*(v+o[j].y))
		ss(j+1,u,v);
}
bool cmp(nyh u,nyh v){
	return u.z<v.z;
}
int main(){
	n=read();
	for(i=1;i<=n;i++)
		scanf("%lld%lld",&o[i].x,&o[i].y);
	for(i=1;i<=1000;i++){
		srand(i*i*123+i*456);
		for(k=1;k<=n;k++)
			o[k].z=rand();
		sort(o+1,o+n+1,cmp);
		ss(1,0,0);
	}
	ans2=sqrt(ans);
	printf("%.13lf\n",ans2);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n ;
    string s;
    cin >> n;
    cin.ignore();
    getline(cin, s);
    if(s.length() > n){
        cout << s.substr(0, n) << "...";
    }else cout << s;
    
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)

{


         int a,b;


         scanf("%d %d",&a,&b);


         if(a<b)


         {


                     printf("a < b\n");


         }


         if(a>b)


         {


                     printf("a > b\n");


         }


         if(a==b)


         {


                     printf("a == b\n");


         }


         return 0;


}

Measured memory_bytes: 1008
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	string S;
	int N, K;
	cin >> N >> K >> S;
	S[K-1] -= ('A' - 'a');
	cout << S << endl;


}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,a,b,c,d;
  scanf("%d",&x);
  
  d = x%10;x/=10;
  c = x%10;x/=10;
  b = x%10;x/=10;
  a = x%10;
  
  if(a+b+c+d==7){printf("%d+%d+%d+%d=7",a,b,c,d);return 0;}
  if(a+b+c-d==7){printf("%d+%d+%d-%d=7",a,b,c,d);return 0;}
  if(a+b-c+d==7){printf("%d+%d-%d+%d=7",a,b,c,d);return 0;}
  if(a-b+c+d==7){printf("%d-%d+%d+%d=7",a,b,c,d);return 0;}
  if(a+b-c-d==7){printf("%d+%d-%d-%d=7",a,b,c,d);return 0;}
  if(a-b-c+d==7){printf("%d-%d-%d+%d=7",a,b,c,d);return 0;}
  if(a-b+c-d==7){printf("%d-%d+%d-%d=7",a,b,c,d);return 0;}
  if(a-b-c-d==7){printf("%d-%d-%d-%d=7",a,b,c,d);return 0;}

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n, t; cin >> n >> t;
	vector<int>tn(n);
	for (auto&& x : tn)cin >> x;

	int ans = t;
	for (int i = 0; i < n - 1; i++) {
		ans += min(t, tn[i + 1] - tn[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
while True:
    t=[]
    n=int(input())
    if n==0:
        break
    else:
        m=input().strip().split()
        k=[int(i) for i in m]
        x=sum(k)/n
        for i in range(n):
            if k[i]<=x:
                t.append(k[i])
            else:
                pass
        print(len(t))
   


Measured memory_bytes: 6808
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace abc94_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            if(input[0] <= input[2] && input[2] <=input[0]+input[1])
            {
                WriteLine("YES");
            }
            else
            {
                WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
    int i=0;
    for(int j=0; j<k; j++) {
        llong s=0;
        while(s+T[i] <= P) {
            s += T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve() {
    llong left=0;
    llong right=100000 * 10000;
    llong mid;
    while(right>1+left) {
        mid = (left + right)/2;
        int v = check(mid);
        if(v>=n) right=mid;
        else left=mid;
    }
    
    return right;
}

int main() {
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3832
#include <vector>
#include <algorithm>
#include <limits.h>
#include <iostream>
#include <set>
#include <cmath>
#include <queue>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#define MOD 1000000007
typedef  long long int  lli;
using namespace std;
int f(int n)
{
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
           if(n/i == i) cnt++;
           else cnt+=2;
        }
    }
    return cnt;
}
int main() {
    int n; cin>>n;
    lli ans=0;
    int dp[n+1]; memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
        {
            dp[j]++;
        }
        ans+=((lli)dp[i]*i);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 42724
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] s = new int[N];

        int sum = 0;
        for (int i = 0; i < N; i++) {
            s[i] = sc.nextInt();
            sum += s[i];
        }

        if (sum % 10 != 0) {
            System.out.println(sum);
            return;
        }

        Arrays.sort(s);
        for (int i = 0; i < N; i++) {
            int cand = sum - s[i];
            if ((cand % 10) != 0) {
                System.out.println(cand);
                return;
            }
        }

        System.out.println(0);
        return;
    }

}

Measured memory_bytes: 22736
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= b) P(a);
  else P(a - 1);
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	if((a*b)%2==0){cout<<"No";}
	else{cout<<"Yes";}




	cout<<endl;
} 


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

#define ll long long
int main()
{
	string s,ans="";
	cin>>s;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]=='0')
			ans=ans+"0";
		else if(s[i]=='1')
			ans=ans+"1";
		else
		{
			if(ans.size()>0)
				ans.pop_back();
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int i, j, t;
  int mt[10];

  for(i = 0 ; i <= 9 ; i++)
    {
      scanf("%d", &mt[i]);
    }  

  i = 0;
  while(i <= 8)
    {
      j = 9;
      while(j >= i+1 )
	{
	  if(mt[j] < mt[j-1])
	    {
	      t = mt[j];
	      mt[j] = mt[j-1];
	      mt[j-1] = t;
	    }
	  j = j - 1;
	}
      i = i + 1;
    }
  printf("%d\n%d\n%d\n",mt[9],mt[8],mt[7]);
  return 0;
}

Measured memory_bytes: 600
// Substring

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func diffChars(s, t []rune) int {
	c := 0
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			c++
		}
	}
	return c
}

func doIt(s, t string) int {
	m := 99999999999
	for i := 0; i <= len(s)-len(t); i++ {
		ss := s[i : i+len(t)]
		d := diffChars([]rune(ss), []rune(t))
		if d < m {
			m = d
		}
	}

	return m
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	t := sc.Text()
	return strconv.Atoi(t)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	s := nextString(sc)
	t := nextString(sc)

	r := doIt(s, t)
	fmt.Println(r)
}


Measured memory_bytes: 3860
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	c := 0
	for i := 1; i <= n; i++ {
		switch len(strconv.Itoa(i)) {
		case 1:
			c++
		case 3:
			c++
		case 5:
			c++
		}
	}
	fmt.Println(c)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int K;
ll C[2222][2222];
ll pw[2222];
ll f[2222][2222];
ll sum[2222][2222];

void solve(int casi){
	cin>>n>>K;
	C[0][0] = C[1][0] = C[1][1] = 1;
	for(int i = 2; i <= 2000; i++){
		C[i][0] = C[i][i] = 1;
		for(int j = 1; j < i; j++)
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MM;
	}
	pw[0] = 1;
	for(int i = 1; i <= 2000; i++){
		pw[i] = (2 * pw[i-1]) % MM;
	}
	ll ans = 0;//pw[n-K-1];
	f[0][0] = 1;
	for(int i = 0; i <= n; i++)
		sum[0][i] = 1;
	for(int i = 1; i < K; i++){
		for(int j = 0; j <= n - i; j++){
			f[i][j] = sum[i-1][j+1];
		}
		sum[i][0] = f[i][0];
		for(int j = 1; j <= n - i; j++)
			sum[i][j] = (sum[i][j-1] + f[i][j]) % MM;
	}
	for(int i = 0; i <= n - K; i++)
		ans = (ans + f[K-1][i]) % MM;
	cout<<((K!=n)?(ans * pw[n-K-1] % MM):ans)<<endl;
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}
// ??????????



Measured memory_bytes: 70144
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

int find_i(string s, char c){
  auto itr = find(s.begin(), s.end(), c);
  size_t index = distance(s.begin(), itr);
  return (int)index;
}

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

  string res = s.substr(0);
  REP(i, s.size()-t.size()+1){
    string tmp = s.substr(0);
    REP(j,t.size()){
      if(s[i+j] != '?' && s[i+j] != t[j]) break;
      tmp[i+j] = t[j];
    }
    if(res.find(t) == -1 || (tmp.find(t) != -1 && tmp < res)){
      res = tmp.substr(0);
    }
  }
  REP(i, s.size()) if(res[i] == '?') res[i] = 'a';

  if(res.find(t) == -1) cout << "UNRESTORABLE\n";
  else cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 -O2 -Wall -Wl,--stack=268435456

#include <bits/stdc++.h>
using namespace std;

typedef long long          ll;
typedef vector<int>        vi;
typedef vector< vi >       vvi;
typedef pair<int, int>     pi;
typedef vector< pi >       vpi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LARGE_INT   1000000007
#define REP(i,a,b) for (int i = (int)(a); i < (int)(b); i++)

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string line;
    int  r, c;
    cin >> r >> c;
    getline(cin, line);
    vi  dp(c+1,0);
    dp[1] = 1;
    REP(i, 0, r) {
        getline(cin, line);
        REP(j, 0, c) {
            //cout << line[j] << " ";
            if (line[j] == '#')   dp[j+1] = 0;
            else                  dp[j+1] = (dp[j+1] + dp[j]) % LARGE_INT;
            //cout << dp[j+1] << " ";
        }
        //cout << endl;
    }
    cout << dp[c];
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0
cand = []

def dfs(s) :
    if s != '' and int(s) > N:
        return
    cand.append(s)
    dfs(s+'3')
    dfs(s+'5')
    dfs(s+'7')

dfs('')
for i in cand:
    if '3' in i and '5' in i and '7' in i:
        ans += 1

print(ans)

Measured memory_bytes: 5224
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    rep(k, K)
    {
        vector<int> B(N, 0);
        rep(i, N)
        {
            int l = max(0, i - A[i]);
            int r = min(N - 1, i + A[i]);
            B[l]++;

            if (r + 1 < N)
            {
                B[r + 1]--;
            }
        }

        A[0] = B[0];
        for (int i = 1; i < N; i++)
        {
            B[i] += B[i - 1];
            A[i] = B[i];
        }

        if (log(N) + 30 < k)
        {
            break;
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << A[i] << " ";
    }

    cout << endl;
}


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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] B = new int[N-1];
    for (int i = 0; i < N-1; i++) {
      B[i] = Integer.parseInt(sc.next());
    }
    
    int sum = B[0];
    for (int i = 1; i < N - 1; i++) {
      if (B[i] > B[i-1]) {
        sum += B[i-1];
      } else {
        sum += B[i];
      }
    }
    sum += B[N-2];
    
    System.out.println(sum);
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int N = scan.nextInt();  //点の個数
	int now_t = 0;
	int now_x = 0;
	int now_y = 0;
	
	int[] t_ = new int[N];
	int[] x_ = new int[N];
	int[] y_ = new int[N];

	for(int i = 0; i < N; i++){
	    t_[i] = scan.nextInt();
	    x_[i] = scan.nextInt();
	    y_[i] = scan.nextInt();
	}

	int flag = 1;
	for(int i = 0; i < N; i++){
	    int len_t = t_[i]-now_t;
	    int len_x = Math.abs(now_x-x_[i]);
	    int len_y = Math.abs(now_y-y_[i]);
	    if(len_t >= len_x+len_y &&
	       (len_t-len_x-len_y) % 2 == 0){
		//移動できる
		now_t = t_[i];
		now_x = x_[i];
		now_y = y_[i];
	    }else{
		flag = -1;
		break;
	    }
	}

	if(flag == 1){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}


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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

void solve(long long X){
    for(ll b=-1000; b <= 1000; b++){
        ll a5 = X + b*b*b*b*b;
        // これが5乗数か？
        for(ll a=-1000; a <= 1000; a++){
            if(a*a*a*a*a == a5){
                cout << a << " " << b << endl;
                return;
            }
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<algorithm>

using namespace std;

#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
typedef long long ll;
////////////////
int const N = 1e5 + 41;
int const MOD = 1e9 + 7;
ll const INF = 4e18;

int n;
ll a[N], A, B;
int dp[N], pref[N];


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

void read(){
	scanf("%d",&n);
	scanf("%lld %lld",&A,&B);
	fi(1, n+1){
		scanf("%lld",&a[i]);
	}
	++n;
	a[n] = INF;
	a[0] = -a[n];
}

void checkZero(){
	fi(2, n+1){
		if(a[i] - a[i-2] < A){
			printf("0\n");
			exit(0);
		}
	}
}

int getPref(int l, int r){
	if(l > r){
		return 0;
	}
	int ret = pref[r] - (l > 0 ? pref[l-1] : 0);
	while(ret < 0){
		ret += MOD;
	}
	return ret;
}

void solve(){
	if(A > B){
		swap(A, B);
	}
	checkZero();
	dp[0] = pref[0] = 1;

	int posB = 0;
	int posA = 0;

	fi(1, n+1){
		while(a[i] - a[posB+1] >= B){
			++posB;
		} 
		dp[i] = getPref(posA, posB);
		pref[i] = dp[i];
		add(pref[i], pref[i-1]);
		if(a[i] - a[i-1] < A){
			posA = i - 1;
		}
	}

	printf("%d\n",dp[n]);
	
}

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

int main(){
	prepare();
	read();
	solve();





	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
typedef pair <int,int> pii;
typedef pair <int,LL> piL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005;
int n;
int L[N],R[N];
int idL[N],idR[N];
int del[N];
int p;
LL ans;
bool cmpL(int a,int b){
	return L[a]>L[b];
}
bool cmpR(int a,int b){
	return R[a]<R[b];
}
void Go(int x){
	if (L[x]<=p&&p<=R[x])
		return;
	if (p>R[x])
		ans+=p-R[x],p=R[x];
	else
		ans+=L[x]-p,p=L[x];
}
LL calc(int k){
	ans=p=0;
	clr(del);
	int lp=1,rp=1;
	For(i,1,n){
		if ((i&1)==k)
			del[idR[rp]]=1,Go(idR[rp]);
		else
			del[idL[lp]]=1,Go(idL[lp]);
		while (del[idL[lp]])
			lp++;
		while (del[idR[rp]])
			rp++;
	}
	ans+=abs(p);
	return ans;
}
int main(){
	n=read();
	For(i,1,n)
		L[i]=read(),R[i]=read();
	For(i,1,n)
		idL[i]=idR[i]=i;
	sort(idL+1,idL+n+1,cmpL);
	sort(idR+1,idR+n+1,cmpR);
	cout<<max(calc(0),calc(1))<<endl;
	return 0;
}

Measured memory_bytes: 2176
import sys
k=int(input())
if k<=9:
    for i in range(1,k+1):
        print(i)
    sys.exit()
for i in range(1,9):
    print(i)
count=8
s=0
lst=[]
for i in range(1,17):
    for j in range(1,1000):
        a=j*(10**i)-1
        b=list(str(a))
        c=0
        for u in b:
            c+=int(u)
        if (10**i)*c>=a:
            lst.append(a)
            count+=1
        else:
            break
lst.sort()
s=1
while s<len(lst):
    if lst[s]==lst[s-1]:
        lst.pop(s)
    else:
        s+=1
for i in range(k-8):
    print(lst[i])

Measured memory_bytes: 39280
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;
typedef unsigned int UINT;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	int ans;
	int n;
	cin >> n;
	ans = 3 * n * n;




	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

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

int main(void) {
    int n;
    cin >> n;
 
    vector<int> p;
    int tmp;
    for (int i = 0; i < n; i++) {
      cin >> tmp;
      p.push_back(tmp);
    }
    sort(p.begin(), p.end());
    cout << p[n/2] - p[n/2-1] << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    string s;
    cin >> s;
    for(i=0;i<3;i++){
        if(s[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
x, y = map(int, input().split())
if 0 <= x <= y:
  r = y-x
elif x <= y <= 0:
  r = y-x
elif x <= 0 <= y:
  r = 1+abs(x+y)
elif y <= 0 <= x:
  r = 1+abs(x+y)
elif 0 <= y < x:
  r = 2+x-y
elif y < x <= 0:
  r = 2+x-y
else:
  r = -1
print(r)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll h,w;
  cin>>h>>w;
  ll ans=h*w;
  if(h==1 || w==1){
    cout<<1<<'\n';
    return(0);
  }
  cout<<(h*w%2==0 ? h*w/2 : h*w/2+1);
  return(0);
}


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


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    cout << c << endl;
  }else if(a==c){
    cout << b << endl;
  }else{
    cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import deque
N,M = map(int,input().split())
g = [[] for _ in range(0,N+1)]
e = []
for i in range(0,M):
    a,b,t = map(int,input().split())
    g[a].append((b,t))
    g[b].append((a,t))
    e.append((a,b,t))

d = [[float("inf") for _ in range(0,N+1)]for _ in range(0,N+1)]
def dijkstra(s):
    d[s][s] = 0
    queue = deque([[s,g[s]]])
    while queue:
        start,edge = queue.popleft()
        for to,cost in edge:
            if d[s][to] > d[s][start] + cost:
                d[s][to] = d[s][start] + cost
                queue.append((to,g[to]))
for i in range(1,N+1):
    dijkstra(i)

ans = [1 for _ in range(0,M)]
for i in range(1,N+1):
    j = 0
    for a,b,t in e:
        if d[i][a] + t == d[i][b]:
            ans[j] = 0
        j += 1
print(sum(ans))


Measured memory_bytes: 4084
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#define ll long long
 
using namespace std;
map<ll,ll>dp;
const ll mod=1e9+7;
ll solve(ll n)
{
  if(dp[n])
    return dp[n];
  else
    return dp[n]=(solve(n/2)%mod+solve((n-1)/2)%mod+solve((n-2)/2)%mod)%mod;
}
int main()
{
   ll n;
   while(~scanf("%lld",&n))
         {
            dp[0]=1;
            dp[1]=2;
             printf("%lld\n",solve(n));
         }
         return 0;
}

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

int main()
{
  int n;
  cin >> n;
  
  long long th = 1e18;
  long long res = -1;
  long long a[n];
  REP(i, n)
  {
    cin >> a[i];
    if(a[i] == 0)
    {
      res = 0;
    }
  }
  
  if(res == 0)
  {
    cout << res << endl;
  }
  else
  {
    res = 1;
    REP(i, n)
    {
      if(res >= LONG_MAX / a[i])
      {
        cout << "-1" << endl;
        return 0;    
      }
      res *= a[i];
      if(res > th)
      {
        cout << "-1" << endl;
        return 0;
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 4376