akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

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

int main(){
    ll A, B; cin >> A >> B;
    ll GCD = gcd(A, B);
    set<ll> ST;
    for(ll i = 1;  i*i<=GCD; i++ ){
        if(GCD % i == 0){
            ST.insert(i);
            ST.insert(GCD/i);
        }
    }
    //cout << ST.size() << endl;

    //ll Max = 0;
    set<ll> ST2; ST2.insert(1);
    for(auto s1 : ST){
        bool flag = true;;
        for(auto s2 : ST2){
            if(gcd(s1, s2) != 1) flag = false;
        }
        if(flag) ST2.insert(s1);
    }
    cout << ST2.size() << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define pb push_back
#define len(x) (int)(x).size()

typedef long long ll;
typedef long double ld;

using namespace std;
const int N = 5e3 , M = 200;
int B[N][M] , a[N];
ll answer[N] , MX[M];

const int LG = 13;
ll mx[N][M][LG] , pref[N];
void build(){
    for(int i = 0; i < N; ++i)
        for(int j = 0 ; j  < M; ++j){
            mx[i][j][0] = B[i][j];
        }
    for(int st = 1 ; st < LG; ++st){
        for(int i = 0 ; i + (1<<st) <= N ;++i){
            for(int j = 0 ; j < M; ++j){
                mx[i][j][st] = max(mx[i][j][st-1] , mx[i+(1<<(st-1))][j][st-1]);
            }
        }
    }
}
int get_mx(int l , int r , int m){
    int bt = 32 - __builtin_clz(r - l + 1) - 1;
//    if(!((r-(1<<bt)+1) >= l)){
//        cout << l << ' ' << r << ' ' << bt << '\n';
//    }
    return max(mx[l][m][bt] , mx[r - (1<<bt)+1][m][bt]);
}
void solve(int l , int r,  int optl , int optr){
    int mid = (l + r) >> 1;
    /// we wonder to find fucking opt
    int opt = -1;
    fill(MX , MX + M , 0);
    ll cur = 0 , d = 0;
    for(int j = max(mid , optl); j <= optr; ++j){
        cur = 0;
        for(int f = 0 ; f < M; ++f){
            cur += get_mx(mid , j, f);
        }
        cur -= (pref[j] - pref[mid]);
        if(answer[mid] < cur){
            answer[mid] = cur;
            opt = j;
        }
    }
    if(l <= mid - 1)
        solve(l , mid-1 , optl , opt);
    if(mid + 1 <= r)
        solve(mid + 1 , r , opt , optr);
}
int main()
{
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n ,m ;cin >> n >> m;
    for(int i = 0 ;i < n -1; ++i)
        cin >> a[i] , pref[i +1] = pref[i] + a[i];
    for(int i = 0; i < n; ++i){
        for(int j= 0 ; j < m ;++j)
            cin >> B[i][j];
    }
    build();
    solve(0 , n-1 , 0, n-1);
    cout << *max_element(answer , answer + N);
    return 0;
}


Measured memory_bytes: 109124
N,T=map(int,input().split())
c=[]
t=[]
result=[]
for i in range(N):
    S=input()
    c.append(int(S[0:S.find(' ')]))
    t.append(int(S[S.find(' ')+1:]))
for i in range(N):
    if t[i]<=T:
        result.append(c[i])
print(min(result) if len(result) != 0 else 'TLE')


Measured memory_bytes: 3064
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();
      if((a * b % 2) == 1){
        System.out.println("Odd");
      }else{
        System.out.println("Even");
      }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m; cin >> n >> m;
	map<int, int> f = { {1,2},{2,5},{3,5},{4,4},{5,5},{6,6},{7,3},{8,7},{9,6} };
	vector<int> a(m), dp(n + 1, -10000);
	dp[0] = 0;
	rep(i, 0, m - 1)cin >> a[i];
	sort(all(a), greater<int>());
	rep(i, 0, n)
	{
		rep(j, 0, m - 1)
		{
			if (i + f[a[j]] <= n) dp[i + f[a[j]]] = max(dp[i + f[a[j]]], dp[i] + 1);
		}
	}
	int digit = dp[n];
	int match = n;
	string ans = "";
	while (digit > 0)
	{
		rep(i, 0, m - 1)
		{
			if (match - f[a[i]] >= 0 && digit == dp[match - f[a[i]]] + 1)
			{
				ans += to_string(a[i]);
				match -= f[a[i]];
				--digit;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n,A[200000] = {0};
    int B[200000] = {0};

    scanf("%d",&n);

    for(int i = 1; i < n+1; i++){
        scanf("%d",&A[i]);
    }

    int ans = 0;
    int i = 1;
    B[i] = i;
    while (1)
    {
        i = A[i];
        if(B[i]){
            ans = -1;
            break;
        } 
        B[i] = 1;
        ans++;
        if(i == 2) break;
    }

    printf("%d\n",ans);
    

}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	string s;
	cin >> s;
	vector<vector<ll>> dp(s.length()+5, vector<ll>(13, 0));
	dp[s.length()][0] = 1;
	int a = 1;
	for(int i = s.length(); i > 0; i--){
		if(s[i-1]=='?'){
			for(int j = 0; j < 10; j++){
				for(int k = 0; k < 13; k++){
					dp[i-1][(j*a+k)%13] += dp[i][k];
				}
			}
			for(int j = 0; j < 13; j++){
				dp[i-1][j] %= MOD;
			}
		}else{
			int p = s[i-1] - '0';
			for(int j = 0; j < 13; j++){
				dp[i-1][(p*a+j)%13] += dp[i][j];
			}
			for(int j = 0; j < 13; j++){
				dp[i-1][j] %= MOD;
			}
			
		}
        a = a*10%13;
	}
	cout << dp[0][5] << endl;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 5e5 + 7;

int a[N], fst[N], ans[N];

int bit[N];

void add(int pos, int val) {
	for(;pos < N; pos += pos&-pos)
		bit[pos] += val;
}

int qry(int pos) {
	int ret = 0;
	for(;pos;pos -= pos&-pos)
		ret += bit[pos];
	return ret;
}

signed main()
{
	IO_OP;
	int n, q;
	cin >> n >> q;
	for(int i = 1; i <= n; i++) cin >> a[i];
	V<pair<pi, int>> v;
	for(int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		v.PB({{l, r}, i});
	}	
	sort(ALL(v));
	for(int i = n; i >= 1; i--) {
		if(fst[a[i]]) add(fst[a[i]], -1);
		fst[a[i]] = i;
		add(fst[a[i]], 1);
		while(v.size() && v.back().F.F == i) {
			int j = v.back().S, r = v.back().F.S;
			ans[j] = qry(r);
			v.pop_back();
		} 
	}
	for(int i = 0; i < q; i++) cout << ans[i] << endl;
	
}





Measured memory_bytes: 17504
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
// 最大公約数を求める関数
int mygcd(int x, int y)
{
	int r;
	// ユーグリッドの互除法
	while ((r = x % y) != 0)  // yで割り切れるまでループ
	{
		x = y;
		y = r;
	}
	return y;
}
int calc(int*n, int s, int e)
{
	if (e - s == 1) return mygcd(n[s], n[e]);
	else if (s == e) return n[s];
	else return mygcd(calc(n, s, (s + e) / 2), calc(n, (s + e) / 2, e));
}
int main()
{ 
	static int n, i, j,a[100000+10];
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	sort(a + 1, a + n);
	for (i = 1; i <= n; i++)
	{
		//printf("%d\n", a[i]);
	}
	cout << calc(a, 1, n) << endl;
}


Measured memory_bytes: 640
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N,M; cin>>N>>M;
    vector<vector<int>> vec(1e5);
    for (int i = 0; i < N; ++i) {
        int A,B; cin>>A>>B;
        vec[A-1].push_back(B);
    }
    int ans=0;
    priority_queue<int> pq;
    for (int i = 0; i < M; ++i) {
        for (int j:vec[i]) pq.push(j);
        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

int main() {
    // input
    int N, L;
    cin >> N >> L;

    // solve
    int sum = 0;
    for (int i = 1; i <= N; ++i) {
        sum += L + i - 1;
    }

    int diff = abs(L);
    for (int i = 2; i <= N; ++i) {
        diff = min(diff, abs(L + i - 1));
    }
    int ans = 0;
    if (sum > 0) ans = sum - diff;
    else ans = sum + diff;

    // output
    cout << ans << endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String y = "consonant";

		if (x.equals("a") || x.equals("i") || x.equals("u") || x.equals("e") || x.equals("o")) {
			y = "vowel";
		}
		System.out.println(y);
	}
}

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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector <bool> ok(n);
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int x;
			cin >> x;
			x--;
			ok[x] = true;
		}
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (!ok[i]) {
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination


int main(void) {
  int n; cin >> n;
  ll res = 0;
  while(n >= 500){
    n -= 500;
    res += 1000;
  }
  while(n >= 5){
    n -= 5;
    res += 5;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=1e5+10;
struct node
{
    ll va,num;
}a[MAX];
bool cmp(node p,node q)
{
    return p.va<q.va;
}
int main()
{
    int n;
    ll m;
    scanf("%d %lld",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%lld %lld",&a[i].va,&a[i].num);
    }
    sort(a,a+n,cmp);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(m<=a[i].num)
        {
            ans+=m*a[i].va;
            break;
        }
        else ans+=a[i].va*a[i].num,m-=a[i].num;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


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

    vector<int> v(26, 0);
    REP(i, 4) {
        v[s[i] - 'A']++;
    }
    REP(i, 26) {
        if (v[i] != 0 && v[i] != 2) {
            std::cout << "No" << '\n';
            return 0;
        }
    }
    std::cout << "Yes" << '\n';

    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

exit_flag = False
for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        exit_flag = True
        print('No')
        break

if not exit_flag:
    print('Yes')


Measured memory_bytes: 14252
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#define LL long long


using namespace std;

int main() {
	string a, b, c, s;
	cin >> a >> b >> c;
	s = { a[0],b[0],c[0] };
	transform(s.cbegin(), s.cend(), s.begin(), ::toupper);
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>
#include<unordered_set>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

ll ptoInd(ll a,ll b){
    return a + 1000000*b;
}

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

    vector<ll> a(n),b(n);

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

    vector<list<pair<ll,ll>>> x(100001),y(100001);

    for(int i = 0; i < n; i++){
        x[a[i]].push_back(make_pair(a[i],b[i]));
        y[b[i]].push_back(make_pair(a[i],b[i]));
    }

    unordered_set<ll> usedp;
    vector<bool> usedx(100001,false),usedy(100001,false);

    ll ans = 0;

    for(int i = 1; i < 100001; i++){
        if(x[i].size() > 0 && usedp.find(ptoInd(x[i].front().first,x[i].front().second)) == usedp.end()){
            queue<pair<ll,ll>> q;
            for(auto itr = x[i].begin(); itr != x[i].end(); itr++){
                q.push(*itr);
            }
            ll xsize = 0;
            ll ysize = 0;
            ll count = 0;
            while(!q.empty()){
                auto tmp = q.front();
                q.pop();
                if(usedp.find(ptoInd(tmp.first,tmp.second)) != usedp.end()){
                    continue;
                }
                count++;
                usedp.insert(ptoInd(tmp.first,tmp.second));
                if(!usedx[tmp.first]){
                    for(auto itr = x[tmp.first].begin(); itr != x[tmp.first].end(); itr++){
                        if(usedp.find(ptoInd((*itr).first,(*itr).second)) == usedp.end()){
                            q.push(*itr);
                        }
                    }
                }
                if(!usedy[tmp.second]){
                    for(auto itr = y[tmp.second].begin(); itr != y[tmp.second].end(); itr++){
                        if(usedp.find(ptoInd((*itr).first,(*itr).second)) == usedp.end()){
                            q.push(*itr);
                        }
                    }
                }
                if(!usedx[tmp.first]){
                    xsize++;
                    usedx[tmp.first] = true;
                }
                if(!usedy[tmp.second]){
                    ysize++;
                    usedy[tmp.second] = true;
                }
            }
            ans += (xsize * ysize) - count;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 20132
import java.util.Scanner;

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

		int n = sc.nextInt();
		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(sc.next());
			b[i] = Long.parseLong(sc.next());
		}

		long ans = 0;
		for (int i = n - 1; i >= 0; i--) {
			if ((a[i] + ans) % b[i] != 0)
				ans += b[i] - (a[i] + ans) % b[i];
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 57472
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <limits.h>
#define MAXN 200000;
#define Amari 1000000007;
#define p pair <int,int>
using namespace std;
int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  vector<long long> a(n,0);
  long long sum=0;
  long long min=LONG_MAX;
  long long temp=0;
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
      sum+=a[i];
    }
  for(int i=0;i<n-1;i++)
    {
      temp+=a[i];
      if((abs(sum-2*temp))<min) min=abs(sum-2*temp);
    }
  cout << min << endl;
  return 0;
}


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

bool compare_f(ll x, ll y) {
  return abs(x) < abs(y);
}

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll mod=pow(10,9)+7;
  int n,k;cin>>n>>k;
  vector<ll> vll(n),  vll_m(n);
  int cnt_m=0,cnt_z=0,cnt_p=0;
  for(int i=0;i<n;i++){
    cin>>vll[i];
    if(vll[i]<0)cnt_m++;
    if(vll[i]==0)cnt_z++;
    if(vll[i]>0)cnt_p++;
  }
  sort(vll.rbegin(), vll.rend());
  int ans_f;
  int t=min(k, cnt_m);
  if(t%2==1)t--;
  if(k<=t+cnt_p+cnt_z)ans_f=0;
  else ans_f=-1;

  // cout<<ans_f<<endl;

  ll ans=0;
  if (ans_f>=0) {
    ans=1;
    int pf=0,pb=vll.size()-1;
    int cnt=0;
    while(cnt<k){
      if(k-cnt>=2){
        ll t1 = vll[pf]*vll[pf+1];
        ll t2 = vll[pb]*vll[pb-1];
        if(t1>t2){
          t1 %= mod;
          ans = ans*t1%mod;
          if(ans<0)ans+=mod;
          pf+=2;
          cnt+=2;
        }else{
          t2 %= mod;
          ans = ans*t2%mod;
          if(ans<0)ans+=mod;
          pb-=2;
          cnt+=2;
        }
      }else{
        ans = ans*vll[pf]%mod;
        if(ans<0)ans+=mod;
        cnt++;
      }
    }
  } else{
    sort(vll.begin(), vll.end(), compare_f);
    ans=vll[0];
    for(int i=1;i<k;i++){
      ans = ans*vll[i]%mod;
      if(ans<0)ans+=mod;
    }
  }
  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 6308
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 2e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
ll cnt, n;
ll a[maxn];
map<ll, ll> miu;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	qread(n);
	for(int i = 1;i <= n;i++){
		qread(a[i]);
		miu[i - a[i]]++;
	}
	for(int i = 1;i <= n;i++){
		miu[i - a[i]]--;
		cnt += miu[a[i] + i];
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 27864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}

int main()
{
    int a[3];
    for(int i = 0; i < 3; i++)sc(a[i]);
    sort(a, a+3);
    int ans = a[2]*10+a[1]+a[0];
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

     public static void main(String []args){
         Scanner s=new Scanner(System.in);
         int a=s.nextInt();
         int b=s.nextInt();
         int x=s.nextInt();
         if(a+b>=x&&a<=x){
             System.out.println("YES");
         }
        
         else
         System.out.println("NO");
        
     }
}

Measured memory_bytes: 22100
k,n=map(int,input().split())
a=list(map(int,input().split()))
b=k+1
for m in range(len(a)):
  a.append(a[m]-k)
a.sort()
for l in range(int(len(a)/2)):
  if b > -a[l]+a[n+l-1]:
    b=a[n+l-1]-a[l]
print(b)

Measured memory_bytes: 25452
K = int(input())
A = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(K):
  x = A[i]
  if x % 10 != 0:
    A.append(10 * x + (x % 10) - 1)
  A.append(10 * x + (x % 10))
  if x % 10 != 9:
    A.append(10 * x + (x % 10) + 1)
else:
  print(A[i])

Measured memory_bytes: 15784
N = int(input())

base = [0] * 3
out = 0
point = 0
inning = 0

while True:
    event = input()

    if event == "HIT":
        if base[2] == 1:
            point += 1
        base[2] = base[1]
        base[1] = base[0]
        base[0] = 1

    elif event == "HOMERUN":
        point += sum(base) + 1
        base = [0] * 3

    elif event == "OUT":
        out += 1
        if out == 3:
            print(point)
            inning += 1
            if inning == N:
                break
            base = [0] * 3
            out = 0
            point = 0

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
int main()
{ int x1=1,x2=2,x3=3,x4=4,x5=5;
cin>>x1>>x2>>x3>>x4>>x5;
if(x1==0)
{ cout<<1;
}
else if(x2==0)
{cout<<2;
}
    else if(x3==0)
{ cout<<3;
}
    else if(x4==0)
{ cout<<4;
}
else
{ cout<<5;
}
    return 0;
    
}

Measured memory_bytes: 3576
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = -float('inf')
for i in range(1, 2 ** 10):
    t = 0
    for j in range(N):
        c = 0
        for k in range(10):
            c += ((i >> k) & 1) & F[j][k]
        t += P[j][c]
    ans = max(ans, t)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  string s; cin >> s;
  char c = s[0];
  int res = 1;
  for(int i = 0; i < N; i++){
    if(s[i] != c){
      res++;
      c = s[i];
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 512
n, k = gets.strip.split(' ').map(&:to_i)
ro, si, pa = gets.strip.split(' ').map(&:to_i)
t = gets.strip.split('')

# スコアのハッシュ
score = {"r": pa, "s": ro, "p": si }

ans = 0
(0..t.length-1).each do |i|
  ad = score[t[i].to_sym]
  if i >= k && t[i]==t[i-k]
    ad = 0
    t[i] = 'n'
  end
  ans += ad
end
puts ans.to_s

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

using namespace std;

int A, B, C, D ;
int X ;


int cal(int a, int b, char c){
  if(c == '+') return a + b ;
  if(c == '-') return a - b ;
}

int main(void){
  bool flag = true ;
  string str;
  cin >> str ;
  A = str[0]-'0';
  B = str[1]-'0';
  C = str[2]-'0';
  D = str[3]-'0';

  char op[2] = {'+','-'} ;

  for(int i = 0 ; i < 2; i++ ){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < 2; k++){
        if( cal(cal(cal(A,B,op[i]),C,op[j]),D,op[k]) == 7  && flag ) {
          cout << A << op[i] << B << op[j] << C << op[k] << D <<  '=' << 7 <<endl ;
          flag = false ;}
      }
    }
  }

  return 0;




}

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

int main(){
    int k;
    cin>>k;
    string str;
    cin>>str;
    for (int i=0;i<str.size();i++){
        str[i]+=k;
        if (str[i]>'Z'){
            str[i]=64+(str[i]-'Z');
        }
    }
    cout<<str<<endl;
}


Measured memory_bytes: 3592
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,k,a[202020],sum[202020];
map<long long,long long>mp;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		sum[i+1]+=(sum[i]+(a[i]-1))%k;
	}
	mp[0]=1;
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		if(i+1>=k)
		{
			mp[sum[i+1-k]]--;
		}
		if(mp.count(sum[i+1])>0)
		{
			ans+=mp[sum[i+1]];
		}
		else
		{
			mp[sum[i+1]]=0;
		}
		mp[sum[i+1]]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	while(cin>>N>>K) {
		VI H(N);
		REP(i, N) cin>>H[i];
		sort(ALLR(H));
		ll h = min(K, N);
		ll ans = accumulate(H.begin()+h, H.end(), 0LL);
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
			#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
			#define endl "\n"

			using namespace std;
	
		int main() {	
			int a, b, c; cin >> a >> b >> c;
			if (a == b && b == c) cout << 1;
			else if (a == b || b == c || a == c) cout << 2;
			else cout << 3;
			return 0;
			}
	

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
main()
{
    long long i,j,k,l,m,n,p,q;
    while(cin>>p)
    {m=0;
 for(i=-200;i<=200;i++){
 for(j=-200;j<=200;j++){
    k=pow(i,5);
    l=pow(j,5);
if(k-l==p){cout<<i<<" "<<j<<endl;m++; break; }
 }
 if(m>0) break;
}
}
    return 0;
}


Measured memory_bytes: 4008
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		sc.close();
		if(H % 3 == 0 || W % 3 == 0) {
			System.out.println(0);
			System.exit(0);
		}
		long min = H * W;
		for(int i = 1; i < H; i++) {
			long[]S = new long[3];
			S[0] = i * W;
			S[1] = (H - i) * (W / 2);
			S[2] = (H - i)  * (W - W / 2);
			Arrays.sort(S);
			if(S[0] == 0) continue;
			min = Math.min(min, S[2] - S[0]);
		}


		for(int i = 1; i < H; i++) {
			long[]S = new long[3];
			S[0] = i * W;
			long r = H - i;
			S[1] = W * (r / 2);
			S[2] = W * (r - r / 2);
			Arrays.sort(S);
			if(S[0] == 0) continue;
			min = Math.min(min, S[2] - S[0]);
		}
		long t = H;
		H = W;
		W = t;
		for(int i = 1; i < H; i++) {
			long[]S = new long[3];
			S[0] = i * W;
			S[1] = (H - i) * (W / 2);
			S[2] = (H - i)  * (W - W / 2);
			Arrays.sort(S);
			if(S[0] == 0) continue;
			min = Math.min(min, S[2] - S[0]);
		}


		for(int i = 1; i < H; i++) {
			long[]S = new long[3];
			S[0] = i * W;
			long r = H - i;
			S[1] = W * (r / 2);
			S[2] = W * (r - r / 2);
			Arrays.sort(S);
			if(S[0] == 0) continue;
			min = Math.min(min, S[2] - S[0]);
		}

		System.out.println(min);
	}
}

Measured memory_bytes: 38484
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pl = pair<ll, ll>;
constexpr double PI = 4*atan(1.0);

bool ccw(pl p, pl q, pl r) { return (q.f - p.f) * (r.s - p.s) - (r.f - p.f) * (q.s - p.s) > 0; }

vector<pl> convex_hull(vector<pl> & P) {
	int n = P.size(), k = 0;
	vector<pl> H(2 * n);
	sort(P.begin(), P.end());
	for (int i = 0; i < n; i++) {
		while (k >= 2 && ccw(H[k - 2], H[k - 1], P[i]) <= 0) k--;
		H[k++] = P[i];
	}
	for (int i = n - 2, t = k + 1; i >= 0; i--) {
		while (k >= t && ccw(H[k - 2], H[k - 1], P[i]) <= 0) k--;
		H[k++] = P[i];
	}
	H.resize(k);
	return H;
}

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int N; cin >> N;
    vector<pl> P(N);
    map<pl, int> M;
    for (int i = 0; i < N; ++i) {
        cin >> P[i].f >> P[i].s;
        M[P[i]] = i;
    }

    vector<pl> CH = convex_hull(P);

    vector<double> S;
    for (int i = 0; i < CH.size() - 1; ++i) {
        S.push_back(atan2(CH[i].s-CH[i+1].s, CH[i].f-CH[i+1].f));
    }

    vector<double> ans(N);
    for (int i = 0; i < CH.size() - 1; ++i) {
        ans[M[CH[i]]] = fmod(S[i] - S[(i-2+CH.size())%(CH.size()-1)] + 4*PI, 2*PI) / (2*PI);
    }

    for (int i = 0; i < N; ++i) {
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 4148
h,w,k = map(int, input().split())
mod = 10 ** 9 + 7
dp = [[0] * w for i in range(h+1)]
dp[0][0] = 1
b0,b1 = 1,0
c = [1]
for i in range(w-1):
  b0, b1 = b0+b1, b0
  c.append(b0+b1)
d = [0] + c[1:]
if w == 1:
  print(1)
  exit()
for i,v_i in enumerate(dp[:h]):
  for j,now in enumerate(v_i):
    if j == 0:
      dp[i+1][j] += (now * (c[max(0,w-2)])) % mod
      dp[i+1][j+1] += (now * (c[max(0,w-3)])) % mod
    elif j == w-1:
      dp[i+1][j] += (now * (c[max(0,w-2)])) % mod
      dp[i+1][j-1] += (now * (c[max(0,w-3)])) % mod
    else:
      dp[i+1][j-1] += (now * c[max(0,j-2)]*c[max(0,w-j-2)]) % mod
      dp[i+1][j] += (now * c[max(0,j-1)]*c[max(0,w-j-2)]) % mod
      dp[i+1][j+1] += (now * c[max(0,j-1)]*c[max(0,w-j-3)]) % mod
ans = dp[h][k-1] % mod
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using  namespace  std ;
int  main ()
{
  int  a ,  b ,  c ,  d ;
scanf ("%d%d%d%d" , &a , &b , &c , &d);
int  x = c-a,y = d-b;
cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
}

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    vector<int> v(5);
    for (auto &&i : v) {
        cin >> i;
        if(i < 40) i = 40;
    }
    cout << accumulate(v.begin(), v.end(), 0)/5 << "\n";
    return 0;
}



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

void solve()
{
	int n, r;
	cin >> n >> r;

	if (n >= 10)
		cout << r << endl;
	else
	{
		cout << r + 100 * (10 - n) << endl;
	}
}

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

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

int main() {
	char a[102], b[102];
	cin >> a >> b;
	int lena = strlen(a);
	int lenb = strlen(b);
	if (lena > lenb)
		cout << "GREATER";
	else if (lena < lenb)
		cout << "LESS";
	else {
		for (int i = 0; i < lena; i++) {
			if (a[i] > b[i]) {
				cout << "GREATER";
				break;
			}
			else if (a[i] < b[i]) {
				cout << "LESS";
				break;
			}
			else if (i == lena-1)
				cout << "EQUAL";
		}
	}
	system("pause");
}



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

const int N = 205;

int n;
vector<int> g[N];

int bfs(int start) {
  vector<int> color(n, -1);
  color[start] = 1;
  queue<int> q;
  q.push(start);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : g[u]) {
      if (color[v] == -1) {
        color[v] = color[u] + 1;
        q.push(v);
      }
    }
  }
  for (int u = 0; u < n; ++u)
    for (int v : g[u])
      if (abs(color[u] - color[v]) != 1)
        return -1;
  return *max_element(color.begin(), color.end());
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  { // build graph
    vector<string> t(n);
    for (int i = 0; i < n; ++i)
      cin >> t[i];
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        if (t[i][j] == '1') {
          g[i].push_back(j);
          g[j].push_back(i);
        }
      }
    }
  }

  int ans = -1;
  for (int i = 0; i < n; ++i)
    ans = max(ans, bfs(i));

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1<<28;
const ll MOD = 1000000007;

int n;
bool flg;
vi a;
set<ull> s;
int d[9][9] = {
	{0, 1, 2, 3, 6, INF},
	{-1, 0, 1, 3, 6, INF},
	{-2, -1, 0, 3, 6, INF},
	{-3, 0, 1, 2, 3, INF},
	{-3, -1, 0, 1, 3, INF},
	{-3, -2, -1, 0, 3, INF},
	{-6, -3, 0, 1, 2, INF},
	{-6, -3, -1, 0, 1, INF},
	{-6, -3, -2, -1, 0, INF}
};

bool chk(int cnt, int cl, string &now) {
	if(cl == 0 && (0b1100110000000000 & a[cnt]) == 0) {
		now[0] = now[1] = now[4] = now[5] = '7';
		return true;
	}
	if(cl == 1 && (0b0110011000000000 & a[cnt]) == 0) {
		now[1] = now[2] = now[5] = now[6] = '7';
		return true;
	}
	if(cl == 2 && (0b0011001100000000 & a[cnt]) == 0) {
		now[2] = now[3] = now[6] = now[7] = '7';
		return true;
	}
	if(cl == 3 && (0b0000110011000000 & a[cnt]) == 0) {
		now[4] = now[5] = now[8] = now[9] = '7';
		return true;
	}
	if(cl == 4 && (0b0000011001100000 & a[cnt]) == 0) {
		now[5] = now[6] = now[9] = now[10] = '7';
		return true;
	}
	if(cl == 5 && (0b0000001100110000 & a[cnt]) == 0) {
		now[6] = now[7] = now[10] = now[11] = '7';
		return true;
	}
	if(cl == 6 && (0b0000000011001100 & a[cnt]) == 0) {
		now[8] = now[9] = now[12] = now[13] = '7';
		return true;
	}
	if(cl == 7 && (0b0000000001100110 & a[cnt]) == 0) {
		now[9] = now[10] = now[13] = now[14] = '7';
		return true;
	}
	if(cl == 8 && (0b0000000000110011 & a[cnt]) == 0) {
		now[10] = now[11] = now[14] = now[15] = '7';
		return true;
	}
	return false;
}

void dfs(int cnt, int cl, string now) {
	if(flg) return;
	REP(i, 16) {
		if(now[i] == '0') return;
		now[i]--;
	}
	if(cnt == n) flg = true;
	REP(i, 9) {
		if(d[cl][i] == INF) break;
		string now2 = now;
		if(chk(cnt, cl + d[cl][i], now2)) {
			ull u = stoull(now2) * 10000 + cnt + 10 + cl+d[cl][i];
			if(!s.count(u)) {
				s.insert(u);
				dfs(cnt+1, cl + d[cl][i], now2);
			}
		}
	}
	return;
}

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

	while(cin >> n, n) {
		flg = false;
		a.clear();
		s.clear();
		REP(i, n) {
			a.pb(0);
			REP(j, 16) {
				int in; cin >> in;
				if(j)
					a[i] <<= 1;
				a[i] |= in;
			}
		}
		if((a[0] & 0b0000011001100000)) {
			cout << 0 << endl;
			continue;
		}
		dfs(1, 4, "6666677667766666");
		cout << flg << endl;
	}
	return 0;
}

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

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<ll>> g(n, vector<ll>(n, 1e18));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c, a--, b--;
    g[a][b] = g[b][a] = c;
  }
  for (int i = 0; i < n; i++) {
    g[i][i] = 0;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  vector<vector<int>> ans(n, vector<int>(n, 1e3));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (g[i][j] > l) continue;
      ans[i][j] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    ans[i][i] = 0;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j]);
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int s, t;
    cin >> s >> t, s--, t--;
    int res = ans[s][t];
    cout << ((res == 1e3) ? -1 : res - 1) << endl;
  }
}


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

int main(){
  int A, B;
  cin >> A >> B;
  
  if( A >= 13 ){
    cout << B << endl;
  }
  
  else if( A <= 12 && A >= 6 ){
    cout << B / 2 << endl;
  }
  
  else if( A <= 5 ){
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String sline = sc.next();
		int n = sline.length();
		sc.close();
		StringBuffer sb = new StringBuffer(sline);
		String reversed = sb.reverse().toString();
		
		boolean ans = true;
		String[] words = {"maerd", "remaerd", "esare", "resare"};
		for (int i = 0; i < n;) {
			boolean can = false;
			for(String w: words){
				int end = w.length();
				if (i + end > n) continue;
				if (reversed.substring(i, i + end) .equals(w)) {
					i += end;
					can = true;
				}
			}
			if (can == false) {
				ans = false;
				break;
			}
		}
		if (ans){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}

}


Measured memory_bytes: 28136
#include <cstdio>

bool testcase_ends() {
    int d;
    if (scanf("%d", &d) == EOF)
        return 1;

    auto f=[](int x)->int {
        return x*x;
    };

    int s=0;
    for (int i=0; i<600; i+=d)
        s += d*f(i);

    printf("%d\n", s);
    return 0;
}

int main() {
    int solved=0;
    while (!testcase_ends())
        ++solved;

    return !solved;
}

Measured memory_bytes: 2736
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < n; ++i)

int main() {
    int n, Q;
    cin >> n >> Q;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    REP(j,Q) {
        ll x; cin >> x;
        ll res = 0;
        int right = 0;
        ll sum = 0;
        REP(left,n) {
            while (right < n && sum + a[right] <= x) {
                sum += a[right];
                ++right;
            }
            res += right - left;
            if (right == left) ++right;
            else sum -= a[left];
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3628
#include <cstdio>
#include <vector>

using namespace std;

const int N = 1e5 + 5;
int a[N];
vector<int> g[N];
bool vis[N];

void dfs(int x)
{
	vis[x] = true;
	for (int i : g[x]) {
		if (!vis[i]) {
			dfs(i);
		}
	}
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			cnt++;
			dfs(i);
		}
	}
	printf("%d\n", cnt - 1);
	return 0;
}


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

int main()
{
    int a,b,y,z;
    int _max;
    scanf("%d%d",&a,&b);
    _max = a + b;
    if(a-b>_max)
        _max = a-b;
    if(a*b>_max)
        _max = a*b;
    printf("%d\n",_max);
    return 0;
}


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

int main(){

    int N;
    cin >> N;
    int a[N];
    int Alice = 0,Bob = 0;
    for(int i=0;i<N;i++) cin >> a[i];

    sort(a,a + N);
    for(int i = 0;i<N;i++){
        //cout << a[i] << endl;
        if(i%2 == 0) Alice += a[i];
        else Bob += a[i];
    }

    if(N % 2 == 1) cout << Alice - Bob << endl;
    else cout << Bob - Alice << endl;


    return 0;
}

Measured memory_bytes: 256
from collections import deque
N,U,V = map(int, input().split())
U,V = U-1, V-1
E = [[] for _ in range(N)]

for _ in range(N-1):
  a,b = map(int, input().split())
  a,b = a-1, b-1
  E[a].append(b)
  E[b].append(a)

def BFS(root):
  D = [ 0 for _ in range(N) ]
  visited = [False for _ in range(N)]
  willSearch = [ False for _ in range(N)]
  Q = deque()
  Q.append(root)
  willSearch[root] = True
  while len(Q) > 0:
    now = Q.pop()
    visited[now] = True
    for nx in E[now]:
      if visited[nx] or willSearch[nx]:
        continue
      willSearch[nx] = True
      D[nx] = D[now] + 1
      Q.append(nx)
  return D

UD = BFS(U)
VD = BFS(V)

#print(UD)
#print(VD)

#初手で青木くんのPOINTにしか行けないケース
if E[U] == [V]:
  print(0)
  exit(0)
  
ans=0
 
for i in range(N):
    if UD[i]<=VD[i]:
        ans=max(ans,VD[i]-1)

print(ans)

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

using namespace std;

int n,m,cnt,sum = 1000001,t,f;
int a[102];
string s;
pair <int, string> p1[10001];
int main (){	
	cin >> n >> m >> t;
	if (n * m <= t){
		cout << n * m;
	}
	else {
		cout << t;
	}
	return 0;
}

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

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

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define MAX 1100000

using namespace std;

typedef long long ll;

ll A,B,MOD;
ll dp[MAX];

inline
int toIndex(ll a){ return a-A+1; }

int main()
{
  while(cin >> A >> B >> MOD,A|B|MOD)
    {
      ll range = B-A+5;
      rep(i,MAX)dp[i] = 0;
      dp[1] = 1;//1-indexed
      dp[toIndex(B+1)] = -1;

      REP(cur,A,B+1)
	{
	  if(cur != A)dp[toIndex(cur)] = (dp[toIndex(cur)] + dp[toIndex(cur-1)]) % MOD;
	  ll sp = cur;
	  while(sp <= B)
	    {
	      int digit = (int)log10(sp) + 1;
	      ll p10 = 1LL;
	      rep(i,digit)p10 *= 10LL;
	      ll nsp = (sp == cur?cur+1LL:sp);
	      p10 = min(p10,B+1);

	      //cout << cur << "-th :"  << " sp = " << sp << " nsp = " << nsp << " p10 = " << p10 << endl; 
	      dp[toIndex(nsp)]  = (dp[toIndex(nsp)]  + dp[toIndex(cur)]) % MOD;
	      dp[toIndex(p10)] = (dp[toIndex(p10)] + MOD- dp[toIndex(cur)]) % MOD;
	      sp = sp*10;
	    }

	}
      ll ans = 0;
      REP(i,A,B+1)
	{
	  ans = (dp[toIndex(i)] + ans) % MOD;
	  //cout << "dp[" << toIndex(i) << "] = " << dp[toIndex(i)] << "\n";
	}
      cout << ans << endl;

    }
  return 0;
}

Measured memory_bytes: 9796
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
var n=Arr.shift()-0;
for(var i=0;i<n;i++){
    var arr=Arr[i].split(" ").map(Number);
    var s=arr[0];
    var g=arr[1];
    var ans=[s];
    var plus=1;
    if(s<g){
        do{
            s++;
            ans.push(s);
        }while(s!=g)
    }
    else if(s>g && s<=5){
        do{
            s--;
            ans.push(s);
        }while(s!=g)
    }
    else if(s>g && s>=6){
        do{
            s+=plus;
            if(s==10){
                s=5;
                plus=-1;
                
            }
            if(s==0){
                plus=1;
            }
            ans.push(s);
        }while(s!=g);
    }
    console.log(ans.join(" "));
}


Measured memory_bytes: 15120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a>>b;
  if(a==b) cout << "Draw" <<endl;
  else if(a==1) cout <<"Alice" << endl;
  else if(b==1) cout << "Bob" << endl;
  else if(a<b) cout << "Bob" << endl;
  else cout << "Alice" << endl;
  return 0;
}


Measured memory_bytes: 256
/**
  @file a.cpp
  @title A - Rounding
  @brief https://atcoder.jp/contests/abc130/tasks/abc130_a
**/

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

template <class T>
void show(vector<T>& v) {
  for (uint i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << "\n";
}

int main(int argc, char* argv[]) {
  int X, A;
  cin >> X >> A;

  if (X < A) {
    cout << "0" << endl;
  } else {
    cout << "10" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t,i,j,k,l,m,n,a[200005],b[200005];
    char s[200005],s1[200005];
    map<long long,long long>mp;
    pair<long long,long long>p[200005];
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>j>>k;
        p[i].first=j;
        p[i].second=k;
    }
    sort(p,p+n);
    k=m;
    long long ans=0;
    for(i=0;i<n;i++)
    {
        if(p[i].second>=k)
        {
            ans=ans+k*p[i].first;
            k=0;
        }
        if(p[i].second<k)
        {
            ans=ans+p[i].second*p[i].first;
            k=k-p[i].second;
        }
        if(k==0)
        break;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3328