akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;
bool isEven(string);

int main()
{
	string s;
	cin >> s;
	if (s.size()%2==0)
	{
		s = s.substr(0, s.size() - 2);
	}
	else
	{
		s = s.substr(0, s.size() - 1);
	}
	while (!isEven(s))
	{
		s = s.substr(0, s.size() - 2);
	}
	int ans = s.size();
;	cout << ans << endl;
	return 0;
}

bool isEven(string s)
{
	bool even = false;
	string s1 = s.substr(0, s.size() / 2);
	string s2 = s.substr(s.size() / 2, s.size() / 2);
	if (s1==s2)
	{
		even = true;
	}
	return even;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 550;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
vector<int> s[20];
vector<int> tr[20];
bool isok(int num)
{
  int nnum = num;
  while(true)
  {
    rep(i, 0, 16)
    {
      if((num & (1 << i)) != 0)
      {
        for(int j: tr[i])
          num |= (1 << j);
      }
    }
    if(num == nnum) break;
    nnum = num;
  }
  rep(i, 0, 16)
  {
    if((num &(1 << i)) != 0)
    {
      for(int j: s[i])
      {
        if((num & (1 << j)) != 0) return false;
      }
    }
  }
  return true;
}
int main()
{
  int n;
  cin>>n;
  rep(i, 0, n)
  {
    int x;
    cin>>x;
    while(x--)
    {
      int a, b;
      cin>>a>>b;
      if(b == 0) s[i].pb(a-1);
      if(b == 1) tr[i].pb(a-1);
    }
  }

  int ans = 0;
  rep(i, 0, (1 << n))
  {
    int cnt = 0;
    int z = i;
    while(z != 0)
    {
      if(z&1 == 1) cnt++;
      z = z >> 1;
    }

    if(isok(i)) ans = max(ans, cnt);
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <vector>

using namespace std;

int main(void) {
	int i, j, a, b, c, d, e, f, aa, ab = 0, x = 0;
	cin >> a >> b >> c >> d >> e >> f;
	priority_queue<int, vector<int>, greater<int>> w, s;
	for (i = 0; i * 100 < f; i += a) {
		for (j = 0; (i + j) * 100 < f; j += b) {
			w.push(i + j);
		}
	}
	for (i = 0; i <= f; i += c) {
		for (j = 0; i + j <= f; j += d) {
			s.push(i + j);
		}
	}
	b = 0;
	aa = a * 100;
	w.pop();
	while (!w.empty()) {
		a = w.top();
		w.pop();
		while (b <= a * e && a * 100 + b <= f) {
			if (b * 100000 / (a + b) > x) {
				x = b * 100000 / (a + b);
				aa = a * 100 + b;
				ab = b;
			}
			b = s.top();
			s.pop();
		}
	}
	printf("%d %d\n", aa, ab);
	return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = Integer.parseInt(sc.next());
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());

    if(A >= B) System.out.println("delicious");
    else if(A + X + 1 <= B ) System.out.println("dangerous");
    else System.out.println("safe");

}
}


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

int main()
{
    string s;
    cin >> s;

    int len = s.size();
    int mid = len/2;

    int x = 0, y = len-1;

    while(x != y)
    {
        if(s[x] != s[y])
        {
            cout << "No" << endl;
            return 0;
        }
        x++;
        y--;
    }

    x = 0; y = mid - 1;

    while(x < y)
    {
        if(s[x] != s[y])
        {
            cout << "No" << endl;
            return 0;
        }
        x++;
        y--;
    }

    x = mid + 1; y = len-1;

    while(x < y)
    {
        if(s[x] != s[y])
        {
            cout << "No" << endl;
            return 0;
        }
        x++;
        y--;
    }

    cout << "Yes" << endl;

    return 0;
}


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

int main(){
  int n,d,a,ans=0;
  cin>>n>>d;
  for(int i=0;i<n;i++){
    cin>>a;
    ans+=max(0,a-d);
  }
  if(ans==0)cout<<"kusoge"<<endl;
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,n) for(int i=l; i<(int)(n); i++)
#define REP(i,n) FOR(i,0,n)

int main(){
  int n,cnt=0;
  string s;
  cin>>n>>s;
  REP(i,1000){
    int s0,s1,s2;
    s0=i/100,s1=(i%100)/10,s2=i%10;
    int f0=0,f1=0,f2=0;
    REP(j,n){
      if(s[j]-'0'==s2&&f0==1&&f1==1) f2=1;
      else if(s[j]-'0'==s1&&f0==1) f1=1;
      else if(s[j]-'0'==s0) f0=1;
    }
    if(f0*f1*f2==1) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;




int main(){
    string S;
    cin >> S;
    int N = S.size();
    int MOD = 1000000007;
    
    long long dp[100010][4] = {};
    
    dp[0][0] = 1LL;
    FOR(i,1,N+1){
        
        if (S[i-1] == '?'){
            dp[i][1] = dp[i-1][1]*3LL + dp[i-1][0];
            dp[i][2] = dp[i-1][2]*3LL+ dp[i-1][1];
            dp[i][3] = dp[i-1][3]*3LL+ dp[i-1][2];
            dp[i][0] = dp[i-1][0]*3LL;
        }
        if (S[i-1] == 'A'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1]+ dp[i-1][0];
            dp[i][2] = dp[i-1][2];
            dp[i][3] = dp[i-1][3];
        }
        if (S[i-1] == 'B'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1];
            dp[i][2] = dp[i-1][2]+ dp[i-1][1] ;
            dp[i][3] = dp[i-1][3];
        }
        if (S[i-1] == 'C'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1];
            dp[i][2] = dp[i-1][2];
            dp[i][3] = dp[i-1][3]+ dp[i-1][2];
        }
        rep(j,4) dp[i][j] %= MOD;
    }
    cout << dp[N][3]%MOD << endl;
    rn 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		while(true){
     		int H=scan.nextInt();
	    	int W=scan.nextInt();
		    if(H==0 && W==0)break;
			
			for(int i=0;i<H;i++){
				
				if(i==0 || i==H-1){
					for(int j=0;j<W;j++)System.out.print("#");
					System.out.println();
				}
				
				else {
					for(int j=0;j<W;j++){
						if(j==0 || j==W-1)System.out.print("#");
						else System.out.print(".");
					}
					System.out.println();
				}
				
			}
			System.out.println();
		}
	}
}


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

int main() {
	int a, b;
	string c;
	map<char, char> m;
	m['A'] = 'a';
	m['B'] = 'b';
	m['C'] = 'c';
	cin >> a >> b;
	cin >> c;
	c[b-1] = m[c[b-1]];
	cout << c;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict

(n, k), s = map(int, input().split()), list(map(int, input().split()))
x, c = [1, s[0]], 0
for i in range(n): x.append(s[x[-1] - 1])
if len(x) > k: print(x[k]); exit()
while x[c] != s[x[-1] - 1]: c += 1
print(x[((k - c) % (len(x) - c)) + c])

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

int main()
{
	std::complex<long double> xy[3];
	for (auto& e: xy)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		e.real(x);
		e.imag(y);
	}

	long double tan_inv[3];
	for (int i{}; i < 3; i++)
		tan_inv[i] = std::abs(1 / std::tan(std::arg((xy[(i + 1) % 3] - xy[i]) / (xy[(i + 2) % 3] - xy[i])) / 2));
	
	long double max{};
	for (int i{}; i < 3; i++)
		max = std::max(max, std::abs(xy[i] - xy[(i + 1) % 3]) / (2 + tan_inv[i] + tan_inv[(i + 1) % 3]));

	printf("%.10Lf", max);

	return 0;
}

Measured memory_bytes: 384
def yakusu(x):
    tmp=int(pow(x, 1/2))+1
    out=set()
    for i in range(1, tmp):
        if x%i==0:
            out.add(i)
            out.add(x//i)
    if pow(x, 1/2)%1==0:
        out.add(pow(x, 1/2))
    out=list(out)
    out.sort()
    return out

N=int(input())
A=list(map(int, input().split()))
A.sort()

pairwise=True
X=set()

for a in A:
  tmp=yakusu(a)
  for i in tmp[1:]:
    if i in X:
      pairwise=False
      break
    else:
      X.add(i)
  if pairwise==False:
    break
      
import math
tmp=A[0]+0
for a in A[1:]:
  tmp=math.gcd(tmp, a)
  
if tmp==1:
  setwise=True
else:
  setwise=False
  
if pairwise==True:
  print('pairwise coprime')
elif setwise==True:
  print('setwise coprime')
else:
  print('not coprime')

Measured memory_bytes: 205792
#include "bits/stdc++.h"
using namespace std;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int x,y;
    cin >> x >> y;
    if(x >= y){
        int t = x;
        x = y;
        y = t;
    }
    int d = y-x;
    x -= d;
    y -= 2*d;
    if(x >= 0 && x%3 == 0){
        int t = x/3;
        COMinit();
        cout << COM(2*t + d, t) << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 23680
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        String S = "";
        if(N == 0)  S = "0";
        while(Math.abs(N) > 0){
            if(N%2 == 0){
                S = "0"+S;
                N /= -2;
            }else{
                S = "1"+S;
                N = (N-1)/(-2);
            }
        }
        System.out.println(S);
    }
}

Measured memory_bytes: 26836
#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
bool f1[30], f2[30];
int main() {
	map<char, int>mp;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		mp[s[i]]++;
		if (mp[s[i]] > 1) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}


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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int main() {
	long long a, b, x;

	cin >> a >> b >> x;

	long long ans = b / x;
	if( a == 0 ) {
		ans++;
	}
	else if( a == x ) {
	}
	else if( a > x ) {
		ans -= (a - 1) / x;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
int main()
{
    int r=1,n,i,sum=0,ma=0,ans,x,a,b;
    scanf("%d %d",&a,&b);
    printf("%d\n",a*b);

}



Measured memory_bytes: 3788
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2, n):
    cost = []
    for j in range(1, k+1):
        if i-j < 0 : break
        cost.append(dp[i-j] + abs(h[i] - h[i-j]))
    dp[i] = min(cost)

print(dp[n-1])


Measured memory_bytes: 52448
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define MOD 1000000007
using namespace __gnu_pbds;
using namespace std;

int dp[2010][2010],sum[2010][2010];

inline void add(int &x,int y)
{
	x+=y;
	if(x>=MOD) x-=MOD;
}

signed main()
{
	ios::sync_with_stdio(false);
	int s;cin>>s;
	dp[0][0]=1;
	for(int j=0;j<=s;j++){
		if(j>0) sum[0][j]=sum[0][j-1];
		add(sum[0][j],dp[0][j]);
	}
	for(int i=1;i<=s;i++){
		for(int j=0;j<=s;j++){
			if(j>=3) add(dp[i][j],sum[i-1][j-3]);
		}
		for(int j=0;j<=s;j++){
			if(j>0) sum[i][j]=sum[i][j-1];
			add(sum[i][j],dp[i][j]);
		}
	}
	int ans=0;
	for(int i=0;i<=s;i++) add(ans,dp[i][s]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 34936
l=list(input())
if len(l)==2:
    if l[0]==l[1]:
        print('1 2')
    else:
        print('-1 -1')
    exit()
for i in range(len(l)-1):
    if l[i]==l[i+1]:
        print(*[i+1,i+2])
        exit()
for i in range(len(l)-2):
    if l[i]==l[i+2]:
        print(*[i+1,i+3])
        exit()
print('-1 -1')


Measured memory_bytes: 3956
#include <cstdio>

int main() {
	int X, Y, Z;
	scanf("%d %d %d", &X, &Y, &Z);
	int sum = 0;
	int end = Z;
	for (int i = 0; ; i++) {
		end += Y + Z;
		if (end > X)
			break;
		sum++;
	}
	printf("%d\n", sum);
}


Measured memory_bytes: 128
A=input()
B,C=int(A[0:2]),int(A[2:4])
if 1<=B<=12 and 1<=C<=12:
    print("AMBIGUOUS")
elif 1<=B<=12:
    print("MMYY")
elif 1<=C<=12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include<iostream>
#include<string.h>
using namespace std;
int main(void)
{   int n;
    cin>>n;
    int i;
    string v[n];
    double x[n],sum;
    sum=0;
    for(i=0;i<n;i++)
    {
        cin>>x[i]>>v[i];
        if(v[i]=="BTC")
        x[i]=x[i]*380000;
    }
    for(i=0;i<n;i++)
    {
        sum=sum+x[i];
    }
    cout<<sum<<endl;
    return 0;
    

}

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

#define M 1000000/* your task*/
#define L 14
#define true 1
#define false 0

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') {
      return 1;
  }
  else if ( ch == 'C') {
      return 2;
      }
  else if ( ch == 'G') {
      return 3;
  }
  else if ( ch == 'T') {
      return 4;
  }
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ 
    return (key%M);
     }
int h2(int key){
     return 1+(key%(M-1))/* your task */;
      }

int find(char str[]){

    /* your task */
long long k,i,h;
k=getKey(str);
    i=0;
while(1){
    h=(h1(k)+i*h2(k))%M;
    if(strcmp(H[h],str)==0){
        return true;
    }else if(strlen(H[h])==0){
        return false;
    }
    i++;
}
return false;
}

int insert(char str[]){

    /* your task */
    long long k,i,h;
    k=getKey(str);
        i=0;
while(1){
        h=(h1(k)+i*h2(k))%M;
        if(strcmp(H[h],str)==0){
            return true;
        }else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return false;
        }
        i++;
    }
return false;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 15456
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

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

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n);
	if (n == 3) {
		cout << "2 5 63" << endl;
		return 0;
	}
	if (n == 4) {
		cout << "2 5 20 63" << endl;
		return 0;
	}
	if (n == 5) {
		cout << "2 5 20 30 63" << endl;
		return 0;
	}
	ll sum = 0;
	int s2 = 0, s3 = 0, s4 = 0, s6 = 1;
	for (int i = 0; i < n; i++) {
		if (i % 4 == 0) {
			a[i] = 6 * s2 + 2;
			s2++;
		}
		if (i % 4 == 1) {
			a[i] = 6 * s3 + 3;
			s3++;
		}
		if (i % 4 == 2) {
			a[i] = 6 * s4 + 4;
			s4++;
		}
		if (i % 4 == 3) {
			a[i] = 6 * s6;
			s6++;
		}
		sum += a[i];
	}
	if (sum % 6 == 2) {
		a[4] = s6 * 6;
	}
	if (sum % 6 == 3) {
		a[5] = s6 * 6;
	}
	if (sum % 6 == 5) {
		a[5] = s4 * 6 + 4;
	}
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << a[i];
	}
	cout << endl;

}

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

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

int N,M;
int a[110];
bool ok[100010];

int main(void) {
	cin >> N >> M;
	REP(i,N) cin >> a[i];
	sort(a,a+N);
	REP(i,100010){
		if(ok[i] == true) continue;
		REP(j,N) {
			if(a[j]+i > M) continue;
			ok[a[j]+i] = true;
		}
	}
	if(ok[M] == true) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        int count = 1;

        while (true)
        {
            int num = int.Parse(Console.ReadLine());

            if (num == 0)
            {
                break;
            }

            Console.WriteLine("Case {0}: {1}", count, num);

            count++;

        }

    }
}

Measured memory_bytes: 9452
#include <stdio.h>
#define N 1000000
int A[N];
int Partition(int p, int r){
  int x, i, j, tmp;
  x = A[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
} }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}
 int main(){
  int n, i, x;
  scanf("%d", &n);
  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);
  }
  x = Partition(1, n);
 for(i = 1; i <= n; i++){
  if(i == x){
    printf("[%d]",A[i]);
} else {
    printf("%d",A[i]);
  }
if(i < n) {
    printf(" ");
  }
 }
  printf("\n");
  return 0;
}


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

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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) cin >> P.at(i);

  int min = P.at(0);
  int ans = 0;

  for(int i=0; i<N; i++){
    if(P.at(i)<=min){
      min = P.at(i);
      ans++;
    }
  }
  cout << ans;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Vertex
{
    vector<ll> node;
};

Vertex V[200005];
bool U[200005];

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, M)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.push_back(b);
        V[b].node.push_back(a);
    }

    memset(U, 0, sizeof(U));
    REP(i, V[0].node.size())
    {
        U[V[0].node[i]] = true;
    }

    REP(i, V[N - 1].node.size())
    {
        if (U[V[N - 1].node[i]])
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

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

    if (a == b) {
        cout << c << endl;
    }
    if (a == c) {
        cout << b << endl;
    }
    if (b == c)
    {
        cout << a << endl;
        }
}

Measured memory_bytes: 256
#ifndef DEBUG
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,popcnt,tune=native")
#endif // DEBUG
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <stack>
using namespace std;
typedef long long ll;
inline ll read()
{
    int ch=getchar(),f=1;
    ll ans=0;
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=0;
    for(;ch>='0'&&ch<='9';ch=getchar())
        ans=(((ans<<2)+ans)<<1)+(ch^'0');
    return f?ans:-ans;
}
int main()
{
    int a=read();
    char s[100];
    if(a<3200)
    {
        puts("red");
    }
    else
    {
        scanf("%s",s);
        printf("%s",s);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]
for i in range(10**N):
    stop = True
    for t in sc:
        if i//(10**(N-t[0]))%10 != t[1]:
            stop = False
    if stop:
        if i//(10**(N-1)) > 0 or (N==1 and i==0):
            print(i)
            break
        else:
            stop = True
if not stop:
    print(-1)


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

using namespace std;

const int MAX_N = 105, MAX_K = 1e5 + 5, MOD = 1e9 + 7;

inline int add (int a, int b) { return (1LL * a + b) % MOD; }

struct BIT {
  vector <int> ft;
  int n;
  BIT (int n): n(n + 10) {
    ft.resize(n + 10, 0);
  }
  void update (int pos, int var) {
    pos++;
    while (pos < n) {
      ft[pos] = add(ft[pos], var);
      pos += pos & -pos;
    }
  }
  int get (int pos) {
    pos++;
    int ret = 0;
    while (pos) {
      ret = add(ret, ft[pos]);
      pos -= pos & -pos;
    }
    return ret;
  }
};

int main () {
  int n, k;
  cin >> n >> k;
  vector <int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  BIT dp(k);
  dp.update(0, 1);
  dp.update(1, MOD - 1);
  for (int i = 1; i <= n; i++) {
    for (int c = k; c >= 0; c--) {
      int from = c + 1, to = c + min(a[i], k - c);
      if (from > to) continue;
      int val = dp.get(c);
      dp.update(from, val);
      dp.update(to + 1, MOD - val);
    }
  }
  cout << dp.get(k) << endl;
  return (0);
}


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

using ll=long long;
int main()
{
  int n;
  ll k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  
  vector<int> root(n,0);
  int n_start=1;
  ll n_behind=0;
  while(root[n_start-1]==0)
  {
    root[n_start-1]++;
    n_start=a[n_start-1];
    n_behind++;
  }
  
  //cout<<n_start<<endl;
  //cout<<n_behind<<endl;
  
  ll n_loop=0;
  vector<int> loop;
  int m=n_start;
  do
  {
    loop.push_back(m);
    m=a[m-1];
    n_loop++;
  }while(m!=n_start);
  
  //cout<<n_loop<<endl;
  
  if(k<n_behind)
  {
    int result=1;
    for(int i=0;i<k;i++)
    {
      result=a[result-1];
      if(i==k-1)
      {
        cout<<result<<endl;
        return 0;
      }
    }
  }
  else
  {
    k-=n_behind;
    cout<<loop[k%n_loop]<<endl;
  }
}
  

Measured memory_bytes: 5876
#include <iostream>
#include "math.h"

using namespace std;

//const int max_n = 10;

int n;
int l;

int main() {
    
    cin >> n;
    
    int m = 0;
    int s = 0;
    
    for (int i=0; i<n; i++) {
        cin >> l;
        m = max(l, m);
        s = s + l;
    }
    
    s = s - m;
    
    if (m < s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
    
}

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

typedef long long LL;

int n;
LL cw;

LL w[105];
int v[105];

LL memo[105][100005];

LL dp(int id, int val){
	if(id>n){
		if(val == 0) return 0LL;
		else return 1e12;
	}
	LL &ret = memo[id][val];
	if(ret!=-1) return ret;
	ret = dp(id+1,val);
	if(val>=v[id]) ret = min(ret,dp(id+1,val-v[id]) + w[id]);
	return ret;
}

int main(){
	memset(memo,-1,sizeof(memo));
	scanf("%d%lld",&n,&cw);
	for(int i=1;i<=n;i++) scanf("%lld%d",&w[i],&v[i]);
	LL ans = 0;
	for(int i=100000;i>=1;i--) if(dp(1,i) <= cw){ans = i; break;}
	printf("%lld\n",ans); 
	return 0;
}

Measured memory_bytes: 82304
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
Alice = 0
Bob = 0
for i in range((n - 1) // 2 + 1):
    Alice = Alice + a[2 * i]
for i in range(n // 2):
    Bob = Bob + a[2 * i + 1]
gap = Alice - Bob
print(gap)

Measured memory_bytes: 3064
#line 2 "/home/toof/working/library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 3 "/home/toof/working/library/union_find.hpp"

struct UnionFind {
  struct Node {
    ll parent;
    ll size;
  };
  vector<Node> data;
  ll num;

  UnionFind(ll size) : data(size) {
    rep(i, size) {
      data[i].parent = i;
      data[i].size = 1;
    }
    num = size;
  }

  ll find(ll x) {
    while (data[x].parent != x) {
      ll p = data[x].parent;
      data[x].parent = data[p].parent;
      x = p;
    }
    return x;
  }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (data[x].size < data[y].size) swap(x, y);
    data[y].parent = x;
    data[x].size += data[y].size;
    num--;
  }

  bool same(ll x, ll y) {
    return find(x) == find(y);
  }

  ll count() const {
    return num;
  }
};
#line 3 "c.cpp"

int main() {
  ll n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    uf.unite(a-1, b-1);
  }

  cout << uf.count()-1 << el;
}


Measured memory_bytes: 4748
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	string S;
	int n;
	cin>>S;
	cin>>n;
	string command;
	string ans[n];
	int index=0;
	int begin,end;
	for(int i=0;i<n;++i){
		cin>>command;
		if(command=="print"){
			cin>>begin>>end;
			ans[index]=S.substr(begin,end-begin+1);
			index++;
		}
		else if(command=="reverse"){
			cin>>begin>>end;
			reverse(S.begin()+begin,S.begin()+end+1);
		}
		else{
			cin>>begin>>end;
			string SS;
			cin>>SS;
			for(int j=begin;j<=end;++j){
				S[j]=SS[j-begin];
			}
		}
	}
	for(int i=0;i<index;++i)cout<<ans[i]<<endl;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007
#define sz 100005
using namespace std;


ll dp[sz][2];
vector <ll> ve[sz];
void dfs(ll s, ll p)
{
  dp[s][1] = 1;
  dp[s][0] = 1;
  for(auto it:ve[s])
  {
    if(it == p)continue;
    dfs(it,s);
    dp[s][1] = (dp[s][1]*((dp[it][1] + dp[it][0])%mod))%mod;
    dp[s][0] = (dp[s][0]*(dp[it][1]))%mod;
  }
  return;
}
int main()
{


    FASTIO
    cin.tie(NULL);
    ll n;
    cin >> n;
    for(ll i=1;i<=n-1;i++)
    {
      ll u,v;
      cin >> u >> v;
      ve[u].pb(v);
      ve[v].pb(u);
    }
    ll ans = 0;
    dfs(1,-1);
    ans = (ans + dp[1][0])%mod;
    ans = (ans + dp[1][1])%mod;
    cout<<ans<<endl;




return 0;
}


Measured memory_bytes: 14208
n = int(input())
s = input()

strlist = "abcdefghijklmnopqrstuvwxyz".upper()
charnum = len(strlist)

ans = ""
for i in s:
    num = strlist.index(i)
    indx = (num + n) % charnum
    anschar = strlist[indx]
    ans = ans+anschar

print(ans)


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

int main() {
  int n, sum = 0;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) {
    cin >> vec.at(i);
  }
  for(int i = 0; i < n - 1; i++) {
    for(int j = i + 1; j < n; j++) {
      sum += vec.at(i) * vec.at(j);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3624
def digitSum(n):
    s = str(n)
    array = list(map(int, s))
    return sum(array)

n, a, b = map(int,input().split())
array = []
for i in range(n+1):
    c = digitSum(i)
    if c >= a and c <= b:
        array.append(i)
print(sum(array))

Measured memory_bytes: 3424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end(),greater<int>());
  int c=0;
  vector<ll> b={};
  for(int i=0;i<n-1;){
    if(a[i]==a[i+1]){
      b.push_back(a[i]);
      i+=2;
    }
    if(a[i]!=a[i+1]) i++;
    if(b.size()==2) break;
  }
  if(b.size()<=1) cout<<0<<endl;
  else cout<<b[0]*b[1]<<endl;
}
    

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N;
vector<int> A;
vector<int> ans;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N;
  A.resize(N);
  rep(i, N) cin >> A[i];
  rep(i, N) ans.push_back(i+1);

  map<vector<int>, int> rd;
  rd[ans] = 0;
  queue< vector<int> > que;
  que.push(ans);
  while(!que.empty()) {
    auto v = que.front(); que.pop();
    int tmp = rd[v];
    if(tmp >= (N-1)/2) break;
    rep(l, N-1) reps(r, l+2, N+1) {
      auto w = v;
      reverse(w.begin()+l, w.begin()+r);
      if(!rd.count(w)) {
	rd[w] = tmp + 1;
	que.push(w);
      }
    }
  }

  if(rd.count(A)) {
    cout << rd[A] << endl;
    return 0;
  }

  map<vector<int>, int> d;
  d[A] = 0;
  while(!que.empty()) que.pop();
  que.push(A);
  while(!que.empty()) {
    auto v = que.front(); que.pop();
    int tmp = d[v];
    if(tmp >= (N-1)/2) break;
    rep(l, N-1) reps(r, l+2, N+1) {
      auto w = v;
      reverse(w.begin()+l, w.begin()+r);
      if(rd.count(w)) {
	cout << rd[w] + tmp + 1 << endl;
	return 0;
      } else if(!d.count(w)) {
	d[w] = tmp + 1;
	que.push(w);
      }
    }
  }

  cout << N-1 << endl;

  return 0;
}

Measured memory_bytes: 118352
def satisfy(x,conds,n):
    x = list(str(x))
    if len(x) != n:
        return False

    for i in conds:
        s,c = i[0],i[1]
        if int(x[s]) != c:
            return False

    return True

def main():
    n,m = map(int,input().split())
    conds = []
    for i in range(m):
        s,c = map(int,input().split())
        conds.append((s-1,c))
    
    for i in range(1000):
        if satisfy(i,conds,n):
            print(i)
            return

    print(-1)

main()


Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k = map(int,input().split())
r,s,p = map(int,input().split())
point_dict = {"r":p,"s":r, "p":s}
t = input()
# ゲームの問題
# ジャンケンをNかいする
# Kかい前の手と同じ手を出すことはできない
# 事前に相手が出す手がわかっている時の得点の最大化
# for i in range(k): に対してi+k*j 番目での手を前からgreedyにう考える
# bit を立ててk個前と同じ手だった時に勝てる手を出していいかを管理
ans = 0
for i in range(k):
    bit = 1 # 勝てる手を出していい
    j =0
    ans += point_dict[t[i+k*j]]
    j += 1
    while i+k*j <= n-1:
        if t[i+k*j] != t[i+k*j-k]:
            ans += point_dict[t[i+k*j]]
            bit = 1
        elif (t[i+k*j] == t[i+k*j-k] and bit == 0):
            ans += point_dict[t[i+k*j]]
            #print(t[i+k*j])
            bit = 1
        else:
            bit = 0
        j += 1
        #print(ans,i,j)
print(ans)

Measured memory_bytes: 40688
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int a,x;
	cin>>a;
	set <int> n;
	for(int i=0;i<a;i++)
	{
		cin>>x;
		n.insert(x);
	}
	if(n.size()==a) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        long ratio = 100000/1000;
        int n = new Scanner(System.in).nextInt();
        for(int i=0;i<n;i++){
            ratio = (long) Math.ceil(ratio*1.05);
        }
        System.out.println("" + (ratio*1000));
    }
}

Measured memory_bytes: 17164
#BFSだとかえって考えにくい
#それぞれの頂点に対して塗られてない色で塗り分け
n=int(input())
paths=[[] for i in range(n)]
colors=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    paths[a-1].append(i)
    paths[b-1].append(i)
m=0
for i in range(n):
    m=max(m,len(paths[i]))
print(m)
#print(paths)
for i in range(n):
    cand1,cand2=set(),[]
    #print(paths[i])
    for j in paths[i]:
        if colors[j]!=0:
            cand1.add(colors[j])
        else:
            cand2.append(j)
    now=1
    for j in cand2:
        while now in cand1:
            now+=1
        colors[j]=now
        now+=1
for i in range(n-1):
    print(colors[i])

Measured memory_bytes: 23724
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
 
 
class Main
{
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        
        if(a <= 8){
            if(b <= 8){
                System.out.println("Yay!");
            }else{
                System.out.println(":(");
            }
        }else{
            System.out.println(":(");
        }
        scanner.close();
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define F first
#define S second
#define mt make_tuple
#define pb push_back


int readint(){
	char c;
	int a = 0;
	while(!( c >= '0' && c <= '9')) c = getchar();
	while(c >= '0' && c <= '9') a = 10*a + (c - '0') , c = getchar();
	return a;
}



int32_t main(){
	int n , x;
	cin>>n>>x;
	vector<int>v(n);
	for(int i = 0 ; i < n; i ++) cin>>v[i];
	sort(v.begin() , v.end());
	int ans = 0;
	for(int i = 0 ; i < n;i ++){
		int r = min(x , v[i]);
		if(r == v[i]) ans++;
		x -= r;
	}
	if(x > 0) ans--;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (u == s) cout << a -1 << " " << b << endl;
  if (u == t) cout << a << " " << b -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back
 
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)
int main(){
	string str;
	cin>>str;
	ll lf=-1,r=-1,mx=0;
	map<char,ll>mp,fst;
	fr(i,0,str.size()){
		// if(!mp.count(str[i])){
		// 	mp[str[i]]=1;
		// 	fst[str[i]]=i;
		// }
		// else{
		// 	mp[str[i]]++;
		// 	if(i-fst[str[i]]>1){
		// 		if(mp[str[i]]>((i-fst[str[i]]+1)/2)&&i-fst[str[i]]>mx){
		// 			lf=fst[str[i]]+1;
		// 			r=i+1;
		// 			mx=i-fst[str[i]];
		// 		}
		// 	}
		// }
		if(str[i]==str[i+1]){
			lf=i+1;
			r=i+2;
		}
		if(str[i]==str[i+2]){
			lf=i+1;
			r=i+3;
		}
	}
	//for(auto)
	wl2(lf,r);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    ll k, a, b;
    cin >> k >> a >> b;
    if (k < a + 1 || b - a < 3) {
        cout << k + 1 << "\n";
        return 0;
    }
    else if ((k - a + 1) % 2 == 0){
        cout << a + (b - a) * (k - a + 1) / 2 << "\n";
        return 0;
    }
    else {
        cout << a + (b - a) * ((k - a + 1) / 2) + 1 << "\n";
        return 0;
    }
}

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

int main(){
  int A,B,C,D;
  scanf("%d%d%d%d",&A,&B,&C,&D);
  if ((A+B)>(C+D)) { printf("Left\n"); }
  else if ((A+B)<(C+D)) { printf("Right\n"); }
  else { printf("Balanced\n"); }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

// 魚の生息範囲


int x[100];
int y[100];
int z[100];
int x1[50];
int x2[50];
int y_1[50];
int y2[50];
int z1[50];
int z2[50];
int table[100][100][100];
signed main(){
  int a,b;
  cin>>a>>b;
  for(int i=0;i<a;i++){
    cin>>x1[i]>>y_1[i]>>z1[i]>>x2[i]>>y2[i]>>z2[i];
    x[i*2]=x1[i];x[i*2+1]=x2[i];
    y[i*2]=y_1[i];y[i*2+1]=y2[i];
    z[i*2]=z1[i];z[i*2+1]=z2[i];
  }
  sort(x,x+a*2);
  sort(y,y+a*2);
  sort(z,z+a*2);
  for(int i=0;i<a;i++){
    int X1=lower_bound(x,x+a*2,x1[i])-x;
    int Y1=lower_bound(y,y+a*2,y_1[i])-y;
    int Z1=lower_bound(z,z+a*2,z1[i])-z;
    int X2=lower_bound(x,x+a*2,x2[i])-x;
    int Y2=lower_bound(y,y+a*2,y2[i])-y;
    int Z2=lower_bound(z,z+a*2,z2[i])-z;
    
    for(int i=X1; i<X2; i++){
      for(int j=Y1; j<Y2; j++)
        for(int k=Z1; k<Z2; k++){
          table[i][j][k]++;
        }
    }
  }
  
  int ret=0;
  for(int i=0; i<a*2; i++){
    for(int j=0; j<a*2; j++){
      for(int k=0; k<a*2; k++){
        if(table[i][j][k]>=b) ret+=(x[i+1]-x[i])*(y[j+1]-y[j])*(z[k+1]-z[k]);
      }
    }
  }
  
  
  cout<<ret<<en;
}




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

string b[11];
int solve(int i, int j){
    if(b[i][j+1]=='1'&&b[i+1][j]=='1'&&b[i+1][j+1]=='1') cout << 'A';
    else if(b[i+1][j]=='1'&&b[i+2][j]=='1'&&b[i+3][j]=='1') cout << 'B';
    else if(b[i][j+1]=='1'&&b[i][j+2]=='1'&&b[i][j+3]=='1') cout << 'C';
    else if(b[i][j+1]=='1'&&b[i+1][j+1]=='1'&&b[i+1][j+2]=='1') cout << 'E';
    else if(b[i+1][j]=='1'&&b[i+1][j+1]=='1'&&b[i+2][j+1]=='1') cout << 'F';
    else if(b[i+1][j-1]=='1'&&b[i+1][j]=='1'&&b[i+2][j-1]=='1') cout << 'D';
    else cout << 'G';
}
    
int main(){
    int i, j;
    char c;
    while(cin >> b[0]){
        b[0] += "000";
        for(int i=1;i<8;i++){
            cin >> b[i];
            b[i] += "000";
        }
        for(int i=8;i<11;i++){
            b[i] = "00000000000";
        }
        for(int i=0;i<64;i++){
            if(b[i/8][i%8] == '1'){
                solve(i/8, i%8);
                cout << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1180
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        
        
        
        
        
        
        public static void main(String[]args){
                String S=sc.next();
                long K=sc.nextLong();
                int ichi=0;
                for(int i=0;i<S.length();i++){
                        if(S.charAt(i)=='1'){
                                ichi++;
                        }else{
                                break;
                        }
                }
                if((ichi>=K)){
                        System.out.println(1);
                }else{
                        System.out.println(S.charAt((int)ichi));
                }
                
                
                


                
        }
        
        
        

		
	
}


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

int main() {
    int n;
    auto ret = 0ll;
    std::cin >> n;
    std::vector<std::vector<long long>> a(n, std::vector<long long>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            std::cin >> a[i][j];
        }
    }
    auto cost(a);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                cost[j][k] = std::min(cost[j][k], cost[j][i] + cost[i][k]);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (cost[i][j] < a[i][j]) {
                std::cout << -1 << std::endl;
                return 0;
            }
            ret += a[i][j];
            for (int k = 0; k < n; k++) {
                if (k == i || k == j) continue;
                if (cost[i][j] == cost[i][k] + cost[k][j]) {
                    ret -= a[i][j];
                    break;
                }
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
}

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


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

int main(){
	int k;
	double x1,x2,x3,x4,y1,y2,y3,y4;
	scanf("%d",&k);
	while(k--){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if(fabs((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1))<1e-10) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 620
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    REP(i, n){
        int x;
        cin >> x;
        ans += min(x * 2, (k - x) * 2);
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    ll dp[n],a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	bool flag = true;
	int low = 1e8, up = 0;
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		mp[a[i]]++;
		low = min(low, a[i]);
		up = max(up, a[i]);
	}

	if (mp[low] + mp[up] < N || up - low>=2)cout << "No" << endl;
	else if (mp[low] == N) {
		//cout<<"mp[low]==N" << endl;
		if (a[0] == N - 1)cout << "Yes" << endl;
		else if (N >= 2 * a[0])cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	else {
		if (N - mp[low] >= 2 * (up - mp[low]) && mp[low] < up)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
}


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

void reverseStr(string &str){
  int n=str.length();
  for (int i=0;i< n/2;i++){
    swap(str[i], str[n-i-1]);
  }
}
int main(){
    string str;
    getline(cin, str);
    reverseStr(str);
    cout << str << endl;
    return 0;
}


Measured memory_bytes: 2996
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[100];

int main()
{
    a[0]=2,a[1]=1;
    for(int i=2;i<=86;i++)
        a[i]=a[i-1]+a[i-2];
    int n;
    while(cin>>n){
        cout<<a[n]<<endl;
    }
    return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> w(n,0),b(n,0);
    int now = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '#') now++;
        b[i] = now;
    }
    now = 0;
    for(int i = n-1; i >= 0; i--){
        if(s[i] == '.') now++;
        w[i] = now;
    }
    int ans = mod;
    for(int i = 0; i < n; i++){
        //cout << w[i]+b[i] << endl;
        ans = min(ans,w[i]+b[i]);
    }
    cout << ans-1 << endl;

    return 0;
}

Measured memory_bytes: 5228
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int[] h = new int[n];
    for(int i=0;i<n;i++){
      h[i]=sc.nextInt();
    }
    int[] dp = new int[n];
    dp[0]=0;
    dp[1]=Math.abs(h[0]-h[1]);
    
    for(int i=2;i<n;i++){
      dp[i]=Math.min(dp[i-2]+Math.abs(h[i]-h[i-2]),dp[i-1]+Math.abs(h[i]-h[i-1]));
    }
    
    System.out.println(dp[n-1]);
  }
}

Measured memory_bytes: 50616
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        PrintWriter out = new PrintWriter(System.out);

        for (int i = 1; i <= B; i++) {
            if (A * i % B == C) {
                out.println("YES");
                sc.close();
                out.flush();
                return;
            }
        }

        out.println("NO");
        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 35692