akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int N, x, a[100000];
	long long int count = 0;
	scanf("%d%d", &N, &x);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i < N; i++) {
		if (a[i] + a[i - 1] > x) {
			if (a[i - 1] <= x) {
				count += a[i] + a[i - 1] - x;
				a[i] = x - a[i - 1];
			}
			else {
				count += a[i] + a[i - 1] - x;
				a[i] = 0;
				a[i - 1] -= x;
			}
		}
	}
    printf("%lld\n", count);
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        if(str.equals("SSS"))
            System.out.println(0);
        if(str.equals("SSR"))
            System.out.println(1); 
        if(str.equals("SRS"))
            System.out.println(1);
        if(str.equals("SRR"))
            System.out.println(2);
        if(str.equals("RSS"))
            System.out.println(1);
        if(str.equals("RSR"))
            System.out.println(1);
        if(str.equals("RRS"))
            System.out.println(2);
        if(str.equals("RRR"))
            System.out.println(3);
    }
}


Measured memory_bytes: 35560
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=2000005;
const int NN=2005;
const ll md=998244353;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b,n,t,tmp;
	cin>>n;
	vii v,v1(N,0);
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.pb(a);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++)
	{
		tmp=v[i];
		for(int j=tmp;j<=v[n-1];j+=tmp)
            v1[j]++;
	}
	ll cnt=0;
	for(int i=0;i<n;i++)
    {
        if(v1[v[i]]==1)
            cnt++;
    }
    cout<<cnt<<E;
    r0;
}


/*







*/


Measured memory_bytes: 20960
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}
int main(){
  int n,m,i,j;
  scanf("%d%d", &n, &m);
  int a[n],tmp[m][2];
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }
  for(i=0;i<m;i++){
    scanf("%d%d", &tmp[i][1], &tmp[i][0]);
  }
  qsort(a,n,sizeof(int),cmp);
  qsort(tmp,m,sizeof(tmp[0]),cmp);
  int p=0;
  for(i=m-1;i>=0;i--){
    for(j=0;j<tmp[i][1] && p<n;j++){
      if(a[p]<tmp[i][0]){
        a[p]=tmp[i][0];
        p++;
      }else{
        break;
      }
    }
  }
  long long int sum=0;
  for(i=0;i<n;i++){
    sum+=a[i];
  }
  printf("%lld", sum);
}

Measured memory_bytes: 2164
N=int(input())
a=list(map(int, input().split()))
sumlist=[]
for i in range(min(a),max(a)+1):
    sum=0
    for j in range(N):
        sum+=(a[j]-i)*(a[j]-i)
    sumlist.append((sum,i))
print(sorted(sumlist, key=lambda x: x[0])[0][0])


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

int main() {
  int64_t A,V,B,W,T;
  cin>>A>>V>>B>>W>>T;
  if(abs(A-B)<=T*abs(V-W)&&V-W>0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 3624
N, M = map(int, input().split())
H = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(M)]



graph = [[] for _ in range(N+1)]
for edge in edges:
    graph[edge[0]].append(edge[1])
    graph[edge[1]].append(edge[0])

ans = []

for i in range(1,N+1):
    can = graph[i]
    hights = []
    for j in can:
        hights.append(H[j-1])
    if len(hights) == 0:
        ans.append(i)
    else:
        h = max(hights)
        if H[i-1] > h:
            ans.append(i)

print(len(set(ans)))

Measured memory_bytes: 51272
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
template <class T>
inline void read(T &x)
{
    x=0; char c=getchar();  int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
    while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=2e5+10;
ll pre[N][5];
int n,a[N];
int main()
{
//	freopen("in.txt","r",stdin);
	read(n);
	for(int i=1;i<=n;++i) read(a[i]);
	ll ans=1e18;
	for(int i=1;i<=n;++i)
	{
		pre[i][0]=pre[i-1][0];
		for(int j=1;j<5;++j) pre[i][j]=min(pre[i][j-1],pre[i-1][j]);
		pre[i][0]+=a[i];
		pre[i][1]+=(a[i]==0?2:a[i]%2);
		pre[i][2]+=(a[i]%2==0);
		pre[i][3]+=(a[i]==0?2:a[i]%2);
		pre[i][4]+=a[i];
	}
	for(int j=0;j<5;++j) ans=min(ans,pre[n][j]);
	printf("%lld",ans);
	return 0;
}	

Measured memory_bytes: 8832
#include <stdio.h>
void swap(int *pa,int *pb){
	int temp=*pa;
	*pa=*pb;
	*pb=temp;
}

int main(void){
	int a,b;
	int r=1;
	
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<b) swap(&a,&b);
	
	while(r!=0){
		r=a%b;
		a=b;
		b=r;
	}
	
	printf("%d\n",a);
	
	
	return 0;
}

Measured memory_bytes: 1776
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100005
#define mod 1000000007
long long pow[N],a[N],c[N],n[N],m[N];
char s[N];
int main()
{
	pow[0]=1ll;
	for(int i=1;i<=N;i++)
		pow[i]=pow[i-1]*3%mod;
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len;i++)
	{
		a[i]=a[i-1]+(s[i]=='A');
		m[i]=m[i-1]+(s[i]=='?');
	}
	for(int i=len;i>=1;i--)
	{
		c[i]=c[i+1]+(s[i]=='C');
		n[i]=n[i+1]+(s[i]=='?');
	}
	long long ans=0;
	for(int i=1;i<=len;i++)
	{
		if(s[i]=='B'||s[i]=='?')
		{
			ans=(ans+
			a[i]*c[i]*pow[m[i-1]+n[i+1]]%mod+
			a[i]*n[i+1]%mod*pow[m[i-1]+n[i+1]-1]%mod+
			c[i]*m[i-1]%mod*pow[m[i-1]+n[i+1]-1]%mod+
			pow[m[i-1]+n[i+1]-2]*m[i-1]%mod*n[i+1])%mod;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4224
package main

import (
	"fmt"
)

func stdinput() string {
	var st string
	fmt.Scan(&st)
	return st
}
func main() {
	s := stdinput()
	stateb := false
	statea := false
	for _, val := range s {
		if string(val) == "B" {
			stateb = true
		} else if string(val) == "A" {
			statea = true
		} else {
			statea = false
			stateb = false
		}
	}
	if statea && stateb {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N, H, W;
	cin >> N >> H >> W;
	int ans = (N - H + 1) * (N - W + 1);
	cout << ans << endl;
}

Measured memory_bytes: 256
x = int(input())

if x >= 1800:
    print(1)
elif x >= 1600:
    print(2)
elif x >= 1600:
    print(2)
elif x >= 1400:
    print(3)
elif x >= 1200:
    print(4)
elif x >= 1000:
    print(5)
elif x >= 800:
    print(6)
elif x >= 600:
    print(7)
elif x >= 400:
    print(8)


Measured memory_bytes: 9200
S = input()
s = S[::-1]

cnt = [0]*2019
cnt[0] = 1
number = 0
d = 1

for i in s:
  number += int(i)*d
  cnt[number % 2019] += 1
  d *= 10
  d = d % 2019

ans = 0
for i in cnt:
  ans += i*(i-1) // 2

print(ans)

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

int main(void){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;

    int at = a%10;
    int bt = b%10;
    int ct = c%10;
    int dt = d%10;
    int et = e%10;

    if(at!=0){
        a = a+(10-at);
    }
    if(bt!=0){
        b = b+(10-bt);
    }
    if(ct!=0){
        c = c+(10-ct);
    }
    if(dt!=0){
        d = d+(10-dt);
    }
    if(et!=0){
        e = e+(10-et);
    }

    int ans = a+b+c+d+e;
    int cp_ans = ans;
    if(at!=0) ans = cp_ans-(10-at);
    if(cp_ans-(10-bt) < ans && bt!=0) ans = cp_ans-(10-bt);
    if(cp_ans-(10-ct) < ans && ct!=0) ans = cp_ans-(10-ct);
    if(cp_ans-(10-dt) < ans && dt!=0) ans = cp_ans-(10-dt);
    if(cp_ans-(10-et) < ans && et!=0) ans = cp_ans-(10-et);

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int board[8] = { -20, -20, -20, -20, -20, -20, -20, -20 };
int check[8];
int flag;
int count;

void output(int box[]) {
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			if (j == box[i])
				printf("Q");
			else
				printf(".");
		}
		printf("\n");
	}
}

void eight_queens(int c, int box[]) {
	if (c == 8) {
		output(box);
	}
	else if (check[c] == 1){
		eight_queens(c + 1, box);
		if (check[c + 1] == 0)
			box[c + 1] = -20;
	}
	else {
		int flag;
		for (int i = 0; i < 8; i++) {
			flag = 0;
			for (int j = 0; j < 8; j++) {
				if (i == box[j] || i == box[j] - c + j || i == box[j] + c - j)
					flag = 1;
			}
			if (flag == 0) {
				box[c] = i;
				eight_queens(c + 1, box);
			}
			if (check[c + 1] == 0)
				box[c + 1] = -20;
		}
	}
}

int main(void) {
	int n, r, c;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &r, &c);
		board[r] = c;
		check[r] = 1;
	}

	eight_queens(0, board);
		
	//printf("Fin\n");
	//while(1) {}

	return 0;
}


Measured memory_bytes: 2100
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc140/tasks/abc140_e
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647;
const LL mod = 1000000007ll;
 
int N;
int P[100000];
 
LL ans = 0;
 
void solve(){
	//入力が順列なので次のような記録の仕方ができる
	//iの位置（インデックス）をidx[i]とおく
	vector<int> idx(N);
	set<int> s;
	for(int i=0;i<N;i++) idx[P[i]] = i;
	//Pは1~Nの順列　Pが大きい順に調べていく
	for(int x=N-1;x>=0;x--){
		int i = idx[x];//P[i] = x
		LL c = 0;

		//今xがいる場所のイテレータを取得
		s.insert(i);
		//left[0] = 左に進んで1個目の赤丸（赤丸については動画参照）
		//left[1] = 左に進んで2個目の赤丸
		vector<int> left(2,-1);//-1で存在しないことを表すとする
		//right[0] = 右に進んで1個目の赤丸
		//right[1] = 右に進んで2個目の赤丸
		vector<int> right(2,N);//Nで存在しないことを表すとする

		{
			//leftを計算
			auto it = s.find(i);
			for(int j=0;j<2;j++){
				if(it==s.begin()) break;//begin=先頭の要素
				it--;//イテレータを1個戻す
				left[j] = *it;//
			}
		}
		{
			//rightを計算
			auto it = s.find(i);
			for(int j=0;j<2;j++){
				it++;//イテレータを1個戻す
				if(it==s.end()) break;//end=末尾の要素+1
				right[j] = *it;//
			}
		}

		vector<int> ls(2);
		ls[0] = i-left[0]; ls[1] = left[0]-left[1];
		vector<int> rs(2);
		rs[0] = right[0]-i; rs[1] = right[1]-right[0];

		c = (LL)ls[0]*rs[1] + (LL)ls[1]*rs[0];

		ans += c*(x+1);
	}
}
 
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> P[i];
		P[i]--;
	}
 
	solve();
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	string S;

	cin >> S;

	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; cin>>s;
	vector<int>L(s.size()),R(s.size());
	for(int i=1,l=0,r=s.size()-1;i<s.size();++i){
		if(s.at(i-1)=='R'&&s.at(i)=='L'){
			for(int j=l;j<=i;++j){
				R.at(j)=i;
			}
			l=i+1;
		}
		int j=abs((int)s.size()-i);
		if(s.at(j-1)=='R'&&s.at(j)=='L'){
			for(int k=r;k>=j;--k){
				L.at(k)=j;
			}
			r=j-1;
		}
	}
	vector<int>ans(s.size(),0);
	for(int i=0;i<ans.size();++i){
		if(s.at(i)=='R'){
			if((R.at(i)-i)&1)++ans.at(R.at(i)-1);
			else ++ans.at(R.at(i));
		}
		else{
			if((L.at(i)-i)&1)++ans.at(L.at(i)-1);
			else ++ans.at(L.at(i));
		}
	}
	cout<<ans.front();
	for(int i=1;i<ans.size();++i){
		cout<<" "s<<ans.at(i);
	}
	cout<<"\n"s;
}


Measured memory_bytes: 4528
#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 n;
  cin >> n;
  n %= 10;
  if(n==3) cout << "bon";
  else if(n==0||n==1||n==6||n==8) cout << "pon";
  else  cout << "hon";
  cout << endl;
}


Measured memory_bytes: 3636
N, M = map(int, input().split(' '))

conditions = []
for _ in range(M):
    s, c = input().split(' ')
    conditions.append((int(s) - 1, c))


def check(n):
    sn = str(n)
    for s, c in conditions:
        if sn[s] != c:
            return False
    else:
        return True


if N == 1:
    lowest = 0
else:
    lowest = int('1' + '0' * (N - 1))
highest = int('1' + '0' * N)

for n in range(lowest, highest):
    if check(n):
        print(n)
        break
else:
    print(-1)


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  } else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int L[70];

int rec(int N, int X) {
  //cout << "N is : " << N << " X is : " << X<< endl;
  if (X == 0) {
    //cout << "1" << endl;
    return 0;
  } else if (N == 0) {
    //cout << "2" << endl;
    return 1;
  } else if (X > 4 * pow(2, N) - 3) {
    //cout << "3" << endl;
    return rec(N, 4 * pow(2, N) - 3);
  } else if ( X <= 4 * pow(2, N-1) - 2) {
    //cout << "4" << endl;
    return rec(N-1, X-1);
  } else {
    //cout << "5: L[N-1] is :" << L[N-1] << endl;
    
    return L[N-1] + 1 + rec(N-1, X - (4 * pow(2, N-1) - 2) - 1);
  }
}

signed main() {
  int N, X; cin >> N >> X;
  rep(i, N) {
    L[i] = 2 * pow(2, i) - 1;
  }

  int x = rec(N, X);
  cout << x << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String a[] = new String[n];
        for (int i=0; i<n; i++) {
            a[i] = sc.next();
        }

        int ac = Arrays.stream(a)
            .filter(s -> s.equals("AC")).toArray().length;

        int wa = Arrays.stream(a)
            .filter(s -> s.equals("WA")).toArray().length;

        int tle = Arrays.stream(a)
            .filter(s -> s.equals("TLE")).toArray().length;

        int re = Arrays.stream(a)
            .filter(s -> s.equals("RE")).toArray().length;

        System.out.println("AC x "+ac);
        System.out.println("WA x "+wa);
        System.out.println("TLE x "+tle);
        System.out.println("RE x "+re);
    }
}

Measured memory_bytes: 64916
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

ll dp[1000010];

int main(){
  rep1(i,1000000){
    for(int j=i;j<=1000000;j+=i){
      dp[j]++;
    }
  }
  rep1(i,1000000){
    dp[i]+=dp[i-1];
  }
  int n; cin >> n;
  cout << dp[n-1] << endl;
  
}

Measured memory_bytes: 11444
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main(){
    int k;
    string s = "ACL";
    cin >> k;
    for(int i = 0; i < k; i++){
        cout << s;
    }
    cout << endl;
}

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

using namespace std;

int n,k,i,j,a[100005];

int main(){
	scanf("%d%d", &n, &k);
	
	int gcd = 0;
	
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
		gcd = __gcd(gcd, a[i]);
	}	
	
	sort(a, a + n);
	
	if(k > a[n - 1])
	return 0 * printf("IMPOSSIBLE\n");
	
	if(k % gcd == 0)
	printf("POSSIBLE\n");
	else
	printf("IMPOSSIBLE\n");
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
#include<stack>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

int main(){
	string s;
	int K;
	cin>>s>>K;
	ll dp[110][5][2];//dp[i][k][f]:=i文字目までで、非ゼロがk個あって、Sと等しいかがf
	rep(i,s.size())rep(k,K+1)rep(f,2)dp[i][k][f]=0;
	dp[0][0][0]=1;
	dp[0][1][0]=max(0,s[0]-'0'-1);
	dp[0][1][1]=1;
	for(int i=0;i<s.size()-1;i++)rep(k,K+1){
		dp[i+1][k+1][0]+=dp[i][k][0]*9;
		dp[i+1][k+1][0]+=dp[i][k][1]*max(0,s[i+1]-'0'-1);
		dp[i+1][k][0]+=dp[i][k][0];
		dp[i+1][k][0]+=dp[i][k][1]*(s[i+1]!='0');
		dp[i+1][k+1][1]+=dp[i][k][1]*(s[i+1]!='0');
		dp[i+1][k][1]+=dp[i][k][1]*(s[i+1]=='0');
	}
	ll ans=0;
	rep(f,2)ans+=dp[s.size()-1][K][f];
	cout<<ans<<endl;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define max(a, b) (a>b?a:b)
#define min(a, b) (a>b?b:a)

int main() {
  int d, x, y;
  vector<int> P, Q;
  cin >> d;
  cin >> x;
  rep(i, x) {
    char a; int p;
    cin >> a >> p;
    if(a=='D') P.push_back(p);
  }
  sort(P.begin(), P.end(), greater<int>());

  cin >> y;
  rep(i, y) {
    char b, c; int q;
    cin >> b >> c >> q;
    if(b=='D' && c=='D') Q.push_back(q);
  }
  sort(Q.begin(), Q.end(), greater<int>());

  int c = min(d, (int)P.size())+1;
  int ans = 0, pnt;
  rep(i, c) {
    pnt = 0;
    rep(j, i) pnt += P[j];
    rep(j, min((d-i)/2, Q.size())) pnt += Q[j];
    ans = max(ans, pnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;;
int main() {
  int N; cin>>N;
  string W[100];
  for(int i=0;i<N;i++)
    cin>>W[i];
  for(int i=0;i+1<N;i++){
    for(int j=i+1;j<N;j++){
      if(W[i]==W[j]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  for(int i=1;i<N;i++){
    if(W[i-1].back()!=W[i].front()){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  string s;cin>>s;
  REP(i,12){
    if(i==4)
      cout<<" ";
    cout<<s[i];
  }
  cout<<endl;
}


Measured memory_bytes: 256
N=int(input(''))

a=[list(map(int,input().split())) for l in range (N)]

b=0
c=0
while b<=N-3:
  if a[b][0]==a[b][1] and a[b+1][0]==a[b+1][1] and a[b+2][0]==a[b+2][1]:
     c=c+1
  
  b=b+1

if c>0:
  print('Yes')

else:
  print('No')

 

Measured memory_bytes: 9188
import java.math.BigDecimal;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double T = sc.nextInt();
		double X = sc.nextInt();
//		String A = sc.next();

		double answer = T/X;

		 String str = BigDecimal.valueOf(answer).toPlainString();


		 System.out.println(answer);
	}
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int n,t;
  cin>>n>>t;
  vpii v(n);
  rep(i,n){
    int c,t;cin>>c>>t;
    v[i]=mp(c,t);
  }
  vsort(v);
  string ans="TLE";
  rep(i,n){
    if(v[i].second<=t){
      ans=to_string(v[i].first);
      break;
    }
  }
  cout(ans);
  return 0;
}

Measured memory_bytes: 125568
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };



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

	bool yes = false;

	for (int i = 0; i < 15; i++) {
		if ((N - 7 * i) % 4 == 0 && (N - 7 * i) >= 0) {
			yes = true;
			break;		
		}
	}

	if (yes)printf("Yes");
	else printf("No");

}





/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N,K,ans=0;
    cin>>N>>K;
    REP(i,N){
        int a;cin>>a;
        ans+=min(a,abs(K-a))*2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

ll f(vector<vector<ll>> &dp,int l,int r,vector<ll> &a){
	if(dp[l][r] >= 0)
		return dp[l][r];
	if(l==r)
		return dp[l][r] = a[l];
	return dp[l][r] = max(a[l] - f(dp, l + 1, r, a), a[r] - f(dp, l, r - 1, a));
}

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	vector<vector<ll>> dp(n, vector<ll>(n, -1));
	cout << f(dp, 0, n - 1, a) << endl;

	return 0;
}

Measured memory_bytes: 70912
#include<stdio.h>

main()
{
	int a,b,c,d,n,cou;
	
	while(scanf("%d",&n)!=EOF){
		cou=0;
		
		for(a=0;a<=9;a++){
			for(b=0;b<=9;b++){
				for(c=0;c<=9;c++){
					for(d=0;d<=9;d++){
						if(a+b+c+d==n){cou++;}
					}
				}
			}
		}
		
		printf("%d\n",cou);
	}
	
	return 0;
}

Measured memory_bytes: 596
import bisect

N, K = [int(i) for i in input().split()]
candles = [int(i) for i in input().split()]

if 0 not in candles:
    zero_index = bisect.bisect(candles, 0)
else :
    zero_index = candles.index(0)

start_index = max(0, zero_index-K)
end_index = min(start_index+K, N-K+1)

distances = []
for i in range(start_index, end_index):
    if candles[i] < 0 and 0 < candles[i+K-1]:
        dist_left = abs(candles[i])
        dist_right = candles[i+K-1]
        dist = (2 * min(dist_left, dist_right)) + max(dist_left,dist_right)
    else :
        dist = max(abs(candles[i]), abs(candles[i+K-1]))
    distances.append(dist)

print(min(distances))

Measured memory_bytes: 20348
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll A[81];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> A[i];
  ll lower = A[0];
  ll higher = A[0];
  vector<P> V;
  rep(i, N) {
    if (i==0) continue;
    if (A[i]<higher) {
      V.push_back(P(lower, higher));
      lower = A[i];
      higher= A[i];
    } else {
      higher = A[i];
    }
  }
  V.push_back(P(lower, higher));
  ll ans = 1000ll;
  for (auto p: V) {
    ll lower = p.first; ll higher = p.second;
    ans = (ans / lower) * higher + ans%lower;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    string s;
    cin >> s;
    if(s.size()==2){
        cout << s << endl;
    }else{
        cout << s[2] << s[1] << s[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let mut s = String::new();
    let ts: Vec<String> = vec![String::from("maerd"), String::from("remaerd"), String::from("esare"), String::from("resare")];

    std::io::stdin().read_line(&mut s);

    let mut acc = String::new();

    for ch in s.trim().chars().rev() {
        acc.push(ch);

        if let "maerd" = &*acc {
            acc = String::from("");
        }
        if let "remaerd" = &*acc {
            acc = String::from("");
        }
        if let "esare" = &*acc {
            acc = String::from("");
        }
        if let "resare" = &*acc {
            acc = String::from("");
        }
    }

    if( acc.len() > 0 ) {
        println!("NO");
    } else {
        println!("YES");
    }
}

Measured memory_bytes: 2240
package main

import (
	"fmt"
	"math"
)

func main() {
	H, A := float64(readInt()), float64(readInt())

	fmt.Println(int(math.Ceil(H / A)))
}

func loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func readInt() int {
	var v int
	fmt.Scan(&v)
	return v
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;

int main() {
	cin >> n;
	if(n & 1) printf("%d\n", (n + 1) / 2);
	else printf("%d\n", n / 2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a, b, c;
int l[8];
int use[8];
int mpmin = INT_MAX;

int cal() {
	int aa = 0, bb = 0, cc = 0;
	int cnt = 0;
	for(int i=0;i<n;i++){
		if(use[i]==0){
			aa+=l[i];
			cnt++;
		}
		if(use[i]==1){
			bb+=l[i];
			cnt++;
		}
		if(use[i]==2){
			cc+=l[i];
			cnt++;
		}
	}
	if(aa!=0 && bb!=0 && cc!=0){
		return abs(aa-a)+abs(bb-b)+abs(cc-c)+(cnt-3)*10;
	}else{
		return INT_MAX;
	}
}

void dfs(int d) {
	if(d==n){
		mpmin = min(cal(), mpmin);
		return;
	}
	for(int i=0;i<4;i++){
		use[d] = i;
		dfs(d+1);
	}
	return;
}

int main() {
	cin >> n;
	cin >> a >> b >> c;
	for(int i=0;i<n;i++){
		cin >> l[i];
	}
	dfs(0);
	cout << mpmin << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin>>n;
  int p[n];
  rep(i, n){
    cin>>p[i];}
  
  int cnt=0;
  for(int i=1;i<=n-2;i++){
    if(p[i]>p[i-1]&&p[i]<p[i+1]){
      cnt++;}
    if(p[i]<p[i-1]&&p[i]>p[i+1]){
      cnt++;}
  }
  
  cout<<cnt<<endl;
 
 
}

Measured memory_bytes: 256
"""n,m,q = (int(i) for i in input().split())
a = []
ans = 0

for i in range(q):
	a.append(list(map(int,input().split())))

for i in range(q):
	if
		ans+=a[i][3]

print(ans)
"""

a,b,n = (int(i) for i in input().split())
x = 0
if b<=n:
	x = b-1
else:
	x = n
c = a*x
print(c//b)

Measured memory_bytes: 9196
n=int(input())
lst=[]
for i in range(n):
  s,t=input().split()
  T=int(t)
  lst.append([s,T])
x=input()
for j in range(n):
  if lst[j][0]==x:
    k=j
    break
totl=0
for j in range(k+1,n):
  totl+=lst[j][1]
print(totl)


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

int main()
{
    int n,m,c,a;
    cin >> n >> m >> c;
    int b[m];
    int counter =0, value;
    
    for (int i=0;i<m;i++){
        cin >> b[i];
    }
    
    for (int i=0;i<n;i++){
        value = 0;
        for(int j=0;j<m;j++){
            cin >> a;
            value += a*b[j];
        }
        if (value+c>0){counter ++;}
    }
    cout << counter;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int i, a[3], b[3], cnt[4], cnt_1 = 0, cnt_2 = 0;
	
	for(i = 0; i < 4; i++){
		cnt[i] = 0;
	}
    
	for(i = 0; i < 3; i++){
		scanf("%d %d", &a[i], &b[i]);
	}
	
	for(i = 0; i < 3; i++){
		cnt[a[i] - 1]++;
		cnt[b[i] - 1]++;
	}
	
	for(i = 0; i < 4; i++){
		if(cnt[i] == 1){
			cnt_1++;
		}else if(cnt[i] == 2){
			cnt_2++;
		}
	}
	
	if(cnt_1 == 2 && cnt_2 == 2){
		printf("YES");
	}else{
		printf("NO");
	}
	
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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

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

int n,k;int a[110];
bool dp[510000];
signed main(){
  cin>>n>>k;rep(i,n)cin>>a[i];
  repd(i,1,k+1){
    rep(j,n){
      if(i-a[j] >= 0 && !dp[i-a[j]]){
        dp[i] = true;break;
      }
    }
  }
  cout << (dp[k] ? "First" : "Second") << endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int x1, y1, x2, y2, dx, dy;
int main() {
	cin>>x1>>y1>>x2>>y2;
	dx = x2 - x1;
	dy = y2 - y1;
	x2 -= dy;
	y2 += dx;
	cout<<x2<<' '<<y2<<' ';
	x2 -= dx;
	y2 -= dy;
	cout<<x2<<' '<<y2<<' ';
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
S = [None] * n
for i in range(n):
  S[i] = Counter(input())
s = ''
for i in range(26):
  cnt = 50
  for j in range(n):
    cnt = min(S[j][chr(97 + i)], cnt)
  s += chr(97 + i) * cnt
print(s)

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

using namespace std;

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

struct Clothes {
	int a, b, c;
};

int main() {
	int dp[201][200] = {};
	int d, n, mt[200];
	Clothes clothes[200];

	cin >> d >> n;
	REP(i, d) scanf("%d", &mt[i]);
	REP(i, n) scanf("%d %d %d", &clothes[i].a, &clothes[i].b, &clothes[i].c);
	
	REP(i, d) {
		REP(j, n) {
			if (clothes[j].a > mt[i] || clothes[j].b < mt[i]) continue;
			REP(k, n) {
				if (clothes[k].a > mt[i+1] || clothes[k].b < mt[i+1]) continue;
				dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abs(clothes[k].c - clothes[j].c));
			}
		}
	}

	int ans = 0;
	REP(i, n) ans = max(ans, dp[d - 1][i]);
	cout << ans << endl;

	return 0;
}

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

int main() {
    int H, W;
    
    while(true) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for(int y=0; y < H; y++) {
            for(int x=0; x < W; x++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;


class point 
{
	
public:
	int dim;
	std::vector<int> pts;
	void dimension(int n)
	{
		dim = n;
	}
	void input()
	{
		int k;
		for (int i = 0; i < dim; ++i)
		{
			cin >> k;
			pts.push_back(k);
		}
	}
	void print()
	{
		for (int i = 0; i < dim; ++i)
		{
			cout << pts[i] << " ";
		}
		cout << endl;
	}
};


long double dist(point a, point b)
{
	long double sum = 0;
	for (int i = 0; i < a.dim; ++i)
	{
		sum = sum + pow((a.pts[i]-b.pts[i]), 2);
	}
	return(sqrt(sum));
}

int main()
{
	int d, n, cnt = 0;
	cin >> n >> d;

	point pt[n];

	for (int i = 0; i < n; ++i)
	{
		pt[i].dimension(d);
		pt[i].input();
	}

	for (int i = 0; i < n-1; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			long double x = dist(pt[i], pt[j]);
			if((x - floor(x)) == 0)
			{
				cnt++;
			}
		}
	}

	cout << cnt << endl;


}

Measured memory_bytes: 256
K,A,B = map(int,input().split())
if B<=A+2:
    print(K+1)
else:
    if (K-A+1)%2==0:
        print(A+(B-A)*((K-A+1)//2))
    else:
        print(A+(B-A)*((K-A)//2)+1)

Measured memory_bytes: 2940
group31 = {1, 3, 5, 7, 8, 10, 12}
group30 = {4, 6, 9, 11}
group28 = {2}

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

if x in group31 and y in group31 or x in group30 and y in group30 or x in group28 and y in group28:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  long long n, m;
  cin >> n >> m;
  if(n == 1 && m == 1){
    cout << 1 << endl;
  }else if(n == 1 || m == 1){
    cout << n + m - 3 << endl;
  }else{
    cout << (n - 2) * (m - 2) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		if (A + B > C + D) {
			System.out.println("Left");
		} else if (A + B < C + D) {
			System.out.println("Right");
		} else {
			System.out.println("Balanced");
		}
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main() {
    
    int n, t, a, h;
    int score[1000];
    
    cin >> n >> t >> a;
    for (int i = 0; i < n; i++) {
        cin >> h;
        score[i] = abs((t * 1000 - h * 6) - a * 1000);
    }
    
    cout << min_element(score, score + n) - score + 1 << endl;
    
}

Measured memory_bytes: 256
mod = 10**9+7
n,m,k = map(int,input().split())
##nCk:0,nにkが寄る時 O(k)

#nCkのkのmaxをxとする
x = k
fact = [1] * (x + 1)
for i in range(1, x + 1):
    fact[i] = fact[i - 1] * i % mod

def mod_comb_k(n,k,mod):
    ret = 1
    if n - k < k:
        k = n - k
    for i in range(n, n - k, -1):
        ret = ret * i % mod
    return ret % mod * pow(fact[k], mod - 2, mod) % mod

res = 0
for d in range(1,n):
    res += m*m*(n-d)*d
    res = res%mod

n,m = m,n
for d in range(1,n):
    res += m*m*(n-d)*d
    res = res%mod

res *= mod_comb_k(n*m-2,k-2,mod)
'''
for d in range(1,m):
    res += n*n*(m-d)*mod_comb_k(n*m-2,k-2,mod)%mod
    res = res%mod
'''
print(res%mod)

Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define N 2000001
#define M 1000000007
#define MOD 998244353
#define INF 1000000000000000

int main()
{
	ll n;
	cin>>n;
	while(n-->0)cout<<"ACL";
}


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

int main(){
  ll n,a,b,sum=0;
  cin >> n >> a >> b;
  if(a==0){
    cout << 0 << endl;
    return 0;
  }
  else{
    sum=(n/(a+b))*a;
    if(n%(a+b)<=a){
      sum+=n%(a+b);
    }
    else{
      sum+=a;
    }
    cout << sum << endl;
    return 0;
  }
}

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

typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if(a1 + a2 + a3 >= 22)
    printf("bust");
  else
    printf("win");
  return 0;
}


Measured memory_bytes: 256
/*
 *created by Kraken on 19-04-2020 at 17:29
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    FastReader sc = new FastReader();
    long n = sc.nextLong();
    int m = sc.nextInt();
    long sum = 0;
    for (int i = 0; i < m; i++) sum += sc.nextLong();
    System.out.println((sum <= n) ? n - sum : "-1");
  }

  static class FastReader {

    BufferedReader br;

    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        }
        catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      }
      catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 34092
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
LL A, B;
LL n;
int main (){
	LL i, j, k;
	LL ans = 0, last;
	scanf ( "%lld%lld%lld", &n, &A, &B );
	scanf ( "%lld", &last );
	for ( i = 2; i <= n; i ++ ){
		LL x;
		scanf ( "%lld", &x );
		if ( (LL)A*(x-last) < B ) ans += A*(x-last);
		else ans += B;
		last = x;
	}
	printf ( "%lld\n", ans );
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<string>> a(n,vector<string>(m,0))
#define P pair<int,int>
#define Sort(a) sort((a).begin(),(a).end())
#define Reverse(a) reverse((a).begin(),(a).end())
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
void Debug(auto a);

signed main(){
    int n;
    cin >> n;
    vec(a,n);
    vec(b,n);
    vec(c,n);
    REP(i,n){
        cin >> a[i];
    }
    REP(i,n){
        cin >> b[i];
        c[i] = a[i]-b[i];
    }
    Sort(c);
    int x=0,s=0,t=n-1;
    int ans = 0;
    while(x==0){
        if(s>t){
            ans = -1;
            x=1;
        }
        if(c[s]<0){
            if(c[t]+c[s]<0){
                c[s]+=c[t];
                c[t]=0;
                t--;
            }
            else{
                c[t]+=c[s];
                c[s]=0;
                s++;
            }
            ans++;
        }
        else{
            x=1;
        }
    }
    if(ans == 0 || ans == -1){
        cout << ans << endl;
    }
    else{
        cout << ans+1 << endl;
    }
    
    
    
    return 0;
}
void debug(auto a){
    cout << "{ ";
    int len = a.size();
    REP(i,len){
        cout << a[i] << " ";
    }
    
    cout << "}" << endl;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
using namespace std;
int main(void){
long long int a=0,b[1000000],c=0,max=0;
cin>>a;
for(int i=0;i<a*2;i++){
    cin>>b[i];
}
for(int i=0;i<a*2;i=i+2){
    if(b[i]>max){
        max=b[i];
        c=b[i+1];
    }
}
cout<<max+c<<endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
int ans[N];
#define pii pair<int, int> 
set<pair<int, pii> > s;
set<pii> pers;
int main(){
    int n, q;
    sc(n);sc(q);
    fr(i, 1, n){
        int st, en, x;
        sc(st);sc(en);sc(x);
        s.insert({x, {st, en}});
    }
    fr(i,1,q){
        int x;sc(x);
        pers.insert({x, i});
    }
    fr(i, 1, q) ans[i] = -1;
    for(auto it: s){
        int x = it.fi;
        int st = it.se.fi;
        int en = it.se.se;
        while(pers.size()){
            auto lb = pers.lower_bound({st - x, -1});
            if (lb == pers.end()) break;
            if (lb->fi < en-x){
                pers.erase(lb);
                ans[lb->se] = x;
            }
            else break;
        }
    }
    fr(i,1,q){
        pr(ans[i]);n_l;
    }
    return 0;
}



Measured memory_bytes: 26428