akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x, y;
	cin >> x >> y;
	ll ans=0;
	while(x<=y){
		ans++;
		x*=2;
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

int main()
{
  int n,f;
  cin>>n;
  int c=0;
  while(n)
  {
    f = n%10;
    n = n/10;
    if(f==7)
    {
      c=1;
      break;
    }
  }
  if(c==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}
    

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
char c[310][310];
ll ans[310][310];
pair<ll,ll>p[100010];
int main() {
	ll h,w,k;
	cin>>h>>w>>k;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>c[i][j];
	ll num=1,cnt=-1;

	for(int i=0;i<h;i++){
		bool f=0;
		for(int j=0;j<w;j++){
			if(c[i][j]=='#'){
				f=1;
				cnt++;
			}
		}
		if(f){
			for(int j=0;j<w;j++){
				ans[i][j]=num;
				if(c[i][j]=='#'&&cnt){
					num++;
					cnt--;
				}
			}
			num++;
			f=0;
			cnt=-1;
		}
	}
	for(int i=1;i<h;i++){
		for(int j=0;j<w;j++){
			if(ans[i][j]==0)ans[i][j]=ans[i-1][j];
		}
	}
	for(int i=h-2;i>=0;i--){
		for(int j=0;j<w;j++){
			if(ans[i][j]==0)ans[i][j]=ans[i+1][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j==w-1)cout<<ans[i][j]<<endl;
			else cout<<ans[i][j]<<' ';
		}
	}
	return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> p(n);
	rep(i, n) cin >> p[i].first >> p[i].second;
	sort(p.begin(), p.end());
	ll ans = 0;
	ll tmp = 0;
	rep(i, n) {
		if (tmp + p[i].second >= m) {
			while (tmp < m) {
				tmp++;
				ans += p[i].first;
			}
			break;
		}
		else {
			tmp += p[i].second;
			ans += p[i].first * p[i].second;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

typedef long long ll;
const int Max = 1e5 + 5;
using namespace std;
ll a[Max], ans;

int main(){
	int a, b, c, n, m, i, j;
	scanf("%d %d %d", &a, &b, &c);
	ans = 1;
	ans += 2 * b;
	c -= (1 + b);
	if(c >= a) ans += a;
	else ans += c;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,s;
int main(){
    scanf("%d%d%d%d",&a,&b,&c,&n);
    for (register int i=0;i<=a;i++) for (register int j=0;j<=b;j++) if((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50)) s++;
    printf("%d\n",s);
    return 0;
}

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

A_list = list(map(int, input().split()))

A_kyori = []
for i in range(N - 1):
    A_kyori.append(A_list[i + 1] - A_list[i])

A_kyori.append(K - A_list[-1] + A_list[0])

print(sum(A_kyori) - max(A_kyori))

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

int main(){
    string s;
    cin>>s;
    int ans=0,cnt=0;
    for(auto c : s){
        if(c=='A'||c=='G'||c=='C'||c=='T'){
            ans=max(ans,++cnt);
        }
        else cnt=0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
A,B=map(int,input().split())
lst=set()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if A==B==1:
    print(1)
else:
    print(len(set([i[0] for i in factorization(A)])&set([i[0] for i in factorization(B)]))+1)


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,sum=0;
  cin>>n>>m;
  while(m--){
    int x;
    cin>>x;
    sum+=x;
  }
  if(sum>n)
    cout<<-1<<endl;
  else cout<<n-sum<<endl;
}
  

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

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    if(a + 5*b + 10*c + 50*d + 100*e + 500*f >= 1000){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
n, k = map(int, input().split())
*A, = map(int, input().split())
p = 10**9 + 7
A.sort()
ans = 1
if A[n - 1] <= 0 and k % 2 == 1:
    for i in range(k):
        ans *= A[n - 1 - i]
        ans %= p
    print(ans)
    exit()
i = 0
j = n - 1
if k % 2 == 1:
    ans *= A[j]
    ans %= p
    j -= 1
    k -= 1
    n -= 1
for _ in range(k // 2):
    left = A[i] * A[i + 1]
    right = A[j] * A[j - 1]
    if (left > right):
        ans *= left
        ans %= p
        i += 2
    else:
        ans *= right
        ans %= p
        j -= 2
print(ans)


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

using namespace std;

int main()
{
   int n;
   cin>>n;
   double a[n];
   for(int i=0;i<n;i++)
   {
      cin>>a[i];
   }
   sort(a,a+n);
   int i;
   double m;
   m=(a[0]+a[1])/2;
   for(i=2;i<n;i++)
   {
      m=(a[i]+m)/2;
   }
   cout<<m;

    return 0;
}


Measured memory_bytes: 256
a=input().split()
n=(int)(a[0])
q=(int)(a[1])
b=[0 for i in range(2*n)]
cnt=0
tmp=0
for i in range(n):
    B=input().split()
    b[2*i]=B[0]
    b[2*i+1]=int(B[1])
while len(b)>0:
    tmp=b[1]-q
    if tmp>0:
        b.append(b[0])
        b.append(tmp)
        del b[0]
        del b[0]
        cnt=cnt+q
    else:
        cnt=cnt+b[1]
        print(b[0],cnt)
        del b[0]
        del b[0]


Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int ok=-1,ng=n;
    while(ng-ok>1){
        int mid=(ok+ng)/2;
        swap(a[mid],a[n-1]);
        bool dp[k]={};
        dp[0]=true;
        for(int i=0;i<n-1;i++){
            for(int j=k-1;j>=0;j--){
                if(dp[j]&&j+a[i]<k){
                    dp[j+a[i]]=true;
                }
            }
        }
        bool flag=false;
        for(int i=0;i<k;i++){
            if(dp[i]&&k-a[n-1]<=i){
                flag=true;
                break;
            }
        }
        (flag?ng:ok)=mid;
        swap(a[mid],a[n-1]);
    }
    cout<<ok+1<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int fx = 0;
        for(int i = 0; i < s.Length; i++)
        {
            fx += Convert.ToInt32(s[i].ToString());
        }
        Console.WriteLine(int.Parse(s) % fx == 0 ?
            "Yes" : "No");
    }
}


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

int main(){
  int k,n;
  cin >> k >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i];
  a[n]=a[0]+k;
  sort(a.begin(),a.end());
  int l=k;
  rep(i,n){
    l=min(k-(a[i+1]-a[i]),l);
  }
  cout<<l;
  return 0;
}

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

using namespace std;

int main() {
	int H, W, N;
	cin >> H >> W >> N;
    
    int sx, sy;
    cin >> sy >> sx;

    string S, T;
    cin >> S >> T;

    int tu = 0, td = 0, tl = 0, tr = 0, au = 0, ad = 0, al = 0, ar = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'L') ++tl;
        if (S[i] == 'R') ++tr;
        if (S[i] == 'U') ++tu;
        if (S[i] == 'D') ++td;
        int uy = sy - tu, lx = sx - tl, dy = sy + td, rx = sx + tr;
        if (uy + ad <= 0 || lx + ar <= 0 || H < dy - au || W < rx - al) {
            cout << "NO" << endl;
            return 0;
        }
        if (T[i] == 'L' && 1 < sx + tr - al) ++al;
        if (T[i] == 'R' && sx - tl + ar < W) ++ar;
        if (T[i] == 'U' && 1 < sy + td - au) ++au;
        if (T[i] == 'D' && sy - tu + ad < H) ++ad;
    }

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double

using namespace std;

    const ll N = 1e5 + 7;
    const ll mod = 1e9 + 7;
ll n  , ans , m , a ,b , c , d, cnt;
string s , s1;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> a;
    cout << a * a + a * a * a + a;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int N=9,S=100;
	vvi dp(N+1,vi(S+1));
	dp[0][0]=1;
	loop(x,0,10)for(int i=N-1;i>=0;i--)for(int j=S;j>=0;j--)if(j+x<=100){
		dp[i+1][j+x]+=dp[i][j];
	}
	int n,s;
	while(cin>>n>>s,n+s){
		cout<<dp[n][s]<<endl;
	}
}

Measured memory_bytes: 3160
<?php
fscanf(STDIN, "%d %d %d", $h, $w, $n);

$vs = [[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1]];
$x = array_fill(0, 10, 0);
$x[0] = ($h - 2) * ($w - 2);
while ($n--) {
	fscanf(STDIN, "%d %d", $a, $b);
	foreach ($vs as $v) {
		$i = $a - 2 + $v[0];
		$j = $b - 2 + $v[1];
		if ($i >= 0 && $i < $h - 2 && $j >= 0 && $j < $w - 2) {
			if (isset($m[$i][$j])) {
				$x[$m[$i][$j]]--;
				$x[++$m[$i][$j]]++;
			} else {
				$m[$i][$j] = 1;
				$x[0]--;
				$x[1]++;
			}
		}
	}
}
echo implode("\n", $x), "\n";

Measured memory_bytes: 219512
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

int main(void){
    int N;
    int A,B,C;

    cin>>N>>A>>B>>C;

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

    int size=1;
    for(int i=0;i<N;i++){
        size*=4;
    }

    int ans=INT32_MAX;

    for(int i=0;i<size;i++){
        int A_temp=0;
        int B_temp=0;
        int C_temp=0;
        int MPsum=0;

        for(int k=0;k<N;k++){

            int ABCjudge=i;
            for(int l=0;l<k;l++){
                ABCjudge/=4;
            }
            ABCjudge%=4;

            if(ABCjudge==1){
                if(A_temp>0){MPsum+=10;}
                A_temp+=l[k];
            }else if(ABCjudge==2){
                if(B_temp>0){MPsum+=10;}
                B_temp+=l[k];
            }else if(ABCjudge==3){
                if(C_temp>0){MPsum+=10;}
                C_temp+=l[k];
            }
        }

        MPsum+=abs(A-A_temp);
        MPsum+=abs(B-B_temp);
        MPsum+=abs(C-C_temp);
        if(MPsum<ans && A_temp!=0 && B_temp!=0 && C_temp!=0){ans=MPsum;}
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

int ar[1010];
vector<ll> arz;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n, k;
    cin >> n >> k;
    forn(i, n)
        cin >> ar[i];
    int sz = 0;
    forn(i, n) {
        ll sum = 0;
        for (int j = i; j < n; ++j) {
            sum += ar[j];
            arz.pb(sum);
        }
    }
    sort(all(arz));
    reverse(all(arz));
    ll mask = 0;
    for (ll st = 1LL << 42; st; st >>= 1) {
        int cnt = 0;
        ll cur_mask = mask | st;
        forn(i, arz.size()) {
            if ((cur_mask & arz[i]) == cur_mask)
                ++cnt;
            if (cnt == k)
                break;
        }
        if (cnt < k)
            continue;
        forn(i, arz.size()) {
            if ((cur_mask & arz[i]) == cur_mask)
                continue;
            swap(arz[i], arz.back());
            arz.pop_back();
            --i;
        }
        mask = cur_mask;
    }
    cout << mask << '\n';


    return 0;
}

Measured memory_bytes: 6512
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, D, A = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = list(tuple(map(int, input().split())) for i in range(N)) #改行行列
    S.sort()
    xs=[0]*N
    hs=[0]*N
    
    for i,s in enumerate(S):
        x,h=s
        xs[i]=x
        hs[i]=h
    tot=[0]*N
    accu=0
    count=0
    for i,x in enumerate(xs):
        accu+=tot[i]
        h=hs[i]-accu*A
        num=max(0,math.ceil(h/A))
        accu+=num
        count+=num
        ei=bisect_right(xs,x+2*D)
        if ei<N:
            tot[ei]-=num
    print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 112960
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

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

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

#define N 86400
int main() {
	int n, time[N], max, num, h, m, s;
	while (cin >> n, n) {
		max = 0; num = 0;
		for (int i = 0; i < N; ++i) time[i] = 0;
		for (int i = 0; i < n; ++i) {
			scanf("%02d:%02d:%02d", &h, &m, &s);
			++time[h * 3600 + m * 60 + s];
			scanf("%02d:%02d:%02d", &h, &m, &s);
			--time[h * 3600 + m * 60 + s];
		}
		for (int i = 0; i < N; ++i) {
			num += time[i];
			if (max < num) max = num;
		}
		cout << max << endl;
	}
	return 0;
}


Measured memory_bytes: 3360
#include<cstdio>
#include<iostream>
int a[100009],n,m,ans=1;
using namespace std;
int main() {
	int u,v;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		a[u]++,a[v]++;
	}
	for(int i=1;i<=n;i++)
		if(a[i]%2){
			ans=0;break;
		}
	if(ans)cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int int_sort( const void * a , const void * b ) {
  return (*(int*)a - *(int*)b);
}

int main(void) {
  int N;
  scanf("%d", &N);

  int A[100000];
  for(int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  qsort((void*)A, N, sizeof(int), int_sort);

  int Min = A[0];
#if 0  
  for(int i = N-1; i >= 1; i--) {
    for(int j = (i-1); j >= 0; j--) {
      int mod = A[i] % A[j];
      if(mod != 0 && Min > mod)
	Min = mod;
      if(Min == 1)
	break;
    }
  }
#endif
  while(Min > 1) {
    int Min2 = Min;
    for(int i = 0; i < N; i++) {
      int mod = A[i] % Min2;
      if(mod != 0 && Min2 > mod)
	Min2 = mod;
    }
    if(Min2 == Min)
      break;
    Min = Min2;
  }
  printf("%d\n", Min);

  return 0;
}


Measured memory_bytes: 892
import math
N,K=map(int,input().split())
R=N-K
mod = 10**9+7    
def cnr(n,r):
    a=math.factorial(n)
    b=math.factorial(n - r)
    c=math.factorial(r)
    return a//(b*c)

# def cmb(n, r, mod):
#     if ( r<0 or r>n ):
#         return 0
#     r = min(r, n-r)
#     return g1[n] * g2[r] * g2[n-r] % mod


# N = 10**5
# g1 = [1, 1]
# g2 = [1, 1]
# inverse = [0, 1]

# for i in range( 2, N + 1 ):
#     g1.append( ( g1[-1] * i ) % mod )
#     inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
#     g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(1,K+1):
    if R+2>i:
        print(cnr(K-1,i-1)*cnr(R+1,i)%mod)
    else:
        print(0)


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

ll n, a, b;

int main() {
    scanf("%lld%lld%lld", &n, &a, &b);
    if((n == 1 && a != b) || a > b) printf("0\n");
    else if(a == b) printf("1\n");
    else printf("%lld\n", ((n - 1) * b + a) - ((n - 1) * a + b) + 1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.141592653589793238462643383279L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
double kaku(double x,double y){
    if(x==0){
        if(y>=0)return pi/2.0;
        else return 3*pi/2.0;
    }
    else{
        double ret=atan(y/x);
        if(x<0)ret+=pi;
        else if(y<0)ret+=2*pi;
        return ret;
    }
}
double dist(double a,double b,double c,double d){
    return pow(((a-c)*(a-c)+(b-d)*(b-d)),0.5);
}
int main(){
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    double x[n],y[n];
    double ka[n];
    vector<double> v;
    rep(i,0,n){
        scanf("%lf %lf",&x[i],&y[i]);
        ka[i]=kaku(x[i],y[i]);
        v.push_back(ka[i]);
    }
    vector<double> w;
    rep(i,0,n){
        rep(j,i,n){
            double nk=(x[i]+x[j])/2.0;
            double ny=(y[i]+y[j])/2.0;
            w.push_back(kaku(nk,ny));
        }
        w.push_back(v[i]);
        w.push_back(v[i]+pi/2.0);
        w.push_back(v[i]-pi/2.0);
    }
    double noww=kaku(50000,1);
    double e=0;
    for(;;){
        w.push_back(e);
        e+=noww;
        if(e>=2*pi)break;
    }
    double di[n];
    rep(i,0,n)di[i]=dist(x[i],y[i],0,0);
    double ans=0;
    rep(j,0,w.size()){
        double now=w[j];
        double sum=0;
        rep(i,0,n){
            double si=ka[i];
            double sa=si-now;
            double r=di[i];
            r*=cos(sa);
            if(r>0)sum+=r;
        }
        ans=max(ans,sum);
    }
    
    cout<<fixed<<setprecision(15)<<ans<<endl;
    
}




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

int n;
int q;
int A[2000];
int m[2000];
int i;

bool solve (int i, int m){
    if (m==0) return true;
    if (i > n) return false;
    bool res;
    res = solve(i+1, m) | solve(i+1, m-A[i]);
    return res;
    }




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

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

    for (i = 0; i < q; i++){
        if (solve(0, m[i])){
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}

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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

const int N = 100005;



void solve() {
	ld n;
	cin >> n;
	n *= 2;
	n *= 3.14159265358979323846;
	cout << setprecision(10) << fixed;
	cout << n;
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}


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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;
const double PI = 3.14159;

using namespace std;


int main() {

    int n;
    cin >> n;
    int ans = 0;
    int a;
    rep(i, n) {
        cin >> a;

        if ( (i + 1) % 2 == 1 && a % 2 == 1) 
            ans++;
    }

    AA(ans);
}

Measured memory_bytes: 3616
q,h,s,d,n=map(int,open(0).read().split())
if n%2==0:
  print(min(8*q,4*h,2*s,d)*(n//2))
else:
  print(min(8*q,4*h,2*s,d)*(n//2)+min(4*q,2*h,s))

Measured memory_bytes: 3060
use proconio::input;

// based on: https://atcoder.jp/contests/abc177/submissions/16620466
// Im just learning rust by rewriting others code ¯\_(ツ)_/¯
// I only copy those solutions I would know how to type in C++ myself anyway

fn main() {
    input! {
        d: usize,
        t: usize,
        s: usize,
    }

    println!("{}", if (t * s) >= d { "Yes" } else { "No" });
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ll 				long long
#define int             long long int
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define modp            998244353
#define inf             (ll)1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO           	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl 			'\n'
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void solve()
{
	int x;
	cin >> x;
	if(x >= 30)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
 
int32_t main()
{
	FIO
    // w(t)
    {
    	solve();
    }
    return 0;
}
	

	

Measured memory_bytes: 3648
from collections import deque
S = deque(list(input()))
Q = int(input())

count = 0
for i in range(Q):
    a = list(map(str, input().split()))
    if a[0] == '1':
        count += 1
    elif a[0] == '2':
        if count % 2 == 0 and a[1] == '1':
            S.appendleft(a[2])
        elif a[1] == '1':
            S.append(a[2])
        elif count % 2 == 0:
            S.append(a[2])
        else:
            S.appendleft(a[2])


if count % 2 == 0:
    print(''.join(S))
else:
    S.reverse()
    print(''.join(S))


Measured memory_bytes: 8668
D = [[-1,0],[0,1],[1,0],[0,-1]]
def s(N):
    used = [[False]*N+[True] for _ in xrange(N)]+[[True]*(N+1)]
    ret = [[" "]*N for _ in xrange(N)]
    d,y,x = 0,N-1,0
    used[N-1][0] = used[N-1][1] = True
    while True:
        ret[y][x] = "#"
        sy,sx = D[d]
        ry,rx = D[(d+1)%4]
        if not used[y+sy][x+sx]:
            used[y+sy][x+sx] = used[y+ry][x+rx] = True
            d,y,x = d,y+sy,x+sx
        elif not used[y+ry][x+rx]:
            used[y+ry][x+rx] = True
            d,y,x = (d+1)%4,y+ry,x+rx
        else:
            break
    return ret

n = input()
while True:
    n -= 1
    N = input()    
    print "\n".join(map(lambda a:"".join(a),s(N)))
    if n == 0:
        break
    print

Measured memory_bytes: 4300
import sys

k, x= map(int,input().split())

min_x = x - k + 1
if(min_x < -1000000):
	min_x = -1000000

max_x = x + k - 1
if(max_x > 1000000):
	max_x = 1000000

for i in range(min_x,max_x+1):
	sys.stdout.write(str(i))
	if i != max_x:
		sys.stdout.write(" ")

Measured memory_bytes: 3060
N,D  =map(int,input().split())
ans = 0
X = []
for i in range(N):
    x = list(map(int,input().split()))
    X.append(x)
for i in range(N-1):
    for j in range(i+1,N):
            dis = 0
            for k in range(D):
                dis += (X[i][k]-X[j][k])**2
            if dis**(1/2)-int(dis**(1/2))==0:
                ans += 1
print(ans)

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

//for (auto& e : array)



signed main()
{
    int N;
    cin >> N;

    switch(N%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
        default:
            cout << "pon" << endl;

    }
}


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	int n, l;
	cin >> n >> l;
	vector<int> v(n);
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		v[i - 1] = l + i -1;
		sum += v[i - 1];
	}
	debug() << imie(sum) imie(v);
	int maxi = -1;
	for (int i = 0; i < n; i++) {
		maxi = max(maxi, abs(sum) - abs(v[i]));
		//debug() << imie(sum - v[i]);
	}
	if (sum < 0) maxi = -maxi;
	cout << maxi << "\n";
}


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

#define rep(i,begin,end) for(int i=begin; i<end; i++)

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int a[n], b[n], c[m+1], d[m+1];
    int ans[n];
    rep(i, 0, n){
        scanf("%d %d", &a[i], &b[i]);
    }
    rep(i, 1, m+1){
        scanf("%d %d", &c[i], &d[i]);
    }
    rep(i, 0, n){
        int x = 500000000;
        rep(j, 1, m+1){
            int len = abs(c[j] - a[i]) + abs(d[j] - b[i]);
            if(len < x){
                x = len;
                ans[i] = j;
            }
        }
    }
    rep(i, 0, n){
        printf("%d\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int Array[105];

int main(){
    int N , i , Ans = 0;
    scanf( "%d" , &N );

    for( i = 1 ; i < N ; ++i )
        scanf( "%d" , Array + i );
    
    Ans = Array[1];

    for( i = 2 ; i < N ; ++i )
        Ans += min( Array[i - 1] , Array[i] );

    Ans += Array[N - 1];
    printf( "%d\n" , Ans );
    return 0;
}

Measured memory_bytes: 256
S = input()

def f(i, s):
    if i == len(S) - 1:
        return sum(map(int, s.split("+")))
    else:
        return f(i + 1, s + S[i+1]) + f(i + 1, s + "+" + S[i+1])

print(f(0, S[0]))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=2e5+50;
vec l(N),r(N);
vec a(N);

ll cal(ll x) {
  if(x<3) {
    return 0;
  }
  return max({l[x-1],r[x-1],cal(x-2)+a[x]});
}

int main() {
  ll n;
  cin >> n;
  for(ll i=1;i<=n;i++) cin >> a[i];
  for(ll i=2;i<=n;i+=2) {
    l[i]=l[i-2]+a[i-1];
    r[i]=max(r[i-2],l[i-2])+a[i];
  }
  if(n%2) {
    cout << cal(n) << endl;
  }
  else {
    cout << max(l[n],r[n]) << endl;
  }
}

Measured memory_bytes: 11064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int N,X,T;
  cin >> N >> X >> T;
  int ans = ((N - 1) / X + 1)*T;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    VAR(i64, a, b, c);
    const i64 k = c - a - b;
    dump(k * k, 4 * a * b);
    if (4 * (a * b) < k * k && k >= 0) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int sum = 0;
	for (int i = 1; i<N + 1; i++) {
		int n = 1;
		int len = floor(log10(i)) + 1;
		int tempsum = 0;
		for (int j = 0; j <= len; j++) {
			tempsum += (i/ ((int)pow((double)10, j))) % 10;
		}
		if (tempsum >= A && tempsum <= B) {
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 512
def inner?(x,y,l1x,l1y,l2x,l2y)
  return true if x.between?(l1x,l2x) and y.between?(l1y,l2y)
  return false
end

while gets
  xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2=$_.split.map(&:to_f)
  if inner?(xa1,ya1,xb1,yb1,xb2,yb2) or inner?(xa1,ya2,xb1,yb1,xb2,yb2) or inner?(xa2,ya1,xb1,yb1,xb2,yb2) or inner?(xa2,ya2,xb1,yb1,xb2,yb2) or
     inner?(xb1,yb1,xa1,ya1,xa2,ya2) or inner?(xb1,yb2,xa1,ya1,xa2,ya2) or inner?(xb2,yb1,xa1,ya1,xa2,ya2) or inner?(xb2,yb2,xa1,ya1,xa2,ya2) or
     (xa1<xb1 and xa2>xb2 and ya1>yb1 and ya2<yb2) or (xa1>xb1 and xa2<xb2 and ya1<yb1 and ya2>yb2) then
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 8632
import sys
input = sys.stdin.readline
from collections import deque

H, W = map(int, input().split())
S = [list(input().split()[0]) for _ in range(H)]

def bfs(S, H, W, start):
    INF = -1
    stack=deque([start])
    distance = [[INF]*W for _ in range(H)]
    distance[start[1]][start[0]] = 0
    while stack:
        x, y = stack.popleft()
        for i, j in [(1,0),(0,1),(-1,0),(0,-1)]:
            next_x = x + i
            next_y = y + j
            if not(0 <= next_x < W and 0 <= next_y < H):
                continue
            if S[next_y][next_x] != '#' and distance[next_y][next_x] == -1:
                stack.append([next_x, next_y])
                distance[next_y][next_x] = distance[y][x] + 1
    return max(map(max, distance))

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] != "#":
            ans = max(ans, bfs(S, H, W, (j, i)))
print(ans)

Measured memory_bytes: 3316
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> 

using namespace std;

const long long inf = 0x7fffffffffffffff;

struct node
{
	long long r,b;
}bag[200100];

long long n;
long long ans = inf,rmax,rmin = inf,bmax,bmin = inf;

bool cmp(node a,node b)
{
	return a.b < b.b;
}

int main()
{
	scanf("%lld",&n);
	for(int i = 1;i <= n;i++)
	{
		long long a,b;
		scanf("%lld%lld",&a,&b);
		bag[i].r = max(a, b);
		bag[i].b = min(a, b);
		rmax = max(bag[i].r,rmax);
		rmin = min(bag[i].r,rmin);
		bmax = max(bag[i].b,bmax);
		bmin = min(bag[i].b,bmin);
	}
	ans = (rmax - rmin) * (bmax - bmin);
	sort(bag + 1,bag + 1 + n,cmp);
	if(rmin > bmax)
	{
		printf("%lld\n",ans);
		return 0;
	}
	rmin = bmin;
	bmin = bag[1].r;
	bmax = max(bag[1].r,bmax);
	int i;
	for(i = 2;i < n;i++)
	{
		bmin = min(bmin,bag[i].r);
		bmax = max(bmax,bag[i].r);
		ans = min(ans,(bmax - min(bmin, bag[i + 1].b)) * (rmax - rmin));
	}
	if(i != n)
		printf("%lld\n",min(ans,(bmax - min(bmin, bag[i + 1].b)) * (rmax - rmin)));
	else
		printf("%lld\n",min(ans,(bmax - bmin) * (rmax - rmin)));
	return 0;
}

Measured memory_bytes: 3328
public class Main {
	public static void main(String args[]) {
		
		for (int i = 1; i < 10; i++) {
			for (int j = 1;j < 10; j++) {
				int ans = i * j;
				System.out.println(i + "x" + j +"=" + ans);
			}
		}
		
	}
}

Measured memory_bytes: 24328
r, c = map(int, input().split())
table = [[0 for i in range(c+1)]for j in range(r+1)]
for i in range(r):
    a = list(map(int, input().split()))
    for j in range(c):
        table[i][j] = a[j]
for i in range(r):
    for j in range(c):
        table[i][-1] += table[i][j]
        table[-1][j] += table[i][j]
    table[-1][-1] += table[i][-1]
for i in range(r+1):
    for j in range(c+1):
        if j > 0:
            print(" ", end="")
        print(table[i][j], end="")
    print()



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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  string s;cin>>s;
  s[5]=' ';
  s[13]=' ';
  cout<<s<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		char[] s = sc.next().toCharArray();
		boolean found = true;
		for(int i=0;i<s.length;++i) {
			if(s[i] == 'L' && i%2 == 0) found = false;
			if(s[i] == 'R' && i%2 != 0) found = false;
		}
		if(found)
		out.print("Yes");
		else out.print("No");
		out.close();
	}
	
	
}

Measured memory_bytes: 22740
string = input()
q = int(input())
for _ in range(q):
    line = input().split()
    a = int(line[1])
    b = int(line[2])
    if line[0] == "print":
        print(string[a:b+1])
    elif line[0] == "reverse":
        tmp = string[a:b+1]
        tmp = tmp[::-1]
        new_s = string[:a] + tmp + string[b+1:]
        string = new_s
    else:
        new_s = string[:a] + line[3] + string[b+1:]
        string = new_s



Measured memory_bytes: 5612
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if((i+j)%2 == 0) printf("#");
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 1000
//Atcoder-Begginer-Contest
//2018/10/1
//A

#include<stdio.h>

int main(void)
{
  int s;
  int a;
  scanf("%d",&s);
  if(s%10==1){
    a = 9;
  }
  else{
    a = 1;
  }
  if(((s/10)%10)==1){
    a += 90;
  }
  else{
    a += 10;
  }
  if((s/100)==1){
    a += 900;
  }
  else{
    a += 100;
  }
  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e5+5,LG=19,SM=4000+5,inf=1e18+1;
ll mod=1e9+7;

ll n;
ll a[M];
str z[2]={ "Impossible","Possible" };

int main()
{
	ios::sync_with_stdio(0);
    cin >> n;
    For(i,0,n)
        cin >> a[i];
    sort(a,a+n);
    ll mx=a[n-1];
    mx+=mx%2;
    mx/=2;
    if (a[0]!=mx || a[n-2]!=a[n-1])
        RET(z[0]);
    mx=a[n-1]%2;
    if (mx&&(a[0]!=a[1])) RET(z[0]);
    if (a[mx]==a[mx+1]) RET(z[0]);
    ll ted=2;
    For(i,mx+1,n)
    {
        if (abs(a[i]-a[i-1])>1) RET(z[0]);
        if (a[i]==a[i-1]) ted++;
        else
        {
            if (ted<2) RET(z[0]);
            ted=1;
        }
    }
    RET(z[1]);
}

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

using namespace std;

ifstream fi("MARKET.INP");
ofstream fo("MARKET.OUT");

#define fi cin
#define fo cout

int n,T,S;
int a[3010],b[3010],F[3001],G[3001];
int f[3001][3001],res;

void nhapdl()
{
    fi>>n>>T>>S;
    for (int i=1; i<=n; ++i) fi>>a[i]>>b[i];
}

void tinh(int x)
{
    S=T-S;

    res+=f[n][S];
}

void xuli()
{
    for (int i=1; i<=n; ++i)
        for (int j=0; j<=S; ++j)
        {
            f[i][j]=f[i-1][j];
            if (j-b[i]>=0) f[i][j]=max(f[i][j],f[i-1][j-b[i]]+a[i]);
            F[i]=f[i][j];
        }
    for (int i=n; i>=1; --i)
        for (int j=0; j<=T-S; ++j)
        {
            f[i][j]=f[i+1][j];
            if (j-b[i]>=0) f[i][j]=max(f[i][j],f[i+1][j-b[i]]+a[i]);
            G[i]=f[i][j];
        }
    for (int i=0; i<=n; ++i) res=max(res,F[i]+G[i+1]);
}

int main()
{
    nhapdl();
    xuli();
    fo<<res<<'\n';
}

Measured memory_bytes: 36444
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n,k,q;
    cin>>n>>k>>q;
    vector<int> a(n,k-q);
    REP(i,q){
        int t;
        IN(t);
        t--;
        a[t]++;
    }
    REP(i,n){
        if(a[i]<=0) OUT("No");
        else OUT("Yes");
    }
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();

		int[] cnt = new int[n + 1];
		for (int i = 0; i < n - 1; i++) {
			if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
				cnt[i + 1] = cnt[i] + 1;
			} else {
				cnt[i + 1] = cnt[i];
			}
		}

		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(cnt[r - 1] - cnt[l - 1]);
		}
		sc.close();

	}
}


Measured memory_bytes: 70320
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int p = cin.Int();
			int q = cin.Int();
			int r = cin.Int();

			Console.WriteLine(Math.Min(p + q, Math.Min(q + r, r + p)));
		}
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

const int N = 1e5;
vector<bool> isp(N+1,true); 

void sieve(){
	isp[0] = false;
	isp[1] = false;
	for(int i = 2; i*i <= N; i++){
		if(isp[i] == true){
			for(int j = 2; i*j < N; j++){
				isp[i*j] = false;
			}
		}
	}
}

bool isLike2017(int num){
	if( isp[num] == true && isp[ (num + 1)/2] == true){
		return true;
	}else{
		return false;
	}
}

int main()
{
	sieve();
	vector<int> cumulativeSum(N+2,0);
	for(int i = 0; i <= N; i++){
		if(isLike2017(i) == true){
			cumulativeSum[i+1] = cumulativeSum[i] + 1;
		}else{
			cumulativeSum[i+1] = cumulativeSum[i];
		}
		
	}
	/*for(int i = 0; i < 100; i++){
		cout<<i<<" : "<<isLike2017(i)<<" "<<cumulativeSum[i]<<endl;
	}*/
	int Q;
	cin>>Q;
	for(int i = 0; i < Q; i++){
		int l,r;
		cin>>l>>r;
		cout<<cumulativeSum[r+1] - cumulativeSum[l]<<endl;
	}
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int a[n][m];
  memset(a,0,sizeof(a));
  int k,l,count=0;
  for(int i=0;i<n;i++)
  {
    cin>>k;
    for(int j=0;j<k;j++)
    {
      cin>>l;
      a[i][l-1]=1;
    }
  }
  int flag=1;
  for(int i=0;i<m;i++)
  {
    for(int j=0;j<n;j++)
    {
      if(a[j][i]==0)
      {
        flag=0;
        break;
      }
    }
    if(flag==1)
    {
      count++;
    }
    else
    {
      flag=1;
    }
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 256