akhauriyash/Code-Regression huggingface dataset:
//#pragma  GCC optimize("Ofast")

//#ifdef  DEBUG
//#define _GLIBCXX_DEBUG
//#endif

// -Ofast
// -O3
// -O2
// -fsanitize=address
// -fsanitize=undefined

// add_compile_options()

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#include <cassert>
#include <random>

using namespace std;
//using namesparsace __gnu_pbds;

void solve();

int main() {
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

#define ld double
#define int long long

const int maxN = 3e3 + 10, maxK = 1e5 + 10, inf = 1e15 + 10, mod = 1e9 + 7, base = 223;

int n, a[16][16], cost[1 << 16], dp[1 << 16];

bool bit(int a, int i) {
    return (a >> i) & 1;
}

int get(int mask) {
    vector < int > v;
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (bit(mask, i)) {
            for (int j = 0; j < v.size(); j++) {
                res += a[v[j]][i];
            }
            v.push_back(i);
        }
    }
    return res;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i < (1 << n); i++) {
        cost[i] = get(i);
    }
    for (int mask = 1; mask < (1 << n); mask++) {
        int submask = mask;
        while (submask > 0) {
            dp[mask] = max(dp[mask], dp[mask ^ submask] + cost[submask]);
            submask = mask & (submask - 1);
        }
    }
    cout << dp[(1 << n) - 1];
}

// submask = mask & (mask - 1);

Measured memory_bytes: 1280
#include <stdio.h>
#define N 10
#define GOAL 20

int main(void){
     int count; int c[3], i;
	
     while(~scanf("%d %d %d",&c[0],&c[1],&c[2])){
	  count=0;
	
	  for(i=1; i<=N; i++)
	       if(c[0]!=i && c[1]!=i && c[2]!=i)
		    if(c[0]+c[1]+i<=GOAL)
			 count++;
		
	  if(count/(double)(N-3)>0.5) puts("YES");
	  else puts("NO");
     }
	
     return 0;
}

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

int main(){
  int n;
  std::cin >> n;
  std::vector<ll> A(n),B(n);
  rep(i,n)std::cin >> A[i];
  rep(i,n)std::cin >> B[i];

  std::vector<ll> ok(n,0);

  ll needs=0;
  bool cl=true;
  rep(i,n){
    if(A[i]<B[i]){
      ok[i]=A[i]-B[i];
      needs+=A[i]-B[i];
      cl=false;
    }
    if(A[i]>B[i]){
      needs+=A[i]-B[i];
      ok[i]+=A[i]-B[i];
    }
  }

  if(cl==false && needs<0){
    std::cout << "-1" << '\n';
    return 0;
  }

  sort(ok.begin(),ok.end());

  ll ans=0;
  ll stock=0;
  ll last=ok.size()-1;
  for (int i = 0; i < n; i++) {
    // std::cout <<"ok:"<<ok[i] << '\n';
    if(ok[i]>=0)break;
    stock+=ok[i];
    ans++;
    while (stock<0) {
      stock+=ok[last];
      last--;
      ans++;
    }
  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 1; i < (int)(n); i++)
#define invrep(i,n) for(int i = (int)(n); i > 0; i++)
using ll = long long;

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if (a >= k) {
        cout << k << endl;
        return 0;
    }

    int tmp = k - a;
    if (tmp <= b) {
        cout << a << endl;
        return 0;
    }
    tmp -= b;
    if (tmp <= c) {
        cout << a - (k - (a + b)) << endl;
        return 0;
    }
    
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
#include<map>
#include<vector>
#include<cmath>
#define int long long int
int power(int a,int b)
{
	int x=pow(a,b);
	return x;
}
int solve(int val)
{
	int j;
	if(val>0)
	{
		int sum=0;
		for(j=0;;j+=2)
		{
			sum+=power(2,j);
			if(sum>=val)
			{
				return j;
			}
		}
	}
	else
	{
		int sum=0;
		val*=-1;
		for(j=1;;j+=2)
		{
			sum+=power(2,j);
			if(sum>=val)
			{
				return j;
			}
		}
	}
}
int32_t main()
{
     
     vector<int> vec(41,0);
     int n;
     cin>>n;
     if(n==0)
     {
		 cout<<0<<endl;
		 exit(0);
	 }
     while(n!=0)
     {
		 int index=solve(n);
		 vec[index]=1;
		 n-=power(-2,index);
	 }
	 int i,j;
	 for(j=40;j>=0;j--)
	 {
		 if(vec[j]==1)
		 {
			 break;
		 }
	 }
	 for(i=j;i>=0;i--)
	 {
		 cout<<vec[i];
	 }
	 cout<<endl;
}


Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
 
int main()
{
    int K, A, B;
    cin >> K;
    scanf("%d %d", &A, &B);

    bool flag = false;
    REP(i, K){
        if(i+A >B) break;
        // printf("%d\n", i+A);
        if((i+A)%K == 0){
            flag=true;
            break;
        }
    }
    if(flag){
        printf("OK\n");
    }else{
        printf("NG\n");
    }
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int a[n+1];
	int b[n];
	long long int ans = 0;
	for (int i = 0; i < n+1; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];

	for (int i = n-1; i >= 0; i--){
		int tmp = min(a[i+1], b[i]);
		ans += tmp;
		a[i+1] -= tmp;
		b[i] -= tmp;
		tmp = min(a[i], b[i]);
		ans += tmp;
		a[i] -= tmp;
		b[i] -= tmp;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  for(int i=b-a+1;i<=b+a-1;i++){
    if(i!=b-a+1) cout<<" ";
    cout<<i;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())

N = I()

A = [0]*(N+1)

for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            a = i**2+j**2+k**2+i*j+j*k+k*i
            if a <= N:
                A[a] += 1

del A[0]

print(*A,sep='\n')

Measured memory_bytes: 68804
graph = [[]for _ in range(4)]
for i in range(3):
    a,b = map(int,input().split())
    a-= 1
    b-= 1
    graph[a].append(b)
    graph[b].append(a)
maxa = 0
for i in range(4):
    maxa = max(len(graph[i]),maxa)

if maxa == 3:
    print("NO")
    exit(0)
print("YES")


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

int card[255][14]={{0}};

int main(void){
   int n; 
   cin >> n;
   for(int i=0; i<n; i++){
      char c; /*文字コードは0~255*/
      int num;
      cin >> c >> num;
      card[(int)c][num]=1; //発見
   }
   
     /*Sを探す*/
     for(int i=1; i<=13; i++){
        if(card[(int)'S'][i]==0){
            cout << "S " << i << endl;
        }
     }
     /*Hを探す*/
     for(int i=1; i<=13; i++){
        if(card[(int)'H'][i]==0){
            cout << "H " << i << endl;
        }
     }
     /*Cを探す*/
     for(int i=1; i<=13; i++){
        if(card[(int)'C'][i]==0){
            cout << "C " << i << endl;
        }
     }
     /*Dを探す*/
     for(int i=1; i<=13; i++){
        if(card[(int)'D'][i]==0){
            cout << "D " << i << endl;
        }
     }

}


Measured memory_bytes: 3084
import java.util.*;	
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String o = sc.next();
		String e = sc.next();
		int a = 0,mozilong = o.length() + e.length();
		char ans[] = new char[mozilong];
		for(int i = 0;i < e.length() ;i++) {
			ans[a] = o.charAt(i);
			a++;
			ans[a] = e.charAt(i);
			a++;
		}
		if( o.length() > e.length())ans[a] = o.charAt(o.length()-1);
		System.out.println(ans);
	}

}

Measured memory_bytes: 20564
#include <stdio.h>
int main (int argc, char * argv[])
{
    int W,H;
   
    while (1){
         scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(int j=0;j<H;j++){
            for(int i=0;i<W;i++){
                if(j%2==0&&i%2==0){
                    printf("#");
                }else if(j%2==1&&i%2==1){
                    printf("#");
                }else{
                    printf(".");
                }
                
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2040
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m, c;
    cin >> n >> m >> c;
    int odp = 1000000000;
    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= m; ++j)
            if (i * m + j * n - i * j >= c)
                odp = min(odp, i + j);
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    S = input()[:-1]

    n = 753
    ans = n
    for i in range(len(S)-2):
        ans = min(ans, abs(n-int(S[i:i+3])))
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
import numpy as np
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
f=[int(i) for i  in input().split()]
#Aについても、修行前の大小で並べてしまって良いです
A=np.array(sorted(a))
F=np.array(sorted(f, reverse=True))
#最大値の最小化▶︎二分探索！
#答えxを決めて、A*Fペア全てをx以下にするために必要な修行がk回以下かを調べていく。(xについて二分探索)
left=-1
right=10**12
s=A.sum()
#A-x//Fは、x以下にするのに必要な最小の修行回数。
#np.maximum(A-x//F,0)は、２つの配列の大きい方を取っていきながらあたらしい配列を作っている。
while left+1<right:
    x=(left+right)//2
    if np.maximum(A-x//F , 0).sum()<=k:
        #この時答えはx以下なので
        right=x
    else:
        #この時答えはxより大きいので
        left=x
print(right)

Measured memory_bytes: 43532
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ll long long
using namespace std;

void solve() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i)
        if (s[i] == '7') {
            puts("Yes");
            return;
        }
    puts("No");
    return;
}

int main() {
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int H,W,N;
    int a[10010];
    cin>>H>>W>>N;
    vector<int> s;
    for (int i = 0; i < N; i++)
        cin >> a[i];
    for (int i = 0; i < N;i++){
        for (int j = 0; j < a[i];j++){
            s.push_back(i+1);
        }
    }
    //cerr << s << endl;
    for (int i = 0; i < H; i++)
    {   if(i%2==0){
        for (int j= 0; j < W; j++)
        {   
            cout << s[j+i*W] << " ";
        }
         printf("\n");
        }
       
        else
        {
            for (int j = 0; j < W; j++)
            {
                cout << s[(i + 1) * W - 1 - j] << " ";
            }
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX + 1];

void maxHeapify(int i){
  int l, r, largest;
  
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  int i;
  
  cin >> H;

  for(i = 1 ; i <= H ; i++){
    cin >> A[i];
  }
  for(i = H / 2 ; i >= 1 ; i--){
    maxHeapify(i);
  }
  for(i = 1 ; i <= H ; i++){
    cout << " " << A[i];;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 5004
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;

int w,h,n;

int x[110];
int y[110];
int a[110];
int zu[110][110];
int main()
{
	cin>>w>>h>>n;
	rep(i,n)
	{
		cin>>x[i]>>y[i]>>a[i];
		if(a[i]==1)
		{
			rep(j,x[i])
			{
				rep(k,h)
				{
					zu[j][k]=1;
				}
			}
		}
		if(a[i]==2)
		{
			rep2(j,x[i],w)
			{
				rep(k,h)
				{
					zu[j][k]=1;
				}
			}
		}
		if(a[i]==3)
		{
			rep(j,y[i])
			{
				rep(k,w)
				{
					zu[k][j]=1;
				}
			}
			
		}
		if(a[i]==4)
		{
			rep2(j,y[i],h)
			{
				rep(k,w)
				{
					zu[k][j]=1;
				}
			}
		}
	}
	int ans=0;
	rep(i,w)rep(j,h)
	{
		if(zu[i][j]==0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int nums[200005];
int N;
map<long long, int> m;

long long C(long long n) {
	if (n == 1) return 0;
	return 1ll * n * (n - 1) / 2;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> nums[i];
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		sum += nums[i];
		m[sum]++;
	}
	map<long long, int>::iterator iter = m.begin();
	long long ans = 0;
	while (iter != m.end()) {
		if (iter->first == 0) ans += iter->second;
		ans += C(iter->second);
		iter++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 13568
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <bitset>
#include <cassert>
#include <queue>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 1e4 + 4;
const double EPS = 1e-7;
const int mod = 1e9;
const int hashpow = 2;
const int inf = 2e9;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n, m;
int a[SZ];
int sum = 0;

void read() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
        sum += a[i];
    }
}

void solve() {
    if (sum > n) {
        cout << -1 << "\n";
        return;
    }
    cout << n - sum << "\n";
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 3684
// inputに入力データ全体が入る
function Main(input) {
    var a = input[0]-0;
    var ans = 0;
    for(var i=1;i<=a;i++){
        ans += i;
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 998244353
#define MAX 1000000000000
#define N 3005
string a,b;
int dp[N][N];
int dir[N][N];
ll solve(ll i,ll j)
{
    if(i==a.size() || j==b.size()) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    int ans1=0,ans2=0;
    if(a[i]==b[j])
    {
        dir[i][j]=1;
        return dp[i][j]=1+solve(i+1,j+1);
    }
    else{
        ans1=solve(i+1,j);
        ans2=solve(i,j+1);
        if(ans1>ans2) dir[i][j]=2;
        else dir[i][j]=3;
        return dp[i][j]=max(ans1,ans2);
    }
}
void print(int i,int j)
{
    if(i==a.size() || j==b.size()) return ;
    if(dir[i][j]==1)
    {
        cout<<a[i];
        print(i+1,j+1);
    }
    else if(dir[i][j]==2) print(i+1,j);
    else if(dir[i][j]==3) print(i,j+1);
}
int main()
{
    fastio;
    cin>>a>>b;
    memset(dp,-1,sizeof dp);
    solve(0,0);
    print(0,0);
}



Measured memory_bytes: 71040
# -*- coding: utf-8 -*-
s = input()
n = len(s)
l = [1]*n

i = 0
while i<n:
    if s[i]=="R":
        j = i
        e,o = 0,0
        while s[j]=="R":
            o += l[j]
            l[j] = 0
            e,o = o,e
            j += 1
        l[j-1] += e
        l[j] += o

        i = j
    i += 1
# print(*l)

i = n-1
while i>=0:
    if s[i]=="L":
        j = i
        e,o = 0,0
        while s[j]=="L":
            o += l[j]
            l[j] = 0
            e,o = o,e
            j -= 1
        l[j+1] += e
        l[j] += o

        i = j
    i -= 1
print(*l)

Measured memory_bytes: 6512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

    int n; cin >> n;

    vector<int> a;

    while( n-- ){
        int x; cin >> x;
        a.push_back(x);
    }

    sort(a.begin(), a.end());

    vector<int>::iterator it = a.end();
    it --;
    int maxv = *it;
    int mid = maxv / 2;
    int min_dif = 1e9;

    int half_max;

    for( int i = 0; i < a.size() - 1; i++){
        if( abs(mid - (maxv - a[i])) < min_dif){
            half_max = a[i];
            min_dif = abs(mid - (maxv - a[i]));
        }
    }

    cout << maxv << " " << half_max;
    return 0;
}


Measured memory_bytes: 892
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d/n", &a, &b, &c)
	tmp := make([]int, b)
	ans := "NO"
	for i := 1; true; i++ {
		amari := ((a * i) % b)
		if amari == c {
			ans = "YES"
			break
		}
		if tmp[amari] == -1 {
			break
		} else {
			tmp[amari] = -1
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1868
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>
//#pragma warning(disable : 4996)
#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back
using namespace std;
typedef long long ll;

const int maxn = (int)1e6 + 13;
const ll INFL = 9223372036854775807;
const int INF = 2147483647;
const ll MOD = (int)1e9 + 7;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101;
const long double pi = 3.1415926535897932;


int main() {
	drobucs;
	
	int n;
	cin >> n;
	set<string> st;
	for (int i = 1; i <= n; ++i) {
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size();
	return 0;
}

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


int n;
int nQuery;
char buf[200000+10];
char cs[200000+10];
char ds[200000+10];

int detect(int idx) {
  REP(i, nQuery) {
    if(cs[i] == buf[idx]) {
      idx += (ds[i] == 'L' ? -1 : 1);
    }
    if(idx == n) {
      return 1;
    }
    if(idx == -1) {
      return -1;
    }
  }
  return 0;
}

int calcI2(void) { // 右に消える最初のidx
  int left = -1;
  int right = n;
  while(left + 1 < right) {
    int md = (left + right) / 2;
    if(detect(md) == 1) {
      right = md;
    } else {
      left = md;
    }
  }
  return right;
}

int calcI1(void) { // 左に消えない最初のidx
  int left = -1;
  int right = n;
  while(left + 1 < right) {
    int md = (left + right) / 2;
    if(detect(md) == -1) {
      left = md;
    } else {
      right = md;
    }
  }
  return right;
}

int main(void) {
  scanf("%d%d %s", &n, &nQuery, buf);
  REP(i, nQuery) {
    scanf(" %c %c", &cs[i], &ds[i]);
  }
  int i2 = calcI2();
  int i1 = calcI1();
  int res = i2 - i1;
  cout << res << endl;
  
  
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s; cin >> s;
    ll n = s.size() + 1;
    vector<ll> a(n, 0);
    ll cnt = 0;
    s = '.' + s;
    for(int i=n-1; i>=1; i--){
        if(s[i] == '>'){
            a[i] = cnt;
            if(s[i-1] == '>'){
                cnt++;
            }
            else cnt = 0;
        }
        else cnt = 0;
    }
    //cout << a << endl;
    if(s[1] == '<') a[0] = 0;
    else a[0] = a[1] + 1;
    cnt = 1;
    for(int i=1; i<=n-2; i++){
        if(s[i] == '<'){
            if(s[i+1] == '<'){
                a[i] = cnt;
                cnt++;
            }
            else{
                a[i] = max(a[i+1] + 1, cnt);
                cnt = 1;
            }
        }
        else cnt = 1;
    }
    if(s[n-1] == '<') a[n-1] = cnt;
    //cout << a << endl;
    ll res = 0;
    REP(i, n) res += a[i];
    cout << res << endl;
}

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

Measured memory_bytes: 5276
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
// string s;b
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>k;
  x = n-k;
  y = n%k;
  if(k==1)
  {
    c(0);
    return;
  }
  cout<<n-k;  

}

signed main(){
   
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


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

int main(){
  int n;
  cin >> n;
  bool can = false;
  for(int i = 1; i <= 9; i++) {
    for(int j = 1; j <= 9; j++) {
      if(i*j == n) can = true;
    }
  }
  cout << (can? "Yes" : "No") << endl;
  return 0;
}

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

public class Main {
	private StringTokenizer st;
	private BufferedReader bf;
	private int n;
	private int m;
	private int k;
	
	Main() {
		readData();
		
		if ((n < m) && (m < k))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	
	private void readData() {
		try {
			bf = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(bf.readLine());
			n = nextInt();
			m = nextInt();
			k = nextInt();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	private String next() throws IOException {
		if (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(bf.readLine());
		return st.nextToken();
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main m = new Main();
	}

}

Measured memory_bytes: 16856
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())

for i in range(30) :
  for j in range(30) :
    if i*4 + j*7 == N :
      print ("Yes")
      exit()
print ("No")




Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){

  int H,W;
  while(1){
    cin>>H>>W;
  if(H==0,W==0)break;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<"#";
    }   
    cout<<endl;
  }
  cout<<endl;
  }
 return 0;
}

Measured memory_bytes: 3064
n,k=map(int,input().split())
point=[]
for i in range(n):
    x,y=map(int,input().split())
    point.append((x,y))
point.sort()
ans=10**20
for i in range(n):
    for j in range(i+1,n):
        y_list=[]
        for p in range(i,j+1):
            y_list.append(point[p][1])
        y_list.sort()
        yl=len(y_list)
        y_d=10**10
        if yl<k:
            continue
        else:
            for p in range(yl-k+1):
                y_d=min(y_d,y_list[p+k-1]-y_list[p])
        x_d=point[j][0]-point[i][0]
        temp=x_d*y_d
        ans=min(ans,temp)
print(ans)


Measured memory_bytes: 40816
//I'll put my armour on to show you how strong I am!!!
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define N 1100005
struct node
{
	int st,ed,cnt;
	char c;
}a[N];
int c[N];
int n,z;
char ch[N],cc[N];
queue<int>q;
int main()
{
	//freopen("copy.in","r",stdin);
	//freopen("copy.out","w",stdout);
	scanf("%d%s%s",&n,ch+1,cc+1);
	bool flag=true;
	for(int i=1;i<=n;i++)
	{
		if(ch[i]!=cc[i])
		{
			flag=false;
			break;
		}
	}
	if(ch[1]!=cc[1])
	{
		puts("-1");return 0;
	}
	if(flag)
	{
		puts("0");return 0;
	}
	for(int i=1;i<=n;i++)
	{
		int j=i;
		while(j<=n&&cc[j]==cc[i])j++;
		a[++z].st=i;a[z].ed=j;
		if(cc[j]!=cc[i])a[z].ed--;
		a[z].c=cc[i];
		i=a[z].ed;
	}
	int la=n,ans=0;
	for(int i=z;i;i--)
	{
		la=min(la,a[i].st);
		while(la&&a[i].c!=ch[la])la--;
		if(la==0)
		{
			puts("-1");return 0;
		}
		while(!q.empty()&&q.front()-q.size()>=a[i].ed)q.pop();
		q.push(la);
		int te=q.size();
		ans=max(ans,te);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 24704
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    rep(i, 5) {
        int x;
        cin >> x;
        if (x == 0) write(i + 1);
    }
}


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
bool compare(int a,int b)
{
return a>b;
}
int num[100000],n;
int num1[300000];
 int countt[3000001]={0};
int main(){
	cin>>n;
	int count=0;
	for(int i=0;i<n;i++)
		scanf("%d",&num[i]);
	int i=0,k=0;
	while(n--){
		num1[i]=num[k]+1;
		i++;
		num1[i]=num[k]-1;
		i++;
		num1[i]=num[k];
		i++;
		k++;
	}
	
	for(int j=0;j<i;j++){
		countt[num1[j]]++;
	}
	sort(countt,countt+100000,compare);
	cout<<countt[0]<<endl;
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

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

	using pii = pair<int, int>;
	vector<pii> ary;

	rep(i, n) {
		int x, l;
		cin >> x >> l;
		ary.push_back(pii(x + l, x - l));
	}

	sort(begin(ary), end(ary));
	const int inf = 1 << 30;
	int cur = -inf, ans = 0;

	for(auto &elem: ary){
		const int to = elem.first;
		const int from = elem.second;
		if (cur <= from) {
			cur = to;
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var (A, B) = ReadLine().Split(' ').Select(int.Parse).ToArray();

        var ans = Enumerable.Range(1, 3).Select(C => A * B * C).Any(x => x % 2 == 1) ? "Yes" : "No";

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28312
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int n,a,b,c,d;
string s;

int main() {
	cin >> s;
	int siz = s.size();
	long long ans = 0;
	long long cntBC = 0;
	bool flgC = 0;
	for (int i = siz-1; i >= 0; i--)
	{	if (s[i]=='C')
		{
		if (flgC) {
				flgC = 1;
				cntBC = 0;
			}
		else { flgC = 1; }
		}
		else if (s[i] == 'B') {
			if (flgC)
			{
				cntBC++;
				flgC = 0;
			}
			else {
				flgC = 0;
				cntBC = 0;
			}
		}
		else if (s[i] == 'A') {
			if (flgC)
			{
				flgC = 0;
				cntBC = 0;
			}
			else {
				ans += cntBC;
				//cout << i;
			}
		}
		else {
			flgC = 0;
			cntBC = 0;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
const int MN=10000+2;
using namespace std;
typedef long long ll;
template<typename T>T IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	in*=f;return in;
}
ll n;
int a[MN],L=100,R=L-1;
void input(){
	IN(n);n++;
	int p=40;
	while(!((1ll<<p)&n))p--;p--;
	while(p>=0){
		a[++R]=++a[0];
		if((1ll<<p)&n)a[--L]=++a[0];
		p--;
	}
	n=a[0];printf("%lld\n",n*2);
	for(int i=1;i<=n;++i)a[i]=a[i+L-1];
	for(int i=n+1;i<=n*2;++i)a[i]=i-n;
	for(int i=1;i<=n*2;++i)printf("%d ",a[i]);
}
int main(){
	
	input();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

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

    int cnt[3] = {};
    for(int i=0; i<n; i++){
        if(a[i] % 4 == 0){
            cnt[0]++;
        }
        else if(a[i] % 2 == 0){
            cnt[1]++;
        }
        else{
            cnt[2]++;
        }
    }

    if(cnt[0] >= cnt[2]){
        cout << "Yes";
    }
    else if(cnt[1] == 0 && cnt[0] +1 == cnt[2]){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 640
def is_prime(t):
  i=2
  while i**2<=t:
    if t%i==0:
      return 0
    i+=1
  return 1
q=int(input())
lr=[list(map(int,input().split())) for _ in range(q)]
n=10**5
p=[0]*(n+1)
d=set([])
for i in range(2,n):
  if is_prime(i):
    d.add(i)
  if i in d and (i+1)//2 in d:
    p[i]=p[i-1]+1
  else:
    p[i]=p[i-1]
for l,r in lr:
  print(p[r]-p[l-1])



Measured memory_bytes: 29848
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    vector<int> x(N), y(M);

    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    for(int i = 0; i < M; i++){
        cin >> y[i];
    }

    bool ok = false;
    for(int z = -100; z < 101; z++){
        if(z <= X || z > Y)continue;
        
        bool xok = true;
        for(int i = 0; i < x.size(); i++){
            if(x[i] >= z){
                xok = false;
                break;
            }
        }
        if(!xok)continue;

        bool yok = true;
        for(int i = 0; i < y.size(); i++){
            if(y[i] < z){
                yok = false;
                break;
            }
        }
        if(!yok)continue;

        ok = true;
        break;
    }

    if(ok){
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }

}



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

int main() {
  long long n,k;
  cin >> n >> k;
  vector<long long> vec(n);
  for(long long i = 0; i<n; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  long long ans = 0;
  for(long long i = 0; i < n - k; i++){
    ans += vec.at(i);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		int n = c.length;
		long sum = 0;
		for (int i = 0; i < n; i++) {
			long num = 0;
			for (int j = i; j < n; j++) {
				num *= 10;
				num += c[j] - '0';
				int k = Math.max(0, n - j - 2);
				int l = Math.max(0, i - 1);
				sum += num * Math.pow(2, k) * Math.pow(2, l);
			}
		}
		System.out.println(sum);
	}

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


Measured memory_bytes: 8660
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define F first
#define S second
#define pb push_back
#define eb emplace_back
/*unordered_map<int,int>mp;
mp.reserve(1024);
mp.max_load_factor(0.25);
*/
int main()
{
 //   freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    lli n,t,i,j,k,ans=0,a;
    string s;
    cin>>a>>s;
    if(a>=3200)
        cout<<s;
    else
        cout<<"red";
    return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    if(vec.at(i) >= K){
      ans++;
    }
  }
  cout << ans << endl;
}

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

# define C continue;
# define R return

# define D double
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vpii vector < pii >
# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b));
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(-1,1);
const D tpie = 2*pie;

void solve( int test_case )
{
    ll r,d,x;
    cin>>r>>d>>x;

    vi v ( 11 );
    v[0] = x;
    for ( int i=1 ; i<=10 ; i++ )
    {
        v[i] = r*v[i-1] - d;
        cout<<v[i]; line
    }



}

int main()
{
    int t = 1;
    //cin>>t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}



Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

    int a,b;
	cin>>a>>b;
	if(a>=13)cout<<b<<endl;
	else if(a>=6)cout<<b/2<<endl;
	else cout<<0<<endl;
}


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

int main()
{
	long long int n,a,b,c;
	cin>>n;
	a=n/3;b=n/5;c=n/15;
	cout<<((n*(n+1))/2 - (3*a*(a+1))/2 - (5*b*(b+1))/2 +(15*c*(c+1))/2);
	
	return 0;
}


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

using namespace std;

int n, d;
int t[200];
int a[200], b[200], c[200];
int dp[201][200];


int main()
{
	cin >> d >> n;
	for (int i = 0; i < d; ++i) cin >> t[i];
	for (int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];
	
	for (int i = 1; i < d; ++i) {
		for (int j = 0; j < n; ++j) if (a[j] <= t[i] && t[i] <= b[j]) {
			for (int k = 0; k < n; ++k) if (a[k] <= t[i - 1] && t[i - 1] <= b[k]) {
				dp[i][j] = max(dp[i][j], dp[i - 1][k] + abs(c[j] - c[k]));
			}
		}
	}

	int ma = 0;

	for (int i = 0; i < n; ++i) ma = max(ma, dp[d - 1][i]);

	cout << ma << endl;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=8e18;
const int32_t LOG=21;
const int MOD=MOD2;


int cnt[105];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
          int n,k;
          cin>>n>>k;
          rep(i,0,k)
          {
              int d;
              cin>>d;
              rep(j,0,d)
              {
                 int x;
                 cin>>x;
                 cnt[x]++;
              }
          }
          int ans=0;
          rep(i,1,n+1)
          {
              ans+=(cnt[i]==0);
          }
          cout<<ans<<endl;
      }

      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3660
kn = [int(i) for i in input().split()]
K = kn[0]
N = kn[1]
A = [int(i) for i in input().split()]

Ad = [A[i+1] - A[i] if i != N-1 else K-A[-1]+A[0] for i in range(len(A))]
print(sum(Ad)-max(Ad))

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
//const int MOD = 1e9+7;

int main(){
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    for(int i=0; i<n; ++i){
        int x;
        cin >> x;
        mp[x]++;
    }

    vector<int> ans;
    for(auto x:mp)
        if(x.second)
            ans.push_back(x.second);
        
    sort(ans.begin(), ans.end());
    if((int)ans.size() <= k){
        cout << 0;
        return 0;
    }

    int z=0, sz=ans.size();
    for(int i=0; sz>0 && i<(int)ans.size(); ++i){
        z += ans[i];
        --sz;
        if(sz <= k)
            break;
    }
    cout << z;
}


Measured memory_bytes: 13532
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int n, k; 
 
  while(cin >> n >> k, n+k) {
    vector<int> s(k);
    int b;
 
    for(int i = 0; i < k; i++) {
      cin >> s[i];
    }
 
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < k; j++) {
	cin >> b;
	s[j] -= b;
      }
    }
 
    bool ans = true;
    for(int i = 0; i < k; i++) {
      if(s[i] < 0) ans = false;
    }
     
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1188
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
import itertools

N, M, Q = MAP()
a, b, c, d = [], [], [], []
for _ in range(Q):
    ai, bi, ci, di = MAP()
    a.append(ai-1); b.append(bi-1); c.append(ci); d.append(di)


def solve(lst):
    ans = 0
    for i in range(Q):
        if lst[b[i]] - lst[a[i]] == c[i]:
            ans += d[i]
    return ans

ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    ans = max(ans, solve(A))

print(ans)

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

void randed(int num,int idx){
  cout << "Case " << idx << ":" << endl;
  for(int i=0;i<10;i++){
    int tmp = num*num;
    tmp /= 100;
    int next = 0;
    for(int j=0;j<4;j++){
      if(tmp == 0) break;
      int s = tmp % 10;
      int k = 1;
      for(int z=0;z<j;z++){
	k *= 10;
      }
      next += s * k;
      tmp /= 10;
    }
    cout << next << endl;
    num = next;
  }
}

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int num;
    cin >> num;
    randed(num,i+1);
  }
}

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

int main() {
    long long n, b, r;
    cin >> n >> b >> r;
    long long sum = b + r;
    // if(sum > n)
    // {
    //     if(b > n)
    //         cout << b - n;
    //     else
    //         cout << b;
    //     }
    // else{
    //     if(n % sum >= b)
    //         cout << (n / sum) * b + b;
    //     else
    //         cout << (n / sum) * b + n % sum;
    // }
    
    long long seg = n/sum;
    
    cout << (seg * b) + min(b, n % sum);
    return 0;
}

Measured memory_bytes: 256