akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N;

vector<int> prime;
vector<bool> isPrime;

void sieve(int n) {
  isPrime.resize(n+1, true);
  isPrime[0] = isPrime[1] = false;
  for(int i = 2; i <= n; i++) {
    if(isPrime[i]) {
      prime.push_back(i);
      for(int j = 2*i; j <= n; j += i) isPrime[j] = false;
    }
  }
}

int main () {
  cin >> N;

  sieve(55555);

  for(int i = 0, j = 0; i < N; i++, j++) {
    while(prime[j] % 5 != 1) j++;
    cout << (i == 0 ? "" : " ") << prime[j];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    readln;
    auto xs = readints();

    int[int] m;
    long[] cans;
    foreach (x; xs) {
        int t = ++m[x];
        if (t == 2 || t == 4)
            cans ~= x;
    }

    if (cans.length >= 2) {
        partialSort!"a > b"(cans, 2);
        writeln(cans[0] * cans[1]);
    }
    else {
        writeln(0);
    }
}


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

int main() 
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> v(m);
    for (int i=0; i<m; i++)
        cin >> v[i];
    int res = 0;
    for (int i=0; i<n; i++)
    {
        int sum = 0;
        for (int j=0; j<m; j++)
        {
            int a; cin >> a;
            sum += a*v[j];
        }
        if (sum + c > 0)
            res++;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int M, K;
int main(){
    cin >> M >> K;
    int max = (1 << M) - 1;
    if(M == 1){
        if(K >= 1) cout << -1 << endl;
        else cout << "0 0 1 1" << endl;
        return 0;
    }
    if( (1 << M) - 1 < K) {
        cout << -1 << endl;
        return 0;
    }
    cout << K <<" ";
    for(int i = 0; i <= max; i++){
        if(i != K) cout << i << " ";
    }
    cout << K << " ";
    for(int i = max; i >= 0; i--){
        if(i != K) {
            cout << i;
            if(i == 0) cout << endl;
            else cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  int a,b,i,j;
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0&&b==0)return(0);
    for(i=0;i<a;i++){
      for(j=0;j<b;j++){
	if(i==0||i==a-1){
	  printf("#");
	}
	else{
	  if(j==0||j==b-1){
	    printf("#");
	  }
	  else{
	    printf(".");
	  }
	}
      }
      printf("\n");  
    }
    printf("\n");
  }
  return(0);
}

Measured memory_bytes: 1720
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    string s;
    int value[4];
    int symbol[4];
    int sign[2]={1,-1};
    cin>>s;
    for(int i=0;i<4;i++){
        value[i]=s[i]-'0';
    }
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                if(value[0]+value[1]*sign[i]+value[2]*sign[j]+value[3]*sign[k]==7){
                    symbol[0]=i;
                    symbol[1]=j;
                    symbol[2]=k;
                }
            }
        }
    }
    for(int i=0;i<4;i++){
        cout<<value[i];
        if(i<3){
            if(symbol[i]==0){
                cout<<'+';
            }else{
                cout<<'-';
            }
        }
    }

    cout<<"=7\n";




    return 0;
}


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

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

    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "Yes";
    }
    else if (s[1] == s[2] && s[2] == s[3]) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = gets.chomp.split("")

r=0; g=0; b=0;
s.each do |val|
  case val
    when "R"
    r+=1
    when "G"
    g+=1
    when "B"
    b+=1
  end
end

sum = r*g*b
sub = 0
int = 1

check_size = 3+2*(int-1)
while check_size <= n
  0.upto(n-check_size) do |i|
    if s[i] == s[i+1*int] or s[i] == s[i+2*int] or s[i+1*int] == s[i+2*int]
      next
    else
      sub+=1
    end
  end
  int+=1
  check_size = 3+2*(int-1)
end
result = sum-sub
puts result

Measured memory_bytes: 14356
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
const int modo=998244353;
map<string,int> ma;
void ands(string &a,const string &b)
{
    int i;
    for (i=0;i<(int)a.length();i++)
    {
        if (a[i]=='0') continue;
        if (b[i]=='0') a[i]='0';
    }
}
int dp(string x)
{
    if (ma.find(x)!=ma.end()) return ma[x];
    if (x=="")
    {
        ma[x]=1;
        return 1;
    }
    int ans=0;
    string t=x.substr(0,x.length()-1);
    ans+=dp(t);
    if (x[x.length()-1]=='1')
    {
        ans+=dp(t);
        if (ans>=modo) ans-=modo;
    }
    int i,j;
    for (i=1;i<=(int)x.length()/2;i++)
    {
        string now=x.substr(x.length()-i,i);
        for (j=2;i*j<=(int)x.length();j++)
        {
            ands(now,x.substr(x.length()-i*j,i));
            ans+=(long long)dp(now)*dp(x.substr(0,x.length()-i*j))%modo;
            if (ans>=modo) ans-=modo;
        }
    }
    ma[x]=ans;
    return ans;
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    string a;
    cin>>a;
    printf("%d\n",dp(a));
    return 0;
} 


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

void main_()
{
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> Xs;
    Xs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Xs));

    ll ans = 0;
    for (ll i = 0; i < N - 1; i++) {
        ans += min((Xs[i + 1] - Xs[i]) * A, B);
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::*;
use std::collections::*;
use std::ops::*;
use procon::*;

pub fn main() -> () {
    let _ = read_line();
    println!(
        "{}",
        if read_line().contains('Y') {
            "Four"
        } else {
            "Three"
        }
    );
    return;
}

pub mod procon {
    use std;
    use std::io;
    use std::str::FromStr;

    pub fn read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim_right().to_owned()
    }

    pub fn read_words<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace()
            .map(|word| T::from_str(word).unwrap())
            .collect()
    }

    pub fn read_vec<T>(len: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut vec = Vec::new();
        while vec.len() < len {
            let words = read_words();
            for word in words {
                vec.push(word);
            }
        }
        vec
    }

    pub fn make_vec<T, F>(len: usize, f: F) -> Vec<T>
    where
        F: Fn(usize) -> T,
    {
        return (0..len).into_iter().map(f).collect();
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.Math;
class Program
{
    public static void Main(string[] args)
    {
        Console.ReadLine();
        var v = Console
            .ReadLine()
            .Split(' ')
            .Select(x => int.Parse(x))
            .ToArray();
        var count = 1;
        var hMax = v[0];
        foreach (var h in v.Skip(1))
        {
            if (h >= hMax)
            {
                hMax = h;
                count++;
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define lf double
#define gc getchar()
#define mp make_pair
#define ri register int
#define rc register char
#define rb register bool
#define lowbit(x) (x&(-x))
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)

int n,len,as;

il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}

int main()
{
	//freopen("B.in","r",stdin);freopen("B.out","w",stdout);
	n=read();len=read();rp(i,1,n)if(read()>=len)++as;printf("%d\n",as);
    return 0;
}


Measured memory_bytes: 256
import static java.lang.System.out;
 public class Main {
     public static void main(String[] args){
         String str = new java.util.Scanner(System.in).nextLine();
         String[] tmp = str.split(" ");
         int a = Integer.parseInt(tmp[0]);
         int b = Integer.parseInt(tmp[1]);
         int c = Integer.parseInt(tmp[2]);
         int tmprun;
 
         for(int i = 0;i <= 2;i++){
             if(c < b){
                 tmprun = c;
                 c = b;
                 b = tmprun;
             }
             if(b < a){
                 tmprun = b;
                 b = a;
                 a = tmprun;
             }
         }
         out.print(a + " ");
         out.print(b + " ");                                                                                                                
         out.println(c);
     }
 }

Measured memory_bytes: 26244
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int num = Integer.parseInt(s);
		int sum = 0;
		for (char c : s.toCharArray()) {
			sum  += c - '0';
		}
		System.out.println(num % sum == 0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 23252
import sys
h, w = (int(i) for i in input().split()) 
arr = [['.' for i in range(w)] for j in range(h)]
for j in range(h):
  k = 0
  for char in input():
    arr[j][k] = char
    k += 1
for H in range(h):
  for W in range(w):
    if arr[H][W] =="#":
      if (H+1 <= h-1 and arr[H+1][W] == ".") and (H-1 >= 0 and arr[H-1][W] == ".") and (W+1 <= w-1 and arr[H][W+1] == ".") and (W-1 >= 0 and arr[H][W-1] == "."):
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int A, B, C;
  int count;
  scanf("%d %d %d",&A,&B,&C);
  
  if(A * C <= B){
    count = C;
  }else{
    count = B / A;
  }

  printf("%d",count);

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int TATE = Integer.parseInt(sc.next());
		int YOKO = Integer.parseInt(sc.next());

		String[] s = new String[TATE];
		for (int tate = 0; tate < TATE; tate++) {
			s[tate] = sc.next();
		}

		sc.close();

		int[][] res = new int[TATE][YOKO];

		for (int tate = 0; tate < TATE; tate++) {
			boolean lastTile = false; //壁はfalse
			int begin = 0;
			for (int yoko = 0; yoko < YOKO; yoko++) {
				if (s[tate].charAt(yoko) == '#') {
					if(lastTile) {
						for (int i = begin; i <= yoko - 1; i++) {
							res[tate][i] += yoko - begin;
						}
					}
					lastTile = false;
				} else {
					if (!lastTile) {
						begin = yoko;
					}
					lastTile = true;
				}
			}
			//右端
			if (lastTile) {
				for (int i = begin; i <= YOKO - 1; i++) {
					res[tate][i] += YOKO - begin;
				}
			}
		}

//		for (int tate = 0; tate < TATE; tate++) {
//			for (int yoko = 0; yoko < YOKO; yoko++) {
//				System.out.print(res[tate][yoko] + " ");
//			}
//			System.out.println("");
//		}
//		System.out.println("");

		for (int yoko = 0; yoko < YOKO; yoko++) {
			boolean lastTile = false; //壁はfalse
			int begin = 0;
			for (int tate = 0; tate < TATE; tate++) {
				if (s[tate].charAt(yoko) == '#') {
					if(lastTile) {
						for (int i = begin; i <= tate - 1; i++) {
							res[i][yoko] += tate - begin;
						}
					}
					lastTile = false;
				} else {
					if (!lastTile) {
						begin = tate;
					}
					lastTile = true;
				}
			}
			//下端
			if (lastTile) {
				for (int i = begin; i <= TATE - 1; i++) {
					res[i][yoko] += TATE - begin;
				}
			}
		}

//		for (int tate = 0; tate < TATE; tate++) {
//			for (int yoko = 0; yoko < YOKO; yoko++) {
//				System.out.print(res[tate][yoko] + " ");
//			}
//			System.out.println();
//		}
//		System.out.println("");

		int max = -1;
		for (int tate = 0; tate < TATE; tate++) {
			for (int yoko = 0; yoko < YOKO; yoko++) {
				if (res[tate][yoko] > max)
					max = res[tate][yoko];
			}
		}

		System.out.println(max - 1);
	}

}


Measured memory_bytes: 66956
#include<stdio.h>
int main(void){
	int A[100];
	int n,i,minj,j,a,t;
	int cout=0;
	scanf("%d\n",&n);
	for(t=0;t<n;t++){
		scanf("%d\n",&A[t]);
	}
	for(i=0;i<n;i++){
		minj=i;
		for(j=i;j<n;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		if(minj!=i&&A[i]>A[minj]){
			a=A[minj];
			A[minj]=A[i];
			A[i]=a;
			cout++;
		}
	}
	for(t=0;t<n;t++){
		if(t==n-1){
			printf("%d\n",A[t]);
		}else{
			printf("%d ",A[t]);
		}
	}
	printf("%d\n",cout);
	return 0;
}


Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		var s = Input().ToInt();
		Console.WriteLine(s[0]*s[1]%2==0?"Even":"Odd");
	}


	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
#include<stdio.h>

int main()
{
    double r,area,circum;
    scanf("%lf",&r);
    area=3.14159265358979323846*r*r;
    circum=3.14159265358979323846*2*r;
    printf("%.6lf %.6lf",area,circum);
    return 0;

}




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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

ll n,k;

ll ar[100010] = {0};
ll sum = 0;
int main(){
  scanf("%lld %lld",&n,&k);
  REP(i,n){
    ll a,b;
    scanf("%lld %lld",&a,&b);
    ar[a] += b;
  }
  REP(i,100001){
    k-=ar[i];
    if(k<=0){
      printf("%d\n",i);
      return 0;
    }
  }
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long int;

int main(){
    int n;
    cin >> n;
    vector<ll> f;

    f.resize(n+4, 0);
    for(int i = 1; i * i + 2 * i < n;i++){
        for(int j = 1; i * i + j * j < n; j++){
            for(int k = 1;; k++){
                int now = i * i + j * j + k * k + i * j + j*k + k*i;
                if (now > n)break;
                f[now]++;
            }
        }
    }
    for(int i = 1; i <= n; i++)cout << f[i] << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(string,s);
  REP(i,s.size()){
    OUT(s[i]);
    if(i==3){OUT(" ");}
  }
  BR;
  
  return 0;
}


Measured memory_bytes: 256
# n mを取得
n, m = gets.chomp.split(' ').map(&:to_i)
array = gets.split(' ').map(&:to_i)

# 配列の中身の合計を求めて、それをnと比較して条件分岐する
sum = array.inject(:+)
if sum > n
  puts "-1"
elsif sum <= n
  puts n - sum
end



Measured memory_bytes: 14656
import java.io.*;
 
public class Main {
    public static void main(String[] arg)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String str = br.readLine();

        double r = Double.parseDouble(str);
 
        double menseki =(double)r * (double)r * 3.141592653589;
        double ensyu =(double)2 * 3.141592653589 * (double)r;

         System.out.printf("%.6f %.6f\n", menseki, ensyu);
    }
}

Measured memory_bytes: 17112
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n;

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

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	long long lcm = 1;
	for(int i = 0; i < n; i++){
		long long val;
		cin >> val;
		lcm = lcm / gcd(lcm, val) * val;
	}
	cout << lcm << "\n";
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	res := 1<<60
	for i := 0; i <= len(s)-3; i++ {
		x, _ := strconv.Atoi(s[i:i+3])
		d := 753 - x
		if d < 0 {
			d *= -1
		}
		if res > d {
			res = d
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

bool u[101][101];
int board[101][101];
int gc;
int h,w,n;
int xs,ys,xg,yg;
int dx[] = {-1,0,0,1};
int dy[] = {0,1,-1,0};
bool saiki(int x,int y){
    bool ret = false;
    if(x==xg&&y==yg) return true;
    REP(i,4){
	int nx = x + dx[i];
	int ny = y + dy[i];
	if(1<=nx&&nx<=w&&1<=ny&&ny<=h&&board[ny][nx] == gc&&!u[ny][nx]){
	    u[ny][nx] = true;
	    ret = ret || saiki(nx,ny);
	}
    }
    return ret;
}

int main(){
    while(true){
	memset(board,0,sizeof(board));
	memset(u,false,sizeof(u));
	cin >> w >> h;
	if(w == 0 && h == 0) break;
	cin >> xs >> ys >> xg >> yg;
	cin >> n;
	REP(i,n){
	    int c,d,x,y;
	    cin >> c >> d >> x >> y;
	    if(d == 1){
		REP(i,2){
		    REP(j,4){
			board[y+j][x+i] = c;
		    }
		}
	    }else{
		REP(i,4){
		    REP(j,2){
			board[y+j][x+i] = c;
		    }
		}
	    }
	}
	gc = board[ys][xs];
	if(gc != board[yg][xg]) cout << "NG" << endl;
	else{
	    if(saiki(xs,ys)){
		cout << "OK" << endl;
	    }else cout << "NG" << endl;
	}


    }
    return 0;
}

Measured memory_bytes: 1208
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	long N = Long.parseLong(sc.next());
	long cnt = 0;
	if(N==1) {
	    System.out.println(0);
	    return;
	}
	for(long i = 1; i*i<=N; i++) {
	    if(N%i == 0) {
		for(long j = N/i-1; N%j!=0; j--) {
		    if(N%j==N/j) {
			cnt+=j;
			break;
		    }
		}

	    }
	}
	System.out.println(cnt);
    }
}

Measured memory_bytes: 22100
(let* ((n (read))
       (lst (concatenate 'list (sort (loop :repeat n :collect (read)) #'>) '(0 0 0 0))))
  (defun f (ll a)
    (if (= (first ll) (second ll))
        (if a
            (* a (first ll))
            (f (cddr ll) (first ll)))
        (f (cdr ll) a)))
  (princ (f lst nil)))

Measured memory_bytes: 69856
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin >> t;
    while (t--) {
        int a,b,x;
        cin>>a>>b>>x;
        int count=0;
        for(int i=a;i<=b;i++){
            if(i%x==0) count++;
        }
        cout<<count<<endl;
    }
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

ll f(ll x, ll y)
{
	if (x % y == 0)
	{
		return y;
	}
	else
	{
		return f(y, x % y);
	}
}
ll g(ll x, ll y)
{
	return (x - x % y) / y;
}

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll gcd = f(c, d);
	ll p;
	p = c * d / gcd;
	ll m, n, l;
	
	m = g(b, c) - g(a-1, c);
	n = g(b, d) - g(a-1, d);
	l = g(b, p) - g(a-1, p);

	ll ans = b - a + 1 - m - n + l;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    cout.precision(21);
    double a, b;
    cin >> a >> b;
    double c, d;
    cin >> c >> d;
    int m = c * 60 + d;
    double da = m / 2.0;
    double db = (m * 6) % 360;
    if(da == db){
        cout << abs(a - b) << endl;
        return 0;
    }

    double di = db - da;

    if(abs(di) == 180){
        cout << a + b << endl;
        return 0;
    }

    long double ans = 0;

    if(di > 0){
        if(di < 180){
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(di * M_PI / 180.0));
        } else {
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos((360 - di) * M_PI / 180.0));
        }
    }
    else {
        di = da - db;
        if(di < 180){
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(di * M_PI / 180.0));
        } else {
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos((360 - di) * M_PI / 180.0));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    string S;
    cin>>S;
    int Q;
    cin>>Q;
    bool rev = false;

    deque<char> q;
    for (auto s : S) {
        q.push_back(s);
    }

    rep(i, Q) {
        int t, f;
        char c;
        cin>>t;
        if (t == 1) {
            rev = !rev;
            continue;
        }

        cin>>f>>c;
        if ((f == 1 && !rev) || (f == 2 && rev)) q.push_front(c);
        else q.push_back(c); 
    }
    if (rev) {
        while (!q.empty()) {
            char c = q.back(); q.pop_back();
            cout<<c;
        }
    }
    else {
        while (!q.empty()) {
            char c = q.front(); q.pop_front();
            cout<<c;
        }
    }
    cout<<endl;
}

Measured memory_bytes: 976
X, Y = map(int, input().split())


def Knight(X, Y):
    
    if (X+Y)%3 != 0:
        return 0
    
    else:    
        if X > Y:
            q = X // 2
            r = X % 2
            if Y < q*1 + r*2:
                return 0
        elif Y > X:
            q = Y // 2
            r = Y % 2
            if X < q*1 + r*2:
                return 0

    # 移動回数
    move = (X+Y) // 3
    if X >= Y:
        diff  = X - Y
        i2j1_move = move//2 + move%2 + diff//2
        i1j2_move = move//2 - diff//2
    else:
        diff  = Y - X
        i2j1_move = move//2 - diff//2
        i1j2_move = move//2 + move%2 + diff//2

    # 二項係数
    MOD = 10**9+7    
    fac = [1, 1]
    finv = [1, 1]
    inv = [0, 1]
    for i in range(2, move+1):
        fac.append((fac[-1] * i) % MOD)  
        inv.append((-inv[MOD % i] * (MOD//i)) % MOD)
        finv.append((finv[-1] * inv[-1]) % MOD)

    def COM(n, k):
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    return COM(move, i2j1_move)


print(Knight(X, Y))

Measured memory_bytes: 82264
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

int func(char str[], int m)
{
	char c = str[0];
	if(c=='C') return atoi(str+1) - 1;
	if(c=='H') return m;
	if(c=='D') return m+1;
	return m+1+atoi(str+1);
}

struct Data
{
	int pos, cost;
	Data(int p, int c) : pos(p), cost(c) {}
	bool operator< (const Data& d) const {
		return cost > d.cost;
	}
};

int main()
{
	int m, n, k, d;
	while(scanf("%d%d%d%d", &m, &n, &k, &d), m){
		int cake[6];
		rep(i, m)
			scanf("%d", &cake[i]);
		
		int G[108][108];
		rep(i, m+n+2)
			fill(G[i], G[i]+m+n+2, INF);
		
		rep(i, d){
			char str1[128], str2[128];
			int dist;
			scanf("%s%s%d", str1, str2, &dist);
			int a = func(str1, m), b = func(str2, m);
			G[a][b] = G[b][a] = dist;
		}
		
		int S[8][8];
		rep(i, m+2){
			fill(S[i], S[i]+m+2, INF);
			bool visited[108] = {false};
			priority_queue<Data> Q;
			Q.push(Data(i, 0));
			while(!Q.empty()){
				Data d = Q.top();
				Q.pop();
				if(visited[d.pos])
					continue;
				visited[d.pos] = true;
				if(d.pos < m+2)
					S[i][d.pos] = d.cost;
				if(d.cost==0 || m<=d.pos){
					rep(j, m+n+2){
						if(G[d.pos][j] != INF)
							Q.push(Data(j, d.cost+G[d.pos][j]));
					}
				}
			}
		}

		int dp[1<<6][8];
		rep(i, 1<<m)
			fill(dp[i], dp[i]+m+2, INF);
		dp[0][m] = 0;

		rep(mask, 1<<m){
			rep(i, m+2){
				if(i<m && (mask&(1<<i))==0)
					continue;
				rep(j, m+2){
					if(S[i][j] == INF)
						continue;
					int next = mask;
					int cost = dp[mask][i] + S[i][j] * k;
					if(j < m){
						if((mask&(1<<j))!=0)
							continue;
						next |= 1 << j;
						cost -= cake[j];
					}
					dp[next][j] = min(dp[next][j], cost);
				}
			}
		}

		int ans = INF;
		rep(i, 1<<m)
			ans = min(ans, dp[i][m+1]);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1092
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, a: "List[int]"):
    tmp = 0
    s = set()
    for v in a:
        if v >= 3200:
            tmp += 1
        else:
            s.add(v // 400)
    ret = len(s)
    print(max(1, ret),  ret + tmp)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> p(2*1e5+9, 0);
  vector<int> bai(18, 1);
  FOR(i, 1, 18){
    bai[i] = bai[i-1]*2;
  }
  FOR(i, 1, N+1){
    if(i < K){
      ll me = i;
      while(me < K){
        me*=2;
        p[i]++;
      }
    }
  }
  // FOR(i, 1, N+1){
  //   if(i < K && p[i] == 0){
  //     ll me = i;
  //     while(me <= K){
  //       me*=2;
  //       p[i]++;
  //     }
  //     me = i;
  //     while(me <= K){
  //       me*=2;
  //       p[me] = p[me/2] - 1;
  //     }
  //   }
  //   else if(p[i] != 0){
  //     continue;
  //   }
  // }
  ll ans=0;
  FOR(i, 1, N+1){
    int me = 1;
    REP(j, 17 - p[i]){
      me *=2;
    }
    ans += me;
  }
  while(ans % 2 == 0){
    ans /= 2;
    bai[17]/=2;
  }
  double ans1;
  ans1 = (double) ans / bai[17];
  ans1 /= N;
  printf("%.12lf\n", ans1);
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        sc.close();

        int cnt1 = 0;
        int cnt2 = 0;
        int cnt3 = 0;
        boolean isFound = false;
        for(int i=0; i<n; i++) {
            if(y == 10000*n) {
                cnt1 = n;
                isFound = true;
                break;
            }

            int tmp1 = 0;
            if(y - (i * 10000) > 0) {
                tmp1 = y - (i * 10000);
            }
            cnt1 = i;

            for(int j=0; j<n-i; j++) {
                if(tmp1 == 5000 * (n-i)) {
                    cnt2 = n-i;
                    isFound = true;
                    break;
                }
                int tmp2 = 0;
                if (tmp1 - (5000 * j) > 0) {
                    tmp2 = tmp1 - (5000 * j);
                }
                cnt2 = j;

                if(tmp2 == 1000*(n-i-j)) {
                    cnt3 = n-i-j;
                    isFound = true;
                    break;
                }
            }
            if(isFound) {
                break;
            }
        }

        if(!isFound) {
            System.out.println("-1" + " " + "-1" + " " + "-1");
        } else {
            System.out.println(Integer.toString(cnt1) + " " + Integer.toString(cnt2) + " " + Integer.toString(cnt3));
        }
    }
}


Measured memory_bytes: 23380
N,W=map(int,input().split())

L=[[]for i in range(4)]

A=[]
for i in range(N):
    w,v=map(int,input().split())
    A.append([w,v])
A.sort()
#print(A)

L[0].append(A[0])
P=0
for i in range(1,N):
    if A[i][0]==A[i-1][0]:
        L[P].append(A[i])
    else:
        P+=1
        L[P].append(A[i])
#print(L)
for i in range(4):
    L[i].sort(reverse=True)
#print(L)
S=[]
for i in range(4):
    s=[0]
    for j in range(len(L[i])):
        s.append(s[j]+L[i][j][1])
    S.append(s)
#print(S)
we=[0,0,0,0]
for i in range(4):
    if L[i]==[]:
        pass
    else:
        we[i]=L[i][0][0]
ans=0
for a in range(len(S[0])):
    for b in range(len(S[1])):
        for c in range(len(S[2])):
            for d in range(len(S[3])):
                v=S[0][a]+S[1][b]+S[2][c]+S[3][d]
                w=we[0]*a+we[1]*b+we[2]*c+we[3]*d
                if W>=w and ans<v:
                    ans=v
print(ans)

Measured memory_bytes: 42732
#include<bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)(N);i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<=b)
using namespace std;

int main(){
	string s;
	while(cin>>s){
		if(s==".") break;
		string ans="";
		stack<int> st;
		int diff=0;
		REP(pos,0,s.size()){
			if(ck(s[pos],'A','Z')){
				ans+=(char) (s[pos]-'A'+diff)%26 + 'A';
				diff=0;
			}
			else if(s[pos]=='+')	diff++;
			else if(s[pos]=='-')	diff--;
			else if(s[pos]=='[')	st.push(ans.size());
			else if(s[pos]==']'){
				reverse(ans.begin()+st.top(),ans.end());
				st.pop();
			}else if(s[pos]=='?'){
				ans+='A';
				diff=0;
			}
			diff=(diff+26)%26;
		}
		p(ans);
	}
	return 0;
}

Measured memory_bytes: 3168
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> dp(n + 1);
    irep(i, n)
    {
        if (i == 0) {
            dp[i] = 0;
        } else {
            dp[i] = numeric_limits<int>::max();
            for (int j = 1; j <= i; j *= 6) {
                dp[i] = min(dp[i], dp[i - j] + 1);
            }
            for (int j = 1; j <= i; j *= 9) {
                dp[i] = min(dp[i], dp[i - j] + 1);
            }
        }
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
const int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
const int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
const int MX = 1000;

int main()
{
    string s, t;
    cin >> s >> t;
    int ls = s.size(), lt = t.size();
    int ans = MX;
    rep(i, ls - lt + 1) {
        int tmp = 0;
        rep(j,lt) {
            if (s[i+j] != t[j]) tmp++;
        }
        chmin(ans,tmp);
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll dp[3005][3005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    string s;
    string t;
    cin>>s>>t;
    ll n = s.length();
    ll m = t.length();

    rep(i,n){
        rep(j,m){
            if(s[i]==t[j]){
                chmax(dp[i+1][j+1],dp[i][j]+1);
            }else{
                chmax(dp[i+1][j+1],dp[i][j+1]);
                chmax(dp[i+1][j+1],dp[i+1][j]);
            }
        }
    }
    string ans;
    ll i = n;
    ll j = m;
    while(i>0&&j>0){
        if(dp[i][j] == dp[i][j-1]){
            j--;
        }else if(dp[i][j] == dp[i-1][j]){
            i--;
        }else{
            ans += s[i-1];
            i--;
            j--;
        }
    }
    reverse(ALL(ans));
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 70656
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            HashSet<Integer> g1 =
                new HashSet<Integer>(Arrays.asList(1, 3, 5, 7, 8, 10, 12));

            HashSet<Integer> g2 =
                new HashSet<Integer>(Arrays.asList(4, 6, 9, 11));

            HashSet<Integer> g3 =
                new HashSet<Integer>(Arrays.asList(2));

            final String sl[] = s.split(" ");
            int x = Integer.parseInt(sl[0]);
            int y = Integer.parseInt(sl[1]);

            if ((g1.contains(x) && g1.contains(y))
                || (g2.contains(x) && g2.contains(y))
                || (g3.contains(x) && g3.contains(y))) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define repr(i, n) for(int i = n;i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define MOD 1000000007

typedef long long ll;

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

    int n,flag = 1,count = 0;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
        if(a[i] % 2 != 0) flag = 0;
    }

    if(flag == 0){
        cout << 0 << "\n";

        return 0;
    }
    
    while(flag){
        count++;
        rep(i,n){
            if(a[i] % 2 != 0) flag = 0;
            a[i] = a[i] / 2;
        }
        if(flag == 0) count--;
    }

    cout << count << "\n";

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    k = II()
    x = II()
    y = II()
    ans = 0
    for i in range(n):
        if i >= k:
            ans += y
        else:
            ans += x
    print(ans)
    return

#B
def B():
    w = S()
    d = defaultdict(int)
    for s in w:
        d[s] += 1
    for di in d.values():
        if di % 2:
            print("No")
            return
    print("Yes")
    return

#C
def C():
    n, a = LI()
    x = LI()
    sumx = [0] * n
    for i in range(n):
        sumx[i] = sumx[i - 1] + x[i]
    dp = [[[0] * (n+1) for i in range(sumx[-1] + 1)] for i in range(n)]
    for i in range(n):
        dp[i][x[i]][1] = 1
    for i in range(1, n):
        for s in range(sumx[i] + 1):
            for k in range(1, i + 2):
                if  s >= x[i]:
                    dp[i][s][k] += dp[i - 1][s - x[i]][k - 1]
                dp[i][s][k] += dp[i - 1][s][k]
    ans = 0
    for i in range(1, n + 1):
        if a * i > sumx[-1]:
            break
        ans += dp[-1][a * i][i]
    print(ans)
    return

#D
def D():
    return


#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 101596
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int X,t; cin >> X >> t;
    cout << max(0,X-t) << endl;
    return 0;
}


Measured memory_bytes: 3648
import sys

N, K = map(int, sys.stdin.readline().split())
D = map(int, sys.stdin.readline().split())

for i in xrange(N * 10):
    if i >= N:
        temp = i
        isCorrect = True
        while temp > 0:
            if (temp % 10) in D:
                isCorrect = False
                break
            else:
                temp /= 10
        if isCorrect:
            print i
            break

Measured memory_bytes: 2820
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    int ans = 3;
    if(a == b) ans--;
    if(b == c) ans--;
    if(c == a) ans--;

    if(ans == 0) ans++;

    cout << ans << endl;
}




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

#define ll long long

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

    long long A=1,B,m=INT64_MAX;

    while(N/A>=A){

        if(N%A==0){
            B=N/A;
            if(m>max(to_string(A).length(),to_string(B).length())){
                m=max(to_string(A).length(),to_string(B).length());
            }
        }
        A++;
    }
        cout<<m<<endl;
    
    return 0;
}

Measured memory_bytes: 256