akhauriyash/Code-Regression huggingface dataset:
#if defined(_WIN32)
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using ulong = unsigned long;
using ll = long long;
using ull = unsigned long long;

using namespace std;

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

	int n, a, b, result = 0;
	cin >> n >> a >> b;

	for(int i = 1; i <= n; i++)
	{
		int c = i / 10000, d = (i - c * 10000) / 1000, e = (i - c * 10000 - d * 1000) / 100, f = (i - c * 10000 - d * 1000 - e * 100) / 10, g = i - c * 10000 - d * 1000 - e * 100 - f * 10;
		int sum = c + d + e + f + g;
		if (a <= sum && sum <= b) result += i;
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, K; cin >> N >> K;
	vector<int> A(N, 0);
	rep (i, N) cin >> A[i];

	int res = 0;
	while(true){
		N -= K;
		++res;
		if (N <= 0) break;
		++N;
	} // end while

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"Yes"<<endl
#define cno cout<<"No"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    while(1){
        int x,y;
        cin >> x >> y;
        if(x == 0 && y == 0) return 0;
        if(y < x) cout << y sp x << endl;
        else cout << x sp y << endl;
    }
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, M;
	cin >> N >> M;
	int ans = N;
	int A;
	rep(i, 0, M)
	{
		cin >> A;
		ans -= A;
	}

	cout << max(-1LL, ans) << endl;

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll a, b;
    cin >> a >> b;
    if(b%a==0) pt(a+b);
    else pt(b-a);
    
    
    
    
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> s(n);
    vector<int> t(m);
    int max_x = -101;
    REP(j,n){
        cin >> s.at(j);
        max_x = max(max_x, s.at(j));
    }
    int min_y = 10000;
    REP(k, m){
        cin >> t.at(k);
        min_y = min(min_y, t.at(k));
    }
    int ans_1 = false;
    int ans_2 = false;
    int ans_3 = false;
    int ans = false;
    for(int i = x + 1; i <= y; i++){
        ans_1 = false;
        ans_2 = false;
        ans_3 = false;
        if(max_x < i) ans_1 = true;
        if(min_y >= i) ans_2 = true;   
        if(x < i && i <= y) ans_3 = true;
        if(ans_1 && ans_2 && ans_3) ans = true;
    }
    cout << (ans ? "No War" : "War") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using ll=long long int;
using namespace std;


int main() {

	int m, nmin, nmax;
	

	while (cin >> m >> nmin >> nmax,m!=0||nmin!=0||nmax!=0){
		
		vector <int> p(m);

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

		int maxi = 0;
		int num;
		int ans = 0;

		for (int i = nmin; i <= nmax; i++) {

			num = p[i-1] - p[i];

			if (num == maxi) {
				ans = max(ans, i);
			}

			if (num > maxi) {
				ans = i;
				maxi = num;
			}

			

			
		}

		cout << ans << endl;

		p = { 0 };
		num = 0;
		maxi = 0;
		
}

	
	return 0;
}






Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
const int INF = 1<<30;
int main(){
  int n;cin>>n;
  int bits[40]={};
  for(int i=0;i<n;i++){
  	ll a;cin>>a;
    for(int i=0;i<=32;i++){
      if(a&(1<<i))bits[i]++;
    }
  }
  bool ans=true;
  for(int i=0;i<=32;i++){
  	if(bits[i]%2){ans=false;break;}
  }
  cout<<(ans?"Yes":"No")<<endl;
}


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

using namespace std;

int main()
{
    long long d, t, s;
    float x;

    cin>>d>>t>>s;

    x = 1.0*d/s;
    if(x<=t)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
    return 0;
}

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

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;

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

int D, G;


//核問題についてコンプするか全く手を出さないかの二択
//ただし中途半端に解くのが1種だけある場合あり
//その場合コンプしない問題の中から最も単価が高いもの
int main() {
    cin >> D >> G;
    vector<int> p(D),c(D),comp(D);
    int maxc = -1;
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }
    for (int i = 0; i < D; i++) {
        comp[i] = 100 * (i+1) * p[i] + c[i];
    }
    int res = INF;
    for (int s = 0; s < 1 << D; s++) {
        int point = 0;
        int count = 0;
        int k = 0;
        for (int i = 0; i < D; i++) {
            if (s & 1 << i) {
                point += comp[i];
                count += p[i];
            } else {
                k = i;
            }
        }   
        if (point < G) {
            int j = 0;
            while (point < G) {
                if (j == p[k]-1) {        
                    break;
                }
                point += 100 * (k+1);
                count++;
                j++;
            }
        }
        if (point >= G) {
            chmin(res,count);
        }
    }
    cout << res << endl;

}


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

//??????????????????

int main(){

  int inning_num;
  char inning_data[7];
  int i,j;
  int runner[3] = {0,0,0};
  int sum = 0;
  int out_count = 0;

  scanf( "%d",&inning_num );

  for( i=0;i<inning_num;i++ ){

  for( j=0;j<3;j++ ){
    runner[j] = 0;
  }
  out_count = 0;

    while( out_count<3 ){

      scanf( "%s",inning_data );

      if( strcmp(inning_data,"HIT") == 0){

        if( runner[2] == 1 ){
          sum++;
          runner[2] = 0;
        }

        if( runner[1] == 1 ){
          runner[1] = 0;
          runner[2] = 1;
        }

        if( runner[0] == 1 ){
          runner[0] == 0;
          runner[1] = 1;
        }

        runner[0] = 1;

      }

      else if( strcmp(inning_data,"HOMERUN") == 0 ){
        sum++;
        for( j=0;j<3;j++ ){
          if( runner[j] == 1 ){
            sum++;
            runner[j] = 0;
          }
        }
      }

      else{
        out_count++;
      }

    }

    printf("%d\n",sum);
    sum = 0;

  }

  return 0;

}

Measured memory_bytes: 596
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    if (n == 1 && m == 1) {
      System.out.println(1);
    } else if (n == 1) {
      System.out.println(m - 2);
    } else if (m == 1) {
      System.out.println(n - 2);
    } else {
      System.out.println((n - 2) * (m - 2));
    }

  }
}

Measured memory_bytes: 23124
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4
1 2 2 4
2 1 4
3 0
4 1 3

output:
1 0
2 1
3 2
4 1
"""

import sys
from collections import deque

UNVISITED, VISITED_IN_QUEUE, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(v_info):
    for v_detail in v_info:
        v_index, adj_num, *adj_list = map(int, v_detail)
        # assert len(adj_list) == adj_num
        init_adj_table[v_index].extend(adj_list)
    return init_adj_table


def graph_bfs(v_init):
    status[v_init] = VISITED_IN_QUEUE
    distance[v_init] = 0
    queue.appendleft(v_init)

    while queue:
        current = queue.popleft()
        for v in adj_table[current]:
            if status[v] is UNVISITED:
                status[v] = VISITED_IN_QUEUE
                distance[v] = distance[current] + 1
                queue.append(v)
        status[current] = POPPED_OUT
    return distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    vertices_info = list(map(lambda x: x.split(), _input[1:]))
    init_adj_table = tuple([] for _ in range(vertices_num + 1))
    # assert len(vertex_info) == vertex_num

    # config length = (vertex_num + 1)
    queue = deque()
    status = [UNVISITED] * (vertices_num + 1)
    distance = [-1] * (vertices_num + 1)

    adj_table = generate_adj_matrix(vertices_info)
    ans = graph_bfs(1)
    for k, v in enumerate(ans[1:], 1):
        print(k, v)

Measured memory_bytes: 8028
#include <stdio.h>

int main(void)
{
     int A; int B; int an;

     scanf("%d",&A);
     scanf("%d",&B);

    if (A + B < 24)
       printf("%d\n",A + B);
    else if (A + B >= 24)
       printf("%d\n",(A + B) - 24);

     return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff  first
#define INF 1000000001
#define inf1 1000000000000000001
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 1e7+9;
const lli mod= 1000000007;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli digit(lli n){int res=(int)log10(n)+1;return res;}
lli lcm(lli a,lli b){lli ans=(a*b)/(__gcd(a,b));return ans;}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
///=================== ALWAYS CHECK 1 or 0 base case=================================================================================///
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
int d[maxn];
void solve()
{
    int n,m;cin>>n>>m;
    while(m--)
    {
        int a ,b;cin>>a>>b;
        d[a]++,d[b]++;
    }
    for(int i=1;i<=n;i++)cout<<d[i]<<endl;
}
int main()
{
    solve();
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N;
	
	cin >> N;
	
	int x[N], y[N];
	ll h[N];
	
	rep(i, N)
		cin >> x[i] >> y[i] >> h[i];
		
	rep(i, 101){
		ll H = 0;
		rep(j, 101){
			rep(k, N){
				if(h[k] != 0){
					H = h[k] + abs(i - x[k]) + abs(j - y[k]);
					break;
				}
			}
			bool f = true;
			rep(k, N){
				ll hi = H - abs(i - x[k]) - abs(j - y[k]);
				hi = max(hi, 0LL);
				if(h[k] != hi){
					f = false;
					break;
				}
			}
			if(f){
				cout << i << " " << j << " " << H;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
/* author   : mpily :-()
title : Competing.cpp
time :Sun Sep  1 17:56:15 2019

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int A,B;
	cin>>A>>B;
	int  num = B-1;
	int den = A-1;
	int count = num/den;
	if(B==1)count = 0;
	else if(count*A - (count -1)< B)count+=1;
	cout<<count<<"\n";
	return 0;
}

Measured memory_bytes: 256
inf = float('inf')

# 一点更新　区間取得　1-indexed
class SegmentTree:
    def __init__(self, n):
        tmp = 1
        while tmp < n:
            tmp <<= 1
        # self.N : 完全二分木の葉の数(N以上の最小の2べき)
        self.N = tmp
        # 2*self.N - 1 : 完全二分木のノード数
        # 1-indexedで管理するので１つ余分に設ける
        self.Data = [(inf, -1) for _ in range(2*self.N)]

    # k (0-indexed)
    def update(self, k, x):
        #　インデックスを補正
        k += self.N
        # 指定ノードを更新
        self.Data[k] = (x, k-self.N)
        # kを含む区間ノードを更新していく
        while k > 1:
            k >>= 1
            self.Data[k] = min([self.Data[2*k], self.Data[2*k+1]])

    # [l, r) (0-indexed)
    def query(self, l, r):
        #　インデックスを補正
        l += self.N
        r += self.N
        # 返り値を初期化
        res = (inf, -1)
        while l < r:
            # 右側なら右側を更新 右上に行く
            # 左側なら更新しない　上に行く
            if l & 1:
                res = min([res, self. Data[l]])
                l += 1
            # 右側なら左側を更新　上に行く
            # 左側なら更新しない 上に行く
            if r & 1:
                r -= 1
                res = min([res, self.Data[r]])
            l >>= 1; r >>= 1
        return res

    def value(self, k):
        k += self.N
        return self.Data[k]

N, M = map(int,input().split())
S = input()

ST = SegmentTree(N+1)
ST.update(0, 0)
memo = [-1] * (N+1)

for i in range(1, N+1):
    l = max(i-M, 0)
    r = i
    if S[i] == "0":
        d, j = ST.query(l, r)
        if d != inf:
            ST.update(i, d+1)
            memo[i] = j

if ST.value(N)[0] == inf:
    print(-1)
    exit()

ans = []
now = N
while now != 0:
    pre = memo[now]
    ans.append(now-pre)
    now = pre

print(*ans[::-1])

Measured memory_bytes: 68664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll n,m;
  while(cin>>n>>m,n||m){
    string s,p,g;
    cin>>s>>p>>g;
    vector<P> G[n];
    map<string,int> st;
    vector<string> vs;
    for(ll i=0;i<m;i++){
      string a,b;
      ll d,t;
      cin>>a>>b>>d>>t;
      if(st.find(a)==st.end()){
	st[a]=vs.size();
	vs.push_back(a);
      }
      if(st.find(b)==st.end()){
	st[b]=vs.size();
	vs.push_back(b);
      }
      G[st[a]].push_back(P(st[b],d/40+t));
      G[st[b]].push_back(P(st[a],d/40+t));
    }
    ll ans=0;
    ll dp[n];
    priority_queue<P,vector<P>,greater<P> > q;
    memset(dp,-1,sizeof(dp));
    q.push(P(0,st[s]));
    while(!q.empty()){
      P pp=q.top();q.pop();
      ll v=pp.second,d=pp.first;
      if(~dp[v]&&dp[v]<=d) continue;
      dp[v]=d;
      if(v==st[p]) break;
      for(ll i=0;i<(ll)G[v].size();i++){
	q.push(P(d+G[v][i].second,G[v][i].first));
      }
    }
    while(!q.empty()) q.pop();
    ans+=dp[st[p]];
    memset(dp,-1,sizeof(dp));
    q.push(P(0,st[p]));
    while(!q.empty()){
      P pp=q.top();q.pop();
      ll v=pp.second,d=pp.first;
      if(~dp[v]&&dp[v]<=d) continue;
      dp[v]=d;
      if(v==st[g]) break;
      for(ll i=0;i<(ll)G[v].size();i++){
	q.push(P(d+G[v][i].second,G[v][i].first));
      }
    }
    ans+=dp[st[g]];
    cout<<ans<<endl;
  } 
  return 0;
}

Measured memory_bytes: 3424
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rep2(i,n) for(int i=2;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[200010];
ll amari1[200010];
ll amari2[200010];

int main(){
  ll n; cin >> n;
  string s; cin >> s;
  ll popn=0;
  rep(i,n){
    if(s[i]=='1') popn++;
  }
  dp[0]=0;
  rep1(i,200000){
    dp[i]=dp[i%(__builtin_popcount(i))]+1;
  }
  amari1[0]=1%(popn+1);
  if(popn-1!=0) amari2[0]=1%(popn-1);
  rep1(i,200000){
    amari1[i]=amari1[i-1]*2%(popn+1);
  }
  rep1(i,200000){
    if(popn-1!=0) amari2[i]=amari2[i-1]*2%(popn-1);
  }
  ll x1=0;
  ll x2=0;
  reverse(all(s));
  rep(i,n){
    if(s[i]=='1'){
      x1=(x1+amari1[i])%(popn+1);
      if(popn-1!=0) x2=(x2+amari2[i])%(popn-1);
    }
  }
  reverse(all(s));
  vector<ll> ans(n);
  rep(i,n){
    if(s[i]=='1'&&popn-1!=0) ans[i]=dp[(x2-amari2[n-1-i]+(popn-1))%(popn-1)];
    else if(s[i]=='1') ans[i]=-1;
    else ans[i]=dp[(x1+amari1[n-1-i])%(popn+1)];
  }
  rep(i,n){
    cout << ans[i]+1 << endl;
  }
  
}

Measured memory_bytes: 9724
// Reverse Sequence
#include <cstdio>
#include <cstring>

int main()
{
	char str[20+1] = {0};
	scanf("%s", str);
	
	size_t n = strlen(str);
	
	for (int i = n -1; i >= 0; i--)
		printf("%c", str[i]);
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 932
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int a=0;
	int b=0;
	int N=0;
	scanf("%d %d",&a,&b);
	scanf("%d",&N);
if(N!=0)
{
	int s[N]={0};
	int f[N]={0};
	for(int i=0;i<N;i++)
	{
		scanf("%d %d",&s[i],&f[i]);
	}
        
	for(int i=0;i<N;i++)
	{
		if(a>s[i])
		{
		  if(a<f[i])
		  {
			  printf("1\n");
			  break;
		  }
		}
		if(b>s[i])
		{
		  if(b<=f[i])
		  {
			  printf("1\n");
			  break;
		  }
		}
		if(a<=s[i])
		{
			if(b>f[i])
			{
			  printf("1\n");
			  break;
			}
		}
		if(i==N-1){printf("0\n");}
	}
}else{printf("0\n");}

	return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N; cin >> N;
  VL as(N), bs(N);
  REP(i,N){
	cin >> as[i] >> bs[i];
  }

  LL ans = 0, acc = 0;
  for(int i=N-1;i>=0;--i){
	LL d = (bs[i] - (as[i]+acc) % bs[i]) % bs[i];
	ans += d;
	acc += d;;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, L;
  cin >> N >> L;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  int pos = -1;
  for (int i = 0; i < N - 1; i++){
    if (a[i] + a[i + 1] >= L){
      pos = i + 1;
    }
  }
  if (pos == -1){
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
    for (int i = 1; i < pos; i++){
      cout << i << endl;
    }
    for (int i = N - 1; i > pos; i--){
      cout << i << endl;
    }
    cout << pos << endl;
  }
}

Measured memory_bytes: 3768
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<double, double> pdd;
typedef vector<string> vs;

int main() {
  vi erat(1000000, 1);
  erat[0] = erat[1] = 0;
  for (int i = 2; i * i < erat.size(); ++i) if (erat[i]) {
    for (int j = i * i; j < erat.size(); j += i) erat[j] = 0;
  }
  int n;
  scanf("%d", &n);
  vi p;
  for (int i = 2; i <= 2500; ++i) {
    p.push_back(i);
    for (int j = 2; j * j <= i; ++j) if (i % j == 0) {
      p.pop_back();
      break;
    }
  }
  vl p3;
  for (ll d : p) p3.push_back(d*d*d);
  int was1 = 0;
  vl a;
  for (int i = 0; i < n; ++i) {
    ll x;
    scanf("%lld", &x);
    for (ll d3 : p3) {
      if (d3 > x) break;
      while (x % d3 == 0) x /= d3;
    }
    if (x == 1) {
      was1 = 1;
    } else {
      a.push_back(x);
    }
  }
  sort(a.begin(), a.end());
  if (a.empty()) {
    cout << was1 << endl;
    return 0;
  }
  vl v(1, a[0]);
  vi c(1, 1);
  for (int i = 1; i < a.size(); ++i) {
    if (a[i] == a[i-1]) ++c.back();
    else {
      v.push_back(a[i]);
      c.push_back(1);
    }
  }
  vi was(v.size());
  int res = was1;
//  cerr << was1 << endl;
  for (int i = 0; i < v.size(); ++i) if (!was[i]) {
//    cerr << v[i] << ' ' << c[i] << endl;
    was[i] = 1;
    ll r = 1;
    ll val = v[i];
    for (int it = 0; it < p.size() && p3[it] <= val; ++it) if (val % p[it] == 0) {
      ll mul = p3[it];
      while (val % p[it] == 0) {
        val /= p[it];
        mul /= p[it];
      }
      if (r <= 1e15 / mul) r *= mul;
      else r = 1e15;
    }
    if (val > 1) {
      ll sq = sqrt(val);
      while (sq * sq < val) ++sq;
      while (sq * sq > val) --sq;
      if (sq * sq == val) {
        assert(erat[sq]);
        val = 1;
        if (r <= 1e15 / sq) r *= sq;
        else r = 1e15;
      }
    }
    if (val > 1 && val <= 1000000) {
      ll mul = val * val;
      if (r <= 1e15 / mul) r *= mul;
      else r = 1e15;
      val = 1;
    }
    if (val > 1 || !binary_search(v.begin(), v.end(), r)) {
      res += c[i];
    } else {
      int it = lower_bound(v.begin(), v.end(), r) - v.begin();
      assert(!was[it]);
      was[it] = 1;
      res += max(c[i], c[it]);
    }
  }
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 6780
// atcoder/abc131/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli a, b, c, d;
  while (cin >> a >> b >> c >> d) {
    auto fn = [&] (lli x) {
      return (b / x) - ((a - 1) / x);
    };
    cout << (b - a + 1) - fn(c) - fn(d) + fn(c * d / __gcd(c, d)) << endl;
  }

  return 0;
}


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

template <typename A, typename B>string to_string(pair<A, B> p);template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p);template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p);string to_string(const string& s) {  return '"' + s + '"';}string to_string(const char* s) {  return to_string((string) s);}string to_string(bool b) {  return (b ? "true" : "false");}string to_string(vector<bool> v) {  bool first = true;  string res = "{";  for (int i = 0; i < static_cast<int>(v.size()); i++) {    if (!first) {      res += ", ";    }    first = false;    res += to_string(v[i]);  }  res += "}";  return res;}template <size_t N>string to_string(bitset<N> v) {  string res = "";  for (size_t i = 0; i < N; i++) {    res += static_cast<char>('0' + v[i]);  }  return res;}template <typename A>string to_string(A v) {  bool first = true;  string res = "{";  for (const auto &x : v) {    if (!first) {      res += ", ";    }    first = false;    res += to_string(x);  }  res += "}";  return res;}template <typename A, typename B>string to_string(pair<A, B> p) {  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p) {  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p) {  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {  cerr << " " << to_string(H);  debug_out(T...);}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define set0(x) memset(x,0,sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
template<typename T, typename... Args> void read(T &first, Args& ... args) {
    read(first);
    read(args...);
}

ll n,A[100010],cnt[100010];
int main() {
    read(n);n+=1;
    for(int i=0;i<n;i++){
        read(A[i]);
    }
    cnt[0] = 1;
    for(int i=0;i<n;i++){
        cnt[i+1] = min((ll)1e18,(cnt[i]-A[i])*2);
        //cout<<i<<' '<<cnt[i]<<endl;
    }
    ll mcnt = 0;
    ll ans = 0;
    for(int i=n-1;i>=0;i--){
        if((mcnt+1)/2+A[i]>cnt[i]){
            cout<<-1<<endl;
            return 0;
        }
        mcnt = min(mcnt+A[i],cnt[i]);
        //cout<<mcnt<<endl;
        ans+=mcnt;
    }
    cout<<ans<<endl;
    return 0;
}
//A' = [A*0.5,A]+B


Measured memory_bytes: 5192
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!
ll lcm(ll A, ll B){
    ll w, gcd=A, b=B;
    if(gcd<b) swap(gcd, b);
    while(b){
        w=gcd%b;
        gcd=b;
        b=w;
    }
    return A*B/gcd;
}
int main(void){
    ll A, B, C, D;
    scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
    ll ans = B-A+1 - B/C + A/C -B/D +A/D +B/lcm(C,D) -A/lcm(C,D);
    printf("%lld\n", (A%C==0||A%D==0) ? --ans:ans);
    return 0;
}


Measured memory_bytes: 128
import math
K=int(input())

ans=0
for i in range(1,K+1):
    ans+=i

for i in range(1,K):
    for j in range(i+1,K+1):
        ans+=math.gcd(i,j)*6

for i in range(1,K-1):
    for j in range(i+1,K):
        for k in range(j+1,K+1):
            val=math.gcd(i,j)
            val=math.gcd(val,k)
            ans+=val*6

print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
const int mod = 1000000007;
 
int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(true) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }

        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}

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

int main() {
    const std::string s("CODEFESTIVAL2016");
    std::string in;
    std::cin >> in;
    int ret = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (in[i] != s[i]) ++ ret;
    }
    std::cout << ret << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

// 愚直にやると計算量が大きい

int main() {
    string s; cin >> s;
    string t = {};
    rep(i, 0, sz(s)){
        if(s[i]=='B' && s[i+1]=='C'){
            t.push_back('D');
            i++;
        }
        else t.push_back(s[i]);
    }
    ll cnta = 0, ans = 0;
    rep(i, 0, sz(t)){
        if(t[i]!='A'&&t[i]!='D'){
            cnta = 0;
        }else{
            if(t[i]=='A') cnta++;
            if(t[i]=='D') ans += cnta;
        }
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 776
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class CDistinctOrNot {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        unordered_set<int> sets;
        in >> N;
        REP(i,0,N) {
            int n;
            in >> n;
            sets.insert(n);
        }
        out << (N == sets.size() ? "YES" : "NO") << "\n";
    }
};


signed main() {
    CDistinctOrNot solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 8520
h,w = map(int, input().split())
a = [input() for i in range(h)]

for i in range(w+2):
    print('#', sep='', end='')
print()
for i in range(h):
    print('#'+a[i]+'#')

for i in range(w+2):
    print('#', sep='', end='')
print()



Measured memory_bytes: 3060
#include<iostream>
using namespace std;
struct Card
{
    char name;
    int number;
};
Card a[100005],b[100005],tmp[100005];
int n;
void merge(Card a[],int l,int m,int r,Card tmp[])
{
    int p1=l,p2=m+1,p3=0;
    while(p1<=m&&p2<=r)
    {
        if(a[p1].number<=a[p2].number) tmp[p3++]=a[p1++];
        else tmp[p3++]=a[p2++];
    }
    while(p1<=m) tmp[p3++]=a[p1++];
    while(p2<=r) tmp[p3++]=a[p2++];
    for(int i=0;i<=r-l;i++) a[i+l]=tmp[i];
}
void mergesort(Card a[],int l,int r,Card tmp[])
{
    if(l<r)
    {
        int m=l+(r-l)/2;
        mergesort(a,l,m,tmp);
        mergesort(a,m+1,r,tmp);
        merge(a,l,m,r,tmp);
    }
}
int partition(Card a[],int p,int r)
{
    Card x=a[r],t;
    int i=p-1;
    for(int j=p;j<r;j++)
    {
        if(a[j].number<=x.number)
        {
            i++;
            t=a[j];a[j]=a[i];a[i]=t;
        }
    }
    t=a[i+1];a[i+1]=a[r];a[r]=t;
    return i+1;
}
void quicksort(Card a[],int p,int r)
{
    if(p<r)
    {
        int q=partition(a,p,r);
        quicksort(a,p,q-1);
        quicksort(a,q+1,r);
    }
}
int main()
{
    int i,stable=1;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i].name>>a[i].number;
        b[i].name=a[i].name;
        b[i].number=a[i].number;
    }
    mergesort(b,0,n-1,tmp);
    quicksort(a,0,n-1);
    for(i=0;i<n;i++)
    {
        if(a[i].name!=b[i].name)
        {
            stable=0;
            break;
        }
    }
    if(stable==1) cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    for(i=0;i<n;i++)
    {
        cout<<a[i].name<<" "<<a[i].number<<endl;
    }
    return 0;
}


Measured memory_bytes: 5456
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
    }
    let ans = std::cmp::max(a - 2 * b, 0);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

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 (a>b) { a=b; return 1; } return 0; }


int main() {
    int N; cin>>N;
    vector<vector<int>> shingi(N,vector<int>(N,-1));

    int A,B,C;
    for (int i = 0; i < N; ++i) {
        cin>>A;
        for (int j = 0; j < A; ++j) {
            cin>>B>>C;
            shingi[i][B-1]=C;
        }
    }

    int ans=0;
    for (int i = 0; i < (1 << N); ++i) {
        bool f=true;
        int cnt=0;
        for (int j = 0; j < N; ++j) {
            bool shojiki=true;
            for (int k = 0; k < N; ++k) {
                if(shingi[j][k]==-1) continue;
                if(((i>>k)&1)!=shingi[j][k]){
                    shojiki=false;
                    break;
                }
            }
            if((i>>j)&1) ++cnt;
            if(((i>>j)&1)!=shojiki){
                f=false;
                break;
            }
        }
        if(f){
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean b = true;
		Set<Integer> set = new HashSet<Integer>();//HashSetで空の箱を作る
		for(int  i=0; i<N; i++) {
			int a= sc.nextInt();
			b =	set.add(Integer.valueOf(a));//set.addで空の箱に重複を除いたaを追加する
			if(!b){
				System.out.println("NO");
              	return;
			}
		}
		//元の配列の要素数と異なればNO、変化していなければYES
		System.out.println("YES");
	}
		
}

Measured memory_bytes: 100188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int A[50],B[50],C[50],D[50];
int N,M,Q;
int sum,ans;
void solve(int arr[],int n) {
    if(n == N+1) {
        sum = 0;
        for(int i=0;i<Q;i++) {
            if(arr[B[i]]-arr[A[i]] == C[i]) {
                sum+=D[i];
            }
        }
        ans = max(ans,sum);
        return ;
    }
    for(int i=arr[n-1];i<=M;i++) {
        arr[n] = i;
        solve(arr,n+1);
    }
}
int main () {
    ios_base::sync_with_stdio(false);
    cin>>N>>M>>Q;
    for(int i=0;i<Q;i++) {
        cin>>A[i]>>B[i]>>C[i]>>D[i];
    }
    int arr[11];
    fill(arr,arr+11,1);
    ans = 0;
    solve(arr,1);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x) // big bug here if "-x" is not surrounded by "()"
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}};

int a,b,t;

void dane() {
    cin>>a>>b>>t;
    cout<<(t/a*b)<<endl;
}


int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    fn(0,0,0,0);
    System.out.println(count);
  }
  static int count = 0;
  static int N;
  public static void fn(long num, int a, int b, int c){
    if (a != 0 && b != 0 && c != 0 && num<= N) {
      count++;
    }
    if (num <= N) {
      if (num*10 <N) {
        fn(num*10+3,a+1,b,c);
        fn(num*10+5,a,b+1,c);
        fn(num*10+7,a,b,c+1);
      }
    }
  }
}

Measured memory_bytes: 36552
S = input()
N = ['dream', 'dreamer', 'erase', 'eraser']

S = S[::-1]

t = []
i = 0
T = ''

if len(S) < 3:
    print('No')
else:
    while i<len(S):
        if S[i] == 'm' and S[i+1] == 'a' and S[i+2] == 'e':
            letter = 'dream'
            i += 4
        elif S[i] ==  'r' and S[i+1] == 'e' and S[i+2] == 'm':
            letter = 'dreamer'
            i += 6
        elif S[i] == 'e' and S[i+1] == 's' and S[i+2] == 'a':
            letter = 'erase'
            i += 4
        elif S[i] == 'r' and S[i+1] == 'e' and S[i+2] == 's':
            letter = 'eraser'
            i += 5
        else:
            break
        i += 1
        t.append(letter)

#print(t)

    for x in t[::-1]:
        T += x

#print(T)

    if S == T[::-1]:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 3572
import itertools

n, d = map(int, input().split())
x = [input().split() for x in range(n)]
l = list(itertools.combinations(x, 2))

ans = 0
for i in l:
    tmp = 0
    for j in range(d):
        tmp += (int(i[0][j]) - int(i[1][j])) ** 2
    if (tmp ** 0.5).is_integer():
        ans += 1


print(ans)


Measured memory_bytes: 38384
a, b, c, d = map(int, input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return (x * y) // gcd(x, y)

div1 = b//c - a//c

div2 = b//d - a//d

e = lcm(c,d)
div3 = b//e - a//e

if a%c==0:
    div1 += 1
if a%d==0:
    div2 += 1
if a%e==0:
    div3 += 1

ans = b-a+1 - div1 - div2 + div3
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100005;

char S[MAXN];

int main()
{
	scanf("%s",S);
	int n=strlen(S);
	int ans1=n,ans2=n;
	for(int i=0;i<n;i++)
		if(S[i]=='1')
			ans1=min(ans1,max(n-i-1,i));
		else
			ans2=min(ans2,max(n-i-1,i));
	printf("%d\n",max(ans1,ans2));
	return 0;
}


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

const int64_t MOD = 1e+09;

int main() {
    int N;
    cin >> N;
    
    vector<int64_t> A(N);
    bool flg = false;
    for ( int i = 0; i < N; ++i){
        cin >> A.at(i);
        if ( A.at(i) == 0 ){
            flg = true;
        }
    }
    
    int64_t ans0 = 1, ans1 = 0;
    for ( int i = 0; i < N; ++i){
        ans0 = ans0 * A.at(i);
        ans1 = ans1 * A.at(i);
        if ( ans0 > MOD ){
            ans1 = ans1 + ans0 / MOD;
            ans0 = ans0 % MOD;
        }
        if ( ans1 >= MOD and ans0 > 0){
            ans0 = -1;
            ans1 = 0;
            break;
        }
    }

    
    if ( flg ){
        cout << 0 << endl;
    } else {
        //cout << ans1 << " " << ans0 << endl;
        cout << ans1 * MOD + ans0 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  int w[n];
  REP(i,n){
    cin>>w[i];
  }
  int s[n];
  REP(i,n){
    if(i==0){
      s[i]=w[i];
    }else{
      s[i]=s[i-1]+w[i];
    }
  }
  int ans = s[n-1];
  REP(i,n-1){
    ans = min(ans,abs(s[n-1]-s[i]-s[i]));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int x = 0;

    int K;
    scanf("%d", &K);
    int A, B;
    scanf("%d %d", &A, &B);

    while(A <= B) {
        if (A % K == 0) {
            printf("OK\n");
            return 0;
        }
        A++;
    }
    
    printf("NG\n");
    return 0;
}

Measured memory_bytes: 1644