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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
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;}
int mypow(int x, int n, int 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;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){

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

for(int i = 0; i< b; i++){
	scanf("%d", &c);
   a -=c;
 }
 

 if(a <= 0) printf("Yes");
  else printf("No");
 
 return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]=='?') s[i]='D';
	}
	cout<<s;
}

Measured memory_bytes: 3772
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){

    int k,n;

    cin >> k >> n ;

    int a[n]={};

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

    int s[n] = {};

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

    s[n-1] = k-a[n-1]+a[0];

    int m=0;

    for(int i=0;i<n;i++) m = max(m,s[i]);

    cout << k-m << endl;

}

Measured memory_bytes: 1792
void main() {
  problem();
}

void problem() {
  const N = scan!long;
  const S = scan;

  long solve() {
    long ans;

    const totalR = S.count('R');
    const totalG = S.count('G');
    const totalB = S.count('B');

    long[] R = new long[N];
    long[] G = new long[N];
    long[] B = new long[N];

    int countR, countG, countB;
    foreach(i; 0..N) {
      R[i] = totalR - countR;
      G[i] = totalG - countG;
      B[i] = totalB - countB;
      if (S[i] == 'R') countR++;
      if (S[i] == 'G') countG++;
      if (S[i] == 'B') countB++;
    }
    
    long[][char] RGB;
    RGB['R'] = R;
    RGB['G'] = G;
    RGB['B'] = B;

    char[][char] OTHERS;
    OTHERS['R'] = ['G', 'B'];
    OTHERS['G'] = ['R', 'B'];
    OTHERS['B'] = ['R', 'G'];

    foreach(i; 0..N-2) {
      const c1 = S[i];
      foreach(j; i+1..N-1) {
        const spread = j - i;
        const c2 = S[j];
        if (c1 == c2) continue;

        const others = OTHERS[c1];
        const c3 = others[0] == c2 ? others[1] : others[0];
        // [c1, c2, c3].deb;

        RGB[c3][j+1].deb;
        ans += RGB[c3][j+1];
        if (j + spread < N && S[j + spread] == c3) {
          [i, j, j + spread].deb;
          [S[i], S[j], S[j + spread]].deb;
          ans--;
        }
      }
    }

    return ans;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    vector<int>res(1000000);

    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                res[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }

    rep2(i,1,n)cout<<res[i]<<endl;
}


Measured memory_bytes: 7096
s = input()
ans = ''
for i in range(1 << (len(s) - 1)):
    ans += s[0]
    for j in range(len(s) - 1):
      if i >> j & 1:
        ans += ' '
      ans += s[j+1]
    ans += ' '
print(sum(map(int, ans.split())))

Measured memory_bytes: 9196
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

struct Combination{
    vector<long long> _fac,_finv,_inv;
    const int m = MOD;

    Combination(int sz) : _fac(sz),_finv(sz),_inv(sz){
        _fac[0] = _fac[1] = 1;
        _finv[0] = _finv[1] = 1;
        _inv[1] = 1;
        for(int i = 2; i <= sz; i++){
            _fac[i] = _fac[i-1]*i%m;
            _inv[i] = m-_inv[m%i]*(m/i)%m;
            _finv[i] = _finv[i-1]*_inv[i]%m;
        }
    }

    inline long long fac(int n){return _fac[n];}
    inline long long inv(int n){return _inv[n];}
    inline long long finv(int n){return _finv[n];}

    long long comb(int n,int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return _fac[n]*(_finv[k]*_finv[n-k]%m)%m;
    }
};


int main(){
    int x,y; cin >> x >> y;
    if(x > 2*y || y > 2*x || (2*y-x)%3!=0 || (2*x-y)%3!=0){
        cout << 0 << endl;
        return 0;
    }
    int a = (2*y-x)/3,b = (2*x-y)/3;
    Combination C(2000000);
    cout << C.comb(a+b,a) << endl;
}

    



Measured memory_bytes: 47104
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    if 0 in a:
        print(0)
        return
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 82628
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int n, k;

	cin >> n >> k;
	long long ans = k;
	for (int i = 1; i < n; i++) {
		ans *= k - 1;
	}
	cout << ans << endl;
	return 0;
}


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

int main(void){
   int S, h, m, s;
   cin >> S;
   h=S/3600;
   m=(S-3600*h)/60;
   s=S%60;

   cout << h;
   cout << ":";
   cout << m;
   cout << ":";
   cout << s;
   cout << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> dam(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> dam[i];
  }
  std::vector<int> yama(n);

  yama[0] = 0;
  for (int i = 0; i < n; ++i) {
    yama[0] += (i % 2 == 0) ? dam[i] : -1 * dam[i];
  }

  for (int i = 1; i < n; ++i) {
    yama[i] = (dam[i - 1] - yama[i - 1] / 2) * 2;
  }

  for (int i = 0; i < n; ++i) {
    std::cout << yama[i] << " ";
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string a;
    cin >> a;
    int n = a.length();
    for(int i = 0; i < n; i++)
    {
        cout << 'x';
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    S = input()

    countlist = [0]
    if S[0] == "0":
        countlist.append(0)
    last_char = S[0]
    for s in S:
        if s == last_char:
            countlist[-1] += 1
        else:
            countlist.append(1)
            last_char = s

    if S[-1] == "0":
        countlist.append(0)

    l, r = 0, K * 2 + 1
    maxhito = last_count = sum(countlist[l:r])
    while True:
        l, r = l + 2, r + 2
        if len(countlist) < r:
            break
        count = last_count - (countlist[l - 1] + countlist[l - 2]) + (countlist[r - 1] + countlist[r - 2])
        maxhito = max(maxhito, count)
        last_count = count
    print(maxhito)


main()

Measured memory_bytes: 4596
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	for (int i = 1; i <= 9; i++) {
		for(int j = 1; j <= 9; j++) {
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3036
#include <stdio.h>

int main(void) {
	int count[100] = {0};
	int mode_n = 0;
	int data;
	int i;
	while (scanf("%d", &data) != EOF)
		count[data-1]++;
	for (i = 0; i < 100; i++)
		if( mode_n < count[i])
			mode_n = count[i];
	for (i = 0; i < 100; i++)
		if( mode_n == count[i])
			printf("%d\n", i + 1);
	return 0;
}

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

int keta(int n){
  int a=0;
  while (n!=0){
    a+=n%10;
    n/=10;
  }
return a;
}

int main() {
 int n,a,b;
  cin >>n >> a >> b;
  int ans=0;
  for (int i=1;i<n+1;i++){
    int t=keta(i);
    if (t>=a && t<=b) ans=ans+i;
  }
  cout << ans << endl;
}

  

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

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

  for (int i = 1; i <= n; i ++) {
    int t = i;
    if (t % 3 == 0) {
      cout << " " << i;
      continue;
    }
    while (t > 0) {
      if (t % 10 == 3) {
        cout << " " << i;
        break;
      }
      t /= 10;
    }
  }

  cout << endl;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
        for (int i = 1; i < b; i += a - 1) {
            c++;
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 21844
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
mod=10**9+7
b=0
f=0
for i in range(N):
    for j in range(i+1,N):
        if A[i]>A[j]:
            #print(i,",",j)
            f+=1
           
            
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):
        if A[i]>A[j]:
            b+=1

ans=f*((K+1)*K//2)+b*((K-1)*K//2)
ans%=mod
print(ans)

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

int count(string A, string B){
 int countnum = 0;
  for(int i = 0; i < A.length(); i++){
    char a = A[i];
    int flag = 0;
    for(int k = 0; k < i; k++){
      if(A[k] == a) flag = 1;
    }
    if(flag == 0){
      for(int j = 0; j < B.length(); j++){
       if(a == B[j]){
        countnum++;
         break;
       }
      }
    }
  }
  
  return countnum;
}

int main(void){
  int N;
  string S;
  cin >> N >> S;
  int max = 0;
  for(int i = 1; i < N - 1; i++){
    string A = S.substr(0, i);
    string B = S.substr(i , N);
    int t = count(A, B);
    //cout << A << " " << B << " " << t << endl;
    if(t > max) max = t;
  }
  cout << max;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;

void solve()
{
    int s,w;
    cin >> s >> w;
    if(s<=w)
        cout << "unsafe\n";
    else
        cout << "safe\n";


}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T-- > 0)
        solve();

}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    string s;
    cin >> s;
    map <char, ll> m;
    char c;
    for(auto x : s)
    {
        if(m.find(x) == m.end())
            m[x] = 1;
        else
            m[x]++;
        c = x;
    }
    cout << (m.size() == 2 && m[c] == 2 ? "Yes" : "No") << endl;
    return 0;
}

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

const ll mod = 1000000007;

int main() {
    int N, K; cin >> N >> K;
    vector<ll> S;
    vector<ll> F;
    vector<ll> A(N);
    rep(i, N){
        cin >> A[i];
        if(A[i] >= 0){
            S.push_back(A[i]);
        } else {
            F.push_back(A[i]);
        }
    }
    sort(A.begin(), A.end(), [](ll x, ll y){
        return abs(x) < abs(y);
    });
    sort(S.begin(), S.end());
    sort(F.rbegin(), F.rend());

    ll ans = 1;
    int s = S.size();
    if(K%2 == 1 && s == 0){
        for (int i = 0; i < K; i++){
            ans *= A[i];
            ans %= mod;
        }
    } else if(N == K){
        for (int i = 0; i < K; i++){
            ans *= A[i];
            ans %= mod;
        }
    } else {
        if(K%2 == 1){
            ans *= S.back(); S.pop_back();
            ans %= mod;
        }

        vector<ll> X;
        while(S.size() >= 2){
            ll x = S.back(); S.pop_back();
            x *= S.back(); S.pop_back();
            X.push_back(x);
        }
        while(F.size() >= 2){
            ll x = F.back(); F.pop_back();
            x *= F.back(); F.pop_back();
            X.push_back(x);
        }
        sort(X.rbegin(), X.rend());
        for (int i = 0; i < K/2; i++){
            X[i] %= mod;
            ans *= X[i];
            ans %= mod;
        }

    }
    if(ans < 0){
        ans += mod;
    }
    cout << ans << endl;


    return 0;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int e = a + c;
    int f = a + d;
    int g = b + c;
    int h = b + d;
    vector<int> arr{e,f,g,h};
    int min =  *min_element(arr.begin(), arr.end());
    cout << min << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;
 
void Main()
{
	int N;
    int M;
  
  	cin >> N;
    cin >> M;
  
    int A[N];
    int B[N];
    int max;
    double S = 0;
  
    int count = 0;
  
    for(int i = 0; i < N; i++){
      cin >> A[i];
      S += A[i];
    }
 
  for(int k = 0; k < M; k++){
    max = 0;
    for(int i = 0; i < N; i++){
      
      if(max < A[i] && k == 0)
        max = A[i];
      
      if(k != 0){
        if(max < A[i] && A[i] < B[k - 1])
          max = A[i];
      }
    }
    B[k] = max;
  }
      
  
    for(int i = 0; i < M; i++){
      if(B[i] >= (S / (4 * M))){
        count++;
      }
    }
  
  if(count == M)
    printf("Yes");
  
  else
    printf("No");
  
	
	
}
 
int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

bool isprime(int x)
{
  if(x == 2) return true;
  if(x == 1 || x%2 == 0) return false;
  for(int i=3; i<=sqrt(x); i+=2){
    if(x%i == 0) return false;
  }
  return true;
}

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

  int cnt = 0;
  rep(i, n){
    int a; cin >> a;
    if(isprime(a)) cnt++;
  }
  
  cout << cnt << endl;

  return 0;
}




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

int main(){
	int N;
	cin >> N;
	vector<long long> a(N);
	for(auto &i:a)cin >> i;
	long long ans=0;
	long long count;
	
	do{
		count=0;
		for(int i=0;i<N;i++){
			long long t=a[i]/N;
			count+=t;
			a[i]-=N*t;
			a[i]-=t;
		}
		for(int i=0;i<N;i++)a[i]+=count;
		ans+=count;
	}while(count>0);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
#define INF 99999999

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef unordered_map<int,Edges> Graph;

void shortestPath(Graph &g, int s,
    unordered_map<int,Weight> &dist, unordered_map<int,int> &prev) {
  for(auto &f:g)dist[f.first]=INF; dist[s] = 0;
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev.find(e.dst) != prev.end()) continue;
    prev[e.dst] = e.src;
    for(auto &f:g[e.dst]) {
      if (dist[f.dst] > e.weight+f.weight) {
        dist[f.dst] = e.weight+f.weight;
        Q.push(Edge(f.src, f.dst, e.weight+f.weight));
      }
    }
  }
}

char buf[1001];
int W;
int coor(int x,int y){return (y)*(W*2+2)+x;}
int main(){
	int H,N,X1,Y1,X2,Y2;
	scanf("%d%d%d%d%d%d%d",&W,&H,&N,&X1,&Y1,&X2,&Y2);
	X1=coor(X1*2,Y1*2),X2=coor(X2*2,Y2*2);
	vector<vector<int> >m(H*2+1);
	for(auto &&e:m)e.resize(W*2+1);
	for(int i=0;i<N;i++){
		int x,y,t,l;
		scanf("%d%d%d%s",&x,&y,&t,buf);
		l=strlen(buf);
		x=2*x+1,y=2*y+1;
		for(int j=0;j<t;j++){
			for(int k=0;k<l;k++){
				int c=buf[k];
				if(c=='L'&&1<x)m[y][x-1]++,x-=2;
				if(c=='U'&&1<y)m[y-1][x]++,y-=2;
				if(c=='R'&&x<W*2-1)m[y][x+1]++,x+=2;
				if(c=='D'&&y<H*2-1)m[y+1][x]++,y+=2;
			}
		}
	}
	Graph g;
	for(int h=0;h<=H*2;h+=2)for(int w=0;w<=W*2;w+=2){
		int a=coor(w,h),b;
		if(h<H*2)b=coor(w,h+2),g[a].push_back(Edge(a,b,m[h+1][w])),g[b].push_back(Edge(b,a,m[h+1][w]));
		if(w<W*2)b=coor(w+2,h),g[a].push_back(Edge(a,b,m[h][w+1])),g[b].push_back(Edge(b,a,m[h][w+1]));
	}
	unordered_map<int,Weight> dist;
	unordered_map<int,int> prev;
	shortestPath(g,X1,dist,prev);
	printf("%d\n",dist[X2]);
}

Measured memory_bytes: 56952
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))

int main(void)
{
	//変数の宣言
	long long int n;
	long long int a[100010];
	long long int sum;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	long long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%lld",&n);
	
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	a[n]=a[0];
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	if(n==1){
		printf("YES\n");
		return 0;
	}
	
	sum=0;
	for(i=0;i<n;i++){
		sum=sum+a[i];
	}
	
	if(sum%(n*(n+1)/2)!=0){
		printf("NO\n");
		return 0;
	}else{
		temp=(sum/(n*(n+1)/2));
	}
	
	temp2=temp;
	for(i=0;i<n;i++){
		if((temp+a[i]-a[i+1])%n!=0||(temp+a[i]-a[i+1])/n<0){
			printf("NO\n");
			return 0;
		}else{
			temp2=temp2-(temp+a[i]-a[i+1])/n;
		}
	}
	
	
//	printf("計算部分終了\n");
	//出力
	
	if(temp2==0){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 896
from scipy.sparse.csgraph import dijkstra
N,M = map(int,input().split())
edge = [[int(x) for x in input().split()] for _ in range(M)]

graph = [[0]*(N+1) for _ in range(N+1)]
for a,b in edge:
  graph[a][b] = 1

answer = 0
INF = 10 ** 9
for a,b in edge:
  graph[a][b] = INF
  dist = dijkstra(graph, indices = a, directed = False)
  if dist[b] >= INF:
    answer += 1
  graph[a][b] = 1

print(answer)


Measured memory_bytes: 19272
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Vector2d> p = new ArrayList<>();
		for (int i=0; i<n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			p.add(new Vector2d(x, y));
		}
		sc.close();
		printAns(solve(p));
	}

	static class Vector2d {
		Vector2d(int x, int y){
			this.x = x;
			this.y = y;
		}
		int x;
		int y;
		public String toString() {
			return String.format("%d %d", x, y);
		}

		public static Vector2d sub(Vector2d v1, Vector2d v2){
			return new Vector2d(v2.x - v1.x, v2.y - v1.y);
		}

		// 3点が反時計回りになっているならばtrue
		public static boolean isCounterClockwise(Vector2d v1, Vector2d v2, Vector2d v3) {
			Vector2d a = sub(v1, v2);
			Vector2d b = sub(v1, v3);
			double angle = a.x * b.y - a.y * b.x;
			return angle >= 0;
		}

	}

	static class Vector2dComparator implements Comparator<Vector2d>{
		@Override
		public int compare(Vector2d v1, Vector2d v2) {
			int y = v1.y - v2.y;
			if (y == 0) {
				return v1.x - v2.x;
			}
			return y;
		}
	}

	public static List<Vector2d> solve(List<Vector2d> p) {
		int s = p.size();
		p.sort(new Vector2dComparator());
		// 凸包
		// 右部凸包
		List<Vector2d> ansR = new ArrayList<>();
		ansR.add(p.get(0));
		ansR.add(p.get(1));
		for(int i=2; i<s; i++) {
			ansR.add(p.get(i));
			// ansRが3点以上含み、
			// 最後の3点が反時計回りになってない
			while(ansR.size() >= 3 && !Vector2d.isCounterClockwise(ansR.get(ansR.size()-3), ansR.get(ansR.size()-2), ansR.get(ansR.size()-1))) {
				ansR.remove(ansR.size()-2);
			}
		}
		// 左部凸包
		List<Vector2d> ansL = new ArrayList<>();
		ansL.add(p.get(s-1));
		ansL.add(p.get(s-2));
		for(int i=s-3; i>=0; i--) {
			ansL.add(p.get(i));
			// ansLが3点以上含み、
			// 最後の3点が反時計回りになってない
			while(ansL.size() >= 3 && !Vector2d.isCounterClockwise(ansL.get(ansL.size()-3), ansL.get(ansL.size()-2), ansL.get(ansL.size()-1))) {
				ansL.remove(ansL.size()-2);
			}
		}
		// ansRとかぶる点を除去
		ansL.remove(ansL.size()-1);
		ansL.remove(0);
		// 左右の凸包を合体
		ansR.addAll(ansL);
		return ansR;
	}

	public static void printAns(List<Vector2d> l) {
		System.out.println(l.size());
		for (int i=0; i<l.size(); i++) {
			System.out.println(l.get(i));
		}
	}
}



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

ll res[10010];

int main()
{
	ll n=10000, m, i, j, k, nr=100, x, y;

	for(i=1; i<=n; i++)
	{
		ll range=sqrt(i);
		for(x=1; x<=range; x++)
		{
			for(y=1; y<=range; y++)
			{
				ll nis=(x+y)*(x+y)-4*(x*x+y*y+x*y-i);
				if(nis<0) continue;
				ll r=sqrt(nis);
				if(r*r!=nis) continue;
				r=r-(x+y);
				if(r<=0) continue;
				if(r%2==1) continue;
				r/=2;
				res[i]++;
				if(i==7) cout<<x<<" "<<y<<" "<<r<<endl;
			} 
		}

	}

	scanf("%lld", &n);

	for(i=1; i<=n; i++) printf("%lld\n", res[i]);



	return 0;
}

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


int main() {
  int n,a,b,i=0;
  cin>>n>>a>>b;
  
  while(a>i){
    i+=n;
  }
  
  if(i>b) cout<<"NG"<<endl;
  else cout<<"OK"<<endl;
    
      
     
  
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    bool isEasy = true;
    string S;
    cin >> S;
    int len = S.size();
    for (int i = 0; i < len; ++i) {
        if (i%2 == 0) {
            if (S[i] == 'L') isEasy = false;
        } else {
            if (S[i] == 'R') isEasy = false;
        }
    }
    printf(isEasy ? "Yes\n": "No\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	/**
	 * Traveling
	 * @param 1 ≤ N ≤ 10^5
	 * @param 0 ≤ xi ≤ 10^5
	 * @param 0 ≤ yi ≤ 10^5
	 * @param 1 ≤ ti ≤ 10^5
	 * @param ti < t(i+1) (1 ≤ i ≤ N−1)
	 */
	public static void main(String...args) {
		try (Scanner sc = new Scanner(System.in)) {
			String ans = "Yes";
			int n = sc.nextInt();
			int[] t = new int[n + 1];
			int[] x = new int[n + 1];
			int[] y = new int[n + 1];
			t[0] = 0;
			x[0] = 0;
			y[0] = 0;
			for (int i = 1; i < n + 1; i++) {
				t[i] = sc.nextInt();
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();

				int T = t[i] - t[i - 1];
				int X = Math.abs(x[i] - x[i - 1]);
				int Y = Math.abs(y[i] - y[i - 1]);
				if (T >= X + Y && T % 2 == (X + Y) % 2) {
					// pass
				} else {
					ans = "No";
					break;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 88720
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N;
    cin >> N;
    int V[200005];
    rep(i, N) {
        int a;
        cin >> a;
        V[a] = i;
    }
    set<int> S;
    S.insert(-1);
    S.insert(N);
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        int now = V[i];
        set<int>::iterator ite = S.upper_bound(now);
        int r = *ite;
        ite--;
        int l = *ite;
        S.insert(now);
        ans += i * (now - l) * (r - now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  vector<char> alp(52);
  REP(i,26){
    alp[i] = 'a' + i;
    alp[i+26] = 'A' + i;
  }
  
  while(true){
    int n;
    cin >> n;
    if(n == 0) break;

    vector<int> v(n);
    REP(i,n){
      cin >> v[i];
    }
    string s;
    cin >> s;

    int len = s.length();
    REP(i,len){
      int m;
      //cout << (s[i] - 'a') << " " << v[i%n] << endl;
      if(s[i] >= 'a' && s[i] <= 'z') m = (int(s[i] - 'a') - v[i%n] + 52)%52 ;
      else m = ((s[i] - 'A') + 26 - v[i%n] + 52) % 52;
      //cout << m << endl;
      cout << alp[m];
    }
    cout << endl;
  }
  return 0;
}




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

chance = 0
diff = 0
for i in range(N):
    if A[i] > B[i]:
        diff += A[i] - B[i]
    elif A[i] < B[i]:
        chance += (B[i] - A[i]) // 2

if diff <= chance:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 4596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a;
  for(int i = 0; i < n; i++) {
    int k; cin >> k;
    a.push_back(k);
  }
  vector<int> even, odd;
  for(int i = 0; i < a.size(); i++) {
    if((i+1)%2==0) even.push_back(a[i]);
    else odd.push_back(a[i]);
  }
  if(n % 2 == 0) {
    reverse(even.begin(), even.end());
    for(i : even) cout << i << " ";
    for(i : odd) cout << i << " ";
  } else {
    reverse(odd.begin(), odd.end());
    for(i : odd) cout << i << " ";
    for(i : even) cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    rep(i, s.size())
    {
        if (s[i] == s[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

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

using namespace std;

long long A, B;
int K;
long long temp = 0;

int main()
{
  cin >> A >> B >> K;
  for (int i = 0; i < K; i++)
  {
    if (A + i <= B)
    {
      cout << A + i << endl;
      temp = max(A + i, temp);
    }
    else
    {
      return 0;
    }
  }
  for (int i = K - 1; i >= 0; i--)
  {
    if (temp < B - i)
    {
      cout << B - i << endl;
    }
  }
  return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int diff=abs(N-M);
  if(diff>1){
    cout << 0 << endl;
    return 0;
  }
  int64_t mod=1e9+7;
  vector<int64_t> k(1e5+1);
  k.at(0)=1;
  for(int i=1;i<=1e5;i++){
    k.at(i)=k.at(i-1)*i;
    k.at(i)%=mod;
  }
  int64_t ans=0;
  if(diff==1){
    ans=k.at(N)*k.at(M);
    ans%=mod;
  }else if(diff==0){
    ans=k.at(N)*k.at(M);
    ans%=mod;
    ans*=2;
    ans%=mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b = inpl()
if a >= 13:
    print(b)
elif 6 <= a <= 12:
    print(b//2)
else:
    print(0)

Measured memory_bytes: 64492
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
// always use 1LL instead of 1
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

// using long doubles saves you from corner cases but is very time consuming
#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
// just comment the line below in case of interactive problems
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	//IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n,x,m;
		cin >> n >> x >> m;
		vi v;
		x = x%m;
		v.pb(x);
		mi mp;
		mp[x] = 1;
		x = x*x;
		while(1)
		{
			x = x%m;
			if(mp[x]==1)
				break;
			v.pb(x);
			mp[x] = 1;
			x = x*x;
		}
		//deb1(x);
		//trace(v);
		int c = 0;
		int ans = 0;
		while(c<n && v[c]!=x)
		{
			ans += v[c];
			c++;
		}
		int left = n - c; 
		int idx = c;
		int sz = v.size() - idx;
		//deb3(left,idx,sz);
		int fac = left/sz;
		int sum = 0;
		repp(i,idx,v.size())
		{
			sum += v[i];
		}
		ans += fac*sum;
		left -= fac*sz;
		while(left>0)
		{
			ans += v[c];
			c++;
			left--;
		}
		cout << ans;
		
		
	}
}

Measured memory_bytes: 6672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n,a[200009],c=0;
	string s,s2;
	cin>>s>>s2;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=s2[i])
			c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3800
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;cin>>n;
    ll p = 0;
    for(int i=0;i<n;i++)
    {
        ll a;cin>>a;
        p ^= a;
    }
    cout << (p==0 ? "Yes" : "No") << endl;
}


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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:String = read();
    for _ in 0..s.len() {
        print!("x");
    }
    println!("");
}

Measured memory_bytes: 2132
#include<algorithm>
#include<cassert>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
typedef pair<lint,pii>plpii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const int N=100400;
const int B=400;
const int C=N/B;
int acc[C];
int a[N];

bool check(int l,int r){
  //cerr<<"l r = " << l << " " << r << endl;
  int b=l/B;
  assert(r<=B*b+B);
  if(acc[b]==B)return true;
  for(int i=l;i<r;++i)if(a[i]==0)return false;
  return true;
}

void add_up(int l,int r){
  int b=l/B;
  assert(r<=B*b+B);
  if(acc[b]==B)return;
  for(int i=l;i<r;++i){
    if(a[i]==0)acc[b]++;
    a[i]=1;
  }
}

void check_integra(){
  rep(i,C){
    int cnt=0;
    rep(j,B){
      int val=a[i*B+j];
      assert(val==0||val==1);
      cnt+=val;
    }
    if(acc[i]!=B&&acc[i]!=cnt){
      cerr << "error in block " << i << endl;
      cerr << "acc[i] = " << acc[i] << ", which should be " << cnt << endl;
      assert (0);
    }
  }
  rep(i,100){
    cerr<<" "<<a[i];
  }
  cerr<<endl;
  rep(i,100/B){
    cerr<<" "<<acc[i];
  }
  cerr<<endl;
}

int main(){
  int n,m,q;
  cin>>n>>m>>q;
  vector<plpii>chr;
  rep(i,m+q){
    int d,a,b;
    cin>>d>>a>>b;
    a--,b--;
    chr.push_back(plpii((2*N)*(2*(lint)d+(i>=m?0:1))+i,pii(a,b)));
  }
  sort(chr.begin(),chr.end());
  vi ans(q,-1);
  rep(i,chr.size()){
    lint t=chr[i].first;
    pii lr=chr[i].second;
    int l=lr.first,r=lr.second;
    int lb=(l+B-1)/B,rb=r/B;
    if((t/(2*N))%2==0){
      bool ok=1;
      if(lb>rb){
	if(l>=r){
	  ok=1;
	}else{
	  ok=check(l,r);
	}
      }else{
	ok&=check(l,B*lb);
	for(int j=lb;j<rb;++j){
	  ok&=acc[j]==B;
	}
	ok&=check(B*rb,r);
      }
      int qn=t%(2*N)-m;
      assert(qn>=0&&qn<q);
      ans[qn]=ok;
    }else{
      if(lb>rb){
	add_up(l,r);
      }else{
	add_up(l,B*lb);
	for(int j=lb;j<rb;++j){
	  acc[j]=B;
	}
	add_up(B*rb,r);
      }
    }
    //check_integra();
  }
  rep(i,q){
    assert(ans[i]>=0);
    assert(ans[i]<=1);
    cout<<(ans[i]?"Yes":"No")<<endl;
  }
}



Measured memory_bytes: 7032
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

typedef struct node {
    bool checked;
    int num;
    int mem;
    int dis[100000];
    struct node *next[100000];
} Node;

Node *init_node(int i) {
    Node *a = (Node *)malloc(sizeof(Node));
    a->checked = 0;
    a->num = i;
    a->mem = 0;
    return a;
}

void coloring(Node *start, int *color, int dis_0) {
    if (start->checked == 1) return;
    start->checked = 1;
    int nmem = start->mem;
    for (int i=0; i<nmem; i++) {
        Node *buf = start->next[i];
        if (buf->checked == 1) continue;
        int distan = (dis_0 + start->dis[i]) % 2;
        color[buf->num] = distan;
        coloring(buf, color, distan);
    }
}

int main() {
    int n = 0;
    scanf("%d\n", &n);
    Node *lis[n];
    for (int i=0; i<n; i++) {
        lis[i] = init_node(i);
    }
    int u = 0, v = 0;
    int mem_u = 0, mem_v = 0;
    long int w = 0;
    for (int i=0; i<n-1; i++) {
        scanf("%d %d %ld", &u, &v, &w);
        u--;
        v--;
        mem_u = lis[u]->mem;
        mem_v = lis[v]->mem;
        lis[u]->dis[mem_u] = w%2;
        lis[v]->dis[mem_v] = w%2;
        lis[u]->next[mem_u] = lis[v];
        lis[v]->next[mem_v] = lis[u];
        lis[u]->mem++;
        lis[v]->mem++;
    }
    int color[n];
    color[0] = 0;
    coloring(lis[0], color, 0);
    for (int i=0; i<n; i++) {
        printf("%d\n", color[i]);
    }
    return 0;
}


Measured memory_bytes: 802304
using System;
class aoj
{
    static void Main()
    {
        int[] pasta = new int[3];
        int[] juice = new int[2];
        for(int i = 0; i < 3; i++)
        {
            pasta[i] = int.Parse(Console.ReadLine());
        }
        for(int i = 0; i < 2; i++)
        {
            juice[i] = int.Parse(Console.ReadLine());
        }
        int a = 100000;
        for(int i = 0; i < 3; i++)
        {
            for(int j = 0; j < 2; j++)
            {
                if (a > pasta[i] + juice[j])
                {
                    a = pasta[i] + juice[j];
                }
            }
        }
        Console.WriteLine(a-50);
    }
}

Measured memory_bytes: 9192
n, m, q = map(int, input().split())

train = [[0]*(n+1) for _ in range(n+1)]
for _ in range(m):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    train[l+1][r+1] += 1

for i in range(0, n+1):
    for j in range(1, n+1):
        train[i][j] = train[i][j] + train[i][j-1]
for j in range(0, n+1):
    for i in range(1, n+1):
        train[i][j] = train[i][j] + train[i-1][j]


for _ in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1

    print(train[r+1][r+1] - train[l][r+1] - train[r+1][l] + train[l][l])


Measured memory_bytes: 13300
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double cal(double a,double b,int n){
	if(n==1) return 0.5*a;
	return 0.5*(a+0.5*(n-1)*b)+cal((1.0+1.0/n)*a+1.5*b/n,(1.0+2.0/n)*b,n-1);
}
int main()
{
	int n,d,x;
	cin>>n>>d>>x;
	printf("%.12f\n",cal(2.0*d+x,4.0*x,n));
}


Measured memory_bytes: 6528
N = int(input())
HL = list(map(int,input().split()))
HL.append(10**9+1)  #HLの最後に(最大値+1)をappend
cnt = 0
tmp_c = 0

for i in range(N):
    if HL[i] >= HL[i+1]:
        tmp_c += 1
    else:
        if cnt <= tmp_c:
            cnt = tmp_c
            tmp_c = 0
        else:
            tmp_c = 0

print(cnt)

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

int main(){
    int n; cin >> n;
    vector<string> s(n);
    vector<int> t(n); rep(i,n) cin >> s[i] >> t[i];
    string x; cin >> x;

    map<string, int> m;
    m[s[0]] = t[0];
    rep(i,n-1){
        m[s[i+1]] = m[s[i]] + t[i+1];
    }
    cout << m[s[n-1]] - m[x] << "\n";
}

Measured memory_bytes: 256
import sys
import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def factorization(num):
    prime = []
    n = num
    p = 2
    while p * p <= num:
        if n % p == 0:
            cnt = 0
            while n % p == 0:
                cnt += 1
                n //= p
            prime.append((p, cnt))
        p += 1
    if n != 1:
        prime.append((n, 1))
    if not prime:
        prime.append((num, 1))
    return prime

def Main():
    a, b = read_ints()
    g = math.gcd(a, b)
    if g == 1:
        print(1)
        exit()
    prime = factorization(g)
    print(len(prime)+1)

if __name__ == '__main__':
    Main()

Measured memory_bytes: 9152
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

dp = [[0]+[float('inf')]*100000 for _ in range(N+1)]

for i in range(1, N+1):
    for v in range(0, 100001):
        weight = WV[i-1][0]
        value = WV[i-1][1]
        dp[i][v] = min(dp[i-1][v], dp[i-1][v-value]+weight)
res = 0
for v, w in enumerate(dp[-1]):
    if w <= W: res = v

print(res)


Measured memory_bytes: 394212
#include<iostream>
#include<string>

int main() {
	int alice, bob;
	std::string result;
	std::cin >> alice >> bob;

	(alice + 11) % 13 > (bob + 11) % 13 ? result = "Alice" : (alice + 11) % 13 < (bob + 11) % 13 ? result = "Bob" : result = "Draw";

	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,m; cin >> n >> m;
  vi h(n); rep(i,n) cin >> h[i];
  vector<vi> to(n);
  rep(i,m){
    int a,b; cin >> a >> b;
    --a; --b;
    to[a].emplace_back(b);
    to[b].emplace_back(a);
  }
  int ans = 0;
  rep(i,n){
    int mx = h[i];
    bool ok = true;
    for(int tmp : to[i]){
      if(mx <= h[tmp]) ok = false;
    }
    if(ok) ans++;
  }
  cout << ans;
  cout << endl;
  return 0;
}


Measured memory_bytes: 8752
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second

    using namespace std;
long long int power(int base, int exp)
{
    if (exp == 0)
       return 1;
    else if (exp == 1)
       return base;
    else
    {
       long long int calc;
       if (exp % 2 == 0)
       {
         calc = power(base, exp/2);
         calc =(calc* calc)%mod;
       }
       else
       {
         calc = (base*power(base, exp-1))%mod;
       }
       return calc%mod;
    }
}
    int main()
    {
        std::ios::sync_with_stdio(false);
       int n;
       cin>>n;
       set<string>s;
       for(int i=0;i<n;i++)
       {
           string s1;
           cin>>s1;
           s.insert(s1);
       }
       cout<<s.size()<<endl;
        return 0;
    }


Measured memory_bytes: 19144