akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	vector<int> nums(n, 0);
	for(int i{}; i < n - 1; i++)
	{
		int a; cin >> a;
		nums[a - 1]++;
	}
	for(int i{}; i < n; i++) cout << nums[i] << '\n';
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    bool trump[4][14];
    for(int i=0;i<4;i++){
        for(int j=1;j<=13;j++){
            trump[i][j]=0;
        }
    }
    char x;
    int y;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(x=='S') trump[0][y]=1;
        if(x=='H') trump[1][y]=1;
        if(x=='C') trump[2][y]=1;
        if(x=='D') trump[3][y]=1;
        }
    string mark;
    for(int i=0;i<4;i++){
        for(int j=1;j<=13;j++){
            if(trump[i][j]==1) continue;
            else{
                if(i==0) mark="S";
                if(i==1) mark="H";
                if(i==2) mark="C";
                if(i==3) mark="D";
                cout<<mark<<" "<<j<<endl;
            }
        }
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> x(N);
    vector<int> y(N);
    vector<int> h(N);
    rep(i, N) {
        cin >> x[i] >> y[i] >> h[i];
    }

    rep(cx, 101) rep(cy, 101) {
        int H = 0;
        rep(i, N) {
            if (h[i] != 0) H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
        }
        int flag = true;
        rep(i, N) {
            if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0))
                flag = false;
        }
        if (flag) {
            printf("%d %d %d\n", cx, cy, H);
        }
    }
}

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

int main()
{
    long long N, K;
    cin >> N >> K;

    vector<long long> A(N, 0);
    for (long long &a : A)
    {
        cin >> a;
    }

    vector<long long> sum(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        sum[i + 1] = (sum[i] + A[i]) % K;
    }
    for (int i = 0; i < N + 1; i++)
    {
        sum[i] -= i;
        sum[i] %= K;
        while (sum[i] < 0)
        {
            sum[i] += K;
        }
    }

    queue<long long> q;
    map<long long, long long> m;
    long long ans = 0;
    for (int i = 0; i < N + 1; i++)
    {
        ans += m[sum[i]];
        m[sum[i]]++;
        q.push(sum[i]);
        while (q.size() >= K)
        {
            m[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 17536
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string S;
    cin >> S;
    map<char,int> m;
    m['r'] = p;
    m['p'] = s;
    m['s'] = r;
    int ret = 0;
    for(int i = 0; i < S.length(); i++){
        if(i >= k && S[i-k] == S[i]){
            S[i] = '?';
        }else{
            ret += m[S[i]];
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		
		int[] bnums = new int[m];
		for(int i=0; i<m; i++) {
			bnums[i] = sc.nextInt();
		}
		
		List<List<Integer>> lists = new ArrayList<List<Integer>>();
		
		for(int i=0; i<n; i++) {
			List<Integer> list = new ArrayList<Integer>();
			for(int j=0; j<m; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		}
		
		int cnt = 0;
		for(int i=0; i<n; i++) {
			List<Integer> tmp = lists.get(i);
			int sum = 0;
			for(int p=0; p<m; p++) {
				sum += tmp.get(p)*bnums[p];
			}
			if(sum+c>0) {
				cnt++;
			}else {
				continue;
			}
		}
		System.out.println(cnt);
	}
	
}


Measured memory_bytes: 24148
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s = "AKIHABARA";
  string t;
  cin >> t;
  int i, j;
  for (i = 0, j = 0; i < s.size() && j < t.size(); ) {
    if (s[i] == t[j]) {
      ++i;
      ++j;
    } else {
      if (s[i] == 'A') {
        ++i;
      } else {
        break;
      }
    }
  }
  while (i < s.size() && s[i] == 'A') ++i;
  cout << (i == s.size() && j == t.size() ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int mod=1e9+7;
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )


int main()

{  
   ll n,a,b;
   cin>>n>>a>>b;
   
   ll t=(n)/(a+b);
   ll ans=t*a;
   ll ch=n%(a+b);
   if(ch>a){ch=a;}
   ans+=ch;
   cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;


int main()
{
	int x;
	cin>>x;
	for(int i=-10;i<1000;i++){
		for(int j=-80;j<1000;j++){
			if(pow(i,5)-pow(j,5)==x) {
				cout<<i<<" "<<j<<endl;return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4064
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a.begin(),a.end());

    ll min=LINF;
    int mini=0;
    for(i=0; i<n-1; i++) {
        ll tmp=abs(a[n-1]-2*(ll)a[i]);
        if(tmp<min) {
            min=tmp;
            mini=i;
        }
    }
    printf("%d %d\n", a[n-1], a[mini]);

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll N;
  cin>>N;
  ll ans=0;
  ll s[N];
  ll flag=0;
  FOR(i,0,N-1){
    cin>>s[i];
    ans+=s[i];
    if(s[i]%10!=0)flag=1;
  }
    //cout<<ans<<endl;
  if(flag==0){
    cout<<"0"<<endl;
    return 0;
  }
  if(ans%10!=0){
    cout<<ans<<endl;
    return 0;
  }
  ll min1=1000;
  FOR(i,0,N-1){
    //cout<<"si"<<s[i]<<endl;
    if(s[i]%10!=0){
      min1=min(min1,s[i]);
   // cout<<min1<<endl;
    }
  }
    cout<<ans-min1<<endl;
    return 0;


}
 


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

int main() {
  int n, x, y;
  scanf("%d%d", &n, &x);

  set<int> st;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &y);
    st.insert(abs(x - y));
  }

  int a = 0;
  for (int b : st) {
    a = __gcd(a, b);
  }
  printf("%d\n", a);
  return 0;
}


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

using namespace std;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin >> n;
    int ar[n];
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> t, ar[t - 1] = ctr1 + 1;
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cout << ar[ctr1] << " ";
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm> //sort
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int sum=0,cnt=0;
  while(sum<=x&&cnt<=n){
    sum += a[cnt];
    cnt++;
  }
  if(sum>=x) cout << cnt-1 << "\n";
  else cout << cnt-2 << "\n";
  return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use permutohedron::LexicalPermutation as _;

#[fastout]
fn main() {
    input!{
        n:usize,
        m:usize,
        ab: [(usize, usize); m]
    }
    let mut prm = (1..=n).collect::<Vec<usize>>();

    let mut path_num = 0;
    loop {
        let mut is_path = true;
        for i in 0..n-1 {
            let (v1, v2) = (prm[i], prm[i+1]);
            let mut edge_is_exist = false;
            for (a, b) in &ab {
                if (v1 == *a && v2 == *b) || (v1 == *b && v2 == *a) {
                    edge_is_exist = true;
                }
            }
            if !edge_is_exist {
                is_path = false;
                break;
            }
        }
        if is_path {
            path_num += 1;
        }
        if !prm.next_permutation() {
            break;
        }
        if prm[0] != 1 {
            break;
        }
    }
    println!("{}", path_num);
}


Measured memory_bytes: 2164
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

int main(){
  string S;
  long long K;
  cin >> S >> K;

  int count_1=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='1')  count_1++;
    else  break;
  }

  if(K<=count_1)  cout << 1 << endl;
  else  cout << S.at(count_1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll a,b,c,d;cin>>a>>b>>c>>d;
  ll x=a/d,y=c/b;
  if(a%d!=0){x++;}
  if(c%b!=0){y++;}
  if(y>x){cout<<"No"<<endl;}
  else{cout<<"Yes"<<endl;}
}



Measured memory_bytes: 3672
# -*- coding: utf-8 -*-
figures = {
    'A': [['1', '1'], ['1', '1']],
    'B': [['1'], ['1'], ['1'], ['1']],
    'C': [['1', '1', '1', '1']],
    'D': [['0', '1'], ['1', '1'], ['1', '0']],
    'E': [['1', '1', '0'], ['0', '1', '1']],
    'F': [['1', '0'], ['1', '1'], ['0', '1']],
    'G': [['0', '1', '1'], ['1', '1', '0']],
}


def f1(lines):
    for n, figure in figures.items():
        found = f2(lines, figure)
        if found:
            print(n)
            break


def f2(lines, figure):
    height = len(figure)
    width = len(figure[0])
    for h in range(8 - height + 1):
        for w in range(8 - width + 1):
            found = f3(lines, figure, height, width, h, w)
            if found:
                return True


def f3(lines, figure, height, width, h, w):
    _figure = [[lines[h+_h][w+_w] for _w in range(width)]
               for _h in range(height)]
    if figure == _figure:
        return True


try:
    while True:
        f1([list(input()) for _ in range(8)])
        input()
except EOFError:
    pass

Measured memory_bytes: 7572
#include<stdio.h>
int main(){
  int i,j,k;
  int d;	//365
  int c[26];
  int score[9490];
  int t[365] = {0};
  int day1[26] = {0};
  double x = 0.36787944117;
  int tmp1=-999999,tmp2=-999999;
  int tmpi = 0;
  
  scanf("%d",&d);
  for(i=0;i<26;i++){
      scanf("%d ",&c[i]);
  }
  for(i=0;i<d*26;i++){
      scanf("%d ",&score[i]);
  }
  //st
  
  for(i=0;i<26;i++){
    if(c[i]>tmp1){
     tmp1 = c[i];
    }
    tmpi = i;
  }
  tmp1 = -999999;/*
  for(i=0;i<d;i++){
    for(j=0;j<26;j++){
      if(score[i*26+j]-c[j]*(1+day1[j])>tmp1){
       	t[i] = j;
      }
    }
  }
  */
  //en
  int sp[26]={0};
  int pp=-999999;
  int pp2 = 0;
  for(i=0;i<d;i++){
    
    
    
    pp2=0;
    for(k=0;k<26;k++){  
    if(sp[k]==0&&score[k]+c[k]*(26*day1[k])>pp){	
      pp=score[k];
      pp2 = k;
    }}
    pp=-999999;
    sp[pp2]=1;
    printf("%d\n",pp2+1);
    //printf("%d\n",(tmpi+i)%26+1);
    if(i%26==25){
    	for(k=0;k<26;k++){
         sp[k]=0; 
        }
    }  
    
    
    for(k=0;k<26;k++){
      day1[k] += 1;
    }
    day1[pp2]=0;
  }
 return 0; 
}







Measured memory_bytes: 2188
#重い操作二重は耐えない．minが更新されたか否か
n = int(input())
p = list(map(int,input().split()))
ans = 0
m= 10**10

for i in range(n):
  tmp = m
  m = min(m,p[i])
  if tmp != m:
    ans += 1
    
print(ans)

Measured memory_bytes: 24744
#include <bits/stdc++.h>
#define int long long
using namespace std;
using pii = pair<int, int>;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;
 
signed main()
{
    int n, m;
    cin >> n >> m;
    map<int, vector<int> > v;
    std::priority_queue<int> q;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    int sum = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j < v[i].size(); j++)
            q.push(v[i][j]);
        if (!q.empty()) {
            sum += q.top();
            q.pop();
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	long A,B;cin>>A>>B;
	long m=__gcd(A,B);int count=1;
	rep(i,2,1000001){
		if(m%i==0){
			count++;
			while(m%i==0) m/=i;
		}
	}if(m>1000000) count++;
    cout<<count<<endl;
}

Measured memory_bytes: 256
from collections import deque

d = deque()
S = input()
d.append(S)
Q = int(input())
Flag = True
 
for i in range(Q):
    Query = input()
    if Query[0] == "1":
        Flag = not Flag
    else:
        QueryList = Query.split()
        if Flag:
            if QueryList[1] =="1":
                d.appendleft(QueryList[2])
            else:
                d.append(QueryList[2])
        else:
            if QueryList[1] =="2":
                d.appendleft(QueryList[2])
            else:
                d.append(QueryList[2])

d_string = "".join(list(d))

if not Flag:
    d_string = d_string[::-1]    
print(d_string)

Measured memory_bytes: 6900
N, M = map(int, input().split())
if N == 1:
    min_range = 0
    max_range = 10
else:
    min_range = 10 ** (N-1)
    max_range = 10 ** N
digits_lis = ['not defined' for _ in range(N+1)]
for _ in range(M):
    s, c = map(int, input().split())
    if digits_lis[s] == 'not defined':
        digits_lis[s] = c
    else:
        if digits_lis[s] != c:
            print('-1')
            break
    if digits_lis[1] == 0 and N != 1:
        print('-1')
        break
else:
    for i in range(min_range, max_range):
        for idx, check in enumerate(digits_lis):
            if check == 'not defined':
                continue
            if (i // 10 ** (N - idx)) % 10 != check:
                break
        else:
            print(i)
            break


Measured memory_bytes: 62420
#include<bits/stdc++.h>
using namespace std;
int a[1024];
int n,i=0,flag=1;
int main()
{
	scanf("%d",&n);
	do
	{
		if(n%2)
		{
			if(flag)
			{
				n--;
			}	
			else
			{
				n++;
			}
			a[i]=1;
		}
		else
		{
			a[i]=0;
		}
		n/=2;
		flag=!flag;
		i++;
	}while(n);
	for(i--;i>=0;i--)
	{
		printf("%d",a[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

int solve(vector<int> f, vector<int> s, int st, int len) {
    // cerr << "solve " << len << ' ' << st << endl;
    // for (auto t : f) {
    //     cerr << t << ' ';
    // }
    // cerr << endl;
    // for (auto t : s) {
    //     cerr << t << ' ';
    // }
    // cerr << endl;
    int n = (int)f.size();
    auto can_l = [&](int x) {
        int cp = x;
        for (int i = 0; i < n; i++) {
            if (f[i] == -1) {
                cp--;
                if (cp < 0) return true;
            }
            if (s[i] == 1) {
                cp++;
                cp = min(cp, len - 1);
            }
        }
        return false;
    };
    auto can_r = [&](int x) {
        int cp = x;
        for (int i = 0; i < n; i++) {
            if (f[i] == 1) {
                cp++;
                if (cp >= len) return true;
            }
            if (s[i] == -1) {
                cp--;
                cp = max(cp, 0);
            }
        }
        return false;
    };
    cerr << can_l(st) << ' ' << can_r(st) << endl;  
    return can_l(st) || can_r(st);
}

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

    int h, w, n;
    cin >> h >> w >> n;
    int r, c;
    cin >> r >> c;
    r--;
    c--;
    string s, t;
    cin >> s >> t;
    {
        vector<int> a;
        vector<int> b;
        map<char, int> keks;
        keks['U'] = -1;
        keks['D'] = 1;
        for (int i = 0; i < n; i++) {
            a.push_back(keks[s[i]]);
            b.push_back(keks[t[i]]);
        }
        if (solve(a, b, r, h)) {
            cout << "NO\n";
            return 0;
        }
    }
    {
        vector<int> a;
        vector<int> b;
        map<char, int> keks;
        keks['L'] = -1;
        keks['R'] = 1;
        for (int i = 0; i < n; i++) {
            a.push_back(keks[s[i]]);
            b.push_back(keks[t[i]]);
        }
        if (solve(a, b, c, w)) {
            cout << "NO\n";
            return 0;
        }
    } 
    cout << "YES\n";
}   


Measured memory_bytes: 4424
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N ;
    string a;
    cin>>a;

    char befor;
    befor=a[0];
    int count=1 ;

    for(int i=0;i<N-1;i++){
        if(a[i+1]!=befor){
            count++;
            befor=a[i+1];
        }
    }
    
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
vl adj[200010];
void solve()
{
    bool check=true;
    ll n;
    cin>>n;
    forr(i, n)
    {
        ll x;
        cin>>x;
        if(x%2==0)
        {
            if(x%3!=0&&x%5!=0)
            {
                check=false;
                break;
            }
        }
    }
    if(check)
    cout<<"APPROVED";
    else
    cout<<"DENIED";
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
}

Measured memory_bytes: 8300
# coding: utf-8
# Here your code !
n = input()

a = map(int, raw_input().split())
a = list(reversed(sorted(a)))

i = 1
b = []
cnt = 0

while True:
    if cnt > 1:
        break
    elif i >= len(a):
        print 0
        exit()
    if a[i] == a[i-1]:
        # print(a[i])
        b.append(a[i])
        cnt += 1
        i += 1
    i += 1
if cnt > 1:    
    print b[0] * b[1]

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

int main(){
  vector<vector<int>> A(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> A.at(i).at(j);
    }
  }

  int N;
  cin >> N;
  vector<int> B(N);
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }

  vector<vector<bool>> a(3,vector<bool>(3,false));
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(B.at(i)==A.at(j).at(k)){
          a.at(j).at(k)=true;
        }
      }
    }
  }

  bool b=false;
  for(int i=0;i<3;i++){
    int cnt=0;
    for(int j=0;j<3;j++){
      if(a.at(i).at(j)==true){
        if(cnt==2){
          b=true;
          break;
        }
        cnt++;
      }
    }
  }
  for(int i=0;i<3;i++){
    int cnt=0;
    for(int j=0;j<3;j++){
      if(a.at(j).at(i)==true){
        if(cnt==2){
          b=true;
          break;
        }
        cnt++;
      }
    }
  }
  if(a.at(0).at(0)==true && a.at(1).at(1)==true && a.at(2).at(2)==true) b=true;
  else if(a.at(0).at(2)==true && a.at(1).at(1)==true && a.at(2).at(0)==true) b=true;

  if(b==true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 1000000007;
using P = pair<int, int>;

signed main() {
	string s; s = "ACL";
	int k; cin >> k;
	string ans = "";
	for (int i = 0; i < k; i++) {
		ans += s;
	}
	cout << ans << endl;
	return 0;
}


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

typedef pair<long, long> pl;
int main() {
  long long n, d, a;
  cin>>n>>d>>a;
  pair<long long, long long> xh[n];
  for (int i=0; i<n; i++) cin>>xh[i].first>>xh[i].second;
  queue<pl> q;
  sort(xh, xh + n);
  long long ans = 0;
  long long acc = 0;
  for (int i=0; i<n; i++) {
    while (!q.empty()) {
      auto front = q.front();
      if (xh[i].first > front.first) {
        acc -= front.second;
        q.pop();
      } else {
        break;
      }
    }
    long long h = xh[i].second - acc;
    if (h <= 0) {
      continue;
    }
    long long cnt = (h - 1) / a + 1;
    q.push(make_pair(xh[i].first + d * 2, 1LL * cnt * a));
    ans += cnt;
    acc += 1LL * cnt * a;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

// int main() {
 
//   int64_t N,ans=1;
//   cin>>N;
//   unordered_map<int64_t, vector<int64_t>> map;
// map[1]=1;
//   //vector<int64_t> A(N);
//   for(int64_t i=2; i<=N; i++){
//     int64_t tmp=i,counter=0;
//     for(int64_t j=2; j<=i; j++){
//       if(tmp%j==0){
//         tmp/=j;
//         counter++;
//         cout<<i<<" "<<tmp<<endl;
//         if(map.count(tmp)){
//           ans+=i*(counter+map[tmp]);
//                    cout<<i<<" "<<map[tmp]<<" up "<<(counter+map[tmp])<<" "<<counter<<endl;

//           counter+=map[tmp];
//         map[i]=counter;
//           break;
//         }
//       }
//       if(j==N){
//         ans+=i*counter;
//                   cout<<i<<" "<<ans<<" "<<counter<<endl;
//       }
//         // cout<<i*counter<<" "<<counter<<" "<<ans<<endl;
//         map[i]=counter;
      
//     }
//   }
//   //vector<vector<int64_t> > A(N,vector<int64_t>(M));
//   //for(int64_t i=0; i<N; i++){for(int64_t j=0; j<M; j++){cin>>A[i][j];}}
//   //sort(A.begin(),A.end());
//   //for (int64_t i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
//   //for (int64_t i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
//   cout << ans << endl;
//   cout << map[2] << endl;
// }

int main() {
 
  int64_t N,ans=0;
  cin>>N;
  vector<int64_t> A(N+1,1);
  for(int i=2; i<=N; i++){
    for(int j=1; j<=N/i; j++){
      A[i*j]++;
    }
  }
  for(int i=1; i<=N; i++){
    ans+=A[i]*i;
  }
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
}

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

int main(){
    string a,b;
    cin >> a >> b;
    if(a.size() > b.size()){
        cout << "GREATER" << endl;
    }else if(a.size() < b.size()){
        cout << "LESS" << endl;
    }else{
        if(a.compare(b) > 0){
            cout << "GREATER" << endl;
        }else if(a.compare(b) < 0){
            cout << "LESS" << endl;
        }else{
            cout << "EQUAL" << endl;
        }
    }
}

Measured memory_bytes: 256
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
a=0
b=0
c=0
for num in P:
    if num<=A:
        a+=1
    elif A<num<=B:
        b+=1
    else:
        c+=1

print(min(a,b,c))

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

using static Input;
using static Util;
class Program
{
    static int H, W;
    static bool[][] G;
    static int[] T;
    static void INPUT()
    {
        H = NextInt();
        W = NextInt();
        G = new bool[H + 2][];
        for (int i = 0; i < H + 2; i++)
        {
            G[i] = new bool[W + 2];
        }
        for (int i = 1; i <= H; i++)
        {
            var j = 1;
            foreach (var n in NextString().Select(__ => __ == '.'))
                G[i][j++] = n;
        }
    }

    static void OUT()
    {
        var dp = new long[H + 2,W + 2];

        dp[1, 1] = 1;
        for (int i = 0; i < H + 2; i++)
        {
            for (int j = 0; j < W + 2; j++)
            {
                if (!G[i][j]) continue;
                dp[i, j] += dp[i - 1, j];
                dp[i, j] %= MOD;
                dp[i, j] += dp[i, j - 1];
                dp[i, j] %= MOD;
            }
        }

        Console.WriteLine(dp[H, W]);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 24152
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
vector<vector<ll>> binary_knapsack(vector<int>& val,vector<int>& weight, int W){
    int N = val.size();
    vector<vector<ll>> dp(N,vector<ll>(W+1,0));
    REP(w,W+1){
        if(weight[0]<=w) dp[0][w] = val[0];
    }
    REP(i,N-1){
        REP(w,W+1){
            if(w>=weight[i+1]){
                dp[i+1][w] = dp[i][w-weight[i+1]]+val[i+1];
            }
            chmax(dp[i+1][w], dp[i][w]);
        }
    }
    return dp;
} 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,T;
    cin >> N >> T;
    vi weight(N),val(N);
    REP(i,N){
        cin >> weight[i] >> val[i];
    }
    
    auto dp1 = binary_knapsack(val,weight,T);
    reverse(ALL(val));
    reverse(ALL(weight));
    auto dp2 = binary_knapsack(val,weight,T);
    reverse(ALL(val));
    reverse(ALL(dp2));
    ll ans = 0;
    REP(i,N){
        REP(t,T){
            ll cand = val[i];
            if (i!=0) cand += dp1[i-1][t];
            if (i!=N-1) cand += dp2[i+1][T-t-1];

            chmax(ans,cand);
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 141184
<?php
while(fscanf(STDIN, "%d %d", $n, $p)) {
  if(($n | $p) == 0) break;

  $stone = array();
  for($i = 0; $i < $n; $i++) {
    $stone[] = 0;
  }
  $total = $p;
  $i = 0;

  while(1) {
    if($p) {
      $stone[$i]++;
      $p--;
    }
    else {
      $p = $stone[$i];
      $stone[$i] = 0;
    }

    if($stone[$i] == $total) {
      $ans = $i;
      break;
    }

    $i = ($i + 1) % $n;
  }

  print $ans . "\n";
}

Measured memory_bytes: 6608
#include <iostream>
#include <iomanip>

using namespace std;

void init(int s[][15], int n)
{
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) s[i][j] = 0;
	}
}

void show(int s[][15], int n)
{
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) cout << setw(4) << s[i][j];
		cout << endl;
	}
}

int main()
{
	int n;
	int square[15][15];
	while (true) {
		cin >> n;
		if (n==0) break;
		
		init(square, n);
		
		int x = n/2;
		int y = n/2 + 1;
		for (int i=1; i<n*n; i++) {
			square[y][x] = i;
			x = (x+1) % n; y = (y+1) % n;
			while (square[y][x] > 0) { x = (x+n-1) % n; y = (y+1) % n; }
		}
		square[y][x] = n*n;
		show(square, n);
	}
	
	return 0;
}

Measured memory_bytes: 3124
x, y = map(int, input().split(" "))

g1 = (1, 3, 5, 7, 8, 10, 12)
g2 = (4, 6, 9, 11)
g3 = (2,)

if x in g1 and y in g1:
    print("Yes")
elif x in g2 and y in g2:
    print("Yes")
elif x in g3 and y in g3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int[] a = Console.ReadLine().Trim().Split(' ').Select(z => int.Parse(z)).ToArray();
        Console.WriteLine(a[1] * Math.Pow(a[1] - 1, a[0] - 1));
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	while (1) {
		int cnt = 0;
		int n;
		cin >> n;
		if (n == 0000) {
			return 0;
		}
		bool b = true;
		if (n%1111==0) {
			cout << "NA" << endl;
			b = false;
		}
		while (b) {
			if (n == 6174) {
				break;
			}
			string s;
			s += n / 1000;
			n -= (n / 1000) * 1000;
			s += n / 100;
			n -= (n / 100) * 100;
			s += n / 10;
			s += n - 10 * (n / 10);
			sort(s.begin(), s.end());
			int L = 0, S = 0;
			L = (int)s[3] * 1000 + (int)s[2] * 100 + (int)s[1] * 10 + (int)s[0];
			S = (int)s[0] * 1000 + (int)s[1] * 100 + (int)s[2] * 10 + (int)s[3];
			n = L - S;
			cnt++;
		}
		if(b) cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3228
#include<iostream>
#include<vector>

#define REP(i,j,k) for( int i = j; i < k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;


int main(){
	
	int N,M,C,A[20][20],B[20];
	
	cin >> N >> M >> C;
	
	rep(j,M) cin >> B[j];
	rep(i,N) rep(j,M) cin >> A[i][j];
	
	int cnt = 0;
	
	rep(i,N){
		
		int tmp = C;
		rep(j,M) tmp += A[i][j] * B[j];
		if(tmp>0) cnt++;
		
	}
	
	cout << cnt << endl;
	
	return 0;
	
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a,b;
  	cin >> a >> b;
  	int cross = a * b;
  	if (cross % 2 == 1) {
      cout << "Odd" << endl;
    } else {
      cout << "Even" << endl;
    }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class UnionFind{
	vector<ll> rank;
	vector<ll> diff_weight;
	vector<ll> num;
public:
	vector<ll> par;

	UnionFind(ll N):par(N),num(N),rank(N),diff_weight(N){
		for(ll i=0;i<N;i++){
			par[i]=i;
			num[i]=1;
			rank[i]=0;
			diff_weight[i]=0;
		}
	}

	ll root(ll x){
		if(par[x]==x){
			return x;
		}
		ll r = root(par[x]);
		diff_weight[x]+=diff_weight[par[x]];
		return par[x]=r;
	}

	void unite(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		if (rx == ry) return;
		if(rank[rx]<rank[ry]) swap(rx,ry);
		if(rank[rx]==rank[ry]) ++rank[rx];
		par[ry] = rx;
		num[rx] += num[ry];
	}

	void relate(ll x,ll y,ll w){
		w+=weight(x),w-=weight(y);
		ll rx = root(x);
		ll ry = root(y);
		if (rx == ry) return;
		if(rank[rx]<rank[ry]){
			swap(rx,ry);
			w = -w;
		}
		if(rank[rx]==rank[ry]) ++rank[rx];
		par[ry] = rx;
		diff_weight[ry] = w;
		num[rx] += num[ry];
	}

	bool same(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		return rx == ry;
	}

	ll getsize(ll x){
		return num[root(x)];
	}

	ll weight(ll x){
		root(x);
		return diff_weight[x];
	}

	ll diff(ll x,ll y){
		return weight(y)-weight(x);
	}
};


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

	auto N=in(),Q=in();
	UnionFind uf(N);

	REP(i,Q){
		int q=in();
		int u=in(),v=in();
		if(q==1){
			if(uf.same(u,v)){
				out(uf.diff(u,v));
			}
			else{
				out('?');
			}
		}
		else{
			int w=in();
			uf.relate(u,v,w);
		}
	}
	
	return 0;
}



Measured memory_bytes: 5988
import math
A, B, H, M = list(map(int, input().split()))

a_angle = (H * 30 + M * 0.5) 
b_angle = 6*M


angle = abs(b_angle - a_angle)
if angle >= 180:
    angle = 360 - angle
    
cos_ab = math.cos(math.radians(angle))
print(math.sqrt(math.pow(A, 2) + math.pow(B, 2) - 2 * A * B * cos_ab))


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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

bool solve(int N,int M,vi& a, vi& b) {
    set<int> s1, sN;
    rep(i,M){
        int ai=a[i], bi=b[i];
        // if (ai>bi) swap(ai, bi);
        if (ai==1) s1.insert(bi);
        if (bi==N) sN.insert(ai);
    }
    vector<int> v(N);
    auto it = set_intersection(ALL(s1), ALL(sN), v.begin());
    return (it != v.begin());
}

int main() {
    int N, M; cin >> N >> M;
    vi a(M), b(M);
    rep(i,M) cin >> a[i] >> b[i];
    cout << (solve(N,M,a,b) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}



template< typename Monoid >
struct segTree {
  using F = function< Monoid(Monoid, Monoid) >;
 
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
 
  segTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }
 
  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  Monoid get(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

main(){
  int n;
  cin>>n;
  segTree<int>  seg(n,[](int a,int b) {
      return  __gcd(a,b); },0LL);

  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    seg.set(i,a[i]);
  }

  seg.build();
  int ans=0;
  rep(i,n){
    int l=seg.get(0,i);
    int r=seg.get(i+1,n);
    ans=max(ans,__gcd(l,r));
  }
  cout<<ans<<endl;

  
}




Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i, size_S, size_T, f = 1;
  string S, T;
  
  cin >> S;
  cin >> T;
  size_S = S.size();
  size_T = T.size();
  
  for(i=0; i < size_S; i++){
    if(S.at(i) != T.at(i)){
      f = 0;
      break;
    }
  }
  
  if(f == 0)	cout << "No" << endl;
  if(f == 1)	cout << "Yes" << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX
#define mod 1000000007
using namespace std;
int main(){
    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
n,m = map(int,input().split())

P = [0]*m
Y = [0]*m

city = [[] for _ in range(n)]

for i in range(m):
  P[i],Y[i] = map(int,input().split())
  city[P[i] - 1].append((Y[i],i))

for i in range(n):
  for j,(y,c) in enumerate(sorted(city[i])):
    Y[c] = j + 1

for p,y in zip(P,Y):
  print('{:0>6}'.format(p) + '{:0>6}'.format(y))


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


int main(){
	int n;
	cin >> n;
	vector<ll> a(n+1), b(n);
	rep(i,n+1) cin >> a[i];
	rep(i,n) cin >> b[i];
	ll count=0;
	rep(i,n){
		if(b[i] - a[i] >= 0){
			count += a[i];
			b[i] -= a[i];
		}else{
			count += b[i];
			b[i] = 0;
		}
		if(a[i+1]-b[i] >=0){
			count += b[i];
			a[i+1] -= b[i];
		}else{
			count += a[i+1];
			a[i+1] = 0;
		}
	}
	cout << count << endl;

	return 0;

}

Measured memory_bytes: 1792
N = int(input())
S = [input() for _ in range(2)]
mod = 10**9+7
is_2 = False
cnt = 1
li = []
for ind,i in enumerate(S[0]):
    if(is_2):
        is_2 = False
        continue
    if(ind==N-1):
        li.append(1)
        break
    if(S[0][ind+1]==i):
        li.append(2)
        is_2=True
    else:
        li.append(1)

for ind,i in enumerate(li):
    if(ind==0):
        if(i==1):
            cnt *= 3
        else:
            cnt *= 6
    else:
        if(li[ind-1]==1):
            cnt *= 2
        elif(li[ind-1]==i and i==2):
            cnt *= 3
    cnt%=mod
print(cnt)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int[][][] hito = new int[4][3][10];
        
        int n = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
        	int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();
            
            hito[b-1][f-1][r-1] += v;
            
            
        }
        
        for (int i = 0; i < 4; i++) {
            for (int j = 0 ; j < 3; j++) {
            	for (int k = 0 ; k < 10; k++) {
            		if (k != 9) {
                        System.out.printf(" %d", hito[i][j][k]);
                    }
                    else {
                        System.out.printf(" %d\n", hito[i][j][k]);
            	}
                }
            }
            if (i != 3) {
                System.out.println("####################");
            }
        }
    }
}


Measured memory_bytes: 30884
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  if((s[1] == s[2]) && (s[0] == s[1] || s[2] == s[3])) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define println(x) cout << x << endl
#define fi first
#define se second
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
const int di[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dj[8] = {0, 1, 0, -1, -1, 1, 1, -1};

using pii = pair<int, int>;

int h, w;

bool on_grid(int i, int j)
{
    if (i < 0 || i >= h) return false;
    if (j < 0 || j >= w) return false;
    return true;
}

bool is_road(int i, int j, vector<vector<char>>& grid)
{
    if (on_grid(i, j) == false) return false;
    if (grid[i][j] == '#') return false;
    return true;
}

int main()
{
    cin >> h >> w;
    vector<vector<char>> grid(h, vector<char>(w));
    vector<vector<int>> t(h, vector<int>(w, -1));
    queue<pii> q;
    rep(i, h)rep(j, w)
    {
        char ch; cin >> ch;
        if (ch == '#')
        {
            q.push(pii(i, j));
            t[i][j] = 0;
        }
        grid[i][j] = ch;
    }
    while (!q.empty())
    {
        pii p = q.front(); q.pop();
        rep(k, 4)
        {
            if (is_road(p.fi+di[k], p.se+dj[k], grid) && t[p.fi+di[k]][p.se+dj[k]] == -1)
            {
                q.push(pii(p.fi+di[k], p.se+dj[k]));
                t[p.fi+di[k]][p.se+dj[k]] = t[p.fi][p.se] + 1;
            }
        }
    }
    int max_manip = 0;
    rep(i, h)rep(j, w)
    {
        max_manip = max(max_manip, t[i][j]);
    }
    println(max_manip);
}

Measured memory_bytes: 13456
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n;
  cin >> n;
  int x[n], y[n];
  // taking in the numbers
  for(int i = 0; i < n; i++){
  	cin >> x[i] >> y[i];
  }
  // distance 
  double res = 0.0;
  for(int i = 0; i < n; i++){
  	for(int j= 0; j < i; j++)
      res += sqrt(pow((x[i]-x[j]),2)+ pow(y[i]-y[j], 2));
  }
  cout << setprecision(7) << res*2.0/n<<'\n';
  return 0;
}

Measured memory_bytes: 256