akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = list(input())

li = [[] for _ in range(10)]

for i in range(n):
    t = int(s[i])
    li[t].append(i)

a = 0
b = 0
c = 0
cnt = 0

for i in range(10):
  for j in range(10):
    for k in range(10):
      b = 0
      a = 0
      
      if len(li[i]) > 0:
        a = li[i][0]
          
        for d in li[j]:
            if d > a:
                b = d
                break
        else:
            break
        
        for e in li[k]:
            if e > b:
                cnt += 1
                break
        

print(cnt)


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

using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    vector<long> v;
    long n;
    for (int i=0; i<N ; ++i){
        cin >> n;
        v.push_back(n);
    }
    
    sort(v.begin(), v.end());
    cout << v[N-1]- v[0]<< endl;
    return 0;
}


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

int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  
  long double d = c - a - b;
  
  if(d > 0 && 4 * a * b < d * d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  
}


Measured memory_bytes: 256
/**
 * C - Factors of Factorial
 * https://atcoder.jp/contests/abc052/tasks/arc067_a
 **/
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>

const long long MOD = 1000000007;

using namespace std;

#define ll long long

// Sieve of Erastosthenes の実装
vector<long long> erast(long long n) {
    vector<long long> primes, sieve;
    // 篩の初期化
    for(long long i=2; i<n+1; i++) {
        sieve.push_back(i);
    }
    while(!sieve.empty()) {
        long long ptr = sieve.front();
        primes.push_back(ptr);
        for(auto it = sieve.begin(); it != sieve.end();) {
            if(*it%ptr==0) {
                it = sieve.erase(it);
            } else {
                ++it;
            }
        }
    }
    return primes;
}

int main() {
    ll n; cin >> n;
    vector<ll> prime = erast(n);
    ll ans = 1;
    map<ll, ll> factors;
    for(ll i=1; i<n+1; i++) {
        for(auto p:prime) {
            ll c_n = i;
            while(true) {
                if(c_n%p==0) {
                    c_n = c_n/p;
                    if(c_n>0) {
                        if(factors.count(p)==0) {
                            factors[p] = 1;
                        } else {
                            factors[p] += 1;
                        }
                    } else {
                        break;
                    }
                } else {
                    break;
                }
            }
        }
    }
    for(auto f:factors) {
        ans *= (f.second+(ll)1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n,c=0;
    cin>>n;
    string str;
    cin>>str;
    string str1=str;
    sort(str.begin(),str.end());
    for(int i=0;i<n;i++)
    {
        if(str[i]=='R')
        {
            if(str[i]!=str1[i])
            c++;
        }
    }
    cout<<c<<endl;
    
	return 0;
}


Measured memory_bytes: 3892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; i++) {
        cin >> a.at(i); 
    }
    sort(a.begin(),a.end());
    cout << a.at(N-1)-a.at(0) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int ans=0,f=1;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')f=-1;chr=getchar();}
	while(isdigit(chr)) {ans=(ans<<3)+(ans<<1)+chr-48;chr=getchar();}
	return ans*f;
}const int M = 1e6+5;
char s[M],a[M];
int n,tot;
int main(){
	n=read();
	scanf("%s",s+1);
	int i=1;
	while(i<=n){
		++tot;
		while(i<=n&&s[i]==s[i+1])i++;
		a[tot]=s[i];
		++i;
	}
	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

int main()
{
  int a[4], b[4];
  set<int> A, B;
  while (scanf("%d ", &a[0]) == 1) {
    A.clear(), B.clear();
    for (int i = 1; i < 4; i++) {
      scanf("%d ", &a[i]);
      A.insert(a[i]);
    }
    for (int i = 0; i < 4; i++) {
      scanf("%d ", &b[i]);
      B.insert(b[i]);
    }
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      if (a[i] == b[i]) {
	hit++;
      }
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
	if (b[i] == a[j]) {
	  blow++;
	}
      }
    }
    
    printf("%d %d\n", hit, blow - hit);
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] c = sc.next().toCharArray();
		int ans = 0;
		int max = 0;
		for (int i = 0; i < N; i++) {
			if (c[i] == 'I') {
				++ans;
			}else if(c[i] == 'D') {
				--ans;
			}
			max = Math.max(max, ans);
		}
		System.out.println(max);
	}
}




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

using namespace std;
long long int sum(long long int arr[],long long int n)
{
   long long int i, sum=0;
   for (i=0;i<n;i++)
   {
       sum=sum+arr[i];

    }
    return sum;
}
int main()
{
  long long int n,i,m,sum1,count;
  cin>>n;
  cin>>m;
  long long int arr[n];
  for(i=0;i<n;i++)
  {
      cin>>arr[i];
  }
  sum1=sum(arr,n);
  count=0;
     for(i=0;i<n;i++)
        {
            if(4*m*arr[i]>=sum1)
                count++;
        }
  if(count>=m)
  {
      cout<<"Yes";

  }
  else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String s = scan.next();
        String t = scan.next();

        String sub = t.substring(0, t.length()-1);

        if(s.equals(sub))
            os.println("Yes");
        else
            os.println("No");
    }
}

Measured memory_bytes: 27004
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

#include <bits/stdc++.h>
using namespace std;






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

    string s1, s2, s3;
    cin >> s1 >> s2;
    int a, b;
    cin >> a >> b;
    cin >> s3;


    if (s3 == s1) {
    	cout << a-1 << " " << b;
    } else {
    	cout << a << " " << b-1;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<double,double>
#define pb push_back
#define f first
#define s second
#define ll long long int
#define vi vector<ll>
#define rs resize
int go(int n)
{
  if(n>=1 and n<=399)
   return 0;
  if(n>=400 and n<=799)
   return 1;
  if(n>=800 and n<=1199)
   return 2;
  if(n>=1200 and n<=1599)
   return 3;
  if(n>=1600 and n<=1999)
   return 4;
  if(n>=2000 and n<=2399)
   return 5;
  if(n>=2400 and n<=2799)
   return 6;
  if(n>=2800 and n<=3199)
   return 7;
  return 8;
}
int main()
{
     std::ios::sync_with_stdio(false);
     ll n,i,o = 0,c=0;
     string a;
     cin>>n>>a;
     rep(i,0,n)
     {
        if(a[i] =='(')
         o++;
        if(a[i] == ')')
        {
          if(o != 0)
           o--;
          else
           c++;
        }
     }
     rep(i,0,c)
      a = '(' + a;
     rep(i,0,o)
      a = a+')';
     cout<<a;
     return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int N;
    std::cin >> N;

    int M;
    if(N % 111 == 0){
        M = N;
    }else{
        M = (N / 111 + 1) * 111;
    }
    
    std::cout << M << std::endl;
}


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

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

int main(){
  int N;
  cin >> N;
  
  vector<int>HP(N);
  
  //Nは１からなので注意
  for(int i=0; i <N; i++){
    cin >> HP[i];
  }
  
  int minj = HP[0];
  
  for(int i= 1; i<N; i++){
    minj = gcd(minj,HP[i]);
  }
  cout << minj << endl;
}

Measured memory_bytes: 3712
pub struct Scanner{
    line : Vec<String> ,
    idx : usize
}

#[allow(dead_code)]
impl  Scanner{
   fn new() -> Scanner{
       return Scanner{ line: vec![], idx : 0}
   }
   fn next<T: std::str::FromStr> (&mut self) -> T{
       if self.idx == self.line.len() {
           let mut buffer = String::new();
           std::io::stdin().read_line(&mut buffer).ok();

           let a : Vec<&str>  = buffer.trim().split(' ').collect();
           self.line = a.iter().map(|&s| String::from(s)).collect();
           self.idx = 0;
       }
       let ret : T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
       self.idx += 1;
       ret
   }
   fn next_string(&mut self) -> Vec<char> {
       let s : String = self.next();
       return s.chars().collect::<Vec<char>>();
   }
   fn next_vec<T: std::str::FromStr>  (&mut self, n: usize) -> Vec<T>{
       let mut v : Vec<T>= Vec::with_capacity(n);
       for _i in 0..n {
           v.push(self.next());
       }
       v
   }
}


fn main() {
    let mut scan = Scanner::new();
    let _n:i64  = scan.next();
    let k:i64  = scan.next();
    let c:i64  = scan.next();
    let s = scan.next_string();

    let mut a :Vec<i32> = Vec::with_capacity(k as usize);
    let mut b: Vec<i32> = Vec::with_capacity(k as usize);
    let mut sleep = 0;

    for day in 0..s.len(){
        if sleep > 0{
            sleep -= 1;
            continue;
        }
        if s[day] == 'o'{
            a.push(day as i32);
            sleep = c;
        }
        if a.len() == k as usize{
            break;
        }
    }
    sleep = 0;
    for day in (0..s.len()).rev() {
        if sleep > 0{
            sleep -= 1;
            continue;
        }
        if s[day] == 'o'{
            b.push(day as i32);
            sleep = c;
        }
        if b.len() == k as usize{
            break;
        }
    }
    b.reverse();

    for i in 0..k{
        let idx = i as usize;
        if a[idx] == b[idx] {
            println!("{}", a[idx] + 1);
        }
    }
}


Measured memory_bytes: 7676
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
// #include <boost/multiprecision/cpp_int.hpp>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1e-9;

void Main(int argc, char** argv) {
    ll m;
    cin>>m;
    ll d[m];
    ll c[m];
    rep(i,m) {
        cin>>d[i]>>c[i];
    }
    ll digit = 0;
    ll sum = 0;
    rep(i,m) {
        digit += c[i];
        sum += c[i] * d[i];
    }

    ll ans = digit - 1;
    while(sum >= 10) {
        ans += sum / 10;
        sum = sum / 10 + (sum % 10);
    }
    cout << ans << endl;

}

signed main(int argc, char** argv) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main(argc, argv);
    return 0;
}


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


int main(){
    int n;
    cin >> n;
    set < char > q;
    for(int i = 1; i <= n; i++){
        char c;
        cin >> c;
        q.insert(c);
    }
    if(q.size() == 3){
        cout << "Three";
    }
    else{
        cout << "Four";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	string ans="";
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;

	rep(i,tx-sx){
		ans+="R";
	}
	rep(i,ty-sy){
		ans+="U";
	}
	rep(i,tx-sx){
		ans+="L";
	}
	rep(i,ty-sy){
		ans+="D";
	}

	ans+="D";
	ans+="R";
	rep(i,tx-sx){
		ans+="R";
	}
	rep(i,ty-sy){
		ans+="U";
	}
	ans+="U";
	ans+="L";

	ans+="U";
	ans+="L";
	rep(i,tx-sx){
		ans+="L";
	}
	rep(i,ty-sy){
		ans+="D";
	}
	ans+="DR";

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


Measured memory_bytes: 256
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
R = []
for i in range(N):
  S = int(input())
  R.append(S)

if A1[0] in R and A2[1] in R and A3[2] in R:
  print("Yes")
elif A1[2] in R and A2[1] in R and A3[0] in R:
  print("Yes")
elif A1[0] in R and A1[1] in R and A1[2] in R:
  print("Yes")
elif A2[0] in R and A2[1] in R and A2[2] in R:
  print("Yes")
elif A3[0] in R and A3[1] in R and A3[2] in R:
  print("Yes")
elif A1[0] in R and A2[0] in R and A3[0] in R:
  print("Yes")
elif A2[1] in R and A2[1] in R and A3[1] in R:
  print("Yes")
elif A1[2] in R and A2[2] in R and A3[2] in R:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9224
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define sp(n) setprecision(n)
#define mp make_pair
#define mt make_tuple
#define pi 3.14159265358979323846264
#define MOD 1000000007

using namespace std;
/*
int primeFactors(ll n)  
{  ll f=0;
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        f++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            f++; 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        f++;
        
 return f;        
}  
  
bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = ((C[i - 1][j - 1] + C[i - 1][j]))%MOD;}}}
    return C[n][k];
 }
 
ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}
 
ll expmod(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}
//define temp-functions below
 
 
//some definitions and global variables
vector<ll> primes;
void storePrime(ll n){
    fori(n){
        if(isPrime(i+1)&&(n%(i+1)==0)){primes.push_back(i+1);}
    }
}*/


int main(){ //ake cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
 ll k;
 cin>>k;
 ll x=100;ll z=0;
 while(x<k){
     x=x+x/100;z++;
 }
 cout<<z;




return 0;}


Measured memory_bytes: 3640
n,m = map(int,input().split())
X,Y,Z = [],[],[]
pm = ["+","-"]
for i in range(n):
    x,y,z = map(int,input().split())
    X.append(x)
    Y.append(y)
    Z.append(z)

ans = 0
for p1 in pm:
    for p2 in pm:
        for p3 in pm:
            res = []
            for x,y,z in zip(X,Y,Z):
                res.append(eval(p1+str(x)+p2+str(y)+p3+str(z)))
            res.sort(reverse=1)
            ans = max(ans,sum(res[:m]))
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=j;i<n;i++)
int main(){
    int n;cin>>n;
    int R[n];
    rep(i,0,n)cin>>R[i];
    int minv=R[0];int maxv=-2000000000;
    rep(i,1,n){
        maxv=max(maxv,R[i]-minv);
        minv=min(minv,R[i]);
    }
    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 3880
n = int(input())
h = list(map(int, input().split()))
dp = [0 for _ in range(n)]
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
	dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])

Measured memory_bytes: 13980
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while (!str.equals("0")) {
			int n = Integer.parseInt(str);
			for (int i = n; i >= 1; i--)
				Search("" + i, n, i);
			str = br.readLine();
		}
	}

	private static void Search(String output, int l, int t) {
		if (l - t == 0) {
			System.out.println(output);
		} else {
			for (int i = Math.min(l - t, t); i >= 1; i--)
				Search(output + " " + i, l - t, i);
		}
	}
}

Measured memory_bytes: 43432
#include <iostream>
using namespace std;
int N;
int Array[100005];
int V[100005];
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        cin >> Array[i];
        V[Array[i]]++;
        V[Array[i] + 1]++;
        if(Array[i] > 0)
            V[Array[i] - 1]++;
    }

}

void Solve()
{
    int Max = 0;
    for(int i = 0; i <= 100001; i++)
    {
        Max = max(Max, V[i]);
    }
    cout << Max << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 1024
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0
ans="No"
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]:
        ans="Yes"
    if a[0][i]==a[1][i]==a[2][i]:
        ans="Yes"
if a[0][0]==a[1][1]==a[2][2]:
    ans="Yes"
if a[0][2]==a[1][1]==a[2][0]:
    ans="Yes"
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int N,C,a=0,b,d,e,p;
	scanf("%d %d\n",&N,&C);
	for(p=0;p<C;p++){
		scanf("%d",&d);
		a+=d;
	}
	e=a%(N+1);
	b=a/(N+1);
	if(b<1){
		b+=1;
	}
	else if(e>=1){
			b+=1;
	}
	printf("%d\n",b);
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> bukas(N, 0);
  int jyoushi;
  for (int i = 0; i < N - 1; i++) {
    cin >> jyoushi;
    bukas.at(jyoushi-1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << bukas.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}

int main(int argc, char *argv[]){
  ll result;
  ll A, B, T;
  cin >> A >> B >> T;
  result = T / A * B;
  
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/arc074/tasks/arc074_a 
#include<bits/stdc++.h>
using namespace std;
#define ll long long  
const ll inf=((ll)1<<62);
ll solve(ll x,ll y,ll s)
{
	ll X=x/2,Y=y/2;
	return min(
	     max(abs(s-X*y),max(abs(X*y-(x-X)*y),abs(s-(x-X)*y))),//竖 
	     max(abs(x*Y-s),max(abs(x*(y-Y)-s),abs(x*Y-x*(y-Y))))//横 
	) ;
}
int main()
{
	ll h,w;
	cin>>h>>w;
	ll ans=inf;
	for(int i=1;i<=h;i++)
	 ans=min(ans,solve(h-i,w,i*w));
	for(int i=1;i<=w;i++)
	 ans=min(ans,solve(w-i,h,i*h));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
Demand = []
for i in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c == 'W':
        x += K
    x, y = x % (2 * K), y % (2 * K)
    Demand.append([x, y])


class Ruisekiwa2D:
    def __init__(self, h, w):
        self.H = h
        self.W = w
        self.G = [[0] * w for _ in range(h)]

    def load(self, points):
        # 問題によってイメージしやすいよう書き換えてください
        for x, y in points:
            self.G[x][y] += 1

    def load_imos(self, points):
        # pointsは[[左上h, 左上w, 右下h, 右下w], ...]であること
        for i1, j1, i2, j2 in points:
            self.G[i1][j1] += 1  # 左上
            if j2 + 1 < self.W:  # 右上
                self.G[i1][j2+1] -= 1
            if i2 + 1 < self.H:
                self.G[i2+1][j1] -= 1  # 左下
            if j2 + 1 < self.W and i2 + 1 < self.H:  # 右下
                self.G[i2+1][j2+1] += 1

    def calc(self):
        for y in range(self.W):
            for x in range(1, self.H):
                self.G[x][y] += self.G[x-1][y]

        for y in range(1, self.W):
            for x in range(self.H):
                self.G[x][y] += self.G[x][y-1]

    def get(self, i1, j1, i2, j2):
        if i1 > i2 or j1 > j2 or i1 < 0 or j1 < 0 or i2 < 0 or j2 < 0:
            return 0
        elif i1 > 0 and j1 > 0:
            return self.G[i2][j2] - self.G[i1-1][j2] - self.G[i2][j1-1] + self.G[i1-1][j1-1]
        elif i1 <= 0 < j1:
            return self.G[i2][j2] - self.G[i2][j1-1]
        elif j1 <= 0 < i1:
            return self.G[i2][j2] - self.G[i1 - 1][j2]
        else:
            return self.G[i2][j2]


R2D = Ruisekiwa2D(2 * K, 2 * K)
R2D.load(Demand)
R2D.calc()

ans = 0
for x in range(K):
    for y in range(K):
        fulfill = 0
        fulfill += R2D.get(0, 0, x - 1, y - 1)  # 左上
        fulfill += R2D.get(x + K, 0, 2 * K - 1, y - 1)  # 右上
        fulfill += R2D.get(x, y, x + K - 1, y + K - 1)  # 真ん中
        fulfill += R2D.get(0, y + K, x - 1, 2 * K - 1)  # 左下
        fulfill += R2D.get(x + K, y + K, 2 * K - 1, 2 * K - 1)  # 右下

        ans = max(ans, fulfill, N - fulfill)

print(ans)


Measured memory_bytes: 95832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(){
    int n,d[200007],human,h;
    int c[200007];
    scanf("%d",&n);

    for(int i=0;i<n;i++){
        scanf("%d",&d[i]);
    }
      int max=c[0];
      int max2;
      int mem;

    for(int k=0;k<n;k++){
            c[k]=d[k];
             if(max<c[k]){
               mem=k;     
               max2=max;  
                max=c[k];    
            }else if(max2<c[k]){
              max2=c[k];
            }
    }
        for(int i=0;i<n;i++){
          if(i!=mem){
            printf("%d\n",max);
          }else{
            printf("%d\n",max2);
          }
        }

}


Measured memory_bytes: 2304
#include<cstdio>

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

using namespace std;

typedef long long ll;

const ll M=1000000007;

ll fact[220001];

ll xgcd(ll a,ll b,ll &x,ll &y){
	if(b==0){ x=1; y=0; return a; }
	ll g=xgcd(b,a%b,y,x); y-=a/b*x;
	return g;
}

ll modinv(ll a,ll m){
	ll x,y;
	if(xgcd(a,m,x,y)==1) return (x+m)%m;
	return -1;
}

ll nCr(int n,int r){
	if(n<r) return 0;
	return fact[n]*modinv(fact[r],M)%M*modinv(fact[n-r],M)%M;
}

// f(n,x) := (0,0) から x 回左に進んで y 軸をまたがずに (n,0) に行く方法の総数
ll f(int n,int x){
	return (nCr(n+2*x,n+x)-nCr(n+2*x,n+x+1)+M)%M;
}

int main(){
	fact[0]=1;
	rep(i,220000) fact[i+1]=(i+1)*fact[i]%M;

	int n,m,k; scanf("%d%d%d",&n,&m,&k);

	ll ans=0;
	rep(x,k+1){
		int y=k-x; // x 回左に寄り道, y 回下に寄り道
		ans+=nCr(n+m+2*k,n+2*x)*f(n,x)%M*f(m,y)%M;
	}
	ans%=M;
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 2748
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String[] str = buf.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		int l = Integer.parseInt(str[2]);
		int[][] A = new int[n][m];
		int[][] B = new int[m][l];
		long[][] C = new long[n][l];

		for(int i=0; i<n; i++){
			str = buf.readLine().split(" ");
			for(int j=0; j<m; j++){
				A[i][j] = Integer.parseInt(str[j]);
			}
		}
		for(int i=0; i<m; i++){
			str = buf.readLine().split(" ");
			for(int j=0; j<l; j++){
				B[i][j] = Integer.parseInt(str[j]);
			}
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<l; j++){
				for(int k=0; k<m; k++)
					C[i][j] += A[i][k]*B[k][j];
			}
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<l; j++){
				System.out.print(C[i][j]);
				if(j!=(l-1))
					System.out.print(" ");
			}
			System.out.println();
		}
	}
}

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

int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	int st[n];
	for(int i=0;i<n;i++)
		cin>>st[i];
	bool dp[k+1]={false};
	dp[0]=false;
	for(int i=1;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i-st[j]>=0&&!dp[i-st[j]])
				dp[i]=true;
		}
	}
	if(dp[k])
		cout<<"First";
	else
		cout<<"Second";
	
	
}

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

int main() {
	// your code goes here
	int h, m, s;
	cin>>s;
	h = s / 3600;
	s=s%3600;
	m = s /60;
	s=s%60;
	cout << h << ":" << m << ":" << s <<endl;
	return 0;
}

Measured memory_bytes: 3068
{-# LANGUAGE MultiParamTypeClasses,FlexibleContexts,FlexibleInstances,TypeSynonymInstances,BangPatterns,RankNTypes,TupleSections #-}
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Control.Arrow
import Debug.Trace
import Text.Printf

import Data.List
import Data.Int
import Data.Bits
import Data.Maybe
import Data.Monoid
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.Base
import Data.Function(on)
import Data.Tuple(swap)
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    (n,m) <- readIntPair
    moves <- readAllInts
    let res = runSTArray $ do
            arr <- newArray (1,n) (False,1 :: Int)
            writeArray arr 1 (True,1)
            forM_ moves $ \[x,y] -> do
                (!bx,!cx) <- readArray arr x
                (!by,!cy) <- readArray arr y
                let bx' = bx && cx > 1
                    cx' = cx - 1
                    by' = by || bx
                    cy' = cy + 1
                writeArray arr x (bx',cx')
                writeArray arr y (by',cy')
            return arr
    let ans = length $ filter fst $ elems res
    print ans


-- IO
readInt :: B.ByteString -> Int
readInt = fromJust . fmap fst . B.readInt
readInts :: IO [Int]
readInts = map readInt . B.words <$> B.getLine
readIntPair :: IO (Int,Int)
readIntPair = l2p . map readInt . take 2 . B.words <$> B.getLine
readAllInts :: IO [[Int]]
readAllInts = map (map readInt . B.words) . B.lines <$> B.getContents
readLns :: Read a => IO [a]
readLns = map read . words <$> getLine

-- Utilities
l2p :: [a] -> (a,a)
l2p (a:b:_) = (a,b)
l2p _ = error "l2p: the input list is too short"
p2l :: (a,a) -> [a]
p2l (a,b) = [a,b]
itof :: Int -> Double
itof = fromIntegral
inf :: Int
inf = maxBound `div` 2

-- Monad
stepM_ :: Monad m => a -> (a -> Bool) -> (a -> a) -> (a -> m ()) -> m ()
stepM_ i0 judge incr step = sub i0 where 
    sub i | judge i = step i >> sub (incr i) 
          | otherwise = return ()
rep_ :: Monad m => Int -> (Int -> m ()) -> m ()
rep_ n = stepM_ 0 (<n) (+1)
thru :: Monad m => (v -> m ()) -> v -> m v
thru m v = m v >> return v
memoize :: (Monad m) => (k -> m (Maybe v)) -> (k -> v -> m ()) -> k -> m v -> m v
memoize getter setter key action = do
    mv <- getter key
    case mv of
        Just v -> return v
        Nothing -> action >>= thru (setter key)

-- Array
newUArray :: (MArray (STUArray s) e (ST s),Ix i) => 
             (i,i) -> e -> ST s (STUArray s i e)
newUArray = newArray
newBArray :: (Ix i) => (i,i) -> e -> ST s (STArray s i e)
newBArray = newArray
defaultArray :: (IArray a e,Ix i) => e -> (i,i) -> [(i,e)] -> a i e
defaultArray = accumArray $ curry snd
fromEdges :: Ix i => (i,i) -> [(i,e)] -> Array i [e]
fromEdges = accumArray (flip (:)) []


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n,m;
    cin>>n>>m;
    Array h(n);
    REP(i,n) cin>>h[i];
    Graph g(n);
    REP(i,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        add_edge(g,a,b,1,true,1);
    }

    ll con=0;
    REP(i,n){
        bool flag=true;
        for(auto e:g[i]){
            if(h[e.to]>=h[i]) flag=false;
        }
        if(flag) con++;
    }
    cout<<con<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

long long calcGCD(long long x, long long y)
{
    if (x < y)
    {
        swap(x, y);
    }
    long long remain = x % y;
    while (remain != 0)
    {
        x = y;
        y = remain;
        remain = x % y;
    }
    return y;
}

int main()
{
    long long A, B;
    cin >> A >> B;

    long long gcd = calcGCD(A, B);

    vector<int> p;
    for (long long i = 2; i * i <= gcd; i++)
    {
        int count = 0;
        while (gcd % i == 0)
        {
            count++;
            gcd /= i;
        }
        if (count > 0)
        {
            p.push_back(count);
        }
    }
    if (gcd != 1)
    {
        p.push_back(1);
    }

    cout << p.size() + 1 << endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto& e : a) {
		cin >> e;
	}
	sort(begin(a), end(a));
	vector<ll> s(n + 1);
	for (int i = 0; i < n; i++) {
		s[i + 1] = s[i] + a[i];
	}
	int m = 1;
	for (int i = n - 1; i >= 0; i--) {
		if (a[i] <= 2 * s[i]) {
			m++;
		} else {
			break;
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 1408
n=input()
import re
n2 = re.split('(..)',n)[1::2]


if len(n) % 2 != 0:
    print('No')
else: 
    cnt = 0
    for i,s in enumerate(n2):
        if 'hi' in s:
            cnt += 1
    if cnt == len(n2):
        print('Yes')
    else:
        print('No') 

Measured memory_bytes: 3316
n = int(input())
card = list()
typ = ['S', 'H', 'C', 'D']

for i in range(n):
    s, num = input().split()
    num = int(num)

    if s == "S":
        card.append(0 + num)
    elif s == "H":
        card.append(13 + num)
    elif s == "C":
        card.append(26 + num)
    elif s == "D":
        card.append(39 + num)

for i in range(1, 53):
    if not (i in card):
        print(typ[(i-1)//13], (i-1) % 13+1)



Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
double dp[301][301][301];
double expectation(int x, int y, int z, int n){
    if(x < 0 || y < 0 || z < 0) return 0;
    if(x == 0 && y == 0 && z == 0) return 0;
    if(dp[x][y][z] > -0.9) return dp[x][y][z];
    double exp = n + x*expectation(x-1, y, z, n) + y*expectation(x+1, y-1, z, n) + z*expectation(x, y+1, z-1, n);
    dp[x][y][z] = exp/(x + y + z);
    return dp[x][y][z];
}
int main() {
	int n;
	cin>>n;
	int x = 0, y = 0, z = 0;
	for(int i=0;i<n;i++){
	    int curr;
	    cin>>curr;
	    if(curr == 1) x++;
	    else if(curr == 2) y++;
	    else if(curr == 3) z++;
	}
    memset(dp, -1, sizeof(dp));
    cout<<fixed<<setprecision(10)<<expectation(x, y, z, n);
	return 0;
}

Measured memory_bytes: 213376
#include <stdio.h>
#include <stdbool.h>	//ini biar bisa kebaca boolnya

int main(){
	//N integer a1 ke sampe aN
	//cari hasil semuanya
	//kalao lebih dari 10^18 print -1 aja
	//N >= 2
	long long int angka;
	long long int total = 1;	//ini biar pas di total *= apa dia punya nilai sesuatu
	long long int N[100005];
	bool lanjut = true;
	bool printtotal = true;
	
	//ini print test casenya
	//jadi dia ngulang scanf sampe test casenya terpenuhi
	scanf("%lld", &angka);
	for (long long int i = 1; i <= angka; i++){
		scanf("%lld", &N[i]); //ini input apa dikali apa
		
		//nah disini, maksudnya
		//kalo inputnya salah satu ada yg 0, entah dmn, nanti dia cek
		//kalo ada 0
		//dia print 0
		//trs program end
		//kalo gaada, dia lanjut ke fungsi lanjut
		if(N[i] == 0){
			printf("0\n");
			lanjut = false;	//kalo false dia stop, kalo true dia lanjut ke fungsi lanjut
			//kondisinya itu si if index i senilai 0
			//soalnya apapun yg dikali 0 pasti 0 jg
			break;
		}
	}
	
		if(lanjut){
		for (int i = 1; i<=angka; i++){
			if(1000000000000000000/total >= N[i]){
			total *= N[i];		
			//selama si total tidak melebihi 10^18 
			//dan secara logikanya lebih dari index yg diinput
			//fungsi total dikali N akan terus berjalan
			}
	
	//jika kondisi tidak memenuhi, maka jalan ke sini
	//nanti di print -1	trs program end
	//tapi kalo tidak
	//dia lanjut ke print total
		else {
			printf("-1\n");	
			printtotal = false;
			break;
			}
		}	//ini kurawal tutupnya for
	
	//kesini
	//trs pasti dia printf si total
		if(printtotal){
			printf("%lld\n", total);
		}
	}
	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

struct a {
  int damage;
  int hit;
  int rate;

  // 最後のconstを忘れると"instantiated from here"というエラーが出てコンパイルできないので注意
   bool operator<( const a& right ) const {
       return rate == right.rate ? damage < right.damage : rate > right.rate;
   }
};

const ll N = 1e3+5;
const ll DP = 1e7+5;
string s;
ll n,k,result=INF,h;
ll a,b,m;

ll dp[DP];



int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> h >> n;
  vector<struct a> v(n);
  rep(i,n) {
      cin >> a >> b;
      m = max(m,a);
      v[i].damage = b;
      v[i].hit = a;
      v[i].rate = 1.0*a/b;
  }
  VSORT(v);
  rep(i,h+m+5) {
      dp[i] = INF;
  }
  dp[0] = 0;
  rep(i,n) {
      for(int j=0; j < h; j++) {
          if(dp[j] != INF) {
              dp[j+v[i].hit] = min(dp[v[i].hit+j], dp[j] + v[i].damage);
          }
      }
  }
  for(int i = h; i <= h+m; i++) {
      result = min(result, dp[i]);
  }
  std::cout << result << endl;
}


Measured memory_bytes: 384
s = input()
k = int(input())
#k<=5,|s|<=5000
#しらみつぶし
l = []
for i in range(1,min(len(s),k)+1):##
    for j in range(len(s)-i+1):##
        l.append(s[j:j+i])
l = list(set(l))

l.sort()
#print(l)
print(l[k-1])

Measured memory_bytes: 40432
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{
  ll n;
  cin >> n;
  string a,b;
  cin >> a >> b;

  ll ans = 2 * n;

  rep(i,n)
  {
    string buf = a.substr(i);
    ll pos = b.find(buf);

    if(pos != -1)
    {
      ans = (n - sz(buf)) * 2 + sz(buf);
      break;
    }
  }

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 r, d, x;

int main(){
	cin >> r >> d >> x;
	
	for(int i = 0; i < 10; i++){
		x = x*r - d;
		cout << x << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
a=input()
alist=list(a)
s=[int(i) for i in alist]
sa=[str(i) for i in alist]
p='+'
m='-'
if s[0]+s[1]+s[2]+s[3]==7:
    print(sa[0]+p+sa[1]+p+sa[2]+p+sa[3]+'=7')
elif s[0]-s[1]+s[2]+s[3]==7:
    print(sa[0]+'-'+sa[1]+'+'+sa[2]+'+'+sa[3]+'=7')
elif s[0]+s[1]-s[2]+s[3]==7:
    print(sa[0]+'+'+sa[1]+'-'+sa[2]+'+'+sa[3]+'=7')
elif s[0]+s[1]+s[2]-s[3]==7:
    print(sa[0]+'+'+sa[1]+'+'+sa[2]+'-'+sa[3]+'=7')
elif s[0]-s[1]-s[2]+s[3]==7:
    print(sa[0]+'-'+sa[1]+'-'+sa[2]+'+'+sa[3]+'=7')
elif s[0]-s[1]+s[2]-s[3]==7:
    print(sa[0]+'-'+sa[1]+'+'+sa[2]+'-'+sa[3]+'=7')
elif s[0]+s[1]-s[2]-s[3]==7:
    print(sa[0]+'+'+sa[1]+'-'+sa[2]+'-'+sa[3]+'=7')
elif s[0]-s[1]-s[2]-s[3]==7:
    print(sa[0]+'-'+sa[1]+'-'+sa[2]+'-'+sa[3]+'=7')

Measured memory_bytes: 3064
from statistics import mean

N = int(input())
X_list = list(map(int, input().split()))

check_list = range(1, 101)

life_list = []
for check in check_list:
    life = 0
    for x in X_list:
        life += (x - check)**2
    life_list.append(life)

answer = min(life_list)
print(answer)

Measured memory_bytes: 5404
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  int A,B;
  if(N==1){
    printf("Hello World");
  }else if(N==2){
    cin >> A >> B;
    printf("%d\n", A+B);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
#define MAX_H 200009
using ll = long long;

int dp[1009][MAX_H];

int main(){
  int h,n;
  cin>>h>>n;
  vector<int>a(n),b(n);
  rep(i,n)cin>>a[i]>>b[i];
  rep(i,n+1)rep(j,MAX_H)dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,n){
    rep(j,MAX_H){
      chmin(dp[i+1][j],dp[i][j]);
      if(j+a[i]<=MAX_H)chmin(dp[i][j+a[i]],dp[i][j]+b[i]);
    }
  }
  int ans=INF;
  rep2(i,h,MAX_H)chmin(ans,dp[n][i]);
  cout<<ans<<endl;
  return(0);
}


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

int mod=2019;

int main(){
    ll l,r;
    cin >> l >> r;
    r = min(r,l+4038);
    ll ans=2018;
    for(ll i=l; i<=r; i++){
        for(ll j=i+1; j<=r; j++){
            ans = min(ans,(i*j)%2019);
        }       
    }
    cout << ans << endl;
}  

Measured memory_bytes: 3560
// CardGame.c
// 太郎と花子がカードゲームをする。
// 二人はそれぞれn枚のカードを持っており、nターンの勝負を行う。
// 各ターンではそれぞれ１枚ずつカードを出す。
// カードにはアルファベットからなる動物の名前が書かれており、
// 辞書順で大きいものがそのターンの勝者となる。
// 勝者には３ポイント、引き分けの場合にはそれぞれ１ポイントが加算される。
//
// 太郎と花子の手持ちのカードの情報を読み込み、
// ゲーム終了後のそれぞれの得点を出力するプログラムを作成せよ。
//
// 【制約】
// ・入力で与えられるｎが1000を超えることはない。
// ・与えられる文字列の長さは100以下であり、アルファベットの小文字のみを含む。
// 【入力】
// 一行目にカードの数ｎが与えられる。
// 続くn行に各ターンのカードの情報が与えられる。
// １つ目の文字列が太郎のカードに書かれている文字列、
// ２つ目の文字列が花子のカードに書かれている文字列である。
// 【出力】
// １つ目の数字が太郎の得点、２つ目の数字が花子の得点として１行に出力せよ。
// ２つの数字の間に１つの空白を出力せよ。
// 【例】
// 入力；
// 3
// cat dog
// fish fish
// lion tiger
// 出力；
// 1 7
#include<stdio.h>
#include<string.h>

int main( void) {
  int n;
  char t_card[101], h_card[101];
  int t_score = 0, h_score = 0;

  scanf( "%d", &n);
  for ( int i = 0; i < n; i++) {
    scanf( "%s %s", t_card ,h_card);
    if ( strcmp( t_card, h_card) > 0 ) t_score += 3;
    else if ( strcmp( t_card, h_card) < 0) h_score += 3;
    else { t_score += 1; h_score += 1;}
  }

  printf( "%d %d\n", t_score, h_score);

  return 0;
}



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

int h, w;
string s[100];

int main() {
	int i, j;
	
	cin >> h >> w;
	for (i = 0; i < h; i++) {
		cin >> s[i];
	}
	
	for (i = 0; i < 2 * h; i++) {
		for (j = 0; j < w; j++) {
			cout << s[i / 2][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
bit_cnt = 2 ** N # 箱は最大で12個
INF = 10 ** 10
dp = [INF] * bit_cnt
dp[0] = 0
for _ in range(M):
    price, b = lr()
    open = sum([2 ** (x-1) for x in lr()]) # 1と3の箱を開ける鍵なら101となる
    for j in range(bit_cnt):
        if dp[j|open] > dp[j] + price:
            dp[j|open] = dp[j] + price

if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])
# 解き直し08

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main() {
    int a;
    int b;
    int c;
    int t;
    cin >> a >> b >> c ;
    if (a>b){
        t=a;
        a=b;
        b=t;
    }
    if (b>c){
        t=b;
        b=c;
        c=t;
    }
    if (a>b){
        t=a;
        a=b;
        b=t;
    }
    cout << a << ' ' << b  << ' '<< c << endl;
    return 0;
}


Measured memory_bytes: 3084
#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++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string s; cin >> s;
    REP(i,s.size()){
        if(i%2==0) cout << s[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
    int n, s[1001];
    
    
    while(1){
        cin >> n;
        if(n == 0) break;
        
        double sum=0;
        
        for(int i=0; i<n; i++){
            cin >> s[i];
            sum += s[i];
        }
        
        double m = sum/n;
        
        double a = 0;
        for(int j=0; j<n; j++){
            double l =(s[j] - m)*(s[j] - m);
            
            a += l;
        }
        
        double A = a/n;
        
        printf("%f\n", sqrt(A));
    }
    
    
    return 0;
    
}


Measured memory_bytes: 3220
n=int(input())
w=list(map(int,input().split()))
t=0
li=[]
cnt1=0
cnt2=0
for t in range(n):
    for i in range(n):
        if i<=t:
            cnt1+=w[i]
        else:
            cnt2+=w[i]
    li.append(abs(cnt1-cnt2))
    cnt1=0
    cnt2=0
print(min(li))


Measured memory_bytes: 3060
let () = Scanf.scanf "%d %d %d" @@ fun n a b ->
  if a * b < n || n < a + b - 1 then print_endline "-1"
  else if b = 1 then begin
    for i = 1 to n do
      Printf.printf "%d " i
    done;
    print_newline ()
  end else begin
    for i = 1 to (n - a) / (b - 1) do
      for j = b * i downto b * (i - 1) + 1 do
        Printf.printf "%d " j
      done
    done;
    for i = min n (n + 1 - a + (n - a) / (b - 1)) downto (n - a) / (b - 1) * b + 1 do
      Printf.printf "%d " i
    done;
    for i = n + 2 - a + (n - a) / (b - 1) to n do
      Printf.printf "\n%d " i
    done;
    print_newline ()
  end


Measured memory_bytes: 4736
# coding: utf-8

array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(array[k-1])

Measured memory_bytes: 2940